2023 Day 8 part 1

main
Petra 2023-12-08 18:23:21 +13:00
parent ea9ed0eead
commit 490a9c7b7e
5 changed files with 868 additions and 1 deletions

View File

@ -2,7 +2,7 @@ FC:=gfortran
FFLAGS:=-Wall -Wno-maybe-uninitialized
BIN:=./bin
SRC:=./src
BINS:=./bin/day01.bin ./bin/day01b.bin ./bin/day02.bin ./bin/day03.bin ./bin/day04.bin ./bin/day05.bin ./bin/day05b.bin ./bin/day06.bin ./bin/day07.bin ./bin/day07b.bin
BINS:=./bin/day01.bin ./bin/day01b.bin ./bin/day02.bin ./bin/day03.bin ./bin/day04.bin ./bin/day05.bin ./bin/day05b.bin ./bin/day06.bin ./bin/day07.bin ./bin/day07b.bin ./bin/day08.bin
all: aoc19

777
2023/data/day08.txt 100644
View File

@ -0,0 +1,777 @@
LLRRRLLRLRRRLLRLRLRLRLRRRLRRLRRLRLLLRRLLRRLRRLRRLRRRLLLRRLRLRRRLRRRLRLRRLRRRLRLRRRLRLRLLLRLRRLRLRRLRRRLRLRRRLRRRLRRRLRRRLRLRRRLRRRLRLLRRLRLRLRRRLRRLRRRLRRRLRRRLRRRLLLLRRLLRLRRLRRLRRRLRRRLLLRRLRRLRLRRLRRRLRRLRLRRRLRLRRLLRLLRRLRLRRRLRRLRRLRLRRLLLRRRLRLRRRLRLRLLRLRLRRRLRLRLRRRLRRLRRLRRRLRRLLRRRR
VTM = (VPB, NKT)
LHN = (DLF, GQV)
CRN = (TGB, XCM)
TXR = (JQL, JQL)
LJX = (SPR, LLM)
HSH = (SKP, MFC)
JSC = (QPB, VCP)
KKG = (BFT, NBS)
BCB = (GRT, TLB)
GPA = (SDK, MRM)
CNJ = (FDR, GGT)
GQV = (BSJ, DGF)
CNT = (FLM, TVQ)
RLL = (BRB, CRH)
PPN = (KCF, PSJ)
TFL = (GCD, DMF)
KPM = (TKS, CGP)
FBN = (GPF, LCJ)
DQJ = (MHL, VKQ)
NDD = (QLT, PPG)
GNL = (QGD, LTM)
NBG = (XPM, HTV)
LTT = (RLP, NHB)
QHH = (DDD, ZZZ)
DLN = (KNP, KNP)
XMN = (DGV, DNL)
BCL = (FVG, QMH)
GLR = (JDH, RBR)
LXL = (BVC, RSG)
TCV = (JKG, BTF)
HJC = (KTD, JFQ)
DBK = (RCR, CVZ)
FMD = (QGQ, TJX)
JQG = (FHN, HKX)
XFV = (JJM, LBM)
GXQ = (XFV, MVV)
HTT = (THT, CFL)
FTG = (JRP, VGH)
XJF = (FCL, HNF)
MPT = (RDF, NDJ)
FJG = (VPF, LGQ)
CSK = (NSD, MFH)
QJN = (MPT, PLV)
HJP = (VCP, QPB)
KCF = (LVM, XMX)
FPZ = (FMR, GSL)
LRB = (RFF, GQR)
MHN = (TVD, MVF)
FSH = (VPF, LGQ)
GGT = (XJF, RQQ)
RRL = (JTG, TNF)
MPM = (QBD, QHH)
SHG = (JMJ, TLK)
TTD = (DLK, BBJ)
HLF = (JLF, SKB)
XMG = (CGM, RTL)
FFT = (DFJ, RPJ)
FQL = (PTM, LDJ)
NQJ = (CQM, DDL)
VKQ = (TGR, DBC)
RCD = (XPP, FPP)
HPC = (FLM, TVQ)
PBB = (LQR, PQS)
KBS = (BFT, NBS)
HTD = (JMS, HNX)
SKF = (NLJ, NLJ)
GTA = (GSL, FMR)
RSG = (MLL, LJX)
KRB = (PSG, FMD)
XNP = (LFN, XGC)
TVH = (GDG, MNT)
TXM = (JPK, JVQ)
LPB = (CTQ, VQF)
PST = (VPB, NKT)
BSX = (PLS, HQJ)
TKS = (CMC, TFJ)
DCD = (LXR, KTM)
XKR = (BHS, BBT)
JMS = (LDT, JQG)
BVG = (JMQ, BCS)
SPT = (HFN, SPV)
HNF = (NFQ, KPH)
HXG = (VKC, LKM)
DBL = (MDR, VHG)
NVK = (CGQ, SRF)
PLS = (RJN, DVS)
SPR = (XMG, HSS)
FPQ = (VRX, RQX)
LTM = (DBH, KSB)
VRQ = (SXT, KLQ)
XFX = (PFT, NNK)
GFC = (RCH, MFK)
FLK = (DLK, BBJ)
QVN = (LCV, LCV)
HGP = (GMS, MHR)
BVH = (VLQ, CNJ)
BXS = (GQR, RFF)
SKP = (VDS, QPH)
VRM = (TCK, SND)
CGM = (FVK, HGP)
LDT = (FHN, HKX)
BJK = (GFS, PLM)
PVT = (FDX, QHX)
XGC = (TXR, QKJ)
PKF = (NBQ, RCD)
XJB = (RBR, JDH)
GSC = (PTM, LDJ)
SHQ = (KXR, QGK)
TJR = (QGR, NRN)
GQH = (XJB, GLR)
QSM = (MKQ, VRB)
XRF = (NRN, QGR)
PKV = (NQP, JXT)
QNB = (CTL, JVP)
FDX = (DFL, VRQ)
HDS = (QJH, HBF)
NNK = (NDQ, RBL)
RQM = (DQJ, BBQ)
GJG = (QBC, TRD)
NRL = (HTD, SJR)
TKP = (SKF, VDL)
CQM = (TJS, FJF)
KSC = (PFP, DCC)
RSB = (JTQ, HJJ)
DHC = (BQN, SJP)
PFS = (SKP, MFC)
MDP = (LJQ, BML)
CLK = (BJK, QTG)
KST = (CRH, BRB)
MJS = (NDS, TGD)
QBR = (PSG, FMD)
BSB = (PST, VTM)
FPP = (DCD, TGM)
VLF = (LDR, PSP)
NPF = (KBC, PHJ)
TCK = (DFX, RLN)
QNV = (PST, VTM)
JJM = (HMT, DGT)
PTM = (HQV, QLM)
MNS = (JVP, CTL)
KNP = (CPT, CPT)
GGN = (MTG, VVT)
RBT = (MNM, VSQ)
GFH = (VLB, NSK)
HHC = (NGJ, XFT)
QKJ = (JQL, RKB)
XXC = (VJP, HXP)
PSJ = (XMX, LVM)
CFD = (PFL, PPL)
HXD = (BSN, QMC)
HKX = (SSD, CKC)
XPP = (TGM, DCD)
TQB = (FPD, DRT)
PTT = (HHK, HHK)
XRG = (JRP, VGH)
MBN = (KML, KCN)
JDP = (VMS, LCB)
FJF = (STK, GXR)
XQQ = (BST, SPB)
STK = (CKJ, MVM)
LJQ = (DTG, TMF)
DDD = (PBJ, RXK)
FVL = (PXT, NLS)
HRG = (HMV, XTC)
LDN = (JSQ, HQD)
FMJ = (HLP, GXQ)
RQX = (DPD, SNH)
QML = (CCH, PPF)
VGN = (VJP, HXP)
QLH = (FXX, RFB)
GMS = (BVG, SHR)
QCP = (LBC, RBT)
RMS = (LHN, KDR)
RTC = (NDS, TGD)
GBT = (KSJ, GGS)
FNN = (HTH, LXP)
JMQ = (LTX, LKQ)
HMV = (FJS, KCM)
GGM = (XDB, XNP)
NNC = (PBB, NLF)
HSG = (GJG, DSB)
DTG = (LRD, DXH)
TJS = (STK, GXR)
NQB = (RFB, FXX)
BKL = (PDP, XTB)
VQB = (LCV, HPG)
NQP = (CTG, HRG)
TVK = (NQT, QSM)
TJX = (JPH, GRF)
SPB = (MRF, FMJ)
QPH = (XXC, VGN)
TQS = (MPF, MSC)
LQF = (GHS, BQR)
VRB = (CSK, QLG)
NVH = (QXX, TQB)
FPD = (PKV, MFX)
NDB = (JPR, HDS)
HVM = (XRS, SPN)
BSJ = (PHC, FSD)
NPQ = (VBC, HSG)
BXH = (RKS, RPB)
VJP = (HMC, TVX)
NDJ = (FFT, SRP)
SRP = (DFJ, RPJ)
FHQ = (PDP, XTB)
THD = (VMG, DPL)
MRF = (HLP, GXQ)
SND = (DFX, RLN)
BFT = (BVH, BDJ)
MLL = (LLM, SPR)
RKF = (XRQ, STZ)
HGB = (VJQ, MHN)
CBM = (BXH, KMM)
VPD = (HDS, JPR)
RQR = (SMH, KPM)
FVG = (MMM, CLK)
FMP = (VFC, LCC)
QBD = (DDD, DDD)
RGC = (RLL, KST)
HQV = (PKF, TCS)
PLL = (KSJ, GGS)
PPF = (PNT, GFX)
FRN = (LCJ, GPF)
XPM = (TTT, VTP)
BCH = (NFC, FPQ)
KML = (FCB, RMP)
JBM = (VBH, LLG)
VKL = (RMS, SBX)
MMN = (MDR, VHG)
HMG = (PMN, XBV)
BHS = (NPQ, RTT)
XPC = (GGM, KCC)
DGV = (SPT, DNB)
JSB = (DPS, THK)
MND = (KML, KCN)
VCP = (TLD, TVK)
PFX = (RRL, DMX)
SXK = (TVB, PDR)
BML = (TMF, DTG)
XBV = (HXJ, QJB)
DRR = (MSC, MPF)
DCK = (SLD, VRM)
HFP = (LJQ, BML)
RQG = (DDP, TFL)
MRM = (MND, MBN)
PHC = (HHC, GFT)
VGX = (MHN, VJQ)
LMX = (PLL, GBT)
CQF = (FJG, FSH)
MVV = (LBM, JJM)
HSS = (CGM, RTL)
HJK = (HXG, RQF)
CRV = (LCC, VFC)
SHR = (BCS, JMQ)
TDM = (FNR, MSX)
XFS = (LRX, HPP)
TBC = (SKF, VDL)
JXM = (GSL, FMR)
KCC = (XNP, XDB)
LVM = (NJX, GFC)
XRS = (MSL, BSM)
TGV = (LBC, RBT)
SDH = (XPM, HTV)
HGV = (FVL, CSF)
GNH = (SJP, BQN)
TDN = (MNT, GDG)
HJS = (KBC, PHJ)
QGK = (PRK, RSB)
JRN = (FRN, FBN)
TNP = (QVN, VQB)
FXX = (HLF, KPB)
VBH = (QTV, TFR)
XBL = (MSX, FNR)
TRN = (SQR, MQN)
RHP = (JSC, HJP)
JPC = (NNK, PFT)
BSM = (TRN, MCS)
DPD = (DBL, MMN)
DPP = (BSX, NMG)
GFM = (GGN, LLX)
DBC = (SXK, NSL)
KGB = (CBM, DQT)
MCS = (MQN, SQR)
PDR = (NNC, RXP)
MTG = (FGV, LDN)
VGH = (SJH, BRX)
GPF = (QGB, KKM)
PFL = (JPC, XFX)
FFF = (QSR, HMG)
XSS = (PPG, QLT)
LDM = (KNV, BCL)
RMP = (CFD, LHR)
NQT = (VRB, MKQ)
BXM = (FTX, NVK)
CTL = (TKG, RHP)
NBS = (BVH, BDJ)
BVQ = (VPD, NDB)
PGB = (FGQ, KGB)
SLB = (GQH, VSP)
GPV = (JMJ, TLK)
NJX = (RCH, MFK)
LKQ = (JQN, MCR)
BPB = (RFQ, GSP)
FHN = (CKC, SSD)
CKC = (RQM, FCQ)
HTH = (HJC, NTF)
DJP = (NQB, QLH)
TGD = (XPL, KNQ)
CPT = (RCR, RCR)
LLM = (HSS, XMG)
MFC = (QPH, VDS)
VSP = (GLR, XJB)
FMR = (KSC, JVM)
DGF = (FSD, PHC)
KNQ = (XLB, RQR)
CNB = (KRB, QBR)
QHX = (DFL, VRQ)
HBL = (NMN, QJN)
XTC = (FJS, KCM)
LGQ = (LPB, FLQ)
NGJ = (HJK, VTL)
TVX = (MKF, QSN)
GVG = (HRQ, XFS)
QGD = (DBH, KSB)
VPB = (CDD, TNP)
MFK = (BSB, QNV)
SXT = (KDJ, DJP)
GVJ = (GGK, JPT)
HQD = (SXS, CPD)
VRP = (XSQ, KKH)
FNR = (DHC, GNH)
CLT = (BSN, QMC)
CKJ = (VRG, BVQ)
TVQ = (CRV, FMP)
DPS = (XPC, FCP)
SJR = (JMS, HNX)
FLQ = (VQF, CTQ)
HBF = (GVG, XML)
CPD = (RGC, QMS)
BBN = (FPQ, NFC)
MQN = (KBS, KKG)
QTV = (CTB, QJX)
QPJ = (FQL, GSC)
BPD = (CPT, DBK)
FJS = (MNS, QNB)
DDF = (QMD, BPB)
DDL = (FJF, TJS)
QPB = (TLD, TVK)
DFJ = (DJK, FGN)
PFT = (NDQ, RBL)
DQK = (QGD, LTM)
LXR = (LDM, BGD)
FQF = (QJN, NMN)
SLD = (TCK, SND)
RTT = (HSG, VBC)
QSN = (MJQ, KXN)
GGK = (HTG, XNF)
KSB = (VPL, TCV)
BKR = (HSH, PFS)
VRG = (VPD, NDB)
QXX = (DRT, FPD)
LMK = (PTT, XTP)
PQS = (HQR, CQF)
NXS = (TLB, GRT)
VFB = (MFP, CNB)
JVM = (PFP, DCC)
JPK = (XKD, HGV)
KTD = (LXL, QSH)
KKM = (DLN, JXD)
NHB = (NQJ, PFR)
QXK = (KXV, HBV)
CHX = (RRL, DMX)
KKH = (LTT, FHJ)
KDR = (DLF, GQV)
RJD = (RLH, MBJ)
QBC = (VVB, MMD)
MFH = (JRN, RHL)
TLB = (PSN, HNB)
XTB = (FFF, XVV)
SKZ = (VLF, TVV)
DMF = (PDB, JBM)
FMG = (FTX, NVK)
QXP = (DNL, DGV)
GSP = (PXX, PVL)
KXN = (THR, FSN)
GFT = (NGJ, XFT)
QLT = (MDP, HFP)
NBM = (QBD, QBD)
PFP = (BKR, GLT)
NDQ = (KBD, PKH)
JFH = (PTL, QCT)
HRQ = (HPP, LRX)
PNV = (LCB, VMS)
JTG = (NGR, DPP)
THR = (SHQ, CTP)
CBG = (XKR, DRD)
PPL = (XFX, JPC)
RFB = (KPB, HLF)
LCV = (JXM, JXM)
RJN = (SSF, DCK)
NKT = (CDD, TNP)
NTF = (KTD, JFQ)
KLQ = (DJP, KDJ)
QMD = (RFQ, GSP)
TLP = (CNB, MFP)
FGV = (JSQ, HQD)
FGN = (TKH, QKX)
RXK = (TJR, XRF)
PXX = (VJC, FNN)
PHJ = (XRP, PVT)
MVM = (VRG, BVQ)
FSD = (GFT, HHC)
GSL = (JVM, KSC)
VRC = (CFL, THT)
RBL = (KBD, PKH)
RLP = (NQJ, PFR)
BBT = (RTT, NPQ)
MHL = (DBC, TGR)
QGR = (HGB, VGX)
XPL = (XLB, RQR)
SSF = (VRM, SLD)
KRM = (THK, DPS)
MTP = (BCH, BBN)
PDB = (VBH, LLG)
BST = (MRF, FMJ)
DRD = (BHS, BBT)
VHG = (SMJ, QFC)
FTX = (CGQ, SRF)
PNT = (DCT, QPJ)
QJB = (LDX, FPJ)
JKG = (TVH, TDN)
FCQ = (DQJ, BBQ)
HBV = (NBM, MPM)
MDR = (QFC, SMJ)
PTL = (FLK, TTD)
LDR = (HBL, FQF)
NVN = (VFM, VJR)
DQT = (BXH, KMM)
RHL = (FRN, FBN)
MBM = (TLP, VFB)
TVD = (XNJ, VKL)
DNL = (DNB, SPT)
TKH = (XSS, NDD)
JPH = (PVJ, RQG)
VRX = (DPD, SNH)
CVV = (TGB, XCM)
QGB = (DLN, JXD)
SPN = (BSM, MSL)
TGM = (LXR, KTM)
LRD = (XXP, PND)
VMS = (THD, KTF)
MHR = (BVG, SHR)
DMX = (JTG, TNF)
HKJ = (GCF, FXT)
VTP = (DRR, TQS)
VPL = (BTF, JKG)
RCH = (BSB, QNV)
KTM = (LDM, BGD)
QSR = (PMN, XBV)
PXM = (QXP, XMN)
TLK = (CTD, LMX)
BBJ = (MCN, RJD)
RCR = (SDK, MRM)
TVV = (LDR, PSP)
LMQ = (CLT, HXD)
XML = (HRQ, XFS)
RFQ = (PVL, PXX)
QCT = (FLK, TTD)
GXR = (MVM, CKJ)
HPG = (JXM, FPZ)
FCP = (GGM, KCC)
LDX = (PNV, JDP)
MVG = (DQK, GNL)
BNP = (VRC, HTT)
RLH = (QXK, TFF)
DCT = (GSC, FQL)
MFP = (KRB, QBR)
VDA = (CBP, VRP)
THK = (FCP, XPC)
DJK = (QKX, TKH)
VLB = (BXS, LRB)
FCF = (QMD, BPB)
QLM = (TCS, PKF)
BCS = (LKQ, LTX)
MSL = (MCS, TRN)
VQF = (THQ, RBB)
HNB = (QCP, TGV)
SMH = (TKS, CGP)
HMC = (MKF, QSN)
BDJ = (CNJ, VLQ)
NRN = (VGX, HGB)
GSD = (JPK, JVQ)
SXS = (RGC, QMS)
VJR = (CNT, HPC)
RQQ = (FCL, HNF)
FCL = (NFQ, KPH)
JFQ = (QSH, LXL)
TRD = (VVB, MMD)
CTD = (PLL, GBT)
NGR = (BSX, NMG)
MSX = (DHC, GNH)
XNJ = (RMS, SBX)
VHH = (VLB, NSK)
CTG = (XTC, HMV)
NFC = (VRX, RQX)
TNF = (NGR, DPP)
XDB = (LFN, XGC)
PND = (BKL, FHQ)
MFX = (NQP, JXT)
TCS = (RCD, NBQ)
FCJ = (QDF, BNP)
CDQ = (XHV, RSJ)
MBJ = (QXK, TFF)
KPG = (GQH, VSP)
BRX = (NHD, SXL)
HHK = (TVV, VLF)
KCM = (QNB, MNS)
KXR = (RSB, PRK)
HQJ = (RJN, DVS)
XGP = (TQB, QXX)
PCM = (DQN, MKZ)
CDD = (QVN, QVN)
FXT = (DMT, RKF)
FPJ = (JDP, PNV)
DFX = (RSL, HVM)
TFJ = (XBL, TDM)
VFM = (HPC, CNT)
CSF = (PXT, NLS)
MMD = (PGB, PDN)
LHR = (PFL, PPL)
PDP = (FFF, XVV)
GDG = (TKP, TBC)
SNH = (DBL, MMN)
VTL = (HXG, RQF)
KNV = (QMH, FVG)
HMT = (GQT, JFH)
GLT = (PFS, HSH)
QFC = (TXM, GSD)
ZZZ = (RXK, PBJ)
PSG = (QGQ, TJX)
PPG = (HFP, MDP)
RDF = (FFT, SRP)
NSL = (PDR, TVB)
XFT = (HJK, VTL)
GFS = (DDF, FCF)
VPF = (LPB, FLQ)
HTG = (FXN, NVN)
SQR = (KKG, KBS)
SDK = (MND, MBN)
THT = (QML, CTN)
NLS = (GFH, VHH)
KTF = (VMG, DPL)
VDL = (NLJ, LMK)
HFN = (NMQ, LMQ)
QMC = (CFJ, HKJ)
VVL = (KPG, SLB)
DMT = (XRQ, XRQ)
LDJ = (QLM, HQV)
PFR = (DDL, CQM)
HPP = (NXS, BCB)
QLG = (MFH, NSD)
KBC = (PVT, XRP)
FCB = (CFD, LHR)
GCD = (JBM, PDB)
SMR = (GGK, JPT)
CTP = (KXR, QGK)
HXP = (HMC, TVX)
VLQ = (FDR, GGT)
DDP = (GCD, DMF)
JMJ = (CTD, LMX)
CGQ = (KRM, JSB)
XJD = (BCH, BBN)
MNM = (SHG, GPV)
GCF = (DMT, DMT)
DBH = (TCV, VPL)
RKB = (TCX, PCM)
DGT = (JFH, GQT)
JXT = (CTG, HRG)
KPB = (JLF, SKB)
JPT = (XNF, HTG)
NSD = (JRN, RHL)
HTV = (TTT, VTP)
TCX = (DQN, DQN)
MCN = (MBJ, RLH)
CTN = (PPF, CCH)
CTB = (RGB, PXM)
PBJ = (XRF, TJR)
HXJ = (FPJ, LDX)
LLX = (VVT, MTG)
HJJ = (FCJ, NNJ)
CCH = (PNT, GFX)
JVP = (RHP, TKG)
SJH = (NHD, SXL)
RSL = (SPN, XRS)
QMH = (MMM, CLK)
SKB = (FML, MBM)
NBQ = (FPP, XPP)
GQR = (BXM, FMG)
BGV = (DRD, XKR)
HMX = (BQR, GHS)
PVL = (FNN, VJC)
DFL = (SXT, KLQ)
NSK = (BXS, LRB)
MNT = (TKP, TBC)
LTX = (MCR, JQN)
RFF = (BXM, FMG)
NMG = (PLS, HQJ)
LCB = (THD, KTF)
DPL = (QGL, NRL)
SNG = (DQK, GNL)
HQR = (FSH, FJG)
GRF = (RQG, PVJ)
BBQ = (MHL, VKQ)
TMF = (LRD, DXH)
XTP = (HHK, SKZ)
DSB = (QBC, TRD)
QTG = (GFS, PLM)
PKH = (GFM, MXX)
BGD = (BCL, KNV)
LCC = (XJD, MTP)
DQN = (LQF, HMX)
RSJ = (XGP, NVH)
RXP = (PBB, NLF)
LXP = (NTF, HJC)
TGR = (NSL, SXK)
MKF = (MJQ, KXN)
BVC = (LJX, MLL)
BBA = (TVV, VLF)
PDN = (KGB, FGQ)
PLM = (FCF, DDF)
FHJ = (RLP, NHB)
VVT = (FGV, LDN)
STZ = (VRP, CBP)
FVK = (MHR, GMS)
QJX = (PXM, RGB)
GGS = (BGV, CBG)
XRQ = (CBP, VRP)
PSP = (FQF, HBL)
KMM = (RKS, RPB)
VMG = (NRL, QGL)
KXV = (NBM, NBM)
JLF = (MBM, FML)
RLN = (RSL, HVM)
TFF = (KXV, HBV)
DLK = (MCN, RJD)
BTF = (TVH, TDN)
MCR = (PPN, CKH)
TLD = (QSM, NQT)
QKX = (XSS, NDD)
VJC = (HTH, LXP)
XVV = (HMG, QSR)
DNB = (HFN, SPV)
JTQ = (NNJ, FCJ)
XLB = (KPM, SMH)
KSJ = (BGV, CBG)
VDS = (VGN, XXC)
CKH = (PSJ, KCF)
CFJ = (GCF, GCF)
QDF = (VRC, HTT)
VFC = (XJD, MTP)
MPF = (SMR, GVJ)
LRX = (NXS, BCB)
KBD = (MXX, GFM)
XMX = (NJX, GFC)
GHS = (FTG, XRG)
PMN = (QJB, HXJ)
AAA = (PBJ, RXK)
FXN = (VJR, VFM)
XKD = (CSF, FVL)
RQF = (LKM, VKC)
CTQ = (THQ, RBB)
RPJ = (DJK, FGN)
FML = (VFB, TLP)
TKG = (HJP, JSC)
JVQ = (XKD, HGV)
TFR = (QJX, CTB)
JRP = (SJH, BRX)
QGL = (SJR, HTD)
KDJ = (NQB, QLH)
SSD = (RQM, FCQ)
THQ = (VVL, QRN)
CBP = (KKH, XSQ)
LKM = (PFX, CHX)
VSA = (LQF, HMX)
XSQ = (LTT, FHJ)
FDR = (RQQ, XJF)
JQN = (PPN, CKH)
SRF = (KRM, JSB)
NLJ = (PTT, PTT)
PVJ = (DDP, TFL)
CFL = (QML, CTN)
FLM = (FMP, CRV)
DVS = (SSF, DCK)
DXH = (PND, XXP)
PLV = (RDF, NDJ)
NLF = (PQS, LQR)
NMN = (MPT, PLV)
PSN = (TGV, QCP)
RTL = (HGP, FVK)
SJP = (SDH, NBG)
LLG = (TFR, QTV)
DRT = (MFX, PKV)
BQN = (SDH, NBG)
RGB = (XMN, QXP)
NNJ = (BNP, QDF)
JQL = (TCX, TCX)
CRH = (MQF, CDQ)
RBR = (SNG, MVG)
HLP = (MVV, XFV)
MKZ = (HMX, LQF)
TTT = (DRR, TQS)
NHD = (RTC, MJS)
GFX = (DCT, QPJ)
JXD = (KNP, BPD)
XCM = (HJS, NPF)
QGQ = (GRF, JPH)
MKQ = (QLG, CSK)
VJQ = (TVD, MVF)
SBX = (KDR, LHN)
JPG = (BST, SPB)
QRN = (KPG, SLB)
MXX = (LLX, GGN)
QJH = (GVG, XML)
NMQ = (CLT, HXD)
MMM = (BJK, QTG)
PRK = (JTQ, HJJ)
RPB = (CVV, CRN)
LCJ = (QGB, KKM)
FGQ = (DQT, CBM)
SMJ = (GSD, TXM)
KPH = (JPG, XQQ)
BRB = (MQF, CDQ)
HNX = (LDT, JQG)
SXL = (MJS, RTC)
XNF = (NVN, FXN)
LBC = (MNM, VSQ)
BSN = (CFJ, HKJ)
FSN = (SHQ, CTP)
VKC = (CHX, PFX)
MJQ = (THR, FSN)
CGP = (TFJ, CMC)
NFQ = (JPG, XQQ)
NDS = (XPL, KNQ)
LBM = (DGT, HMT)
PXT = (GFH, VHH)
RBB = (QRN, VVL)
JPR = (QJH, HBF)
QSH = (BVC, RSG)
SPV = (NMQ, LMQ)
JSQ = (SXS, CPD)
XXP = (FHQ, BKL)
BQR = (FTG, XRG)
QMS = (KST, RLL)
VSQ = (SHG, GPV)
TGB = (HJS, NPF)
XHV = (NVH, XGP)
CMC = (XBL, TDM)
LQR = (CQF, HQR)
DLF = (BSJ, DGF)
DCC = (BKR, GLT)
VVB = (PGB, PDN)
TVB = (NNC, RXP)
GRT = (PSN, HNB)
VBC = (GJG, DSB)
CVZ = (MRM, SDK)
GQT = (PTL, QCT)
MVF = (VKL, XNJ)
RKS = (CVV, CRN)
MSC = (GVJ, SMR)
KCN = (FCB, RMP)
LFN = (TXR, QKJ)
MQF = (RSJ, XHV)
XRP = (QHX, FDX)
JDH = (SNG, MVG)

