浏览代码

Simplify mod operation.

master
Chris Smith 7 年前
父节点
当前提交
359efc30b3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1
    1
      01.py

+ 1
- 1
01.py 查看文件

@@ -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),

正在加载...
取消
保存