2022 - Day 3 part 1
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kleph 2022-12-03 09:28:15 +01:00
parent 6ccbdfeacd
commit 451fe9e6bf
3 changed files with 327 additions and 0 deletions

21
2022/3/3.py Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python
# 2022 - Advent Of Code 3
#file = 'input_example.txt'
file = 'input.txt'
prio = 0
with open(file, encoding="utf-8") as f:
for line in f.readlines():
half_len = int(len(line.strip()) / 2)
str1 = line[:half_len]
str2 = line[half_len:]
common = list(set(str1).intersection(str2))
num = ord(common[0])
if num > 90: # lower case
prio += num - 96
else:
prio += num - 64 + 26
print(prio)

300
2022/3/input.txt Normal file
View file

@ -0,0 +1,300 @@
NJvhJcQWTJWTNTFFMTqqGqfTmB
VwVzPldRZVLVRmfsvfjvqfmm
ZDPDHZHVcvDhbvnv
FHHwHBzzVCWWmmCzCPrVmgBwbLTtRFFbbbttRGRLjTcLpbbT
vhZZvdsNSdSMdNvjncppCLcLnGnj
CDZZsNZMZqdNSdlNZCqrzPHDzgrgzwVVWwmwwm
ndlndntsFJntFvccLjjLrjBShcBBfc
GpCGHzVwmmzqQWSSSfWHBhQL
mpCMGGCZVzVwGGVwmJsZnFtZnTSTJtdsvl
nCnPDGmDNmVCsVQDmGSWqvzchWSjjcWGqS
gTnBRLpfTRnrTdZgdLfRdrThvqcvWWhFFWvcFSSgjqqzjv
pfZfTMwrbLTTfsbmQtlVtHHnbs
wNdSdsbTvTZMTvTv
rrdRWdWQhFVdHWBGWQmmmnnMvCfmnhvmCmtZ
rJrVDRWpGddpbSlNSlspPP
chTNrthMMwWMTjfsmRzZszJpwm
BLnFFCngbcBnbbldDlpRjGpmsCzGsGsRGmmG
dqvnvlgbqtcPPMhH
QcLNqZbCzJDQBJJRpwzRpdnRldgnpf
GmmmvVGsHrWffrlwdCWd
CMsFVVFjCmFStGQbbLZNBbJBcTjc
LQVggbQvcLbQLHgvVLhWGGsChssrMWfzGccc
qDnRTTRqJttP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