2020-01-01から1年間の記事一覧

Google翻訳で日本語と英語を勉強する

多くのことをすれば多くのことができるようになる。 The more you do, the more you can do. 物事を成し遂げる方法は行動することだ。 The way to get things done is to act. 明日いい仕事をする最良の準備は今日いい仕事をすることだ。 The best preparati…

Common Lisp(SBCL)の開発環境(Emacs+SLIME)を作る

SBCLのインストール $ sudo apt install sbclEmacsのインストール $ sudo apt install emacsEmacsを起動する。そうすると、ホームディレクトリに「.emacs.d」というディレクトリが作成される。SLIMEのインストール $ cd ~/.emacs.d/ $ git clone https://git…

Google翻訳で日本語と英語を勉強する

近日中の一日は近日中のどの日でもない。 The upcoming day is not any of the upcoming days. 近い日の内の一日は近い日の内のどの日でもない。 One of the near days is not any of the near days. あなたがそれを実行する日はいつまでも来ない。 The days…

Julia Plotsパッケージの追加

Pkg modeに入る方法 juliaコマンドを実行して、REPL(対話モード)になっている状態で、]を入力する。 そうすると、プロンプトが (v1.0) pkg> に変わる。 Pkg modeから抜けるには、BackSpaceを押すか、Ctrl+cを入力する。Pkg modeでhelpと入力すると、下記のよ…

Project Euler Problem10

Rubyを使いました limit = 2000000 sieve = Array.new(limit + 1, true) s = 0 (2..limit).each { |n| if sieve[n] s += n n.step(limit, n) { |idx| sieve[idx] = false } end } puts s

Rosetta Code

Rosetta CodeというWebサイトがあります。 http://rosettacode.org/wiki/Rosetta_Code 異なったプログラミング言語で同じ問題の解法を紹介するサイトです。

Google翻訳で日本語と英語を勉強する

私のゴルフの技術は彼のものと比べるとひどい。 My golf skill is terrible compared to his. 私のゴルフの技術は彼のものより劣っている。 My golf skill is inferior to his. 彼のゴルフの技術は私のものより優れている。 His golf skills are better than…

Brainfuckアルゴリズム(代入、加算)

代入のアルゴリズム x = y <セルの配置> cell1 : y cell2 : x cell3 : temp <処理> yをxとtempに移動させる tempをyに移動させる(復元する) +++ [- >+ >+ <<] >>[- <<+ >>] <<++++++++++++++++++++++++++++++++++++++++++++++++. >+++++++++++++++++++++…

Project Euler Problem9

Julia for n = 1:15 for m = (n+1):22 a = m^2 - n^2 b = 2*m*n c = m^2 + n^2 if a+b+c == 1000 println(a*b*c) end end end ピタゴラス数(a, b, c)は(m^2 - n^2, 2mn, m^2 + n^2)で求められるそうです。 参考ページピタゴラス数の求め方とその証明 | 高校…

Google翻訳で日本語と英語を勉強する

あなたがどんなに完璧になろうとしても、あなたが時々失敗することは当然である。 No matter how perfect you may be, it is natural for you to sometimes fail. もしあなたが失敗しても、あなたは希望を持ち続けるだろう。 If you fail, you will continue…

Project Euler Problem8

Rubyによる方法 puts ARGF.read.gsub(/\n/, "").each_char.each_cons(13).collect {|digits| digits.map(&:to_i).reduce(:*) }.max 対象データをファイルに保存して、標準入力から入力する。

Google翻訳で日本語と英語を勉強する

彼らは伝統的な航海技術を持っている最後の人々だと言われている。 They are said to be the last people to have traditional sailing skills. 彼らはエンジンを使わずに風だけを使って海を渡ることができる。 They can cross the sea using only the wind …

Google翻訳で日本語と英語を勉強する

賢い人は話す。 The wise person speaks. より賢い人は聞く。 The smarter people hear. 私達はよく知らないことについてはよく話すが、よく知っていることについてはあまり話さない。 We talk a lot about things we don't know well, but not a lot about …

Debian系Linuxでroot以外のユーザにWiresharkの実行権限を与える手順

下記のコマンドを実行する sudo dpkg-reconfigure wireshark-commonroot以外のユーザにキャプチャする権限を与えるか問われる画面が表示されるので、 チェックボックスにチェックを入れて「next」をクリックする下記のコマンドで権限を与えたいユーザをwires…

