回答編集履歴

1

Update

2021/11/24 03:29

投稿

melian
melian

スコア20655

test CHANGED
@@ -32,19 +32,21 @@
32
32
 
33
33
 
34
34
 
35
- inputs.chars.zip(inputs.chars[1..])[...-1].map{|consecutive|
35
+ inputs.chars.each_cons(2).map{|consecutive|
36
36
 
37
37
  a, b = consecutive.map{|c| index_on_keyboard(c, keyboard)}
38
38
 
39
39
  pos = [[1, 0], [-1, 0], [0, 1], [0, -1]].map{|x, y| [a[0]+x, a[1]+y]}
40
40
 
41
+ nhand = b[0] / 5
42
+
41
43
  if ([a] + pos).include?(b) then
42
44
 
43
- mistake += 1 if hand != (b[0] / 5)
45
+ mistake += 1 if hand != nhand
44
46
 
45
47
  else
46
48
 
47
- hand = index_on_keyboard(consecutive[1], keyboard)[0] / 5
49
+ hand = nhand
48
50
 
49
51
  end
50
52