diff --git a/2023/day_8/input.txt b/2023/day_8/input.txt index b221142..095fd72 100644 --- a/2023/day_8/input.txt +++ b/2023/day_8/input.txt @@ -1 +1,748 @@ -Paste any inputs into this file. \ No newline at end of file +LLLRLRLRLLRRRLRRRLRRRLLLRLRLLRRLLRRLRLRLLRLRLRRLLRRRLRLLRRLRRRLRRLLLRRRLRRRLRRRLLLLRRLRRRLRLRRRLRRLLRLRLRRRLRRRLRRLRRRLLLLLLRLRRRLLLLRLRRRLRRRLRLRRLRLRLRLRLRRRLLRRLRLRRLRRLRRLLRLLLRRLRLLRRLRLRRLRRRLRRLLRLRLRLRRLLRLLRRLLLRLRLRRRLRRLLRRRLRLRLRRLLRLRLRLRRLRLRLRRLRRLLRRLRRRLRRRLLLRRRR + +MQF = (DDG, LSH) +QJP = (PCT, XKJ) +JXF = (PMG, NBN) +JCK = (QCD, NRG) +LPD = (NTM, NTM) +DLN = (TXM, QRG) +MTG = (KGC, DMM) +KFV = (FXH, QLX) +SCJ = (HQH, XSD) +JKJ = (PMX, MHH) +SJK = (JXM, GRQ) +CJZ = (DPF, RMT) +QXM = (HGC, SMX) +XJS = (NRV, CCL) +QLB = (RCH, QVQ) +KDB = (QKT, BJB) +FCX = (DXG, SGQ) +PCT = (DXR, PTS) +MGJ = (FKF, HNG) +VBN = (RBK, JPL) +TRH = (SRT, VJV) +PGK = (SNP, QLP) +XVK = (KFK, QQC) +SXC = (XTB, DPQ) +HNG = (VXF, MVH) +QHT = (TTD, LBH) +LMK = (QQT, QTP) +DXR = (KCT, KQS) +FSA = (RXT, BLP) +GHK = (JMM, VBN) +DMM = (VQM, LTG) +FBQ = (FSV, GHJ) +KCN = (QVR, TDG) +KBF = (XNM, HBL) +KJP = (FKG, CJZ) +JLH = (CKG, XLV) +RJX = (KKN, RJH) +PFS = (BVC, SXR) +DHM = (HXV, FRV) +KFK = (PLL, GQC) +CNB = (KNS, HVP) +DDG = (QTS, VRJ) +QVT = (JCK, DJQ) +LRB = (TXD, MPR) +DMS = (QVD, MFS) +PMJ = (LNN, NPJ) +BXD = (MLL, QKQ) +DGF = (FMX, PKP) +RHQ = (RJH, KKN) +MRG = (TNN, LLX) +BBM = (VFP, VGF) +PLP = (BBK, KFX) +RSN = (SBN, DQF) +XTP = (HMT, XNV) +LLX = (KBF, TDV) +KHR = (QGL, NCM) +PFB = (SXR, BVC) +NKP = (JTF, BJH) +RPH = (RSN, VBM) +HBL = (LVT, JXF) +CBC = (LRB, QGN) +FXH = (GCH, KBD) +QTF = (KVL, DLS) +RPQ = (FJB, RMD) +SLD = (MSH, NSN) +PXF = (QXM, HDF) +QBJ = (RDQ, DJH) +QPH = (RKJ, CSC) +TVF = (JMC, MTV) +MJM = (DLM, BQS) +XQV = (LCD, QCL) +KQH = (SJK, BPR) +CSC = (BLD, PDP) +BLP = (XVK, LJB) +BBK = (DJT, LLJ) +PSH = (GQH, RBQ) +RMD = (XQV, KFT) +TJJ = (QLV, HPG) +STS = (BSB, TMP) +FPN = (TCK, GLD) +JPF = (VCS, CMQ) +NVX = (TLD, GMD) +XLV = (LKV, QNK) +GSF = (CKS, BVB) +QHR = (KTV, KPG) +JRX = (FPN, DTC) +KGC = (VQM, LTG) +SSK = (NHP, NHP) +GLN = (RMX, NGG) +NPJ = (QRV, KTB) +PCP = (XSF, BPL) +JTF = (LSL, BHB) +TDV = (HBL, XNM) +FKV = (JVF, HKK) +GSG = (QJP, CLF) +QNK = (XNQ, CGQ) +RQT = (QVQ, RCH) +XNT = (RKM, XRV) +JMM = (RBK, JPL) +LSL = (NGH, KCN) +QLQ = (TLV, KDN) +KXR = (KRH, KRH) +QLV = (GSR, BQV) +PMG = (LPH, XFB) +VNF = (LVQ, HHG) +CSS = (RKK, RQN) +HGR = (PVX, LFX) +QGN = (MPR, TXD) +XNQ = (GTJ, LXQ) +QQC = (GQC, PLL) +CKR = (KQH, HQD) +TLD = (JLJ, VFL) +XSD = (TTQ, LDQ) +FXF = (BXS, LMQ) +ZZZ = (QBJ, MJJ) +HPG = (GSR, BQV) +LJC = (RNF, FNK) +CCL = (DXF, HRM) +FQR = (QBF, CLH) +GHJ = (MPS, NRB) +LLJ = (NVX, BTR) +MCQ = (RTG, CTK) +PLL = (DJD, FTV) +BLD = (XGL, NDH) +MLL = (NHV, PPJ) +KDN = (LLS, DLN) +KKN = (DCC, CCH) +FHB = (TCJ, VLF) +HCC = (RDN, TRJ) +TGV = (TKF, CFG) +TKB = (SVJ, KHH) +QDN = (RXG, PFF) +GQN = (RKT, NKK) +FLV = (TLV, KDN) +KTV = (LKK, VGH) +XHQ = (JLX, SNS) +MHN = (DHV, KMD) +DLD = (SSQ, LDK) +DKD = (CKR, JPC) +SRD = (KPP, LFS) +LVT = (PMG, NBN) +KPP = (FLQ, XTX) +BQV = (GLN, NQG) +BSB = (KHR, FGL) +HGC = (DBX, QTF) +DSF = (RBQ, GQH) +GRQ = (MVQ, RVP) +JGT = (SFN, GQT) +HDF = (SMX, HGC) +QBF = (VKF, XHQ) +QKM = (JTV, LPP) +LJB = (QQC, KFK) +NTH = (QQV, MHS) +QTX = (FMX, PKP) +HCQ = (FFT, CBC) +XKJ = (DXR, PTS) +BHH = (KPP, LFS) +GRH = (QLQ, FLV) +FNX = (MJX, PFZ) +HQN = (CKS, BVB) +SJV = (CGF, VKD) +RDL = (QJV, MLX) +MFR = (DMF, CFD) +LPF = (SRD, BHH) +HCP = (MPV, NVL) +KNS = (VCD, LJL) +CDX = (LLX, TNN) +SGS = (KMC, RQK) +HQS = (NKP, FRN) +QVD = (VML, QHT) +NRG = (LDS, SCH) +BVB = (HCP, NVM) +RBK = (QLB, RQT) +MPV = (CGR, TSC) +VFP = (JXP, QCM) +QFS = (DFQ, FHB) +FTK = (LSH, DDG) +TJH = (KPL, KTR) +HQF = (MQF, FTK) +FGX = (HVP, KNS) +DDK = (NTM, JNC) +BJC = (SQK, RGB) +HVP = (VCD, LJL) +LTG = (RMV, CJC) +BNR = (CSS, RBN) +GQT = (LCN, DTK) +XSF = (BGT, FCN) +SSQ = (KTL, JMR) +RNH = (BXH, BXH) +FTV = (CMM, PBL) +QRK = (TSF, QFS) +CLR = (NFS, PGK) +SRJ = (PFV, SHX) +FQT = (QKT, BJB) +FRN = (BJH, JTF) +RCN = (NRV, CCL) +QTM = (CKR, JPC) +JHT = (HRC, NVR) +KVB = (KRH, KKT) +HJG = (GHN, GHN) +RNF = (QFF, CKV) +PTT = (VNT, FNX) +GRB = (SVJ, KHH) +TRJ = (PVJ, QKP) +MHS = (FCV, JXD) +VBM = (SBN, DQF) +DLM = (VNH, SCJ) +PPJ = (DMH, PHJ) +QJN = (LSX, KBN) +HXV = (SMH, BJP) +GVL = (VMV, DKF) +QCG = (FKV, NVD) +FNM = (XRV, RKM) +JQJ = (NVT, HGR) +KVX = (GRG, PMJ) +JLV = (SMG, RPH) +TXD = (MFN, HQG) +TLJ = (FHD, MHN) +RPV = (GKH, BPT) +CPR = (JLH, PLC) +FLQ = (TPR, LGG) +BTF = (HGR, NVT) +GCH = (QPT, FDV) +JCF = (GHM, NKS) +CLF = (PCT, XKJ) +RMT = (QKM, XCP) +KPL = (DJB, VLV) +RMV = (NMS, HCC) +XRV = (VPH, PHH) +HBB = (XKH, FBQ) +PXB = (QBF, CLH) +HMR = (PCP, LMJ) +KCT = (PFS, PFB) +DCC = (MBP, BJC) +VFV = (VBD, HQS) +DJB = (BQX, SLD) +MFS = (VML, QHT) +RPC = (PHR, JFD) +RDS = (LFC, RNK) +KMC = (RPR, NRL) +CJD = (VJN, GKK) +VST = (VCS, CMQ) +VMC = (RPC, MCV) +VJV = (XTP, DRK) +BXH = (RXT, BLP) +PNQ = (DSF, PSH) +RJJ = (FXH, QLX) +NKS = (QDQ, DPP) +QDQ = (SJV, MRP) +HQQ = (CJD, DVT) +LKV = (CGQ, XNQ) +KTL = (HFF, FPS) +MBP = (RGB, SQK) +MQQ = (HCQ, MDL) +BQS = (SCJ, VNH) +NRT = (FJD, HTS) +HHG = (RTC, RPQ) +VNH = (XSD, HQH) +QTS = (QTG, MHD) +DJQ = (NRG, QCD) +MDX = (BPT, GKH) +QJV = (QQP, VLJ) +HBD = (HBB, CKC) +GBF = (HJG, FPV) +VDC = (JFJ, VNF) +MPH = (PFV, SHX) +TPR = (BXD, FVX) +KFX = (DJT, LLJ) +LSX = (VKN, STS) +HJL = (KFX, BBK) +QLT = (KGC, DMM) +QFF = (BJM, QCG) +DVM = (GCD, FSC) +MHD = (JCF, JPJ) +DPQ = (JJX, GNL) +NMS = (TRJ, RDN) +VLJ = (XJB, HSJ) +JSP = (MHN, FHD) +BTR = (GMD, TLD) +TTD = (SPC, DFJ) +QKT = (XPV, BVJ) +MKK = (HCQ, MDL) +LFC = (LSS, GQN) +QGL = (RPG, HGJ) +JDT = (FPN, DTC) +NCM = (RPG, HGJ) +LCN = (QLT, MTG) +VGS = (VJV, SRT) +CGF = (FXF, STT) +KQS = (PFB, PFS) +PFF = (DLD, MRJ) +LSH = (QTS, VRJ) +FGF = (MPH, SRJ) +BJG = (TVF, BDN) +HQR = (CXG, CPR) +JVF = (RGM, NCG) +SNP = (BLN, DFD) +DQH = (GSC, CFT) +JVA = (RMT, DPF) +VPH = (CRN, CHT) +DFQ = (VLF, TCJ) +DFD = (HQR, QDF) +NJH = (RXG, PFF) +DTK = (QLT, MTG) +MJJ = (DJH, RDQ) +GGB = (CFT, GSC) +SMH = (RHQ, RJX) +NFS = (SNP, QLP) +LNV = (XLR, KQF) +LCD = (FNM, XNT) +GQH = (JDT, JRX) +JPJ = (GHM, NKS) +GMD = (VFL, JLJ) +HTS = (KXR, KVB) +KFT = (LCD, QCL) +SGH = (NVR, HRC) +QKP = (MQD, MLM) +HFF = (MGM, KSX) +HJM = (KBN, LSX) +MJX = (VHC, PXF) +TSF = (FHB, DFQ) +MSH = (GFM, JHC) +VBG = (HJM, QJN) +CKS = (HCP, NVM) +DQF = (LJC, KXM) +FVP = (FJD, HTS) +DPP = (SJV, MRP) +FKM = (CSS, RBN) +VCD = (FCH, GBX) +DJV = (VMC, HVC) +RKM = (VPH, PHH) +TMP = (KHR, FGL) +BVC = (TLJ, JSP) +SRV = (HQS, VBD) +FCN = (DHM, VDX) +DJH = (FBG, MCQ) +NGG = (RPL, DFV) +SRT = (XTP, DRK) +RMN = (QTD, JGS) +MLH = (MQJ, VDR) +KVL = (VFV, SRV) +VDX = (FRV, HXV) +RXT = (LJB, XVK) +LSS = (RKT, NKK) +LNN = (KTB, QRV) +BCC = (CHL, QXP) +GHN = (XBS, XBS) +FCK = (FKM, BNR) +QLP = (BLN, DFD) +BDN = (JMC, MTV) +MLX = (VLJ, QQP) +RDH = (VNT, VNT) +DFV = (JKJ, KDX) +DXG = (JLV, MVL) +TCF = (DSF, PSH) +JJX = (MKM, TJJ) +VFL = (GGB, DQH) +VLV = (SLD, BQX) +RBQ = (JDT, JRX) +JXP = (QXB, QVT) +PFV = (STX, XHF) +BLN = (QDF, HQR) +FVX = (QKQ, MLL) +QTP = (DJV, GMN) +JLP = (NJF, MFR) +CXG = (PLC, JLH) +VKF = (JLX, SNS) +QQT = (GMN, DJV) +KDX = (MHH, PMX) +FJD = (KXR, KXR) +XJB = (PHB, JTH) +VMV = (RCN, XJS) +MKM = (HPG, QLV) +SQK = (GBF, JCS) +PMT = (SGQ, DXG) +LXQ = (GRB, TKB) +RKK = (SSK, SSK) +QXA = (VHC, PXF) +QDP = (QTD, JGS) +VQC = (KQF, XLR) +QKQ = (PPJ, NHV) +TXM = (JLP, JCJ) +SPC = (LRR, SXC) +BHG = (KFL, BCC) +QBK = (VNF, JFJ) +BPB = (LBJ, JGT) +RNK = (LSS, GQN) +BJP = (RHQ, RJX) +VNT = (MJX, MJX) +QLX = (GCH, KBD) +DXF = (RNH, RNH) +DLS = (VFV, SRV) +SXR = (TLJ, JSP) +SGQ = (JLV, MVL) +NRL = (XPP, XGM) +JFD = (LVD, LTQ) +XNM = (JXF, LVT) +PHH = (CHT, CRN) +QTD = (CTJ, LPF) +FCV = (GTC, CKJ) +QRG = (JLP, JCJ) +DKS = (KPL, KTR) +TTQ = (BFV, LVR) +RPR = (XGM, XPP) +DVS = (FTH, FFG) +RRH = (NJH, QDN) +KTR = (DJB, VLV) +KQM = (BJV, MND) +GKS = (BXH, QCZ) +FSV = (MPS, NRB) +QXB = (DJQ, JCK) +FHX = (QFS, TSF) +FGL = (QGL, NCM) +BHB = (KCN, NGH) +KNA = (KTV, KPG) +NBN = (LPH, XFB) +NVM = (NVL, MPV) +LVR = (CNB, FGX) +QCL = (FNM, XNT) +XRR = (MTB, HMR) +LLS = (TXM, QRG) +AAA = (MJJ, QBJ) +RPL = (JKJ, KDX) +QCM = (QVT, QXB) +QVF = (BQS, DLM) +LMQ = (LMK, BVF) +BLS = (CQK, GTG) +JMC = (PLP, HJL) +KXM = (RNF, FNK) +NDH = (FHJ, GML) +SNS = (VJK, FMJ) +KFL = (QXP, CHL) +FSD = (XNH, MJF) +DTC = (GLD, TCK) +MRP = (CGF, VKD) +JHX = (CJD, DVT) +KPG = (LKK, VGH) +DJT = (NVX, BTR) +MQD = (FQT, KDB) +CKJ = (BLS, CGP) +JXD = (GTC, CKJ) +NVL = (CGR, TSC) +PKV = (DBR, PGB) +JPL = (QLB, RQT) +TSC = (FMS, KRS) +XGL = (GML, FHJ) +DJD = (PBL, CMM) +FSC = (BFG, NTH) +DMH = (PBN, HND) +KRS = (FQR, PXB) +LLM = (GMX, VLX) +FJB = (XQV, KFT) +KRH = (QHR, QHR) +RDQ = (MCQ, FBG) +GLD = (VST, JPF) +RVP = (HBD, RBC) +DHV = (RJJ, KFV) +FMX = (RFL, GSG) +SMX = (DBX, QTF) +LPP = (FSD, PHM) +TDG = (MKK, MQQ) +HPL = (BDN, TVF) +MGM = (RDH, RDH) +FHJ = (XFJ, GVL) +TQB = (VFP, VGF) +JLJ = (DQH, GGB) +FMS = (FQR, PXB) +HQD = (BPR, SJK) +VXR = (XQX, VBG) +GML = (XFJ, GVL) +GCS = (RKJ, CSC) +CTJ = (SRD, BHH) +CLH = (XHQ, VKF) +HND = (RDL, PXS) +QPT = (RRH, CKQ) +NVD = (HKK, JVF) +XGM = (VFK, MLH) +GMN = (HVC, VMC) +QDF = (CXG, CPR) +TCK = (JPF, VST) +BJH = (LSL, BHB) +JNC = (BPB, SLZ) +GSC = (QVF, MJM) +XHG = (SRJ, MPH) +CGQ = (GTJ, LXQ) +CHL = (TGV, HPX) +MRJ = (LDK, SSQ) +GKH = (VQC, LNV) +MLM = (FQT, KDB) +BPT = (LNV, VQC) +BXT = (TKD, ZZZ) +PMP = (NHP, KJP) +PLC = (XLV, CKG) +FXA = (LBJ, JGT) +PKP = (RFL, GSG) +BQX = (MSH, NSN) +LBJ = (SFN, GQT) +KMD = (KFV, RJJ) +PVJ = (MQD, MLM) +LDQ = (LVR, BFV) +SLS = (PGB, DBR) +VTP = (HQQ, JHX) +MPS = (QTX, DGF) +VRJ = (QTG, MHD) +HBH = (HNG, FKF) +RTC = (RMD, FJB) +PHB = (LPD, LPD) +CMM = (DMS, KFB) +QVR = (MKK, MQQ) +XFJ = (DKF, VMV) +TLV = (DLN, LLS) +QRV = (SCL, BSJ) +MFN = (GHK, RRL) +NVT = (LFX, PVX) +FVL = (HMR, MTB) +VCS = (TQB, BBM) +XHF = (QBK, VDC) +JTV = (FSD, PHM) +VML = (TTD, LBH) +SCL = (DKS, TJH) +VHC = (QXM, HDF) +LPV = (GMX, VLX) +CFG = (BTF, JQJ) +MCV = (PHR, JFD) +LDS = (FGF, XHG) +VGF = (QCM, JXP) +BVF = (QQT, QTP) +VKN = (TMP, BSB) +VJK = (KQM, DHQ) +CTK = (GSF, HQN) +PHM = (MJF, XNH) +PVX = (MHK, SXL) +JPC = (KQH, HQD) +JGS = (CTJ, LPF) +XNV = (CLR, BLB) +PTS = (KCT, KQS) +BXS = (BVF, LMK) +BJB = (XPV, BVJ) +MHK = (VTP, KKX) +CJC = (NMS, HCC) +RKT = (PMT, FCX) +BFG = (QQV, MHS) +LPH = (HDD, DVM) +GSR = (GLN, NQG) +MHH = (VGS, TRH) +HMT = (BLB, CLR) +JCJ = (NJF, MFR) +MDK = (RPV, MDX) +LRR = (DPQ, XTB) +RKJ = (PDP, BLD) +MJF = (RXX, SGS) +NCG = (NRT, FVP) +QQV = (JXD, FCV) +MJQ = (BCC, KFL) +TKD = (MJJ, QBJ) +MND = (MDK, KBG) +RXG = (MRJ, DLD) +BGT = (DHM, VDX) +XCP = (LPP, JTV) +TRS = (QPH, GCS) +FPS = (MGM, KSX) +MVL = (SMG, RPH) +BJM = (NVD, FKV) +BSJ = (TJH, DKS) +MTV = (PLP, HJL) +GQC = (FTV, DJD) +CQL = (FTK, MQF) +VQM = (RMV, CJC) +SLZ = (JGT, LBJ) +HVC = (MCV, RPC) +LFX = (MHK, SXL) +BJQ = (LFC, RNK) +BFV = (FGX, CNB) +DRK = (HMT, XNV) +VBD = (NKP, FRN) +KBN = (STS, VKN) +XQX = (HJM, QJN) +MPR = (HQG, MFN) +KFB = (MFS, QVD) +GHM = (QDQ, DPP) +KBD = (QPT, FDV) +MVH = (FVL, XRR) +PGB = (RVG, TRS) +RGM = (NRT, FVP) +KKT = (QHR, GNZ) +TCJ = (RDS, BJQ) +MVQ = (HBD, RBC) +CKC = (XKH, FBQ) +SHX = (XHF, STX) +NVR = (RFF, GRH) +DKF = (RCN, XJS) +KTB = (BSJ, SCL) +HSJ = (PHB, JTH) +RJH = (DCC, CCH) +FNK = (QFF, CKV) +XNH = (SGS, RXX) +NRV = (DXF, DXF) +HRM = (RNH, GKS) +LJL = (GBX, FCH) +RDN = (PVJ, QKP) +JXM = (MVQ, RVP) +XLR = (HBH, MGJ) +QXP = (HPX, TGV) +HQH = (TTQ, LDQ) +HGJ = (FCK, HGS) +JTH = (LPD, DDK) +NKK = (FCX, PMT) +DHQ = (MND, BJV) +RFF = (FLV, QLQ) +RGB = (GBF, JCS) +RMX = (DFV, RPL) +VXF = (XRR, FVL) +SMG = (RSN, VBM) +KBG = (RPV, MDX) +QCZ = (BLP, RXT) +CQK = (BJG, HPL) +FDV = (RRH, CKQ) +CKQ = (QDN, NJH) +RRL = (JMM, VBN) +RVG = (QPH, GCS) +FTT = (GRG, PMJ) +FHD = (KMD, DHV) +GFM = (MRG, CDX) +FFG = (QRK, FHX) +RTG = (GSF, HQN) +PXS = (MLX, QJV) +MQJ = (JHT, SGH) +KSX = (RDH, PTT) +VXP = (VBG, XQX) +PMX = (TRH, VGS) +BPR = (GRQ, JXM) +VKD = (STT, FXF) +SXL = (KKX, VTP) +HDD = (GCD, FSC) +GTJ = (GRB, TKB) +CHT = (VXP, VXR) +RBC = (CKC, HBB) +XBS = (TKD, TKD) +KHH = (CQL, HQF) +XTX = (TPR, LGG) +LKK = (LLM, LPV) +VFK = (VDR, MQJ) +JLX = (VJK, FMJ) +FRV = (SMH, BJP) +GTC = (CGP, BLS) +PHR = (LTQ, LVD) +GCD = (BFG, NTH) +SBN = (KXM, LJC) +STX = (QBK, VDC) +FBG = (RTG, CTK) +CKV = (BJM, QCG) +DPF = (XCP, QKM) +FKF = (MVH, VXF) +BLB = (PGK, NFS) +XPV = (MJQ, BHG) +GMX = (FTT, KVX) +LBH = (DFJ, SPC) +JHC = (CDX, MRG) +GNL = (TJJ, MKM) +DSM = (FTH, FFG) +FFT = (QGN, LRB) +GRG = (NPJ, LNN) +JFJ = (HHG, LVQ) +CGR = (FMS, KRS) +LFS = (XTX, FLQ) +DMF = (TCF, PNQ) +LVQ = (RTC, RPQ) +DFJ = (SXC, LRR) +VLF = (RDS, BJQ) +LMJ = (BPL, XSF) +BVJ = (BHG, MJQ) +NRB = (QTX, DGF) +GKK = (RMN, QDP) +CFD = (PNQ, TCF) +GBX = (DSM, DVS) +NTM = (BPB, BPB) +XKH = (GHJ, FSV) +LGG = (BXD, FVX) +DBR = (RVG, TRS) +GTG = (BJG, HPL) +HKK = (NCG, RGM) +CKG = (LKV, QNK) +FKG = (RMT, DPF) +QVQ = (DKD, QTM) +LDK = (KTL, JMR) +PHJ = (PBN, HND) +PFZ = (PXF, VHC) +VLX = (KVX, FTT) +KQF = (HBH, MGJ) +RQN = (SSK, PMP) +CMQ = (TQB, BBM) +NHP = (FKG, FKG) +DVT = (GKK, VJN) +RPG = (FCK, HGS) +RBN = (RKK, RQN) +PBN = (RDL, PXS) +RCH = (QTM, DKD) +CRN = (VXP, VXR) +TNN = (KBF, TDV) +RFL = (QJP, CLF) +NJF = (DMF, CFD) +NQG = (RMX, NGG) +VDR = (JHT, SGH) +FPV = (GHN, BRB) +PBL = (DMS, KFB) +XTB = (JJX, GNL) +HGS = (FKM, BNR) +CCH = (BJC, MBP) +STT = (LMQ, BXS) +LTQ = (SLS, PKV) +SFN = (LCN, DTK) +NGH = (QVR, TDG) +RQK = (RPR, NRL) +PDP = (NDH, XGL) +FCH = (DSM, DVS) +QCD = (SCH, LDS) +TKF = (BTF, JQJ) +BPL = (BGT, FCN) +SVJ = (CQL, HQF) +QTG = (JPJ, JCF) +NSN = (GFM, JHC) +JCS = (HJG, FPV) +HRC = (GRH, RFF) +VGH = (LLM, LPV) +BRB = (XBS, BXT) +JMR = (HFF, FPS) +VJN = (RMN, QDP) +HPX = (TKF, CFG) +CFT = (QVF, MJM) +DBX = (KVL, DLS) +NHV = (PHJ, DMH) +FTH = (QRK, FHX) +XFB = (DVM, HDD) +XPP = (MLH, VFK) +CGP = (CQK, GTG) +MDL = (FFT, CBC) +GNZ = (KPG, KTV) +BJV = (KBG, MDK) +SCH = (FGF, XHG) +RXX = (KMC, RQK) +HQG = (GHK, RRL) +KKX = (JHX, HQQ) +LVD = (SLS, PKV) +QQP = (XJB, HSJ) +MTB = (LMJ, PCP) +FMJ = (KQM, DHQ) \ No newline at end of file diff --git a/2023/day_8/part 1 solution.py b/2023/day_8/part 1 solution.py index 0bb9c02..d2e2eeb 100644 --- a/2023/day_8/part 1 solution.py +++ b/2023/day_8/part 1 solution.py @@ -3,4 +3,75 @@ import os with open(r'advent_of_code\2023\day_8\input.txt', 'r') as file: input = file.read() -print(input) +#print(input) + +# test_input = '''RL +# AAA = (BBB, CCC) +# BBB = (DDD, EEE) +# CCC = (ZZZ, GGG) +# DDD = (DDD, DDD) +# EEE = (EEE, EEE) +# GGG = (GGG, GGG) +# ZZZ = (ZZZ, ZZZ)''' + +test_input = '''LLR +AAA = (BBB, BBB) +BBB = (AAA, ZZZ) +ZZZ = (ZZZ, ZZZ)''' + +input = input.split('\n') + +top_line = input[0] +#print(top_line) +# change L to 0 and R to 1 and split into list +top_line = list(top_line) +top_line = [s.replace('L', '0').replace('R', '1') for s in top_line] +#print(top_line) + +# create a dictionary of instructions, where is the key is a range of numbers and the value is a number from the top line +instructions = {} +for i in range(0, len(top_line)): + instructions[i] = top_line[i] + +#print(instructions) + +# now we need to take the rest of the input and and split it into a dictionary where the key is left of the = sign +# and the value is a list of the right of the = sign split by commas and stripped of whitespace and brackets + +guide = input[1:] +#print(guide) +if guide[0] == '': + guide.pop(0) +for i in range(0, len(guide)): + if '=' in guide[i]: + guide[i] = guide[i].replace(' ', '').replace('(', '').replace(')', '').split('=') + guide[i][1] = guide[i][1].split(',') + guide[i][1] = [x.strip() for x in guide[i][1]] + +# now we need to create a dictionary where the key is the left of the = sign and the value is a list of the right of the = sign split by commas and stripped of whitespace and brackets +guide_dict = {} +for i in range(0, len(guide)): + guide_dict[guide[i][0]] = guide[i][1] + +print(guide_dict) + +# starting at 'AAA' we need to follow the instructions to get to the bottom of the tree +# we need to follow the instructions until we get to ZZZ +# if we run out of instructions before we get to ZZZ then we need to repeat the instructions from where we are +# Convert the dictionary to a list + + +# Perform the operation + +current_node = 'AAA' +step = 0 +while current_node != 'ZZZ': + print(current_node) + # Use modulo to wrap step around if it's greater than the length of instructions + choose_items = int(instructions[step % len(instructions)]) + next_node = guide_dict[current_node][choose_items] + current_node = next_node + step += 1 + +print(f'finished in {step} steps, current node is {current_node}') +print(current_node) diff --git a/2023/day_8/part 2 solution.py b/2023/day_8/part 2 solution.py index 0bb9c02..3b7eab8 100644 --- a/2023/day_8/part 2 solution.py +++ b/2023/day_8/part 2 solution.py @@ -3,4 +3,80 @@ import os with open(r'advent_of_code\2023\day_8\input.txt', 'r') as file: input = file.read() -print(input) +#print(input) + +test_input = '''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)''' + +#test_input = '''LLR +#AAA = (BBB, BBB) +#BBB = (AAA, ZZZ) +#ZZZ = (ZZZ, ZZZ)''' + +input = input.split('\n') +#input = test_input.split('\n') + +top_line = input[0] +#print(top_line) +# change L to 0 and R to 1 and split into list +top_line = list(top_line) +top_line = [s.replace('L', '0').replace('R', '1') for s in top_line] +#print(top_line) + +# create a dictionary of instructions, where is the key is a range of numbers and the value is a number from the top line +instructions = {} +for i in range(0, len(top_line)): + instructions[i] = top_line[i] + +#print(instructions) + +# now we need to take the rest of the input and and split it into a dictionary where the key is left of the = sign +# and the value is a list of the right of the = sign split by commas and stripped of whitespace and brackets + +guide = input[1:] +#print(guide) +if guide[0] == '': + guide.pop(0) +for i in range(0, len(guide)): + if '=' in guide[i]: + guide[i] = guide[i].replace(' ', '').replace('(', '').replace(')', '').split('=') + guide[i][1] = guide[i][1].split(',') + guide[i][1] = [x.strip() for x in guide[i][1]] + +# now we need to create a dictionary where the key is the left of the = sign and the value is a list of the right of the = sign split by commas and stripped of whitespace and brackets +guide_dict = {} +for i in range(0, len(guide)): + guide_dict[guide[i][0]] = guide[i][1] + +print(guide_dict) + +# starting at 'AAA' we need to follow the instructions to get to the bottom of the tree +# we need to follow the instructions until we get to ZZZ +# if we run out of instructions before we get to ZZZ then we need to repeat the instructions from where we are +# Convert the dictionary to a list + + +# Perform the operation + +# Initialize current_nodes as a list of starting nodes +current_nodes = [node for node in guide_dict.keys() if node.endswith('A')] + +step = 0 +while not all(node.endswith('Z') for node in current_nodes): + #print(current_nodes) + print(step) + # Use modulo to wrap step around if it's greater than the length of instructions + choose_items = int(instructions[step % len(instructions)]) + # Update each node in the list + current_nodes = [guide_dict[node][choose_items] for node in current_nodes] + step += 1 + +print(f'finished in {step} steps, current nodes are {current_nodes}') +print(current_nodes) \ No newline at end of file diff --git a/2023/day_8/puzzle_text.md b/2023/day_8/puzzle_text.md index ecd36f8..d2c29bf 100644 --- a/2023/day_8/puzzle_text.md +++ b/2023/day_8/puzzle_text.md @@ -1 +1,53 @@ -# Day 8 Puzzle Text. \ No newline at end of file + +

