day 8 parts 1 & 2

This commit is contained in:
Lucia Ceionia 2023-12-08 11:10:36 -06:00
parent 43d12dae95
commit 327a6eb4c6
7 changed files with 1200 additions and 0 deletions

3
08/Makefile Normal file
View File

@ -0,0 +1,3 @@
all:
nasm -g -felf32 main.s && ld -melf_i386 -g main.o

732
08/input Normal file
View File

@ -0,0 +1,732 @@
LLLLLLLRRRLRRRLRLRLRLRRLLRRRLRLLRRRLLRRLRRLRRLRLRRLRLRRRLRRLRLRRRLRRLRRLRLRRLLRLLRLRRRLRRLRLLLLRRLLLLRLRLRLRRRLRLRLLLRLRRRLRRRLRRRLRLRRLRRRLRLLLRLLRRLRRRLRRLRRLRRLRLRRRLRLRLRLLRRRLRRRLRRLRRRLLLRRLRRLRRRLRLRRRLRRRLRLRRLRRRLRLRRLRLRRLRRRLRLRRLRLLRRRLLRLRRLRRRLLLRLRRLRRRR
DGK = (KVQ, XHR)
KTC = (TVB, MTH)
CGR = (VVK, BKP)
LCG = (FQC, KHX)
PSZ = (FSF, QSM)
FBJ = (FHP, SPX)
KJD = (NRQ, VDH)
NCM = (JPJ, KNG)
TXH = (HNK, VHQ)
NND = (TRC, DFM)
JQN = (CNX, XLD)
RHB = (CDG, GBT)
JBN = (PXV, GVN)
DFC = (JRN, TXH)
TXG = (CHT, VBL)
XXQ = (JDC, JGV)
SVF = (FVD, LHQ)
FVK = (LCG, RNB)
XKT = (MPF, XJJ)
MHB = (JSJ, VQM)
FVC = (HXF, VVN)
JJR = (VNS, SLM)
RMT = (GDS, XHP)
CHT = (PXS, VLF)
SFJ = (XGC, LPM)
BJL = (XDN, VXN)
PQK = (NHS, DVB)
PDB = (JPQ, TVJ)
RGL = (DNN, NCN)
KRN = (SBL, PHL)
MTF = (PJL, KQR)
BTL = (CCF, LDP)
NLV = (CPM, HVL)
GCQ = (QMF, JVH)
KVH = (VKD, PQG)
RLB = (GSS, JVP)
QRB = (TNL, DKN)
JFV = (RDR, NSB)
BFC = (LGH, XLX)
HGQ = (SLM, VNS)
FQC = (VFQ, BXC)
DDS = (XHR, KVQ)
VQV = (SFT, BFQ)
XFD = (HVV, FLH)
TVP = (XQF, KSS)
GBH = (NPX, LDB)
KHL = (MGS, MMD)
NPX = (BJL, SFF)
VMG = (DHX, GVC)
RTJ = (XRF, BPK)
TLM = (NCG, QBB)
LXS = (TVB, MTH)
XNM = (QFL, KQK)
KQR = (QRD, JBN)
JQD = (DNN, NCN)
QCF = (MXL, MXL)
QMH = (NKG, SDJ)
NKK = (MCB, RLB)
MPJ = (BTL, JTF)
TLS = (VPJ, LMD)
XJB = (LML, TKZ)
HGF = (HBF, QHB)
KNJ = (QKM, XLR)
XCF = (QCJ, HTN)
HFS = (NKC, JFV)
QLS = (QBB, NCG)
QFL = (NXQ, QBN)
MTH = (FLN, LQR)
VND = (KMM, MQH)
NQQ = (VVH, NDL)
BTV = (QSM, FSF)
SLT = (NRQ, VDH)
NKG = (TBV, XCV)
SLM = (LBN, HPK)
CMQ = (KKS, VBH)
JTF = (LDP, CCF)
VFC = (GKH, KPS)
KCC = (JVM, MTF)
KFP = (MVX, NMX)
NQF = (QSK, KCC)
GGC = (VBV, TJR)
QQS = (NKK, NQC)
LXK = (FXC, QBC)
DVQ = (TFF, LKB)
PBL = (BGQ, FHQ)
KHV = (BVJ, XSD)
LDB = (SFF, BJL)
RJG = (LJB, CJM)
RCX = (QTB, PPL)
FLH = (HSX, KVX)
XTV = (HST, VCC)
GDC = (CMH, NCT)
RDP = (FKR, GHJ)
NXM = (PVV, KRX)
SCQ = (MFN, GRB)
MRT = (XGT, VLK)
DHJ = (XHP, GDS)
XFL = (TJK, QMH)
XQF = (CCQ, RPH)
CLV = (CKD, CCD)
CMT = (NCD, XDM)
NCT = (SXG, CLF)
JSS = (GMJ, LJC)
TLQ = (CRC, DXQ)
DMJ = (HHB, DRV)
JBH = (FVC, HDX)
QXK = (QSB, JBH)
DQN = (QMD, GDN)
SDH = (PRH, BCX)
QSB = (HDX, FVC)
MTP = (VVG, SPN)
CTM = (MFG, GGJ)
HND = (MNV, TXG)
MJS = (DMJ, QQG)
JNL = (LKB, TFF)
QLL = (FKM, HNH)
PNM = (PQR, NRL)
VSF = (LPM, XGC)
QBC = (QQS, MVF)
BFM = (FBP, BQJ)
KNG = (RTJ, CXN)
VFQ = (HFS, LBS)
LKB = (QVB, TXF)
KQD = (CDJ, CDJ)
ZZZ = (DHJ, RMT)
XKX = (HVP, NJF)
GSL = (QMS, DHM)
PNT = (CDJ, GJZ)
KBN = (CMQ, JBG)
DNX = (SFM, GFJ)
NMX = (XRR, LKL)
VPJ = (PSK, GQL)
XQD = (QCF, QCF)
HRM = (RHB, XXJ)
LCL = (MRT, FMB)
DRG = (RNB, LCG)
BKP = (QLL, MMQ)
FSF = (SLR, XGV)
KHX = (BXC, VFQ)
SXG = (NHL, KGK)
MJD = (TDH, RFP)
NRL = (CSG, MPT)
FBP = (QGC, GXH)
HDT = (LHQ, FVD)
BMP = (RMG, JXM)
NCN = (SLT, KJD)
NXQ = (JPP, QQL)
NGV = (HNJ, VVQ)
NPN = (MXL, NJK)
FVD = (XBQ, NKF)
GQM = (QCG, GGC)
QBP = (XML, HND)
VQT = (BTL, JTF)
HKP = (CMH, NCT)
JHP = (NDL, VVH)
FRL = (SHD, FNH)
FLN = (NVL, HGF)
MXH = (QSD, KKR)
BGL = (XCX, RFC)
RSQ = (MKH, TLS)
VML = (RJM, CXK)
XHP = (MJS, DNP)
GRV = (XRN, TVQ)
GKH = (BCF, VSD)
SPH = (MVX, NMX)
TLD = (LFR, GFQ)
LML = (QKS, NND)
PKT = (VXC, CMF)
LLQ = (THT, GRV)
CKD = (SPB, QDV)
KRM = (JQV, JNG)
RNS = (HJJ, MLV)
FKR = (FKK, BHN)
XNH = (SCQ, KLF)
GDN = (LBL, FHT)
CRB = (NHQ, QRB)
JKQ = (DPT, KBN)
NJF = (RJG, NGF)
NRT = (NSK, CSL)
LJR = (VTT, HCQ)
HLK = (DFC, DPV)
PQR = (MPT, CSG)
DNF = (NJF, HVP)
MPV = (HJD, XSF)
TBV = (XTJ, SVH)
LKX = (XFJ, HBM)
KTP = (CGR, RVR)
HVL = (BJH, QXK)
GJD = (XJJ, MPF)
HLC = (VVQ, HNJ)
JTX = (NCD, XDM)
CSG = (MFF, RKT)
PCH = (PGJ, GQM)
SFF = (VXN, XDN)
TCF = (KNG, JPJ)
LDP = (XFD, SBS)
XCR = (GJD, XKT)
QBM = (GFB, LRH)
CLP = (RJM, CXK)
MTT = (HST, VCC)
TQL = (BPM, GGT)
LFR = (HNF, RDP)
JHN = (CMT, JTX)
XCX = (CHG, CHG)
XGT = (HLK, QJF)
TQS = (TKL, MNF)
KFL = (HGQ, JJR)
LHQ = (XBQ, NKF)
CCQ = (DBP, HHC)
TKL = (VDN, PBP)
LBX = (BXM, SDH)
XLX = (NGJ, LHJ)
GVN = (BPG, TNK)
CCX = (HCQ, VTT)
KQK = (QBN, NXQ)
NQC = (MCB, RLB)
MPF = (DFT, SBG)
BNH = (MLV, HJJ)
CJM = (LBH, TNM)
CND = (VKB, PGQ)
HXM = (GMJ, LJC)
TKZ = (NND, QKS)
RKT = (LNQ, KFL)
GXH = (RQP, LBX)
TFF = (QVB, TXF)
LNK = (FDC, MXH)
KPK = (BNH, RNS)
QQG = (HHB, DRV)
MFP = (PQK, NBF)
VVK = (QLL, MMQ)
GFB = (RHN, LCN)
PPD = (QCJ, HTN)
FXV = (BPM, GGT)
KSS = (CCQ, RPH)
KCM = (LTB, PCH)
RHN = (FXV, TQL)
LFV = (DDJ, NQF)
JKG = (BGQ, FHQ)
MBS = (RQJ, LDQ)
HHC = (NGV, HLC)
CCD = (QDV, SPB)
RFM = (FTB, HSB)
QCG = (VBV, TJR)
GRH = (LXK, LGQ)
CDJ = (QQJ, BFC)
THT = (TVQ, XRN)
QRD = (PXV, GVN)
VHQ = (SXV, GJL)
MLV = (VRM, MCP)
XRR = (CLV, PBJ)
NMS = (DGK, DDS)
JPS = (JKT, KHL)
DJJ = (QMS, DHM)
MFG = (TLQ, VQD)
GPQ = (SHL, BNR)
QVB = (GDC, HKP)
LNN = (CMF, VXC)
VBQ = (LNN, PKT)
MMS = (SVV, HRM)
BGJ = (HXM, JSS)
QCK = (JSJ, VQM)
PKB = (XNH, JQH)
BCF = (TQR, TLL)
JRN = (VHQ, HNK)
SHL = (DMK, JBX)
LRG = (NSK, CSL)
NJV = (FJH, TXC)
GHQ = (FSB, HFX)
LHN = (TLS, MKH)
HBF = (BMP, GLM)
DTP = (DVQ, JNL)
FXR = (FTB, HSB)
PDS = (XLD, CNX)
SXV = (CPC, JNF)
QMF = (GGF, JDP)
JVP = (GPC, DNX)
RMG = (HRF, PKB)
LRH = (LCN, RHN)
HVP = (RJG, NGF)
TRC = (VKX, RQL)
PJL = (QRD, JBN)
HNK = (GJL, SXV)
CHM = (NBF, PQK)
PGH = (KMM, MQH)
SDN = (MFP, CHM)
DMK = (VRP, NNX)
MRR = (NGK, SMQ)
QDV = (NDM, JPT)
PGJ = (QCG, GGC)
BVJ = (NLV, HBR)
PGQ = (BGK, GBH)
LKL = (CLV, PBJ)
FDC = (KKR, QSD)
JDP = (PDB, PTX)
NJJ = (HSJ, GRH)
TVJ = (HDT, SVF)
NJK = (RBV, ZZZ)
HHN = (DPP, TLD)
QMS = (BLS, TQS)
QVR = (CVB, BNJ)
FFQ = (RMJ, HGZ)
LGQ = (QBC, FXC)
JPP = (RSG, KTG)
DPV = (TXH, JRN)
HBR = (CPM, HVL)
NSK = (JQN, PDS)
SBS = (HVV, FLH)
BFQ = (VBQ, JPB)
LBN = (LXJ, CCR)
RBD = (KRM, PNX)
NQX = (LML, LML)
XSA = (QKS, NND)
NDB = (HFX, FSB)
QMD = (LBL, FHT)
XTJ = (JDT, JDT)
GLH = (SHL, BNR)
FXC = (MVF, QQS)
HSX = (NFN, LVG)
JNF = (JJH, FNR)
CXK = (SPC, TVP)
GGF = (PDB, PTX)
XBQ = (QNX, JCQ)
LJC = (SFJ, VSF)
MMD = (XLK, CND)
HFG = (JKT, KHL)
NHQ = (TNL, DKN)
JVM = (KQR, PJL)
CGH = (RTC, VFC)
HNF = (GHJ, FKR)
TMF = (NMS, GJH)
NGJ = (NXM, BDB)
MRM = (JKQ, MPS)
QTC = (JSS, HXM)
TNM = (JFF, QXR)
DHK = (LJR, CCX)
XSB = (MRR, CXC)
XRN = (XDP, QBP)
XCV = (XTJ, SVH)
VVA = (QSM, FSF)
NKC = (RDR, NSB)
MXL = (RBV, RBV)
PTX = (TVJ, JPQ)
VRL = (NQX, XJB)
RQK = (MPS, JKQ)
PBJ = (CKD, CCD)
VRP = (DQN, QLC)
KLF = (MFN, GRB)
XXJ = (GBT, CDG)
HST = (QHV, MMS)
SFT = (JPB, VBQ)
NRR = (LCL, MQR)
CSL = (JQN, PDS)
LHJ = (BDB, NXM)
TXK = (DHK, KLC)
CDK = (XCX, XCX)
FHT = (NGQ, JHN)
QQJ = (LGH, XLX)
BQJ = (GXH, QGC)
TTA = (QKM, XLR)
TVB = (FLN, LQR)
PPL = (FRL, NCX)
SPS = (XFJ, HBM)
SVH = (JDT, VRL)
QBB = (PXG, MTP)
JSJ = (VVB, NRR)
KKS = (RGL, JQD)
JDT = (NQX, NQX)
GKQ = (LLT, JRH)
VVH = (BPT, KRN)
JCQ = (CRB, PBS)
QXR = (BTV, PSZ)
VQR = (RCX, KKP)
QSM = (SLR, XGV)
JKD = (JDC, JGV)
XLD = (LFS, QVR)
TJK = (NKG, SDJ)
PVV = (HDK, VQV)
BDB = (PVV, KRX)
MPS = (KBN, DPT)
FHP = (PPD, XCF)
HTN = (KCM, PXC)
GHJ = (BHN, FKK)
JCC = (LQM, KVH)
LQR = (HGF, NVL)
LGM = (DDJ, NQF)
NJN = (QCF, NPN)
PRH = (DFF, DFF)
XDM = (FBJ, PJM)
HFN = (KRS, XSB)
GLM = (JXM, RMG)
RQP = (BXM, SDH)
BPG = (QJT, KTP)
JPB = (LNN, PKT)
DKN = (CJD, BGR)
CDG = (GSL, DJJ)
XDN = (CGM, VMG)
NQP = (SKT, JCC)
DNP = (QQG, DMJ)
NNX = (DQN, QLC)
FTB = (JFL, VJJ)
FHQ = (SMJ, XFK)
GGT = (KPK, LNT)
NGF = (LJB, CJM)
QFX = (KCN, TMF)
NKF = (JCQ, QNX)
DBP = (NGV, HLC)
RBV = (RMT, DHJ)
NML = (MBV, VCG)
KXJ = (MXH, FDC)
GFQ = (RDP, HNF)
SHD = (CMG, CTM)
GTX = (LNK, KXJ)
HXF = (KTC, LXS)
CMM = (NQP, SBR)
SDJ = (TBV, XCV)
CHG = (RMJ, RMJ)
DPT = (CMQ, JBG)
BGR = (RLM, NML)
THM = (XQD, NJN)
HJJ = (MCP, VRM)
NRQ = (JHR, GCQ)
KKR = (HSN, NJJ)
KVX = (LVG, NFN)
LTT = (TLD, DPP)
NVL = (QHB, HBF)
CXN = (XRF, BPK)
KLC = (CCX, LJR)
JDC = (DNF, XKX)
MGS = (XLK, CND)
RLM = (VCG, MBV)
VDN = (NMQ, TPR)
HSB = (JFL, VJJ)
HDS = (KLC, DHK)
XSD = (NLV, HBR)
HJD = (NJQ, PBQ)
CGM = (DHX, GVC)
LDQ = (PBL, JKG)
RDR = (XHQ, MGQ)
GPC = (GFJ, SFM)
NQT = (KRS, XSB)
TDH = (RBD, XLP)
QJF = (DFC, DPV)
VNS = (HPK, LBN)
QSD = (NJJ, HSN)
JHR = (QMF, JVH)
SMQ = (FXR, RFM)
CMG = (MFG, GGJ)
NKQ = (VFC, RTC)
VXC = (LHN, RSQ)
DHX = (LCT, XNM)
TCX = (NQT, HFN)
DRV = (TFN, QBM)
JPT = (GQX, XCR)
HRF = (JQH, XNH)
MCS = (BGJ, QTC)
PQG = (NCM, TCF)
XHR = (PJK, VPN)
MLX = (PGH, VND)
MKH = (VPJ, LMD)
TJR = (VQT, MPJ)
VLF = (GLG, QFX)
JNG = (KLR, MPV)
HDK = (BFQ, SFT)
HFX = (MLX, SPL)
BXC = (HFS, LBS)
CCT = (GTX, HPT)
VLK = (HLK, QJF)
NCD = (PJM, FBJ)
VGT = (JNL, DVQ)
LMD = (PSK, GQL)
KRX = (HDK, VQV)
QNX = (CRB, PBS)
NJQ = (GHQ, NDB)
TNV = (FBP, BQJ)
GNR = (XQD, NJN)
KKP = (QTB, PPL)
DBX = (KCQ, CPS)
VRM = (TLM, QLS)
LVG = (BRP, NJV)
NHL = (SPS, LKX)
MNV = (VBL, CHT)
PJK = (HHN, LTT)
VBH = (JQD, RGL)
GRB = (NKQ, CGH)
SKT = (KVH, LQM)
TPR = (RXR, KHV)
VVB = (LCL, MQR)
VKX = (MRM, RQK)
LTB = (PGJ, GQM)
QCJ = (KCM, PXC)
BGQ = (SMJ, SMJ)
RCV = (NQQ, JHP)
DHM = (TQS, BLS)
KRS = (CXC, MRR)
JFL = (BLT, PNM)
TXC = (NRT, LRG)
MVX = (LKL, XRR)
QSK = (JVM, MTF)
BGK = (LDB, NPX)
GJZ = (BFC, QQJ)
PXC = (LTB, PCH)
HMQ = (BGJ, QTC)
RXR = (BVJ, XSD)
BXM = (PRH, BCX)
FJH = (LRG, NRT)
GJH = (DGK, DDS)
BPT = (SBL, PHL)
RQL = (RQK, MRM)
SJB = (RQJ, LDQ)
NFN = (NJV, BRP)
MND = (NQQ, JHP)
NMQ = (KHV, RXR)
XGV = (TXK, HDS)
SPC = (KSS, XQF)
RMJ = (SMR, QRS)
CNX = (LFS, QVR)
KLR = (HJD, XSF)
XLP = (KRM, PNX)
LPM = (CMM, PHF)
FNR = (CCT, VTP)
NGQ = (CMT, JTX)
CCR = (BFM, TNV)
LCN = (FXV, TQL)
HVV = (HSX, KVX)
FSB = (MLX, SPL)
GGJ = (TLQ, VQD)
NHS = (DRG, FVK)
RQJ = (PBL, JKG)
VCC = (MMS, QHV)
HDX = (VVN, HXF)
VQM = (NRR, VVB)
TFN = (GFB, LRH)
QRS = (VQR, MDS)
HBM = (VTQ, SDN)
CCF = (SBS, XFD)
VCG = (HMQ, MCS)
NBF = (DVB, NHS)
DVB = (FVK, DRG)
PGB = (TDH, RFP)
XRF = (KFP, SPH)
KMM = (PDJ, GQN)
KTG = (GGQ, HNR)
BJH = (JBH, QSB)
JJH = (CCT, VTP)
LBH = (JFF, JFF)
GLG = (TMF, KCN)
TQR = (THM, GNR)
MQH = (GQN, PDJ)
MQR = (FMB, MRT)
FNH = (CTM, CMG)
SMR = (VQR, MDS)
GDS = (DNP, MJS)
LCT = (KQK, QFL)
VKB = (GBH, BGK)
VTQ = (CHM, MFP)
TNK = (QJT, KTP)
HNJ = (VVS, GCX)
JKT = (MMD, MGS)
PBP = (TPR, NMQ)
CPS = (KNJ, RFZ)
RNB = (KHX, FQC)
CMF = (LHN, RSQ)
HPK = (CCR, LXJ)
MFN = (NKQ, CGH)
HHB = (QBM, TFN)
DDJ = (QSK, KCC)
DFM = (RQL, VKX)
FKM = (GKQ, VJG)
HSJ = (LGQ, LXK)
HPT = (KXJ, LNK)
BNR = (JBX, DMK)
GJL = (CPC, JNF)
DFF = (KCQ, KCQ)
MCB = (GSS, JVP)
CPC = (JJH, FNR)
XLR = (MJK, DSM)
SBG = (JDG, XFL)
XSF = (NJQ, PBQ)
NGK = (RFM, FXR)
HSN = (GRH, HSJ)
LQM = (PQG, VKD)
VXN = (VMG, CGM)
PSK = (VGT, DTP)
JQH = (KLF, SCQ)
RJM = (SPC, TVP)
VSD = (TLL, TQR)
KCN = (GJH, NMS)
QHB = (GLM, BMP)
FMB = (VLK, XGT)
GBT = (DJJ, GSL)
LGH = (NGJ, LHJ)
SLR = (HDS, TXK)
VVQ = (GCX, VVS)
MDS = (RCX, KKP)
KVQ = (VPN, PJK)
CLF = (NHL, KGK)
XFK = (KQD, PNT)
CJD = (NML, RLM)
MCP = (TLM, QLS)
SPL = (PGH, VND)
GSS = (GPC, DNX)
RPH = (DBP, HHC)
HNR = (XXQ, JKD)
VBV = (VQT, MPJ)
PHF = (NQP, SBR)
BRP = (FJH, TXC)
AAA = (RMT, DHJ)
PBQ = (GHQ, NDB)
PXG = (VVG, SPN)
PNX = (JQV, JNG)
XHQ = (SJB, MBS)
VBL = (VLF, PXS)
VVG = (MTT, XTV)
PXS = (GLG, QFX)
MMQ = (FKM, HNH)
PHG = (HFN, NQT)
MFF = (KFL, LNQ)
PJM = (FHP, SPX)
SMJ = (KQD, KQD)
XGC = (CMM, PHF)
PDJ = (QCK, MHB)
SPN = (MTT, XTV)
BPK = (KFP, SPH)
MVF = (NQC, NKK)
LJB = (LBH, LBH)
GQN = (QCK, MHB)
NCG = (MTP, PXG)
GQL = (VGT, DTP)
NCX = (FNH, SHD)
HGZ = (QRS, SMR)
GMJ = (VSF, SFJ)
RFP = (XLP, RBD)
TXF = (GDC, HKP)
NBA = (SMR, QRS)
QTB = (FRL, NCX)
QLC = (GDN, QMD)
QHV = (SVV, HRM)
XTM = (GRV, THT)
VPN = (HHN, LTT)
RFZ = (XLR, QKM)
CMH = (SXG, CLF)
GFJ = (TCX, PHG)
VTT = (LGM, LFV)
RTC = (GKH, KPS)
XFJ = (VTQ, SDN)
GCX = (PGB, MJD)
MJK = (CLP, VML)
QQL = (RSG, KTG)
NSB = (XHQ, MGQ)
HCQ = (LGM, LFV)
GQX = (GJD, XKT)
RVR = (VVK, BKP)
JBG = (KKS, VBH)
JFF = (BTV, BTV)
BPM = (LNT, KPK)
LNQ = (JJR, HGQ)
FKK = (GLH, GPQ)
SBL = (CDK, BGL)
LNT = (BNH, RNS)
JRH = (JPS, HFG)
VVS = (MJD, PGB)
DPP = (LFR, GFQ)
MNF = (PBP, VDN)
QKM = (DSM, MJK)
JPJ = (CXN, RTJ)
QGC = (RQP, LBX)
CVB = (MND, RCV)
RFC = (CHG, FFQ)
KPS = (BCF, VSD)
XML = (MNV, TXG)
JVH = (JDP, GGF)
CRC = (XTM, LLQ)
VJG = (JRH, LLT)
SPB = (JPT, NDM)
JGV = (XKX, DNF)
GGQ = (XXQ, JKD)
XLK = (PGQ, VKB)
JBX = (NNX, VRP)
RSG = (HNR, GGQ)
GVC = (LCT, XNM)
XDP = (XML, HND)
CXC = (SMQ, NGK)
PXV = (TNK, BPG)
NDM = (XCR, GQX)
CPM = (BJH, QXK)
KGK = (LKX, SPS)
BLT = (NRL, PQR)
BHN = (GLH, GPQ)
BLS = (TKL, MNF)
PHL = (CDK, BGL)
BCX = (DFF, DBX)
HNH = (GKQ, VJG)
VKD = (NCM, TCF)
DSM = (VML, CLP)
DNN = (SLT, KJD)
SBR = (SKT, JCC)
TNL = (BGR, CJD)
DFT = (XFL, JDG)
MPT = (RKT, MFF)
TVQ = (XDP, QBP)
LLT = (JPS, HFG)
DXQ = (XTM, LLQ)
SFM = (PHG, TCX)
BNJ = (MND, RCV)
PBS = (NHQ, QRB)
JXM = (HRF, PKB)
VTP = (HPT, GTX)
SVV = (XXJ, RHB)
MHA = (QQJ, BFC)
MBV = (HMQ, MCS)
VJJ = (BLT, PNM)
QJT = (RVR, CGR)
VVN = (LXS, KTC)
QKS = (TRC, DFM)
MGQ = (MBS, SJB)
NDL = (BPT, KRN)
JPQ = (SVF, HDT)
VDH = (JHR, GCQ)
KCQ = (KNJ, KNJ)
XJJ = (DFT, SBG)
JQV = (MPV, KLR)
VQD = (DXQ, CRC)
JDG = (TJK, QMH)
SPX = (XCF, PPD)
LXJ = (TNV, BFM)
LBL = (NGQ, JHN)
QBN = (QQL, JPP)
LFS = (CVB, BNJ)
LBS = (JFV, NKC)
TLL = (THM, GNR)

