回答編集履歴
6
修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
print(str(sum(list(map(int, open("sample5000.txt").read().split("\n")))))[
|
7
|
+
print(str(sum(list(map(int, open("sample5000.txt").read().split("\n")))))[:10])
|
8
8
|
|
9
9
|
```
|
10
10
|
|
5
修正
test
CHANGED
@@ -39,3 +39,49 @@
|
|
39
39
|
[Project Euler 13: Sum of 50-digit numbers](http://www.mathblog.dk/project-euler-13/)
|
40
40
|
|
41
41
|
[PROJECT EULER PROBLEM 13](http://code.jasonbhill.com/python/project-euler-problem-13/)
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
#追記
|
46
|
+
|
47
|
+
5000個の整数を足す
|
48
|
+
|
49
|
+
```Python
|
50
|
+
|
51
|
+
# coding: utf-8
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
print(sum(list(map(int, sum(list(map(lambda x: list(x), open("sample5000.txt").read().split("\n"))), [])))))
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
結果
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
22660
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```Ruby
|
70
|
+
|
71
|
+
#encoding: utf-8
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
print open("sample5000.txt").read.split("\n").map{|e| e.split("")}.flatten.map(&:to_i).inject(:+).to_s
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
結果
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
22660
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
この数字が正しいかどうかは分かりません。
|
4
修正
test
CHANGED
@@ -21,3 +21,21 @@
|
|
21
21
|
Pythonは全く分かりませんが考えてみました。
|
22
22
|
|
23
23
|
個人的にはlistを使った方が簡単だと思います。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
参考にしたページ
|
28
|
+
|
29
|
+
問題の内容
|
30
|
+
|
31
|
+
[Problem 13 「大きな数の足し算」](http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2013)
|
32
|
+
|
33
|
+
以下の50桁の数字100個の合計の上から10桁を求めなさい。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
答え
|
38
|
+
|
39
|
+
[Project Euler 13: Sum of 50-digit numbers](http://www.mathblog.dk/project-euler-13/)
|
40
|
+
|
41
|
+
[PROJECT EULER PROBLEM 13](http://code.jasonbhill.com/python/project-euler-problem-13/)
|
3
修正
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
print
|
17
|
+
print open("sample5000.txt").read.split("\n").map(&:to_i).inject(:+).to_s[0..9]
|
18
18
|
|
19
19
|
```
|
20
20
|
|
2
修正
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
p File.read("sample5000.txt").split("\n").map(&:to_i).inject(:+).to_s[0..9]
|
17
|
+
print File.read("sample5000.txt").split("\n").map(&:to_i).inject(:+).to_s[0..9]
|
18
18
|
|
19
19
|
```
|
20
20
|
|
1
修正
test
CHANGED
@@ -19,3 +19,5 @@
|
|
19
19
|
```
|
20
20
|
|
21
21
|
Pythonは全く分かりませんが考えてみました。
|
22
|
+
|
23
|
+
個人的にはlistを使った方が簡単だと思います。
|