Przeglądaj źródła

Simplify mod operation.

master
Chris Smith 7 lat temu
rodzic
commit
359efc30b3
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1
    1
      01.py

+ 1
- 1
01.py Wyświetl plik

@@ -19,7 +19,7 @@ moves = [(movement_lookup[move[0]], int(move[1:])) for move in input.split(', ')
19 19
 heading = 0
20 20
 history = [(0, 0)]
21 21
 for move in moves:
22
-    heading = (heading + move[0] + 4) % 4
22
+    heading = (heading + move[0]) % 4
23 23
     delta = map(operator.mul, direction_lookup[heading], (move[1], move[1]))
24 24
     delta_mag = max(abs(delta[0]), abs(delta[1]))
25 25
     history += zip(steps(history[-1][0], delta[0], delta_mag),

Ładowanie…
Anuluj
Zapisz