View File

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

View File

@ -0,0 +1,5 @@
LLR
AAA = (BBB, BBB)
BBB = (AAA, ZZZ)
ZZZ = (ZZZ, ZZZ)

76
2023/src/day08.f90 100644
View File

@ -0,0 +1,76 @@
program day8
implicit none
integer, parameter :: max_chars = 400
integer, parameter :: max_nodes = 1000
integer, parameter :: max_iter = 100000
character(200) :: fname
character(max_chars) :: fline
integer :: n_arguments
integer :: istat
character(max_chars) :: dir_ins
integer :: n_dir_ins
integer :: n_nodes
character(len=3) :: node
character(len=1) :: dir
character(len=3) :: nodes(1:max_nodes), lnodes(1:max_nodes), rnodes(1:max_nodes)
integer :: i, i2, cur, LRcur
n_arguments = command_argument_count()
if (n_arguments .eq. 1) then
call get_command_argument(1, fname)
print *, "File: ", trim(fname)
print *
else
print *, "Wrong number of arguments: ", n_arguments
stop
end if
open(10, file=fname)
read(10, "(a)") dir_ins
n_dir_ins = len_trim(dir_ins)
read(10, "(a)") fline
n_nodes = 0
do i=1,max_nodes
read(10, "(a)", iostat=istat) fline
if ((len_trim(fline) .eq. 0) .or. (is_iostat_end(istat))) then
exit
end if
read(fline(1:3), "(a)") nodes(i)
read(fline(8:10), "(a)") lnodes(i)
read(fline(13:15), "(a)") rnodes(i)
n_nodes = n_nodes + 1
end do
close(10)
cur = -1
do i=1, n_nodes
if (nodes(i) .eq. "AAA") then
cur = i
exit
end if
end do
do i=1,max_iter
LRcur = mod(i-1, n_dir_ins) + 1
dir = dir_ins(LRcur:LRcur)
if (dir .eq. "L") then
node = lnodes(cur)
else
node = rnodes(cur)
end if
do i2=1, n_nodes
if (nodes(i2) .eq. node) then
cur = i2
exit
end if
end do
if (nodes(cur) .eq. "ZZZ") then
exit
end if
end do
if (nodes(cur) .eq. "ZZZ") then
print *, "Found node ZZZ after ", i, " iterations"
else
print *, "Did not find node ZZZ after ", i, " iterations"
end if
end program day8