day 3 both parts

This commit is contained in:
Skye 2022-12-13 19:25:38 +09:00
parent 200456de89
commit 89fd3bed34
Signed by: me
GPG key ID: 0104BC05F41B77B8
3 changed files with 319 additions and 0 deletions

8
3.py Normal file
View file

@ -0,0 +1,8 @@
with open("input3.txt") as f:
a = dict(zip(map(chr,(list(range(97,123))+list(range(65,91)))),range(1,53)))
s = 0
for line in f.readlines():
line = line.strip()
d, f = map(set,(line[:len(line)//2],line[len(line)//2:]))
s += a[(d&f).pop()]
print(s)

11
3pt2.py Normal file
View file

@ -0,0 +1,11 @@
with open("input3.txt") as f:
a = dict(zip(map(chr,(list(range(97,123))+list(range(65,91)))),range(1,53)))
s = 0
h = []
for line in f.readlines():
h.append(set(line.strip()))
if len(h) < 3:
continue
s += a[(h[0]&h[1]&h[2]).pop()]
h = []
print(s)

300
input3.txt Normal file
View file

@ -0,0 +1,300 @@
MVWpzTTrTFNNLtssjV
hRJncnJCnhPCnBSbCQRhhQRPFHmsbHLzbLNHsjNNFmGGGsGF
lSBQJBBBBcnccnQvBnPQznfrgwlrTZfDwTfWqrrpgMpw
sRPgrzSgrSbfTrgspBPsDWWTmdnvdZWZwTmwvdmd
tVGpCGqCGjlHcNGVNHZDmnZMWdWMWCdZDvnZ
HqpQptLlclLGtlpcjHNhQqfRhrSBrrbfbrSRrsPfBSgg
JpjLbQbFPBjDBBJLWltglfBfhhlcctht
vNFmsdFsnmzGtWvgzhzc
rqwRCCqmCTqHCnqRNTNFsJVMQSjLRbbVVbjQVLbLSV
mLNNCNDwBwDnmCwnJwLRvdlqZclRccsgvcZndc
QWMtVWbpVlgHHcgMHs
VsTVWhThsVQWzjtQPpVWjWbpwJNCJDCzSNNCCCSfmfBCSGLL
NbSfHnwDvwwfHwwQsHbWPgrsZsZjRPLRgLWhWP
lmMlTGFzVmzqjGLLZWWGhrCh
qFclMprqmrvbcnwDQtNQ
tWQZFvvtWQWbqQQggZZLvpLrpzDrmGDmmDHPzPzHrfnHTG
NMlhlTMccTCVBlRN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