質問編集履歴

1

加筆

2016/12/02 12:16

投稿

daikitakaya
daikitakaya

スコア229

test CHANGED
File without changes
test CHANGED
@@ -28,6 +28,44 @@
28
28
 
29
29
 
30
30
 
31
+ ```
32
+
33
+ def match_word(word1, word2)
34
+
35
+ result_1 = []
36
+
37
+ result_2 = []
38
+
39
+ i = 0
40
+
41
+ count = 0
42
+
43
+ word1.chars{ |spel_1| result_1 << spel_1}
44
+
45
+ word2.chars{ |spel_2| result_2 << spel_2}
46
+
47
+ word1.length.times{
48
+
49
+ if result_1[i] != result_2[i]
50
+
51
+ count += 1
52
+
53
+ puts "#{i+1}文字目"
54
+
55
+ end
56
+
57
+ i += 1
58
+
59
+ }
60
+
61
+ puts "#{count}回"
62
+
63
+ end
64
+
65
+ ```
66
+
67
+
68
+
31
69
  ###補足情報
32
70
 
33
71
  二つの単語の文字数が異なる場合はerrorを返すこととします。