5
08/input_test Normal file
View File

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

10
08/input_test2 Normal file
View File

@ -0,0 +1,10 @@
LR
DGA = (DGB, XXX)
DGB = (XXX, DGZ)
DGZ = (DGB, XXX)
EHA = (EHB, XXX)
EHB = (EHC, EHC)
EHC = (EHZ, EHZ)
EHZ = (EHB, EHB)
XXX = (XXX, XXX)

207
08/main.s Normal file
View File

@ -0,0 +1,207 @@
global _start
[bits 32]
[section .text]
%include "utils.s"
_start:
mov esi, file
; goto end of move string
skip_move:
lodsb
cmp al, 'L'
jge skip_move
; put pairs in memory
xor ebp, ebp ; state
; s0: IDX s1: L s2: R
; get the next thing
get_next_id:
cmp esi, file.over ; input over
jae got_ids
lodsb
cmp al, 'A'
jl get_next_id
cmp al, 'Z'
jg get_next_id
; we have first char
sub al, 'A'
movzx ebx, al ; id
lodsb ; id += next * 26
sub al, 'A'
movzx eax, al
mov ecx, 26
mul ecx
add ebx, eax
lodsb ; id += next * 26^2
sub al, 'A'
movzx eax, al
mov ecx, 26*26
mul ecx
add ebx, eax
; case based on state
cmp ebp, 0
je .idx
cmp ebp, 1
je .left
; right
mov [pairs+edi*8+4], ebx ; right
xor ebp, ebp ; reset state
jmp get_next_id
.left:
mov [pairs+edi*8], ebx ; left
inc ebp ; progress state
jmp get_next_id
.idx:
mov edi, ebx ; curr_id
cmp eax, 0 ; last is A
jne .d
.idx_a:
mov eax, [used_starts]
mov [curr_ids+eax*4], ebx
inc dword [used_starts]
.d:
inc ebp ; progress state
jmp get_next_id
got_ids:
; set what done is
mov ecx, [used_starts]
mov edi, full_cycled
mov al, 1
rep stosb
mov edx, file
; walk move string
find_move_end:
mov esi, edx ; restore
lodsb
cmp al, 'L'
je .left
cmp al, 'R'
je .right
mov edx, file
jmp find_move_end
.right:
mov edx, esi ; save
mov esi, curr_ids
mov edi, curr_ids
mov ecx, [used_starts]
.right_l:
lodsd
mov eax, [pairs+eax*8+4] ; right
stosd
loop .right_l
jmp check_ZZZ
.left:
mov edx, esi ; save
mov esi, curr_ids
mov edi, curr_ids
mov ecx, [used_starts]
.left_l:
lodsd
mov eax, [pairs+eax*8] ; left
stosd
loop .left_l
check_ZZZ:
; find cycles - i'm sure this is an awful way of doing this
inc dword [final_value]
mov esi, curr_ids
xor ecx, ecx
.zzz_l:
lodsd
cmp eax, 16900
jle .zzz_l_cont ; not Z
; check if this Z and string position in cycles
mov edi, ecx
shl edi, 10 ; *1024
add edi, cycles
.check_cycles:
mov ebx, [edi] ; Z
test ebx, ebx
jz .new_cycle
cmp ebx, eax
jne .check_cycles_cont
cmp edx, [edi+4] ; str pos & cycle str pos
jne .check_cycles_cont
; match, increment count
inc dword [edi+8]
mov byte [starts_cycled+ecx], 1
jmp .zzz_l_cont
.check_cycles_cont:
add edi, 16
jmp .check_cycles
.new_cycle:
mov [edi], eax ; Z
mov [edi+4], edx ; str pos
mov dword [edi+8], 1 ; count
mov eax, [final_value]
mov dword [edi+12], eax ; cycle len
.zzz_l_cont:
inc ecx
cmp ecx, [used_starts]
jl .zzz_l
.cont:
; check if we've seen everything cycle
mov ebx, [starts_cycled]
cmp ebx, [full_cycled]
jne find_move_end
mov ebx, [starts_cycled+4]
cmp ebx, [full_cycled+4]
jne find_move_end
; done, print cycles
xor ecx, ecx
print_cycles:
mov esi, ecx
shl esi, 10 ; *1024
add esi, cycles
.l:
lodsd ; Z
mov ebx, eax
test eax, eax
jz .cont
mov eax, ecx ; Start Num
call print_dec
call space
mov eax, ebx
call print_dec
call space
lodsd ; str pos (skip print)
call print_dec
call space
lodsd ; count
call print_dec
call space
lodsd ; cycle len
call print_dec
call newline
jmp .l
.cont:
inc ecx
cmp ecx, [used_starts]
jl print_cycles
.done:
call newline
; lol go use an online calculator for lcm
game_over:
mov eax, [final_value]
call print_dec
jmp exit
[section .data]
final_value: dd 0
used_starts: dd 0
starts_cycled: dq 0
full_cycled: dq 0
file_lim: dd file.over - file
file: incbin "input"
.over:
[section .bss]
curr_ids: resd 8
cycles: resb 1024*16
pairs: resd 131072

