Browse Source

Random golfing.

master
Chris Smith 6 years ago
parent
commit
97c4a095d6
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      01.py

+ 2
- 2
01.py View File

@@ -8,5 +8,5 @@ with open('data/01.txt', 'r') as file:
8 8
 import numpy as np
9 9
 with open('data/01.txt', 'r') as file:
10 10
     captcha = list(file.readline().strip())
11
-    print('Part one: %s' % sum(int(i) for i, j in zip(captcha, np.roll(captcha, 1).tolist()) if i == j))
12
-    print('Part two: %s' % sum(int(i) for i, j in zip(captcha, np.roll(captcha, len(captcha)//2).tolist()) if i == j))
11
+for part, roll in enumerate([1, len(captcha)//2]):
12
+    print('Part %s: %s' % (part + 1, sum(int(i) for i, j in zip(captcha, np.roll(captcha, roll)) if i == j)))

Loading…
Cancel
Save