Project Euler Problem7

Haskellでの方法 エラトステネスのふるいを使いました sieve :: [Int] -> [Int] sieve (x:xs) = x : (sieve $ filter ((/=0) . (`mod` x)) xs) sieve [2..] !! 10000

Project Euler Problem1

C言語で関数型プログラミングの考え方でやりました #include <stdio.h> #include <stdlib.h> struct list { int value; struct list *next; }; typedef int func_t(int); struct list *cons(int val, struct list *lst) { struct list *p; if ((p = malloc(sizeof(struct list))</stdlib.h></stdio.h>…

Google翻訳で日本語と英語を勉強する

地球温暖化の原因はいくつか存在する。 There are several causes of global warming. いくつかのことが地球温暖化を引き起こしている。 Several things are causing global warming. 化石燃料の使用は地球温暖化の原因の一つである。 The use of fossil fue…

Google翻訳で日本語と英語を勉強する

ここの気候はとても温暖です。ここでは冬でもめったに雪は降りません。 The climate here is very warm. It rarely snows here even in winter. 私達はここでとても温暖な気候を持っています。私達は冬でもほとんど雪を持ちません。 We have a very mild cli…

Project Euler Problem6

Juliaでの方法 方法1 sum(1:100) ^ 2 - sum(map(x -> x * x, (1:100))) 方法2 Int64((100 * (100+1) / 2) ^ 2) - Int64((100 * (100+1) * (2*100+1) / 6))

Project Euler Problem5

Rubyでの方法 (2..20).reduce(:lcm) Haskellでの方法 foldl lcm 1 [2..20] Juliaでの方法 foldl(lcm,2:20)

Google翻訳で日本語と英語を勉強する

将来得られるものより今得られるもののほうが価値がある。 What you get now is more valuable than what you get in the future. あなたが持っていないものを欲しがるのではなく、あなたが持っているものを大切にしろ。 Cherish what you have, not want wh…

Project Euler Problem4

Rubyによる方法 def palindromic_number(n, a=0) if n == 0 a else q, r = n.divmod 10 palindromic_number(q, a * 10 + r) end end def is_palindromic_number(n) n == palindromic_number(n) end largest_palindromic_number = 0 999.downto(100) { |a| 99…

Project Euler Problem3

Juliaを使いました ある数nが合成数ならば、nの最大の素因数 = (n / (nの最小の素因数)) の最大の素因数 であることを使いました。 例 13195の最大の素因数=(13195/5)の最大の素因数 function find_divisor(n, d) if d * d > n n elseif n % d == 0 d else …

Project Euler Problem2

Haskellを使った方法 フィボナッチ数列の無限リストを作成する関数 fibgen :: Integer -> Integer -> [Integer]fibgen a b = a : fibgen b (a + b) 上記の関数を使用して計算する sum (filter even (takeWhile (<4000000) (fibgen 1 1))) 参考URLお気楽 Hask…

Project Euler Problem1

Juliaでの方法 julia> sum( [n for n = 1:999 if n%3==0 || n%5==0] ) Forthでの方法 スタックの1番目のデータが3の倍数であるかを判断するワード: is-multiple3 3 mod 0= ; スタックの1番目のデータが5の倍数であるかを判断するワード: is-multiple5 5 mod …

Google翻訳で日本語と英語を勉強する

一人の若い人がいた。There was one young man.彼の父と母が死んだ。His father and mother died.彼は新しい生活を始めることを決めた。He decided to start a new life.彼の家には紐以外に何もなかった。There was nothing but a string in his house.彼は…

Google翻訳で日本語と英語を勉強する

二人の間に何度も繰り返された過去の光景が彼の前に現れた。A scene of the past repeated between them appeared before him. あのとき彼女は彼を信じていた。At that time she believed in him. だから、彼女は彼にすべての知識を求めた。So she asked him…

Google翻訳で日本語と英語を勉強する

私はそれを開けようとした。I tried to open it.私はそれを開けるために様々なことを試した。I tried various things to open it.私はそれを開けるために様々な方法を試した。I have tried various methods to open it.私はそれを開けるために様々なことをし…

Google翻訳で日本語と英語を勉強する

彼女は残業をした。She worked overtime.彼女は遅くまで働いた。She worked late.彼女は、報告書を書くために、遅くまで働いた。She worked late to write the report.彼女は、報告書を作成するために、遅くまで働いた。She worked late to produce the repo…