summaryrefslogtreecommitdiffstats
path: root/20/py
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-12-16 06:52:49 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-12-16 06:57:23 +0100
commitef4f59a33f226e1b1c619a17417c6c7009d9c017 (patch)
treeeff5fda3527a0dc8367c5fa22658e353b7acf8ec /20/py
parentb49e6b4971f9dbeee7a5308ef557b6dec7179ef1 (diff)
downloadaoc-ef4f59a33f226e1b1c619a17417c6c7009d9c017.tar.gz
16: remove prints
Diffstat (limited to '20/py')
-rw-r--r--20/py/d16.py18
1 files changed, 0 insertions, 18 deletions
diff --git a/20/py/d16.py b/20/py/d16.py
index e2c1170..e9f478b 100644
--- a/20/py/d16.py
+++ b/20/py/d16.py
@@ -8,11 +8,9 @@ def pt1(_in):
for line in _in[:20]:
thing = []
line = line.strip().split(": ")
- name = line[0]
for a in line[1].split(" or "):
b = a.split("-")
thing.append(range(int(b[0]), int(b[1])+1))
- # things.append((name, thing))
things.append(thing)
res = 0
for line in _in[25:]:
@@ -33,13 +31,10 @@ def pt2(_in):
for line in _in[:20]:
thing = []
line = line.strip().split(": ")
- name = line[0]
for a in line[1].split(" or "):
b = a.split("-")
thing.append(range(int(b[0]), int(b[1])+1))
- # constraints.append((name, thing))
constraints.append(thing)
- print("\n".join(str(c) for c in constraints))
tickets = []
for line in _in[25:]:
@@ -60,25 +55,15 @@ def pt2(_in):
# for each field
# assume it can be anything
candidates = [set(range(20)) for _ in range(20)] # one set per field
- print("\n".join(str(c) for c in candidates))
- # for each ticket
for t, ticket in enumerate(tickets):
- print(t, ticket)
for f, field in enumerate(ticket):
- print(f, field)
- print(candidates[f])
for c, constraint in enumerate(constraints):
- print(c, constraint)
if c in candidates[f] and not any(field in cons for cons in constraint):
- print(f"{f} cannot be {c}")
candidates[f].remove(c)
- print("\n".join(str(c) for c in candidates))
-
know = [-1 for _ in range(20)]
while any(len(c) > 0 for c in candidates):
- print(know, "\n", "\n".join(str(c) for c in candidates))
for c, cand in enumerate(candidates):
if len(cand) == 1:
know[c] = cand.pop()
@@ -87,13 +72,10 @@ def pt2(_in):
for cand in candidates:
if to_remove in cand:
cand.remove(to_remove)
- print()
- print("\n".join(str(c) for c in candidates))
my = list(int(n) for n in _in[22].strip().split(","))
res = 1
for f, field in enumerate(know):
- print(f, field)
if field < 6:
res *= my[f]
return res