File tree Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Original file line number Diff line number Diff line change 1
- from collections import Counter
2
-
3
- s1 = [0 ]
4
-
5
- def secret (num ):
6
- prices = Counter ()
7
- last4 = (10 ,10 ,10 ,10 )
8
- for i in range (2000 ):
1
+ s1 , s2 = 0 , {}
2
+ for num in map (int , open (0 )):
3
+ seen = set ()
4
+ last4 = (10 , 10 , 10 , 10 )
5
+ for _ in range (2000 ):
9
6
prev = num % 10
10
7
num ^= (num * 64 ) % 16777216
11
- num ^= ( num // 32 ) % 16777216
8
+ num ^= num // 32
12
9
num ^= (num * 2048 ) % 16777216
13
10
last4 = last4 [1 :] + (num % 10 - prev ,)
14
- if last4 not in prices :
15
- prices [ last4 ] = num % 10
16
- s1 [ 0 ] += num
17
- return prices
11
+ if last4 not in seen :
12
+ seen . add ( last4 )
13
+ s2 [ last4 ] = s2 . get ( last4 , 0 ) + num % 10
14
+ s1 += num
18
15
19
- ints = map (int , open (0 ))
20
- c = sum (map (secret , ints ), Counter ())
21
- print (s1 [0 ])
22
- print (sorted (c .values ())[- 1 ])
16
+ print (s1 )
17
+ print (sorted (s2 .values ())[- 1 ])
You can’t perform that action at this time.
0 commit comments