day 3, add [un]curry and swap to utils
This commit is contained in:
parent
efde27f8c8
commit
883d16a3a3
4 changed files with 366 additions and 0 deletions
4
bin/d3/dune
Normal file
4
bin/d3/dune
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(executable
|
||||||
|
(public_name d3)
|
||||||
|
(name main)
|
||||||
|
(libraries core utils))
|
300
bin/d3/input.txt
Normal file
300
bin/d3/input.txt
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
dtddvvhwttHJhwdhJPddhwJGppmGjgpQgTjQplQpTljwpg
|
||||||
|
BfzSzRSVVMVNRMDDNBSNSnfBmbrglGQbmNpQggFjpgpbQlQb
|
||||||
|
ZSBffLnVZdCCPJjhhL
|
||||||
|
RGCZpWWWFlHQQbgvFssg
|
||||||
|
jLnMzjnrnjjNjhrjdwbHscsVVgDVQPvPwh
|
||||||
|
nfJnLMLzjJMtnjNnnBbZtBWBqqbTTTBRpT
|
||||||
|
nddlhBtqTBqTVSlBtmCmVcRVmZggfWbcZc
|
||||||
|
jDjvPrPSNPwrDNRWbbgWCjRRCcWm
|
||||||
|
DzDwSpFrvrvFPQLzQnsqztBthTJnGJqlsJ
|
||||||
|
gssGmzwgRgsNmTsqgDnDJnbDHHhhzFdDDh
|
||||||
|
WQVFjMWrVQrVvVVjVctSSLSMZhnJZPBnbdnhbnHZZBDJBh
|
||||||
|
VCtcccVQLrfvrSlGmfTfNgfmlFgm
|
||||||
|
DsmfsBbNNZhDWsbmWmNbbPDHLFjcctjjGcnZGzncnctcGH
|
||||||
|
SwVQJrjVwpgSVRpjpVRrlTMCFFCLCFFcHzzGMcHrtHHH
|
||||||
|
ppVwTwSwpwvSlSlJTjVVbPhsvvBssWsNfsqWPvWs
|
||||||
|
BJwqwJtqqDDDrGDnPFzPFfpphD
|
||||||
|
TgZscCHQLSHgZcfMzpjFFjzsshfj
|
||||||
|
LcNlTVQCCVLLZTLNvpRtpvBBvRJmNB
|
||||||
|
bDBGQBBCTTNPGPPwPzcHfVHrDtLWLVrWVjjHWr
|
||||||
|
gpssqqsqlMFfLZQWftjVpr
|
||||||
|
lvqqFMRlFcQvbzCNCG
|
||||||
|
fhhMDdPhWMJMWvhhSfwRSGlzFbSFNlzw
|
||||||
|
LcqTCqcgZqjTggVjcwbFRwbDBTzbRGRwTS
|
||||||
|
cHLpZgnCHpQsDdsmQp
|
||||||
|
jwStJjJhtgJStpgwJMggQWqQTNTfNTWfbNNMCCNG
|
||||||
|
zRZnFPRZPVncPGVFRlRmGHCTqfCCPCHHfLfbTQCbTq
|
||||||
|
lnVmFZRZDnRVBFZcrZlhjpggvppthGhphpwprS
|
||||||
|
lcttSptHHllQbMcsrltSQGpvNBzpgWBBBDDGWzvgLz
|
||||||
|
PdjPVRFhFqFjRRCjzvRWnWLBLgbBBLzg
|
||||||
|
hhCCFbPTmjPdhZjhPhZCmTjjMsrJSfHrcmHJrHHmlcJSsmft
|
||||||
|
WhWnLZSSnSzQQhfLLNSfmDHrCFDDHtpjGGtTGQCG
|
||||||
|
gJbJBcMVwJlRRdbwvwJBVtjdtHHTmptpHTCtTFrFCp
|
||||||
|
JwwgvRMJlvJwgqgvqRMcnWWhLPzzsqfnZWnfWWnj
|
||||||
|
zdwTSvzHMvVSzDCtZhtGmbTGhm
|
||||||
|
lcBHfFjjgtsmDCgshD
|
||||||
|
cJPBnqNFnLfHJFPqljclqJzQvSSVWvSnMwvSzSWWdMWM
|
||||||
|
pNJMcZrsZDLDcbcccMpQffHqvgdwdFFmdmqwvqmgmzsw
|
||||||
|
hhnWjTTStRCGSMgvvgvdqvdFjvVz
|
||||||
|
hCTSWhPGttTCGBWMRlTCMSnPBDJpbDfDpNpbbNJfJDJbpJpN
|
||||||
|
lbcQcSNFchhQNqHLLqhLqrMpqM
|
||||||
|
WfsnsszPWfBBVpHdprrpdnGL
|
||||||
|
WTzWfwjtTBzwwBDzmfSSQmmbFZcpQNcbZZbv
|
||||||
|
PwSJSlmtPPgwgmHhPPvRvGHLRLQRBQGCQVGb
|
||||||
|
rnsFDnnfGGRWQRnW
|
||||||
|
dfTTfTFdfrfFFFzQFPJPSSlhqtllNPzgwS
|
||||||
|
MMbTFZrcrGZMDqNStWScDtzS
|
||||||
|
dvWmhQggQvCnfnqPqDnDjnfP
|
||||||
|
lgvdvLClWCQlgdhlrMBBHpGlwbHHGH
|
||||||
|
CQHgQpPdCQpsCpzRwSVRSzRZwZ
|
||||||
|
JbNBbcbrJvbJnqVznwwTzrzz
|
||||||
|
wNbfLvvfDNNBHPFLhddFsQss
|
||||||
|
VVzqvwzpqvzqNVVHGNqjHpNfSQDWdWwJdPWrWccdQrWrrDdd
|
||||||
|
nLcbtBRtBhcnWSJQlJSgll
|
||||||
|
tFbLLLRRhMtsBMtRCRsLCMBVjjvHTNjHHjzcvFFppGHzTT
|
||||||
|
QCPrPWNPlWjGGZqGmvdPGd
|
||||||
|
JgpHpSfphhfpVmBSgnTvdtddGvZVdvddDv
|
||||||
|
LhphBfHpSwSwfHcMgfpmBWWWbsNCjFWsljNbbjlLjb
|
||||||
|
QJmQbRmdfmdSQRQZSJltTltNvTrtDtrlftDD
|
||||||
|
wpZcHVwwMgBpWMVgWpHLphztDvvGvDPlnGvDLlNrDPnNPl
|
||||||
|
McgWFWHHHzVpMgZQFqbjsdjqqRCq
|
||||||
|
JPhLFfMJDLQnjNCvWWpdjjdM
|
||||||
|
crSwnwVnwSRBcNBNjjWCdC
|
||||||
|
GlbTGbsSzrtbmbfhnJQP
|
||||||
|
fDLSWVDRHHfVWHgPcZlDlZbbQhBcZQbb
|
||||||
|
jrmFmprTpFztmddjdjrpvBQlQZGhQbTsQbGcQbcbQs
|
||||||
|
nvqdpmjFnwpLSWlfnVNnWl
|
||||||
|
nZBRbBJzznNNCnJZwnBSCJMcpcTpcwhcqhmsmWMwFWLL
|
||||||
|
jQfvjgtfvPlHHqWpvWThpWqWch
|
||||||
|
VljjjgjQjrTDlDgrHtVCbnJZzNzNbnRNNJZrJR
|
||||||
|
MQtJnttlMLlJQsNhQrVVrFVWRRbbVFdJDD
|
||||||
|
vGjvzmjzgHqSjjSzmSGHTWbfDFWrbFzFfdDVrfRWDb
|
||||||
|
qPRqvTSPggqGgHCmllnCNLtnhcnnsnnw
|
||||||
|
zrlZsQMFrsgQFMMjMCbjVDCTCW
|
||||||
|
NqHNRdBppcJJcTpdmRfHThpdDWDtvbWVtbLjWbttWqqCCbLt
|
||||||
|
mhJpJHTJmBhcJhwhgwzsQwSSlzQQzGlZ
|
||||||
|
TvsszlvnzRRVTqzVrqrjjZGPfQPFqPqG
|
||||||
|
mcNhDNchppWmWSNhdSmSCQNjPFjrfGjrgPFCrgFPgPgrLf
|
||||||
|
SDddWpdMWSwNDmMNwlJRQwJlsVRRvzlsHt
|
||||||
|
DTtggjsFFFTlPJhvctBqBqSRmSMBSRnmnRcm
|
||||||
|
fGfwZdrbHVLdbGdHHwwQGVwBBCMMfvCNRNSMMMSRBmmRCN
|
||||||
|
dGZzGHGVVbvHvHwbzpGbHLrwFDDFTtsglhFspgJshslTDJjT
|
||||||
|
CbzspssWwCPcvvplrfqfDCJrDqdllB
|
||||||
|
LjttnjNTNGgQQJdBrffTwB
|
||||||
|
nVtLSgggjFwtMczhvzpZbSZW
|
||||||
|
HCzCHHvWthWFHhssWCVmnqZrnqVrmrmgnbrqmN
|
||||||
|
wPPGBjQQGwGbSlSLwgnpnrBZnBBmnMNnMN
|
||||||
|
jTTbJlJjPPLPGHHTthhhHcFWTT
|
||||||
|
qRdvvPDrCpzPHzcdrrcRqtbJJgjhgtWjJgbWJtgCFb
|
||||||
|
GTwGwNscLllGTZmGSTZGlSBMnhggjbgtgbtbsgWFFMhbMF
|
||||||
|
ZSQBSmlmzcrdQRqz
|
||||||
|
cSpTRphwwghRfgSScqPpnDqDCjDjJJJJDvDLCvvn
|
||||||
|
BVmmQFQBQVNBVmsWlbQFGBBlCHTJznzHLHvvCnjjNLHJDLHD
|
||||||
|
MFsZZMbBGblbQTmQsFsQMMfPcPcwSpwtStgPphZtctPc
|
||||||
|
QZbbZBdjPBjbQQbZnSSltlfwWvlvwNtNjwFMMN
|
||||||
|
DLVqTJqpSVtfsptwfWpv
|
||||||
|
rcRRVVTSbPQBPrBZ
|
||||||
|
tjSgSjLFSnVjDWRsQj
|
||||||
|
lcdqhfFpqZGpZqznrVRWPrnWRVBsVG
|
||||||
|
FHddNNNHwTHMHvvS
|
||||||
|
qCSDSQlwBHNbgJrHnLJH
|
||||||
|
GRpRpRfnmRWWVWgVrF
|
||||||
|
jhdZjpnvGfTZZQPlCtqQQSsS
|
||||||
|
FMZSGWWBrZjMBZMrBWMGjjZDnCRqpgPnbRwPbFnvvqFnDR
|
||||||
|
QHcpfVVslfdVlQclcctqRgqgbsCwbCwPCCCPwD
|
||||||
|
NLHfLhclmmhdfNNpfQMBmZWBrJMmZWBzMrjj
|
||||||
|
pBMpRgBMQwzRthmzLC
|
||||||
|
HPcJvrvDbjvrFDcvWrHfHfWHmdddtdTLztmtdtfllmNdNhNz
|
||||||
|
DvPFDvnPJLngQsggMGGQ
|
||||||
|
BbcFHvbhhDbbTSvZmwwgJPPlDlZldd
|
||||||
|
prCrNLMNgWWJBdrJ
|
||||||
|
fQMLCfLLtpqsNNMnnfBhcBSVGbhhhcqVbcjc
|
||||||
|
ZchcZZjmmNpgmJtgmM
|
||||||
|
RLrHllWrQZQGlBpbGFGFFM
|
||||||
|
RQnLHrqPLnZHzqjfVPcvVTfCvPTC
|
||||||
|
fMtwjfMwrbjfGrtrpPGrwpNNVNVqcbdVqHZTFNbcHSNL
|
||||||
|
mgzvDnJmnJhFJHSTNqZLHncHLS
|
||||||
|
vRzhzslJFhRffPPQMjGtGl
|
||||||
|
VMMNjWppQVwzNWrZdrrtMCMZCtMT
|
||||||
|
ngDScLcvPPgDPDGhGDPGSHVbHTHmZtTSrBHZbZBmBb
|
||||||
|
LhlglLghnVlplswJjs
|
||||||
|
bGJQZZTQQLJJbQZlTZLjCGQTsDhWFhmshhvjWVFVVrgtDsst
|
||||||
|
NScqwHcwwnnzBwqPqqsmVNhgsDDVtsghrFFg
|
||||||
|
pcrcwnpcffrcBzfbCRLpRLMMRlRLQl
|
||||||
|
hzCzCzpRgCzzzCctNsNWNqsZqZhPqNPb
|
||||||
|
TdBwmdrrrDmvwTvqNsSRssPlsWsq
|
||||||
|
FDBRRHDMTmBfmrmngnpjGgVptMgLCp
|
||||||
|
ZPLLnSPMFGvFZMSvHhDhqHfqvfqbDW
|
||||||
|
GgcppCgBcrQBBgplrVddhDqqqfdHgWdfqb
|
||||||
|
CcCjQszmGBQjrcCwCmCccPwPTPnMPTnMJSMMRZSPJL
|
||||||
|
LcVVcqqSHRLzRnCfNnGzNW
|
||||||
|
LZPPdljlCggMjgNM
|
||||||
|
PTvwlPtwtlJvZTQvbcHppFLHVVTcFssF
|
||||||
|
fpWzvzNgWJBVfBJzWzBVJNzWbZcbHhlbthjlrrPrjZZPHZhJ
|
||||||
|
hRDmGCFDwQnStncrjnccHcMP
|
||||||
|
GmmsGRmFTsFwSCsRQDsCSqqpfvfgzddWggvqdpfBWzVh
|
||||||
|
wjRBFljJGDFwwlGGpBSjGDtwTVtTgHHHsHHsVTVzsHqq
|
||||||
|
CPLNPdbWvbMWbcmvPNdLVqtsHqgCqHChZhhsVsHt
|
||||||
|
PWcPfPvmvNQbbWdWpJjJBDptGnDFjftn
|
||||||
|
mFFmJpDMmmnJFjWDVclsSpcflSsQwSsc
|
||||||
|
HrjNNjHNfVwLNSSl
|
||||||
|
tdZbhjHZHPbdCTvbbhhrGbbHMFmRMvnRRFmmvJMDmgJDJMnq
|
||||||
|
szJZhshbsfZJjbttchPctdTnWnRWVWMMnBdLRpMnBz
|
||||||
|
SrNwvDSwrCmnVRvjpWLBBn
|
||||||
|
ggGmgNFrgSDwmNgrCmtPsZPsjQGsqPcsqqJP
|
||||||
|
gjSWSjJSWrWzppzW
|
||||||
|
MCMzHNGNqHfscsFtrtwscVcr
|
||||||
|
qGHNGNHLCnLmTCHfMMmNTzzldzgJlJZZgJljgTdD
|
||||||
|
Q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fJhJRDMGFRlCMDMD
|
||||||
|
vLFTDmjVvLgnNHPphN
|
||||||
|
lMClGCmsRdCnPzCccngCpz
|
||||||
|
dlGZwRsRrRwswGsdSbbZSbVDrVBmDWWWFJrTrFvFTmqV
|
||||||
|
SGsZRqGLWLLtZRHRRcLHGTlJjzgJpjzTpNTNJNWpTm
|
||||||
|
MPMPvFFvFBrPPDPMQMPChjgpNpSNTmmmpNlTDljlTz
|
||||||
|
vnhrvMvnhSRqqLqnfn
|
||||||
|
mGFrlBmFQNQFljhqqqqbmHMsTPRbWWCsLMWRsb
|
||||||
|
wnwtvpwVzDVpvzzwZppnctMLtMPWWCstTsWTsTLffRRW
|
||||||
|
vwDJgZnvZJFqgLBFGqgl
|
||||||
|
QdGltnWNWqTdqQWvWsMJcrTcFcrgshJRMs
|
||||||
|
BzPLCDPzzzzCCLLfCBzfSDmLMrDJMglrcRbbhRsFhMrRJcsM
|
||||||
|
fjSzwwHfSzPzfCVBHlpdjGnZqnZptqQWjGvG
|
||||||
|
VbJZbgVzvzmhQpQWpQzhDp
|
||||||
|
tHPPcGcFBlCctCGtGcBBNlDLMGfMLwWfwwqMLLJwQWwp
|
||||||
|
dCHTPTPJdTBFPdrZjgsjrjnmdgms
|
||||||
|
JJpBvJQBZVvcFqqnsWdWvjsn
|
||||||
|
DCfbDbTtbgfCSHqqNdFMPhPDFnPPDWsPjM
|
||||||
|
bTmzTNCTNmfqTgJQcpLrpZLzVlVL
|
||||||
|
dtTLntTjzTftnmwnqGGQHNmm
|
||||||
|
SWbShCPMBgBRRFSFtRZZmm
|
||||||
|
DlJPCJCgPWhttzpvdjcpVl
|
||||||
|
WdzsNvWMzNsMHWddWCVffqmSmScLPvLPgLgLPplrrPmL
|
||||||
|
BtnzbnBhbwttwtZlmmlgcwSrLgmmpm
|
||||||
|
bFhQtbGBTnjBBbjTtFBbVDzddDDfjdDDqNWVjWHj
|
||||||
|
ppmtpgLLZLCbMQvQQThdtrvPhV
|
||||||
|
BBlHBwHRjHqBzzbHHqjjQdDQTDhPQDvnQlrQDQvr
|
||||||
|
HGjFzwHNczbzRFcGzHGFSJSpspsmpssMLLSZCppmfs
|
||||||
|
MpGrMMMcTsHMVHcvbwwmmcRSmDmDmv
|
||||||
|
zCNptqCBQQLCNLCzbfvSvbSzSDRDSmSv
|
||||||
|
CNNqNgNQJNgQtCqLlllZdZhTrThsnHpVVssPTsGP
|
||||||
|
jhSGcShDrLcLLFcw
|
||||||
|
MVzQvQNZVLHvHPdhLW
|
||||||
|
qzhhQlVbgqjmSjJDsgmR
|
||||||
|
CFzSPCgcsVVzFgzSCsBJwjdwJtNllnwglJlp
|
||||||
|
QrvbqWvvLbmvDMMmbdwFWpNNwwwwptjJWn
|
||||||
|
RZRZZqvvvDbDHCRTGchHFSGG
|
||||||
|
SszgPSPPVltDlqtz
|
||||||
|
WfTdTBdQdFnWBBBhBhNjVJtpNsVlDDDHHJWp
|
||||||
|
hQhrLFsBwdQPggbRgPwRMg
|
||||||
|
frRppMMDMpDnJfprnZhrrhpzWgvvGCvvFzWFvzvVVWFGJB
|
||||||
|
TcmLwTsccqwqbPwsdwqdTPSvBvzzztvggVvQCGWQCLBvCv
|
||||||
|
sswNjscwmqjwSssjdZNMfHHlHhfrnrgnfR
|
||||||
|
JpBJBdmdzZzzpngmbCnlqnNbNM
|
||||||
|
MMTHGccLTLvwRMlRnnQnbblnRnSs
|
||||||
|
vVGtvMcjLVGHfHDrPPWZppBpJpfZZZ
|
||||||
|
FGJtlttPdPtGFldlPRGpJTVzSBSSggHgJjVmBMHjJm
|
||||||
|
rhbvqrQLrWqrWLLfqbjjgNmVNSgzTmNgNS
|
||||||
|
hsffZQqnqCfZzlPPGlRlcwDs
|
||||||
|
HDDdZpcFwHFRFcZqDctpRDHpwTCVwjrBTQTBLBLBJJBjjQTJ
|
||||||
|
ldlMzhlPshPbLrrVrQQCMQjB
|
||||||
|
glzNfWlvbHqSdNNNcF
|
||||||
|
jZCMtnZZHCZwBWMwCwtMmfPFfvH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NmNFmtmbFCDF
|
||||||
|
SPGCBPDMtbcbCtchSMccDTTrrrTFTrsrMTWHTHFVWF
|
||||||
|
JmnzqVmmwwfpJpmdHRTRsdsTrFdrQp
|
||||||
|
LqwLgzJgnjqLwgGcVbtjDGjcVbhv
|
||||||
|
PQcMvrvMsvmdSPPVccmSJcSpGBWWWbBHfWWnfttJWnWJpJ
|
||||||
|
wDzqhjzmqRzDRwqDzNDbWtjWBBBtGbtHpHnnBf
|
||||||
|
zglRhDqqDZgRNmZQVCdcCPQvvdZv
|
||||||
|
RpVjRgvFjGBNWtBWFDtt
|
||||||
|
dcqQwlqMMsCLLfbgQmtD
|
||||||
|
snlgzsggTzSTSJTr
|
||||||
|
dLHhDdtlMngFcFsFLFzzsj
|
||||||
|
vWRGGRVrrWvvGQQJBRsmQzmsqnffqcNfNcfz
|
||||||
|
vSRVJBVBwTvWTnHphTgDgtMpDl
|
||||||
|
bvvGnnJbfPmfdgJJSVtwwCpTScVfNpSC
|
||||||
|
sjsZWDqBqqMRZsDjbWMVwtwNNcNtScRHpRRttp
|
||||||
|
hzhDqqWDzZzDZzZLQPJPdPnPvlrbGdlnFQ
|
||||||
|
PwWHTwzFvNHsNzmmMwzNWGQrCqCFjpZbpnGqrqnpbr
|
||||||
|
gRVRgJRJlDLSJddDccQVrtZnCqjndnrZdnqnqpdq
|
||||||
|
chhgSSJfQhRRcSSSSBLVfzmzHTNzMNsTNWHMMvMP
|
||||||
|
lftqSpBSvhlDBDlhBSczQGmcFMcMVVFMmGFWsm
|
||||||
|
rHLHTNdggsLLnwLHbTTgdrTMPPmMGWZGQQMzQVQFZQGM
|
||||||
|
gbJnrHHjnbrgLrRrHpBJvSBDDsfJsDtstq
|
||||||
|
dBTtFLTtVmpdLhMprSRSWMRSMR
|
||||||
|
QvJvQbjbCgCQRBhzzRsNWNBC
|
||||||
|
bjgGqQGbQnjGQgnQgbGgjJnDLHLdfPVtdDmLZdBFVVZttdTf
|
47
bin/d3/main.ml
Normal file
47
bin/d3/main.ml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
let split s =
|
||||||
|
let half = (String.length s) / 2 in
|
||||||
|
(String.sub s 0 half, String.sub s half half)
|
||||||
|
|
||||||
|
let find_duplicates s1 s2 =
|
||||||
|
String.to_seq s1
|
||||||
|
|> Seq.filter (fun c -> String.contains s2 c)
|
||||||
|
|> Seq.fold_left
|
||||||
|
(fun acc c -> if String.contains acc c then acc else acc ^ String.make 1 c)
|
||||||
|
""
|
||||||
|
|
||||||
|
let priority item =
|
||||||
|
let num = int_of_char item in
|
||||||
|
if num > 96 then num - 96
|
||||||
|
else num - 38
|
||||||
|
|
||||||
|
let find_duplicates3 s1 s2 s3 =
|
||||||
|
find_duplicates s1 (find_duplicates s2 s3)
|
||||||
|
|
||||||
|
let get_duplicate dup =
|
||||||
|
try Some(String.get dup 0 |> priority)
|
||||||
|
with Failure _ -> None
|
||||||
|
|
||||||
|
open Utils
|
||||||
|
|
||||||
|
let part1 l = l
|
||||||
|
|> List.filter_map (fun s ->
|
||||||
|
split s
|
||||||
|
|> uncurry find_duplicates
|
||||||
|
|> get_duplicate)
|
||||||
|
|> List.fold_left (+) 0 ;;
|
||||||
|
|
||||||
|
let triplets l =
|
||||||
|
let rec aux res = function
|
||||||
|
| [] | [_] | _ :: _ :: []-> res
|
||||||
|
| elv1 :: elv2 :: elv3 :: tail -> aux ((elv1, elv2, elv3) :: res) tail in
|
||||||
|
aux [] l ;;
|
||||||
|
|
||||||
|
let part2 l = l
|
||||||
|
|> triplets
|
||||||
|
|> List.filter_map (fun triplet ->
|
||||||
|
(uncurry3 find_duplicates3) triplet
|
||||||
|
|> get_duplicate)
|
||||||
|
|> List.fold_left (+) 0 ;;
|
||||||
|
|
||||||
|
"\n1: " ^ string_of_int (read_file "bin/d3/input.txt" |> part1) ^
|
||||||
|
"\n2: " ^ string_of_int (read_file "bin/d3/input.txt" |> part2) |> print_endline
|
15
lib/utils.ml
15
lib/utils.ml
|
@ -9,3 +9,18 @@ let read_file name =
|
||||||
| None -> close_in ic; acc in
|
| None -> close_in ic; acc in
|
||||||
aux []
|
aux []
|
||||||
|
|
||||||
|
module CS = Set.Make(Char);;
|
||||||
|
|
||||||
|
let set_of_string str =
|
||||||
|
let rec aux s i st =
|
||||||
|
if i < 0 then st
|
||||||
|
else aux s (i - 1) (CS.add s.[i] st) in
|
||||||
|
aux str ((String.length str) - 1) CS.empty
|
||||||
|
|
||||||
|
let map_pair f (a, b) = (f a, f b)
|
||||||
|
|
||||||
|
let curry f x y = f (x, y)
|
||||||
|
let uncurry f (x, y) = f x y
|
||||||
|
let uncurry3 f (x, y, z) = f x y z
|
||||||
|
|
||||||
|
let swap x y = y x
|
||||||
|
|
Loading…
Reference in a new issue