27 lines
545 B
Python
27 lines
545 B
Python
#!/usr/bin/env python3
|
|
|
|
def preproc(puzzle_input):
|
|
space = tuple(map(int, puzzle_input.split('-')))
|
|
cands = []
|
|
for i in range(*space):
|
|
digs = str(i)
|
|
|
|
if sorted(digs) != list(digs):
|
|
continue
|
|
if max(digs.count(d) for d in set(digs)) < 2:
|
|
continue
|
|
cands.append(i)
|
|
return cands
|
|
|
|
def partI(cands):
|
|
return len(cands)
|
|
|
|
def partII(cands):
|
|
c = 0
|
|
for i in cands:
|
|
digs = str(i)
|
|
if 2 in [digs.count(d) for d in set(digs)]:
|
|
c += 1
|
|
return c
|
|
|