Completed day 08

This commit is contained in:
Natty 2023-12-09 04:42:17 +01:00
parent 5d49c6428f
commit c7e1a48a71
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
18 changed files with 1780 additions and 2 deletions

2
day08a/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.stack-work/
*~

27
day08a/day08a.cabal Normal file
View File

@ -0,0 +1,27 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack
name: day08a
version: 0.1.0.0
description: Please see the README at <https://git.astolfo.cool/natty/aoc23#readme>
author: Natty
maintainer: natty.sh.git@gmail.com
copyright: 2023 Natty
build-type: Simple
executable day08a
main-is: Main.hs
other-modules:
Paths_day08a
hs-source-dirs:
src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, containers
, megaparsec
, text
default-language: Haskell2010

776
day08a/input.txt generated Normal file
View File

@ -0,0 +1,776 @@
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)

33
day08a/package.yaml Normal file
View File

@ -0,0 +1,33 @@
name: day08a
version: 0.1.0.0
author: "Natty"
maintainer: "natty.sh.git@gmail.com"
copyright: "2023 Natty"
description: Please see the README at <https://git.astolfo.cool/natty/aoc23#readme>
dependencies:
- base >= 4.7 && < 5
- megaparsec
- containers
- text
ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
executables:
day08a:
main: Main.hs
source-dirs: src
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N

23
day08a/src/Main.hs Normal file
View File

@ -0,0 +1,23 @@
{-# LANGUAGE ImportQualifiedPost #-}
module Main (main) where
import Data.Map qualified as M
parseMove :: Char -> (a, a) -> a
parseMove 'L' = fst
parseMove 'R' = snd
parseNode :: String -> (String, (String, String))
parseNode a = (take 3 a, (take 3 . drop 7 $ a, take 3 . drop 12 $ a))
main :: IO ()
main = do
lns <- lines <$> getContents
let moves = cycle (parseMove <$> concat (take 1 lns))
let nodes = M.fromList $ parseNode <$> drop 2 lns
let doMove i "ZZZ" _ = i
doMove i node (x : xs) = doMove (i + 1) (x $ nodes M.! node) xs
print $ doMove 0 "AAA" moves

6
day08a/stack.yaml Normal file
View File

@ -0,0 +1,6 @@
resolver: lts-21.21
packages:
- .
extra-deps: []

12
day08a/stack.yaml.lock Normal file
View File

@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
sha256: 7d4b649cf368f9076d8aa049aa44efe58950971d105892734e9957b2a26a2186
size: 640060
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/21.yaml
original: lts-21.21

9
day08a/test.txt generated Normal file
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)

2
day08b/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.stack-work/
*~

27
day08b/day08b.cabal Normal file
View File

@ -0,0 +1,27 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack
name: day08b
version: 0.1.0.0
description: Please see the README at <https://git.astolfo.cool/natty/aoc23#readme>
author: Natty
maintainer: natty.sh.git@gmail.com
copyright: 2023 Natty
build-type: Simple
executable day08b
main-is: Main.hs
other-modules:
Paths_day08b
hs-source-dirs:
src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, containers
, megaparsec
, text
default-language: Haskell2010

776
day08b/input.txt generated Normal file
View File

@ -0,0 +1,776 @@
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)

33
day08b/package.yaml Normal file
View File

@ -0,0 +1,33 @@
name: day08b
version: 0.1.0.0
author: "Natty"
maintainer: "natty.sh.git@gmail.com"
copyright: "2023 Natty"
description: Please see the README at <https://git.astolfo.cool/natty/aoc23#readme>
dependencies:
- base >= 4.7 && < 5
- megaparsec
- containers
- text
ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
executables:
day08b:
main: Main.hs
source-dirs: src
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N

22
day08b/src/Main.hs Normal file
View File

@ -0,0 +1,22 @@
{-# LANGUAGE ImportQualifiedPost #-}
module Main (main) where
import Data.Map qualified as M
parseMove :: Char -> (a, a) -> a
parseMove 'L' = fst
parseMove 'R' = snd
parseNode :: String -> (String, (String, String))
parseNode a = (take 3 a, (take 3 . drop 7 $ a, take 3 . drop 12 $ a))
main :: IO ()
main = do
moves <- cycle . (parseMove <$>) <$> getLine
nodes <- M.fromList . ((parseNode <$>) . drop 1 . lines) <$> getContents
let doMove i [_, _, 'Z'] _ = i
doMove i node (x : xs) = doMove (i + 1) (x $ nodes M.! node) xs
print $ foldl1 lcm $ flip (doMove 0) moves <$> filter ((== 'A') . last) (M.keys nodes)

6
day08b/stack.yaml Normal file
View File

@ -0,0 +1,6 @@
resolver: lts-21.21
packages:
- .
extra-deps: []

12
day08b/stack.yaml.lock Normal file
View File

@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
sha256: 7d4b649cf368f9076d8aa049aa44efe58950971d105892734e9957b2a26a2186
size: 640060
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/21.yaml
original: lts-21.21

10
day08b/test.txt generated Normal file
View File

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

3
run.sh
View File

@ -26,7 +26,8 @@ case "$1" in
"day03a" | "day03b" | \
"day04a" | "day04b" | \
"day06a" | "day06b" | \
"day07a" | "day07b" ) stack run <input.txt
"day07a" | "day07b" | \
"day08a" | "day08b" ) stack run <input.txt
;;
# Default solutions -- Java
*) ./gradlew run <input.txt

View File

@ -26,7 +26,8 @@ case "$1" in
"day03a" | "day03b" | \
"day04a" | "day04b" | \
"day06a" | "day06b" | \
"day07a" | "day07b" ) stack run <test.txt
"day07a" | "day07b" | \
"day08a" | "day08b" ) stack run <test.txt
;;
# Default solutions -- Java
*) ./gradlew run <test.txt