summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2023-12-08 13:19:54 +0100
committerSanto Cariotti <santo@dcariotti.me>2023-12-08 13:19:54 +0100
commitf00cfad68ad1e28467703aa3cec96c41d3e4821b (patch)
treeaca4cb4406a3e06f8153c71ea94cef1304f81ff8
parentc34b3109bb6d7bc40208428d6afa031227186911 (diff)
day8 p1
-rw-r--r--2023/Cargo.toml2
-rw-r--r--2023/day8/Cargo.toml8
-rw-r--r--2023/day8/example.txt9
-rw-r--r--2023/day8/example2.txt10
-rw-r--r--2023/day8/input.txt796
-rw-r--r--2023/day8/src/lib.rs115
6 files changed, 939 insertions, 1 deletions
diff --git a/2023/Cargo.toml b/2023/Cargo.toml
index 22a53f4..5956f72 100644
--- a/2023/Cargo.toml
+++ b/2023/Cargo.toml
@@ -1,2 +1,2 @@
[workspace]
-members = ["day1", "day2", "day3", "day4", "day5", "day6", "day7", "day7_2"]
+members = ["day1", "day2", "day3", "day4", "day5", "day6", "day7", "day7_2", "day8"]
diff --git a/2023/day8/Cargo.toml b/2023/day8/Cargo.toml
new file mode 100644
index 0000000..4879259
--- /dev/null
+++ b/2023/day8/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day8"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/2023/day8/example.txt b/2023/day8/example.txt
new file mode 100644
index 0000000..9029a1b
--- /dev/null
+++ b/2023/day8/example.txt
@@ -0,0 +1,9 @@
+RL
+
+AAA = (BBB, CCC)
+BBB = (DDD, EEE)
+CCC = (ZZZ, GGG)
+DDD = (DDD, DDD)
+EEE = (EEE, EEE)
+GGG = (GGG, GGG)
+ZZZ = (ZZZ, ZZZ)
diff --git a/2023/day8/example2.txt b/2023/day8/example2.txt
new file mode 100644
index 0000000..5b3fa58
--- /dev/null
+++ b/2023/day8/example2.txt
@@ -0,0 +1,10 @@
+LR
+
+11A = (11B, XXX)
+11B = (XXX, 11Z)
+11Z = (11B, XXX)
+22A = (22B, XXX)
+22B = (22C, 22C)
+22C = (22Z, 22Z)
+22Z = (22B, 22B)
+XXX = (XXX, XXX)
diff --git a/2023/day8/input.txt b/2023/day8/input.txt
new file mode 100644
index 0000000..ac178d0
--- /dev/null
+++ b/2023/day8/input.txt
@@ -0,0 +1,796 @@
+LRRLRLRRRLLRLRRRLRLLRLRLRRLRLRRLRRLRLRLLRRRLRRLLRRRLRRLRRRLRRLRLRLLRRLRLRRLLRRRLLLRRRLLLRRLRLRRLRLLRRRLRRLRRRLRRLLRRRLRRRLRRRLRLRRLRLRRRLRRRLRRLRLRRLLRRRLRRLLRRLRRLRLRLRRRLRLLRRRLRRLRRRLLRRLLLLLRRRLRRLLLRRRLRRRLRRLRLLLLLRLRRRLRRRLRLRRLLLLRLRRRLLRRRLRRRLRLRLRRLRRLRRLRLRLLLRLRRLRRLRRRLRRRLLRRRR
+
+RBX = (TMF, KTP)
+RBP = (MKS, MKS)
+CGR = (XDR, VDX)
+KBX = (DGP, JKM)
+BNJ = (NJC, QRL)
+BXQ = (DKX, CJQ)
+NDX = (PHJ, TRQ)
+KFQ = (KXN, GBQ)
+LRF = (CTS, MTT)
+RTN = (VMK, JTK)
+QKP = (FDS, SFG)
+BVB = (BHS, VRQ)
+NBT = (BPJ, DFF)
+HQM = (QMV, XVG)
+XMR = (RKH, NJQ)
+PHC = (XHP, DKM)
+HTX = (BXK, BQP)
+TPJ = (TNQ, QDX)
+RDJ = (KHB, MFG)
+XTF = (PPR, FHG)
+DVA = (DBM, MVD)
+HFP = (CXV, VCD)
+HPS = (GTD, NBL)
+LBK = (FVN, LHX)
+KKS = (FKM, LHN)
+FJV = (LVN, PLP)
+MLH = (SFR, RJK)
+SVQ = (RCS, FFD)
+PTB = (TMC, QCR)
+RFL = (RXP, VRL)
+PTH = (XTS, GFG)
+QNM = (TJR, MHX)
+BJT = (PJG, SHG)
+JJD = (FMJ, QVV)
+GMX = (CLD, QRM)
+DGZ = (BSL, BRS)
+BVM = (SFC, JGD)
+GNQ = (PLP, LVN)
+XPG = (VLH, BCM)
+PND = (RXV, VGM)
+RNV = (GVL, MTB)
+JSG = (QVP, XCX)
+QHP = (KQG, BML)
+XBK = (NPP, CRN)
+QRL = (RQH, BGH)
+HDJ = (VRQ, BHS)
+XPD = (HSB, LRC)
+KJK = (XCV, MDG)
+NJB = (RKL, SHQ)
+MCQ = (XFT, MRQ)
+QRC = (XVS, CSN)
+FCT = (DFF, BPJ)
+MTF = (PQT, CNQ)
+RXG = (QVP, XCX)
+MVZ = (QRC, GHJ)
+RKL = (QQM, BFT)
+VRT = (GMJ, BDK)
+BNS = (HQV, HPS)
+JSQ = (HTC, PGD)
+BHB = (VGQ, BTM)
+NLP = (RKB, XQB)
+FGF = (CVK, VRT)
+FPM = (GDS, LTG)
+BCX = (NDX, GSL)
+GVL = (VCX, PSP)
+KRM = (MHK, JCX)
+GLJ = (XNX, RKP)
+LBV = (FDC, TPJ)
+GSP = (KMC, LQR)
+TFR = (HXJ, MFJ)
+DLX = (FNK, GLJ)
+DKX = (XSR, LHP)
+SVR = (KPX, QTM)
+JMT = (GXV, RTX)
+XSX = (HHD, HHD)
+RJF = (BRH, HGP)
+BDK = (TGX, HKP)
+TFF = (DSX, DSX)
+TJR = (BKB, LCB)
+BDQ = (CLD, QRM)
+NTC = (BQL, BQL)
+CVS = (RQC, FFV)
+BML = (VNT, JRH)
+CBK = (TGB, RTN)
+HQV = (GTD, NBL)
+PDT = (SRQ, MLD)
+RXV = (KJK, FCD)
+XTS = (SCG, KQJ)
+PXG = (LKG, MTQ)
+PCX = (FKJ, FCV)
+HKR = (LMK, BJR)
+CKK = (XSX, XSX)
+TNP = (TDH, JPR)
+PCH = (RBP, PQH)
+KHB = (RQR, BXQ)
+CJZ = (CNC, HJX)
+JPN = (FRP, QTB)
+RKP = (NKH, FQC)
+BDP = (GCM, VKT)
+HQX = (TQF, NJB)
+PFV = (FPM, VNP)
+NFQ = (GFX, GXH)
+STX = (MCQ, DNS)
+CKX = (CFS, BNS)
+NRJ = (SBG, TLK)
+DHS = (VBH, VMT)
+TVL = (BPQ, NBM)
+QTF = (MPS, RJB)
+FHV = (LMK, BJR)
+JCV = (JSQ, STQ)
+RGX = (GVL, MTB)
+CTS = (PCB, GJV)
+RCS = (TNT, XTF)
+PCS = (NJH, RLX)
+KNG = (CHP, FNN)
+FJL = (KKH, QGQ)
+CPK = (KTX, CGR)
+BLF = (PCQ, TKN)
+FCR = (STF, SVQ)
+BSL = (GFJ, CDL)
+FKS = (GRG, JSB)
+FCM = (LFX, RJF)
+XLK = (CDP, CBD)
+KNB = (VGQ, BTM)
+KGC = (TJR, MHX)
+JHM = (JSP, XDN)
+HFN = (STF, SVQ)
+GCM = (CKX, KPS)
+CGV = (MHK, JCX)
+TQP = (JRM, XSB)
+GSM = (FJV, GNQ)
+KBL = (DLX, BGD)
+CBC = (MQK, RRF)
+NJM = (KLQ, BVL)
+THG = (CPG, PND)
+DXP = (HDJ, BVB)
+DTT = (XDN, JSP)
+PLP = (BKF, FGP)
+MSZ = (MVD, DBM)
+BQC = (NPL, VXF)
+CGB = (LRM, MTH)
+RLX = (DBT, RJN)
+RXP = (HFP, JNS)
+TTH = (QNF, KNG)
+LHS = (QFR, GTN)
+NBL = (THT, VTQ)
+DRS = (PJH, STX)
+PSP = (CPK, QKF)
+PPR = (LQK, VSN)
+QHT = (RLG, TDG)
+FVM = (MLR, HXF)
+DHB = (CQC, BKK)
+MVP = (GHJ, QRC)
+TDG = (RVX, CDB)
+LKN = (HXF, MLR)
+CNR = (KCV, CDR)
+SMC = (BBR, BMS)
+QDP = (LXV, VPS)
+LLD = (CGC, NGQ)
+KXN = (PRR, PSR)
+LRC = (SHB, PBK)
+SQD = (LBV, CRP)
+QTB = (KNS, JTS)
+MTT = (GJV, PCB)
+GMV = (JNH, MJF)
+DTG = (SQD, KVV)
+RTV = (DSB, SJB)
+CDL = (FTQ, CPN)
+JHR = (JRM, XSB)
+BFP = (PFG, MTD)
+DTB = (NDX, GSL)
+SQM = (CXL, NBD)
+NBP = (KBN, LQH)
+BTC = (LJT, TCV)
+PQT = (PXG, BSF)
+QDH = (FPM, VNP)
+VPT = (PRT, VHJ)
+VKC = (GXK, QSB)
+NXB = (QKP, TGK)
+FDF = (VRT, CVK)
+NTG = (FRV, BQR)
+RKB = (PHC, JSD)
+MHV = (XXL, THG)
+PHV = (SNM, TFR)
+XRK = (JNN, LKR)
+XVS = (CBK, NNM)
+GDQ = (BDQ, GMX)
+TKR = (CKJ, LVQ)
+XCX = (LSP, FNB)
+JCX = (FGF, FDF)
+MFJ = (DBB, HBH)
+BQP = (HRT, DQD)
+VNC = (BDQ, GMX)
+SSC = (LQH, KBN)
+TJD = (QFV, KRS)
+NKL = (CKK, DDC)
+NTM = (QHG, MCC)
+JBQ = (HXV, JPN)
+DGP = (FVM, LKN)
+SJB = (LRQ, DMG)
+LJT = (MMT, MDL)
+RFC = (MVM, JXP)
+FFV = (TPG, QMD)
+PJH = (DNS, MCQ)
+VCD = (FHV, HKR)
+MPS = (DHH, LPT)
+VHJ = (RGX, RNV)
+FLT = (FRF, NHG)
+DSF = (SDV, VKC)
+HJQ = (CDR, KCV)
+BQR = (PDX, PMX)
+CRJ = (BPN, KKS)
+MQN = (PNN, DHB)
+KCC = (KMC, LQR)
+BTH = (VLH, BCM)
+KNS = (GGM, SJS)
+SCG = (MBF, RDR)
+VDQ = (JNN, LKR)
+XFT = (VPT, FLH)
+RDR = (GTF, GJR)
+CXS = (RRF, MQK)
+XDN = (SSF, VGC)
+JPR = (VGX, TCF)
+BTF = (LKM, GBG)
+GCJ = (VPS, LXV)
+FGJ = (XVG, QMV)
+MBF = (GJR, GTF)
+TPG = (TND, QSF)
+BNR = (BHG, SMC)
+GJV = (FLB, PCX)
+LQF = (BJT, KTN)
+VSB = (JVB, FVK)
+NHB = (HQX, LLQ)
+CKC = (PJD, TRS)
+JVB = (QQV, NRS)
+BKK = (LSR, LJN)
+SBV = (GTN, QFR)
+JMK = (MFG, KHB)
+LPX = (NBP, SSC)
+KLJ = (CDX, VTL)
+KQJ = (RDR, MBF)
+VMK = (JXJ, BMT)
+TRS = (LQM, JJD)
+KCM = (XBD, XMH)
+JCT = (NFQ, NDJ)
+FGM = (HMK, PGQ)
+QKK = (RLS, LPX)
+QJD = (PDT, RPQ)
+LHP = (PLN, MQN)
+NPL = (TFF, TFF)
+XHP = (PJQ, KBL)
+HMK = (JNV, XPS)
+KMC = (VCG, NTG)
+QDX = (TMM, HHM)
+VNP = (LTG, GDS)
+PDR = (CDX, VTL)
+HVK = (BQC, SCN)
+QMV = (BNJ, CRL)
+DDR = (KRS, QFV)
+RDG = (QHP, QXN)
+CRL = (NJC, QRL)
+SHB = (SQX, JVV)
+TSP = (BPX, FVC)
+RRF = (KJB, PTB)
+CSG = (FRX, RTP)
+RPQ = (SRQ, MLD)
+VXS = (MTN, DJQ)
+PJK = (NGD, NTM)
+QHG = (NXT, DHS)
+LSP = (MTR, GGH)
+SHN = (JJS, RVC)
+TNQ = (TMM, HHM)
+NPK = (GCM, VKT)
+MJF = (NBT, FCT)
+JNN = (PTH, HFK)
+NRS = (CLT, HGV)
+HSX = (BPX, FVC)
+MVM = (DSF, NQS)
+PBK = (SQX, JVV)
+HHD = (DBM, MVD)
+MTD = (DVB, BTX)
+PXP = (NPP, CRN)
+TMF = (LPF, QPD)
+BRT = (FJV, GNQ)
+MFQ = (BHG, SMC)
+DJQ = (MVP, MVZ)
+LKR = (PTH, HFK)
+STQ = (HTC, PGD)
+DXF = (JBX, TRT)
+RJN = (PDR, KLJ)
+CGC = (KKL, RJV)
+SRG = (QKK, LND)
+MCC = (DHS, NXT)
+JMG = (RLX, NJH)
+NKH = (DGF, FJL)
+JXP = (DSF, NQS)
+GXX = (CKC, MFL)
+MXD = (KBC, FGK)
+SCH = (XPG, BTH)
+XSR = (MQN, PLN)
+KKD = (NBD, CXL)
+CLJ = (GCN, GCN)
+QVV = (THK, LQV)
+VLH = (FFB, STD)
+RTP = (CBC, CXS)
+RVX = (BLF, PTM)
+KBN = (JNF, BTC)
+PFX = (JHM, DTT)
+NVL = (KCM, DLK)
+QRM = (CQK, RBB)
+HKP = (SHN, TMV)
+VXF = (TFF, JRP)
+LDL = (LHM, JMT)
+BQL = (DRS, VQQ)
+FDC = (TNQ, QDX)
+MMT = (MSL, JCT)
+CXV = (HKR, FHV)
+BKB = (FCM, QTC)
+HRQ = (RXG, JSG)
+RKH = (JFF, TKR)
+VQR = (JGD, SFC)
+KCV = (LNG, NCV)
+XSB = (DTG, DFK)
+JGD = (HLP, FNS)
+VCK = (RXP, VRL)
+GTN = (BCP, CKB)
+QDK = (CBD, CDP)
+SNF = (JNH, MJF)
+FVK = (QQV, NRS)
+HHM = (VXK, PJK)
+JRM = (DTG, DFK)
+QPL = (XLK, QDK)
+SCV = (QHP, QXN)
+RQC = (QMD, TPG)
+LFX = (BRH, HGP)
+FRX = (CXS, CBC)
+BTM = (FPK, JVF)
+BPN = (LHN, FKM)
+LRQ = (LSQ, PMP)
+TPV = (LQF, KDN)
+XBN = (QDS, DXP)
+RBB = (FCR, HFN)
+XSM = (LNT, STB)
+SBR = (PQT, CNQ)
+LVM = (SBV, LHS)
+KBC = (JHR, TQP)
+DLJ = (FGK, KBC)
+LKG = (VJX, HLQ)
+NXT = (VMT, VBH)
+CBD = (HGN, HBG)
+BHS = (VTF, MRV)
+BTP = (GBG, LKM)
+DSM = (CKK, CKK)
+LSR = (CMB, NLP)
+NPP = (BCX, DTB)
+XCV = (SMS, QJD)
+PNM = (BPQ, NBM)
+VPS = (JJB, XMR)
+JNH = (FCT, NBT)
+KTN = (SHG, PJG)
+FMJ = (LQV, THK)
+GFX = (NBB, NBB)
+SRQ = (GNS, QGB)
+FQC = (DGF, FJL)
+MPA = (BRS, BSL)
+BMS = (FKS, SKF)
+BMT = (JMG, PCS)
+QFV = (SCH, FDJ)
+STF = (RCS, FFD)
+JTS = (GGM, SJS)
+NJQ = (TKR, JFF)
+MTQ = (HLQ, VJX)
+FGK = (TQP, JHR)
+JNF = (TCV, LJT)
+LKM = (KGC, QNM)
+MXV = (BQP, BXK)
+FRF = (LVM, HGK)
+GGH = (BHB, KNB)
+BGH = (KBX, FDN)
+LQH = (JNF, BTC)
+JVF = (LDS, DCD)
+CLT = (QPL, LFV)
+HRV = (TRD, RXH)
+NBD = (PXP, XBK)
+PJD = (JJD, LQM)
+XMV = (BBF, LKX)
+BCN = (PBH, HPL)
+XMH = (JNG, GCX)
+HFK = (GFG, XTS)
+VTL = (RFC, VPF)
+MSL = (NFQ, NDJ)
+THH = (KNG, QNF)
+PCB = (PCX, FLB)
+GBQ = (PRR, PSR)
+NMS = (BQC, SCN)
+PDX = (BGP, SFH)
+LDS = (TLJ, LLD)
+HGV = (QPL, LFV)
+LMK = (VKX, JCV)
+NBM = (PKR, QCS)
+NLR = (LKJ, DGZ)
+QDN = (TRT, JBX)
+MTH = (HMT, NJM)
+CKF = (LKJ, LKJ)
+FDN = (DGP, JKM)
+CDR = (NCV, LNG)
+SGJ = (GBQ, KXN)
+TMM = (VXK, PJK)
+JSL = (CTS, MTT)
+QGB = (TBK, NHB)
+TDA = (GHJ, QRC)
+GTF = (QDP, GCJ)
+TCG = (FVK, JVB)
+LXJ = (FVN, LHX)
+TQF = (RKL, SHQ)
+ZZZ = (VQQ, DRS)
+NCV = (CRJ, GBL)
+BKF = (CJP, PRL)
+QPD = (DQN, JBQ)
+MFL = (PJD, TRS)
+NHG = (HGK, LVM)
+MRV = (MLH, TBV)
+XHS = (PSN, HRQ)
+JJB = (NJQ, RKH)
+TGK = (SFG, FDS)
+CGS = (TRD, RXH)
+GCN = (NCN, CVS)
+PNN = (BKK, CQC)
+LSQ = (KCC, GSP)
+LND = (RLS, LPX)
+CPG = (VGM, RXV)
+GSF = (HMJ, RMH)
+JRH = (VQR, BVM)
+FJB = (DTT, JHM)
+FKM = (BFK, XCQ)
+LPT = (PRD, CGB)
+XVG = (CRL, BNJ)
+KRS = (FDJ, SCH)
+BNL = (BQL, ZZZ)
+JMB = (XVD, MBH)
+KKH = (RLN, PHV)
+MTB = (PSP, VCX)
+NCN = (FFV, RQC)
+FVC = (QJC, SRG)
+FTS = (THG, XXL)
+SFG = (BCN, DBN)
+RXH = (XQT, SDR)
+MLR = (GDQ, VNC)
+TRD = (XQT, SDR)
+BGD = (GLJ, FNK)
+XDJ = (MPS, RJB)
+JMJ = (MDJ, RTV)
+RVC = (PXQ, NRJ)
+QQV = (CLT, HGV)
+MLD = (QGB, GNS)
+KPH = (HRQ, PSN)
+RLN = (TFR, SNM)
+JRP = (DSX, HPD)
+SJS = (DSM, NKL)
+PGD = (CGS, HRV)
+HPL = (GKH, CVN)
+MQK = (PTB, KJB)
+QCR = (MHV, FTS)
+VCG = (BQR, FRV)
+LXV = (XMR, JJB)
+PKR = (QSH, XMV)
+JSB = (DLJ, MXD)
+VRL = (JNS, HFP)
+PHJ = (BTF, BTP)
+CXL = (XBK, PXP)
+FNN = (TSP, HSX)
+XQT = (VHH, QHT)
+LQV = (DQK, JMB)
+RLS = (NBP, SSC)
+TCV = (MDL, MMT)
+QTC = (LFX, RJF)
+LRK = (MFL, CKC)
+MHK = (FGF, FDF)
+RLJ = (HJX, CNC)
+TLK = (RFL, VCK)
+CNC = (HJQ, CNR)
+LQL = (FRX, RTP)
+QQM = (MFQ, BNR)
+VBH = (HLB, JMJ)
+GKX = (TGK, QKP)
+KQG = (JRH, VNT)
+XDR = (DNF, KJV)
+GMJ = (HKP, TGX)
+VRQ = (VTF, MRV)
+HGP = (VNB, LDL)
+LNG = (GBL, CRJ)
+BSF = (LKG, MTQ)
+BRH = (VNB, LDL)
+PJQ = (BGD, DLX)
+QKF = (CGR, KTX)
+QMD = (TND, QSF)
+PQH = (MKS, STP)
+FRV = (PDX, PMX)
+LPF = (JBQ, DQN)
+CQM = (TDH, JPR)
+HJX = (CNR, HJQ)
+AAA = (DRS, VQQ)
+TDH = (VGX, TCF)
+TGX = (TMV, SHN)
+BDH = (XFV, GSF)
+GXK = (BFP, TFH)
+BFT = (MFQ, BNR)
+NGD = (QHG, MCC)
+FPK = (DCD, LDS)
+MTR = (KNB, BHB)
+SNM = (MFJ, HXJ)
+HLP = (RHQ, SVR)
+JSP = (VGC, SSF)
+NJH = (RJN, DBT)
+SKF = (GRG, JSB)
+PTM = (TKN, PCQ)
+QGQ = (PHV, RLN)
+SSF = (NVL, JPB)
+PCQ = (LTC, PCH)
+KJV = (GMS, XGF)
+JSD = (XHP, DKM)
+RRB = (LQF, KDN)
+GJJ = (FLT, BNV)
+FJA = (HJX, CNC)
+HLQ = (XRK, VDQ)
+KTP = (LPF, QPD)
+PRD = (LRM, MTH)
+QNF = (CHP, FNN)
+DQK = (MBH, XVD)
+TMS = (CLJ, XML)
+QVP = (FNB, LSP)
+BPX = (QJC, SRG)
+QXN = (KQG, BML)
+VGQ = (JVF, FPK)
+BRS = (CDL, GFJ)
+NQS = (VKC, SDV)
+LFV = (XLK, QDK)
+SMS = (RPQ, PDT)
+BBF = (CGV, KRM)
+VMT = (HLB, JMJ)
+QSF = (JSL, LRF)
+CJQ = (XSR, LHP)
+RDF = (KKD, SQM)
+MKS = (CKF, CKF)
+STD = (MNM, TMS)
+DNS = (MRQ, XFT)
+MFG = (RQR, BXQ)
+GBG = (QNM, KGC)
+JNG = (RDG, SCV)
+CVN = (GJJ, QVC)
+HMT = (BVL, KLQ)
+VTQ = (NTC, BNL)
+TGB = (JTK, VMK)
+PSR = (NPK, BDP)
+MDJ = (DSB, SJB)
+CKB = (VSB, TCG)
+DNF = (GMS, XGF)
+LQK = (XFR, RDF)
+RHQ = (KPX, QTM)
+VKX = (STQ, JSQ)
+BRX = (DDR, TJD)
+LJN = (NLP, CMB)
+DJR = (HMK, PGQ)
+VNB = (JMT, LHM)
+DBM = (SBR, MTF)
+KLQ = (XBN, MNH)
+MDL = (MSL, JCT)
+SQX = (TPV, RRB)
+CLD = (CQK, RBB)
+HPD = (RLJ, CJZ)
+LHN = (BFK, XCQ)
+KJB = (TMC, QCR)
+RLG = (RVX, CDB)
+PBH = (GKH, CVN)
+DMB = (HHD, MSZ)
+SDV = (GXK, QSB)
+KPX = (XDJ, QTF)
+NBB = (MTN, MTN)
+BTX = (BRT, GSM)
+HGN = (HJT, RBX)
+GDS = (XSM, BGG)
+KDN = (KTN, BJT)
+GSL = (TRQ, PHJ)
+SFR = (XHS, KPH)
+JNV = (TVL, PNM)
+JNS = (VCD, CXV)
+LHM = (GXV, RTX)
+TFH = (MTD, PFG)
+GHJ = (CSN, XVS)
+KNQ = (LRK, GXX)
+PRT = (RNV, RGX)
+JTK = (BMT, JXJ)
+MRQ = (VPT, FLH)
+TKN = (LTC, PCH)
+VSN = (XFR, RDF)
+HXJ = (DBB, HBH)
+PRL = (THH, TTH)
+GCX = (RDG, SCV)
+MNH = (DXP, QDS)
+CMB = (XQB, RKB)
+CHP = (TSP, HSX)
+BCP = (TCG, VSB)
+LNT = (HQM, FGJ)
+FNK = (XNX, RKP)
+HRT = (FJB, PFX)
+HTC = (CGS, HRV)
+SDR = (QHT, VHH)
+CQK = (FCR, HFN)
+LVN = (FGP, BKF)
+FDS = (DBN, BCN)
+QCS = (QSH, XMV)
+TRT = (KFQ, SGJ)
+RQH = (FDN, KBX)
+QJC = (QKK, LND)
+MVD = (SBR, MTF)
+SBG = (RFL, VCK)
+DSX = (RLJ, RLJ)
+JBX = (KFQ, SGJ)
+JVV = (RRB, TPV)
+BBR = (FKS, SKF)
+KTX = (VDX, XDR)
+CSN = (NNM, CBK)
+NNM = (RTN, TGB)
+VXK = (NGD, NTM)
+DQD = (FJB, PFX)
+CDB = (BLF, PTM)
+GBL = (BPN, KKS)
+BGP = (SNT, BRX)
+CRP = (FDC, TPJ)
+DFK = (KVV, SQD)
+LVQ = (KNQ, FBX)
+HSB = (PBK, SHB)
+PJG = (TNP, CQM)
+JPB = (KCM, DLK)
+JJS = (PXQ, NRJ)
+XGF = (QDH, PFV)
+DKM = (KBL, PJQ)
+DVB = (GSM, BRT)
+TMC = (MHV, FTS)
+TRQ = (BTP, BTF)
+FLB = (FCV, FKJ)
+BVL = (MNH, XBN)
+XPA = (NCN, CVS)
+XPS = (PNM, TVL)
+CPN = (RDJ, JMK)
+RQR = (DKX, CJQ)
+SFH = (SNT, BRX)
+DBT = (KLJ, PDR)
+MBH = (XCS, XPD)
+DLK = (XMH, XBD)
+HBG = (HJT, RBX)
+THK = (DQK, JMB)
+DGF = (KKH, QGQ)
+BPJ = (GKX, NXB)
+MTN = (MVP, MVP)
+TMV = (RVC, JJS)
+GMS = (PFV, QDH)
+FDJ = (BTH, XPG)
+FFB = (MNM, MNM)
+RTX = (LBK, LXJ)
+BGG = (LNT, STB)
+LRM = (HMT, NJM)
+XVD = (XPD, XCS)
+THT = (NTC, NTC)
+GXH = (NBB, VXS)
+LTG = (XSM, BGG)
+GKH = (GJJ, QVC)
+TNT = (FHG, PPR)
+CDP = (HGN, HBG)
+DQN = (HXV, JPN)
+FNS = (SVR, RHQ)
+DSB = (DMG, LRQ)
+DCD = (TLJ, LLD)
+FTQ = (JMK, RDJ)
+VGX = (SFN, BDH)
+VDX = (KJV, DNF)
+PMX = (SFH, BGP)
+VTF = (TBV, MLH)
+LQM = (FMJ, QVV)
+VNT = (VQR, BVM)
+XML = (GCN, QFZ)
+VPF = (MVM, JXP)
+TBK = (LLQ, HQX)
+PXQ = (TLK, SBG)
+LKX = (CGV, KRM)
+DBN = (PBH, HPL)
+XXL = (CPG, PND)
+BHG = (BBR, BMS)
+VQQ = (STX, PJH)
+VHH = (RLG, TDG)
+RJK = (KPH, XHS)
+BFK = (MXV, HTX)
+VJX = (XRK, VDQ)
+GFJ = (CPN, FTQ)
+GRG = (MXD, DLJ)
+CQC = (LJN, LSR)
+RJB = (DHH, LPT)
+FGP = (CJP, PRL)
+BCM = (FFB, STD)
+FBX = (GXX, LRK)
+FLH = (VHJ, PRT)
+GTD = (THT, THT)
+GNS = (NHB, TBK)
+QTM = (XDJ, QTF)
+VGM = (KJK, FCD)
+XBD = (JNG, GCX)
+QVC = (BNV, FLT)
+FCV = (LQL, CSG)
+SCN = (NPL, VXF)
+KKL = (HVK, NMS)
+MDG = (QJD, SMS)
+QSB = (BFP, TFH)
+LKJ = (BRS, BSL)
+XCS = (HSB, LRC)
+HLB = (MDJ, RTV)
+TLJ = (NGQ, CGC)
+MNM = (CLJ, CLJ)
+STB = (HQM, FGJ)
+HJT = (TMF, KTP)
+TND = (LRF, JSL)
+FVN = (QDN, DXF)
+SNT = (TJD, DDR)
+JKM = (LKN, FVM)
+LTC = (RBP, PQH)
+STP = (CKF, NLR)
+DMG = (LSQ, PMP)
+CDX = (RFC, VPF)
+CNQ = (PXG, BSF)
+PMP = (KCC, GSP)
+VKT = (CKX, KPS)
+CKJ = (FBX, KNQ)
+VGC = (JPB, NVL)
+LCB = (QTC, FCM)
+TCF = (BDH, SFN)
+DDC = (XSX, DMB)
+SFN = (XFV, GSF)
+HXF = (GDQ, VNC)
+BPQ = (QCS, PKR)
+FFD = (TNT, XTF)
+TBV = (SFR, RJK)
+DBB = (FGM, DJR)
+FHG = (VSN, LQK)
+GGM = (DSM, NKL)
+RJV = (NMS, HVK)
+NGQ = (RJV, KKL)
+CFS = (HQV, HPS)
+PFG = (BTX, DVB)
+VCX = (QKF, CPK)
+XCQ = (MXV, HTX)
+DHH = (PRD, CGB)
+HBH = (DJR, FGM)
+RMH = (GMV, SNF)
+HXV = (QTB, FRP)
+QFZ = (CVS, NCN)
+CVK = (BDK, GMJ)
+SHQ = (QQM, BFT)
+PGQ = (XPS, JNV)
+LQR = (NTG, VCG)
+QDS = (BVB, HDJ)
+CJP = (THH, TTH)
+FNB = (GGH, MTR)
+PSN = (RXG, JSG)
+LHX = (QDN, DXF)
+GFG = (SCG, KQJ)
+PRR = (NPK, BDP)
+QSH = (LKX, BBF)
+KVV = (LBV, CRP)
+DFF = (NXB, GKX)
+JFF = (CKJ, LVQ)
+FCD = (MDG, XCV)
+SFC = (FNS, HLP)
+KPS = (BNS, CFS)
+PLN = (PNN, DHB)
+SHG = (CQM, TNP)
+GJR = (QDP, GCJ)
+NDJ = (GFX, GXH)
+XQB = (PHC, JSD)
+FKJ = (CSG, LQL)
+FRP = (KNS, JTS)
+MHX = (BKB, LCB)
+HGK = (LHS, SBV)
+JXJ = (JMG, PCS)
+NJC = (RQH, BGH)
+LLQ = (TQF, NJB)
+QFR = (BCP, CKB)
+BXK = (DQD, HRT)
+XFR = (KKD, SQM)
+XFV = (HMJ, RMH)
+HMJ = (GMV, SNF)
+BNV = (NHG, FRF)
+GXV = (LBK, LXJ)
+XNX = (NKH, FQC)
+BJR = (VKX, JCV)
+CRN = (BCX, DTB)
diff --git a/2023/day8/src/lib.rs b/2023/day8/src/lib.rs
new file mode 100644
index 0000000..31f2e2c
--- /dev/null
+++ b/2023/day8/src/lib.rs
@@ -0,0 +1,115 @@
+use std::collections::HashMap;
+
+pub fn part1(input: &str) -> u32 {
+ let mut res: u32 = 0;
+
+ let lines: Vec<String> = input
+ .trim_end()
+ .split('\n')
+ .map(|x| x.to_string())
+ .collect();
+ let ltype = &lines[0];
+ let mut hm: HashMap<String, (String, String)> = HashMap::new();
+ for play in &lines[2..] {
+ hm.insert(
+ play[..3].to_string(),
+ (play[7..10].to_string(), play[12..15].to_string()),
+ );
+ }
+
+ let mut current = "AAA".to_string();
+ for i in ltype.chars().cycle() {
+ current = match i {
+ 'R' => hm.get(&current).unwrap().1.clone(),
+ 'L' => hm.get(&current).unwrap().0.clone(),
+ _ => panic!("wtf is this?"),
+ };
+ res += 1;
+
+ if current == "ZZZ".to_string() {
+ break;
+ }
+ }
+
+ res
+}
+
+pub fn part2(input: &str) -> u32 {
+ let mut res: u32 = 0;
+
+ let lines: Vec<String> = input
+ .trim_end()
+ .split('\n')
+ .map(|x| x.to_string())
+ .collect();
+ let ltype = &lines[0];
+ let mut hm: HashMap<String, (String, String)> = HashMap::new();
+
+ for play in &lines[2..] {
+ hm.insert(
+ play[..3].to_string(),
+ (play[7..10].to_string(), play[12..15].to_string()),
+ );
+ }
+
+ let mut currents: Vec<String> = hm
+ .keys()
+ .filter(|x| x.ends_with("A"))
+ .into_iter()
+ .map(|x| x.to_string())
+ .collect::<Vec<String>>();
+
+ dbg!("{currents:?}");
+ 'o: for i in ltype.chars().cycle() {
+ for k in 0..currents.len() {
+ currents[k] = match i {
+ 'R' => hm.get(&currents[k]).unwrap().1.clone(),
+ 'L' => hm.get(&currents[k]).unwrap().0.clone(),
+ _ => panic!("wtf is this?"),
+ };
+ res += 1;
+ }
+
+ for current in &currents {
+ if !current.ends_with("Z") {
+ continue 'o;
+ }
+ }
+ break;
+ }
+
+ res
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn example_part1() {
+ let input = include_str!("../example.txt");
+ let result = part1(input);
+ assert_eq!(result, 2);
+ }
+
+ #[test]
+ fn input_part1() {
+ let input = include_str!("../input.txt");
+ let result = part1(input);
+ assert_eq!(result, 21389);
+ }
+
+ #[test]
+ fn example_part2() {
+ let input = include_str!("../example2.txt");
+ let result = part2(input);
+ assert_eq!(result, 12);
+ }
+
+ // #[test]
+ // fn input_part2() {
+ // let input = include_str!("../input.txt");
+ // let result = part2(input);
+ // assert_eq!(result, 248179786);
+ // }
+}