回答編集履歴
2
修正
answer
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
# rubyっぽく書くなら -----
|
17
17
|
(1..10).each do |x|
|
18
|
-
next if 7/x
|
18
|
+
next if 7/x == 0 || 7.divmod(x)[1] == 0
|
19
19
|
hash[x] = 7.divmod(x)
|
20
20
|
end
|
21
21
|
end
|
1
rubyっぽく書いた
answer
CHANGED
@@ -13,6 +13,14 @@
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
# rubyっぽく書くなら -----
|
17
|
+
(1..10).each do |x|
|
18
|
+
next if 7/x != 0 || 7.divmod(x)[1] == 0
|
19
|
+
hash[x] = 7.divmod(x)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# --------------------
|
23
|
+
|
16
24
|
hash
|
17
25
|
#=> {2=>[3, 1], 3=>[2, 1], 4=>[1, 3], 5=>[1, 2], 6=>[1, 1]}
|
18
26
|
```
|