Day 3 (Puzzle 1) - Rucksack Reorganization

Successfully finished the first puzzle.
main
Peery 2 years ago
parent e29575cb35
commit 34ee2b12a4

@ -1,4 +1,4 @@
from typing import Tuple
from typing import Tuple, List
from entities.items.item import Item
from entities.items.food import Food
@ -75,3 +75,14 @@ class Elf:
raise Exception(f"Something went terribly wrong! Other: {other} Own: {own}")
return was_win, round_score + RPS.RPS_SHAPE_TO_SCORE[own]
def check_rucksack_for_compartment_duplicates(self, rucksack: Tuple[List[str], List[str]]) -> str:
"""
Check a given rucksack for the duplicate item according to day 3 puzzle 1
:return: the duplicate item (as a character)
"""
for a in rucksack[0]:
if a in rucksack[1]:
return a
raise ValueError(f"Couldn't find ANY duplicate in this rucksack: {rucksack[0]} | {rucksack[1]}")

@ -0,0 +1,6 @@
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw

@ -0,0 +1,300 @@
DMwrszrfMzSSCpLpfCCn
RMvhZhQqlvhMvRtbvbcPclPlncddppLTdppd
tVMQhFtjjWmsFJsmsW
trRtvNhfJhSzzSTFVhQQZQhHGphP
CnLMBWLwDMgMcwwdngdHGPVTQGpTHZdGPGpd
LLDqcDgwqCMnLWqtvzrzbbtJqPjJ
wQQwHNQLmbWQbQRHwHNFBbwqPfjqlzRMGRqzpSfvPlzplM
nCtGCZZtsGsrtDMZpfMpSlMlvlZq
cJctJCgVJsCJnDTsCthGhGLwBWBbbQmLbgQLQQdWbbbQ
ZWnNlTNTnhhQQlDNdmmpwrrrqBwjwjZd
GzvlVRSfvMVMvGlSpdCCdjmfpmBCdsqB
bzlFlLzJWLHHttLL
SmzFhVDzrmSrszVDVhSVbhZcCZdfZNcnMfMbZnNN
PTTRGqwqTqWRwLgTLTZGnCbZbNddZCCtMcNs
sgPqPqgJgWWqjj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sBsDZZCzczB
MSjdVHvHnDDhHvdwBwssZVzwcgLcQg
HnMMTdttHSHSpHvDddpSHTjWlNWFlmRtRmRbqGfqGGNNfR
fBLTDppznrfTndfnfTzTLPvZvvHVbRbggjvzVbzvbV
mwmDGGlqDhMqthGqhJMWmlNVRZPHjgwjjRZbbHRgRHvv
DmhsJsshWGhSGlmlmrdcLLsTBBfcfnBppc
mbCGFFmGmcdTrCTQdh
MJHfJNLllJffPLRTdBqTRQNcqQGB
fPJHfSSSWfSLDMLWGHDMLDFmznmsjmvZwzvjZjbvbZ
pPvpJSfZTTvCzNZczzQZchcj
svbHWsqsvbsMFtVHgVtcRQcDlQRRRQLjlqjczj
tBsgvHVMFggbgFrgWnwSndfBmmBJfPSfpn
jwbwfjSbwjVSjvZPzWSvhvhQlCsBFgLRLLgBLRClLLFQQw
GdNJHpmHTDnTNJqnFCgBLFLFzFtsQRCd
NpMJHpnMrDpJGTHqTTmJHTPjfcvbWfrffVzvZfVWSbjz
wFwpqWwwpqwtqqrbCFtptDmCcfNhNRzRBZRRJRChVNBZBJ
svlvjHsQlvdlvMLdlvPSSLtzzczcNhJthfNtRcNMJNMc
HvvPLSHjgltjsvqwbbnmWmDpgwTT
zhCmPVwwChdCBtsWnNWswBWr
GJJSfSgFpjJjGgpfpgrcNNstvnBHNnHLtFHr
jgDTfjpMgZMGMGJTMMJRhzZPCzbhVlPqdNCbhd
bDbQQmVDRpDNbRQlfQQZnfwTlllfsT
FChzzBWhVzrgMwffJwlnngnTlJ
MCvqvhFzcHCChjtpNNVLppGmbq
bZZzJnccqdzcLhrcQDLrDs
FfCfWVfjWTFClClfwjWCfGGwhZSDhSLsSSRpZprLph
mFmTMmFjMMWFfZtttflWjmWTngNHJHggJJHtzgnJvBtBgHdv

@ -1,21 +1,17 @@
from rucksack.file.rucksack_loader import RucksackLoader
from rucksack.ItemPriorities import item_priority
from entities.elf import Elf
from rockpaperscissor.file.guide_list import RockPaperScissorGuide
if __name__ == "__main__":
my_elf = Elf()
other_elf = Elf()
rounds = RockPaperScissorGuide("./input/day2/input.lst").parse_file()
scores = []
for other, own in rounds:
result, score = my_elf.evaluate_RPS_round(other, own)
scores.append(score)
if result:
r = "won"
else:
r = "lost"
print(f"Elf {my_elf} played {own} against {other} and {r} with {score} points!")
rs = RucksackLoader("./input/day3/input.lst").parse_file()
i = item_priority
duplicate_prios = []
for rucksack in rs:
elf = Elf()
duplicate = elf.check_rucksack_for_compartment_duplicates(rucksack)
duplicate_prios.append(item_priority[duplicate])
print(f"{elf} found duplicate \"{duplicate}\" with priority {item_priority[duplicate]}!")
print()
print(f"I've got a total of {sum(scores)} points!")
print(f"The priority sum is {sum(duplicate_prios)}")

@ -0,0 +1,21 @@
from entities.elf import Elf
from rockpaperscissor.file.guide_list import RockPaperScissorGuide
if __name__ == "__main__":
my_elf = Elf()
other_elf = Elf()
rounds = RockPaperScissorGuide("./input/day2/input.lst").parse_file()
scores = []
for other, own in rounds:
result, score = my_elf.evaluate_RPS_round(other, own)
scores.append(score)
if result:
r = "won"
else:
r = "lost"
print(f"Elf {my_elf} played {own} against {other} and {r} with {score} points!")
print()
print(f"I've got a total of {sum(scores)} points!")

@ -0,0 +1,3 @@
alphabet = "abcdefghijklmnopqrstuvwxyz"
item_priority = dict(zip(alphabet+alphabet.upper(), range(1, len(alphabet)+27+1)))

@ -0,0 +1,21 @@
from typing import List, Tuple
class RucksackLoader:
def __init__(self, path: str):
self.path = path
def parse_file(self) -> List[Tuple[List[str], List[str]]]:
rucksacks = []
with open(self.path, "r") as file:
for line in file:
line = line.strip()
if len(line) == 0:
continue
comp_1 = list(line[:len(line)//2])
comp_2 = list(line[len(line)//2:])
rucksacks.append((comp_1, comp_2))
return rucksacks
Loading…
Cancel
Save