-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathday04.py
executable file
·85 lines (69 loc) · 1.08 KB
/
day04.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
from utils.all import *
fin = advent.get_input()
eprint(*fin, sep='')
timer_start()
##################################################
n = 0
for p in range(145852, 616942 + 1):
# for p in range(111122, 111122 + 1):
s = str(p)
x = tuple(map(int, s))
a = x[0]
tot = 1
ok = False
for b in x[1:]:
if b == a:
tot += 1
if tot == 2:
ok = True
break
a = b
if ok:
a = x[0]
for b in x[1:]:
if b < a:
ok = False
break
a = b
if ok:
n += 1
# print(p)
# 47 wrong answer
# 3756 wrong answer
advent.submit_answer(1, n)
n = 0
for p in range(145852, 616942 + 1):
# for p in range(111122, 111122 + 1):
s = str(p)
x = tuple(map(int, s))
a = x[0]
tot = 1
ok = False
for b in x[1:]:
if b == a:
tot += 1
if tot == 3:
ok = False
else:
if tot == 2:
ok = True
break
tot = 1
a = b
if tot == 2:
ok = True
if ok:
a = x[0]
for b in x[1:]:
if b < a:
ok = False
break
a = b
if ok:
n += 1
# print(p)
# 816 wrong answer
# 938 wrong answer
# 990 wrong answer
advent.submit_answer(2, n)