97
08/main_part1.s Normal file
View File

@ -0,0 +1,97 @@
global _start
[bits 32]
[section .text]
%include "utils.s"
_start:
mov esi, file
; goto end of move string
skip_move:
lodsb
cmp al, 'L'
jge skip_move
; put pairs in memory
xor ebp, ebp ; state
; s0: IDX s1: L s2: R
; get the next thing
get_next_id:
cmp esi, file.over ; input over
jae got_ids
lodsb
cmp al, 'A'
jl get_next_id
cmp al, 'Z'
jg get_next_id
; we have first char
sub al, 'A'
movzx ebx, al ; id
lodsb ; id += next * 26
sub al, 'A'
movzx eax, al
mov ecx, 26
mul ecx
add ebx, eax
lodsb ; id += next * 26^2
sub al, 'A'
movzx eax, al
mov ecx, 26*26
mul ecx
add ebx, eax
; case based on state
cmp ebp, 0
je .idx
cmp ebp, 1
je .left
; right
mov [pairs+edi*8+4], ebx ; right
xor ebp, ebp ; reset state
jmp get_next_id
.left:
mov [pairs+edi*8], ebx ; left
inc ebp ; progress state
jmp get_next_id
.idx:
mov edi, ebx ; curr_id
inc ebp ; progress state
jmp get_next_id
got_ids:
mov esi, file
mov ebx, 0 ; curr idx
; walk move string
find_move_end:
lodsb
cmp al, 'L'
je .left
cmp al, 'R'
je .right
mov esi, file
jmp find_move_end
.right:
mov ebx, [pairs+ebx*8+4] ; right
jmp check_ZZZ
.left:
mov ebx, [pairs+ebx*8] ; left
check_ZZZ:
inc dword [final_value]
cmp ebx, 17575 ; ZZZ
jne find_move_end
got_ZZZ:
game_over:
mov eax, [final_value]
call print_dec
jmp exit
[section .data]
final_value: dd 0
file_lim: dd file.over - file
file: incbin "input"
.over:
[section .bss]
pairs: resd 100000 ; idk we only need a few 10,000