--- Day 8: Haunted Wasteland ---

You're still riding a camel across Desert Island when you spot a sandstorm quickly approaching. When you turn to warn the Elf, she disappears before your eyes! To be fair, she had just finished warning you about ghosts a few minutes ago.

+

One of the camel's pouches is labeled "maps" - sure enough, it's full of documents (your puzzle input) about how to navigate the desert. At least, you're pretty sure that's what they are; one of the documents contains a list of left/right instructions, and the rest of the documents seem to describe some kind of network of labeled nodes.

+

It seems like you're meant to use the left/right instructions to navigate the network. Perhaps if you have the camel follow the same instructions, you can escape the haunted wasteland!

+

After examining the maps for a bit, two nodes stick out: AAA and ZZZ. You feel like AAA is where you are now, and you have to follow the left/right instructions until you reach ZZZ.

+

This format defines each node of the network individually. For example:

+
RL
+
+AAA = (BBB, CCC)
+BBB = (DDD, EEE)
+CCC = (ZZZ, GGG)
+DDD = (DDD, DDD)
+EEE = (EEE, EEE)
+GGG = (GGG, GGG)
+ZZZ = (ZZZ, ZZZ)
+
+

Starting with AAA, you need to look up the next element based on the next left/right instruction in your input. In this example, start with AAA and go right (R) by choosing the right element of AAA, CCC. Then, L means to choose the left element of CCC, ZZZ. By following the left/right instructions, you reach ZZZ in 2 steps.

