Browse Source

Starmap!

master
Chris Smith 6 years ago
parent
commit
5b8b1074da
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      15.py

+ 3
- 3
15.py View File

@@ -1,4 +1,4 @@
1
-import itertools
1
+from itertools import starmap, islice
2 2
 import operator
3 3
 
4 4
 
@@ -12,5 +12,5 @@ def gen(seed, factor, multiple=1):
12 12
 
13 13
 with open('data/15.txt', 'r') as file:
14 14
     seeds = [int(line.strip().split()[-1]) for line in file.readlines()]
15
-    print(f'Part one: {sum(map(lambda t: t[0] == t[1], itertools.islice(zip(gen(seeds[0], 16807), gen(seeds[1], 48271)), 40000000)))}')
16
-    print(f'Part two: {sum(map(lambda t: t[0] == t[1], itertools.islice(zip(gen(seeds[0], 16807, 4), gen(seeds[1], 48271, 8)), 5000000)))}')
15
+    print(f'Part one: {sum(starmap(operator.eq, islice(zip(gen(seeds[0], 16807), gen(seeds[1], 48271)), 40000000)))}')
16
+    print(f'Part two: {sum(starmap(operator.eq, islice(zip(gen(seeds[0], 16807, 4), gen(seeds[1], 48271, 8)), 5000000)))}')

Loading…
Cancel
Save