ソースを参照

Fix mistake on day 3

Jonatan Gezelius 3 年 前
コミット
d478515ce9
1 ファイル変更5 行追加8 行削除
  1. 5 8
      2020/03/a.py

+ 5 - 8
2020/03/a.py

@@ -3,15 +3,12 @@ tree = '#'
 
 def hit_function(map, x, y):
     wrapped_x = x % len(map[0])
-
-    if (map[y][wrapped_x] == tree):
-        return True
-    else:
-        return False
+    print(wrapped_x)
+    return map[y][wrapped_x] == tree
 
 def check_stage(map, n):
-    x = 3*n
-    y = n
+    x = 3*(n+1)
+    y = n+1
     return hit_function(map, x, y)
 
 def solve_task(filename):
@@ -22,7 +19,7 @@ def solve_task(filename):
             toboggan_slope.append(line)
 
     trees_hit = 0
-    for n in range(len(toboggan_slope)):
+    for n in range(len(toboggan_slope)-1):
         if check_stage(toboggan_slope, n):
             trees_hit += 1