diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-05 00:28:26 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-05 00:28:26 +0100 |
commit | 60ef4465333784b621429ec564a8a618ca9fb77c (patch) | |
tree | 1af7163810ff6d39cab7c00228c4d686c6a4fa1b /prog/aoc/23/4/1.py | |
parent | aoc3 (diff) | |
download | r-60ef4465333784b621429ec564a8a618ca9fb77c.tar r-60ef4465333784b621429ec564a8a618ca9fb77c.tar.gz r-60ef4465333784b621429ec564a8a618ca9fb77c.tar.bz2 r-60ef4465333784b621429ec564a8a618ca9fb77c.tar.lz r-60ef4465333784b621429ec564a8a618ca9fb77c.tar.xz r-60ef4465333784b621429ec564a8a618ca9fb77c.tar.zst r-60ef4465333784b621429ec564a8a618ca9fb77c.zip |
Diffstat (limited to 'prog/aoc/23/4/1.py')
-rwxr-xr-x | prog/aoc/23/4/1.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/prog/aoc/23/4/1.py b/prog/aoc/23/4/1.py new file mode 100755 index 0000000..2296fb9 --- /dev/null +++ b/prog/aoc/23/4/1.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +s = 0 +c = [] +t = [] +try: + while True: + l = input() + w = set(l.split(":")[1].split(" | ")[0].split(" "))-set([""]) + m = set(l.split(":")[1].split(" | ")[1].split(" "))-set([""]) + c.append(len(m&w)) + t.append(1) + if len(m&w) > 0: + s += 2**(len(w & m)-1) +except: + print(s) + s2 = 0 + for i in range(len(c)): + for j in range(c[i]): + t[1+i+j] += t[i] + s2 += t[i] + print(s2) |