146
08/utils.s Normal file
View File

@ -0,0 +1,146 @@
; call # val val2
; int $0x80 eax eax edx -
;
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
; ebx ecx edx esi edi ebp -
exit:
mov eax, 1 ; exit
int 0x80
; filename in EBX
; return handle in EBX
; read only
open_file:
push eax
push ecx
mov eax, 5 ; open
xor ecx, ecx ; read only
int 0x80
mov ebx, eax
pop ecx
pop eax
ret
; file handle in EBX
; buffer in ECX
; count of bytes to read in EDX
; return bytes actually read in EAX
; exits on error
read_file:
mov eax, 3 ; read
int 0x80
test eax, eax
js .err
ret
.err:
mov eax, 4 ; write
mov ebx, 1 ; stdout
mov ecx, .err_str
mov edx, 21
int 0x80
jmp exit
.err_str: db `Could not read file.\n`
; string input in ESI
; value in EAX
; CF set if none, clear if some
; ESI set past checked area
dec_parse:
push ebx
push edx
push edi
xor eax, eax
xor edi, edi
mov ebx, 10 ; base
lodsb
sub al, '0'
js .no_input
cmp al, 9
jle .got_char
.no_input:
stc ; set CF
jmp .done
.loop:
xor eax,eax
lodsb
sub al, '0'
js .dec_done
cmp al, 9
jg .dec_done
.got_char:
xchg edi,eax
mul ebx
add edi,eax
jmp .loop
.dec_done:
clc ; clear CF
.done:
mov eax,edi
pop edi
pop edx
pop ebx
ret
; modifies no regs
newline:
pushad
push 10
mov eax, 4 ; write
mov ebx, 1 ; stdout
mov ecx, esp ; string
mov edx, 1 ; length
int 0x80
add esp, 4
popad
ret
; modifies no regs
space:
pushad
push 9
mov eax, 4 ; write
mov ebx, 1 ; stdout
mov ecx, esp ; string
mov edx, 1 ; length
int 0x80
add esp, 4
popad
ret
; input in EAX, all regs unmodified
print_dec:
pushad ; save regs
; max 4294967296 is 10 chars
; round to nearest 32-bit boundary
sub esp, 12
; string in ECX, length in EDX
lea ecx, [esp+11] ; last possible byte
; check for 0
test eax, eax
jz .zero
mov ebx, 10 ; base 10
xor esi, esi ; counter
.div_shit:
xor edx, edx
; divide
div ebx
dec ecx ; next char
inc esi
; store
add dl, '0'
mov byte [ecx], dl
; check if done
test eax, eax
jnz .div_shit ; continue
mov edx, esi ; counter in edx
jmp .write
.zero:
mov byte [ecx], '0'
mov edx, 1 ; length
.write:
mov eax, 4 ; write
mov ebx, 1 ; stdout
int 0x80
add esp, 12 ; restore stack
popad ; restore regs
ret