+

Of course, you might not find ZZZ right away. If you run out of left/right instructions, repeat the whole sequence of instructions as necessary: RL really means RLRLRLRLRLRLRLRL... and so on. For example, here is a situation that takes 6 steps to reach ZZZ:

+
LLR
+
+AAA = (BBB, BBB)
+BBB = (AAA, ZZZ)
+ZZZ = (ZZZ, ZZZ)
+
+

Starting at AAA, follow the left/right instructions. How many steps are required to reach ZZZ?

+ +

--- Part Two ---

The sandstorm is upon you and you aren't any closer to escaping the wasteland. You had the camel follow the instructions, but you've barely left your starting position. It's going to take significantly more steps to escape!

+

What if the map isn't for people - what if the map is for ghosts? Are ghosts even bound by the laws of spacetime? Only one way to find out.

+

After examining the maps a bit longer, your attention is drawn to a curious fact: the number of nodes with names ending in A is equal to the number ending in Z! If you were a ghost, you'd probably just start at every node that ends with A and follow all of the paths at the same time until they all simultaneously end up at nodes that end with Z.

+

For example:

+
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)
+
+

Here, there are two starting nodes, 11A and 22A (because they both end with A). As you follow each left/right instruction, use that instruction to simultaneously navigate away from both nodes you're currently on. Repeat this process until all of the nodes you're currently on end with Z. (If only some of the nodes you're on end with Z, they act like any other node and you continue as normal.) In this example, you would proceed as follows:

+ +

So, in this example, you end up entirely on nodes that end in Z after 6 steps.

+

Simultaneously start on every node that ends with A. How many steps does it take before you're only on nodes that end with Z?

\ No newline at end of file diff --git a/get_puzzle_text.py b/get_puzzle_text.py index 1f261e4..521cc02 100644 --- a/get_puzzle_text.py +++ b/get_puzzle_text.py @@ -57,6 +57,6 @@ def populate_data(year = current_year, day=current_day): None """ save_puzzle_text(year, day) - #save_puzzle_input(year, day) + save_puzzle_input(year, day) populate_data() \ No newline at end of file