diff options
author | Marvin Borner | 2022-12-07 06:42:24 +0100 |
---|---|---|
committer | Marvin Borner | 2022-12-07 06:42:24 +0100 |
commit | d9a92b10741fab1ff61064107fd61610a8c16dbc (patch) | |
tree | d7faaa103b839e8eeb6c2d93ebc9ca2b881a933e | |
parent | 5945f4e31ea287d6b7bfaebe9c504e8807a4510c (diff) |
Needs cleanup :D
-rw-r--r-- | 2022/07/input | 1005 | ||||
-rw-r--r-- | 2022/07/solve.py | 54 |
2 files changed, 1059 insertions, 0 deletions
diff --git a/2022/07/input b/2022/07/input new file mode 100644 index 0000000..34b64b2 --- /dev/null +++ b/2022/07/input @@ -0,0 +1,1005 @@ +$ cd / +$ ls +dir bzgf +199775 dngdnvv.qdf +dir fhhwv +dir gzlpvdhd +dir htczftcn +23392 lbcgmm +251030 lsw.jgr +305227 nflgvsgz +dir qcqg +dir qtqpw +dir qzcdscbp +dir rfgvg +dir rzb +202033 zqzlbvgl +$ cd bzgf +$ ls +80802 htczftcn.bdr +$ cd .. +$ cd fhhwv +$ ls +dir bjml +274615 bzmwfgf.wwp +dir ddpf +dir jngvpc +220692 lbcgmm +dir pffdg +dir prwpzhb +21309 qtqpw.mhb +12989 vbvt +46352 vhnsp.dhg +$ cd bjml +$ ls +307491 bzmwfgf.wwp +dir cwghv +164053 dngdnvv.qdf +144223 jbc.zgp +274358 mcqbcttc.mwr +dir pffdg +573 spbw.mnt +dir vdd +dir zzvs +$ cd cwghv +$ ls +298079 htczftcn +33689 nflgvsgz +287144 svfqpfm.bgs +dir tdgw +164244 tzrz.hms +52508 zmm.ndc +$ cd tdgw +$ ls +195017 htczftcn.cnl +$ cd .. +$ cd .. +$ cd pffdg +$ ls +64762 bbqh.wzf +dir bgzdv +56148 bhrw.jls +dir hqwmfdj +28260 htczftcn.lvs +dir lzhz +dir nbmsrl +91675 qtqpw.hsj +$ cd bgzdv +$ ls +205543 srzlfd.hnq +$ cd .. +$ cd hqwmfdj +$ ls +37910 dzpgcrn.rbj +290553 mrrngcdr +175411 nflgvsgz.tsj +$ cd .. +$ cd lzhz +$ ls +73620 bbtdnpvf +dir jbc +$ cd jbc +$ ls +125475 tzrz.hms +$ cd .. +$ cd .. +$ cd nbmsrl +$ ls +106099 dngdnvv.qdf +$ cd .. +$ cd .. +$ cd vdd +$ ls +136746 vlc.vcp +$ cd .. +$ cd zzvs +$ ls +8406 dngdnvv.qdf +dir nflgvsgz +55902 qtqpw.lcc +dir vmbrt +269256 whjmbnm.ngd +$ cd nflgvsgz +$ ls +dir mdgzvzbs +dir nlzc +$ cd mdgzvzbs +$ ls +88913 ggvd +$ cd .. +$ cd nlzc +$ ls +37916 rww +$ cd .. +$ cd .. +$ cd vmbrt +$ ls +194547 dwvbcvw.tmv +54334 htczftcn.bqh +299821 jnqgz +$ cd .. +$ cd .. +$ cd .. +$ cd ddpf +$ ls +dir plv +$ cd plv +$ ls +178177 dzsns +$ cd .. +$ cd .. +$ cd jngvpc +$ ls +276675 dcgmtcb +108711 htczftcn.dsr +dir jbc +280837 rqprcth.dhp +84724 tzrz.hms +$ cd jbc +$ ls +dir htczftcn +74153 tzrz.hms +$ cd htczftcn +$ ls +dir nflgvsgz +$ cd nflgvsgz +$ ls +208092 nnrd.zrj +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd pffdg +$ ls +264811 htczftcn +$ cd .. +$ cd prwpzhb +$ ls +181249 fstwrdqp +dir jbc +140710 nflgvsgz +dir pffdg +103710 qlqfc.qbm +dir qtqpw +15917 sqgmfl +dir zhcs +171467 zls.tmj +$ cd jbc +$ ls +12337 tzrz.hms +$ cd .. +$ cd pffdg +$ ls +302369 cshb.fbd +251192 htczftcn.vnn +dir msdtpqqd +dir sgtqmfgq +$ cd msdtpqqd +$ ls +42614 mptlnbp +$ cd .. +$ cd sgtqmfgq +$ ls +81125 jbc.szn +$ cd .. +$ cd .. +$ cd qtqpw +$ ls +160846 dngdnvv.qdf +$ cd .. +$ cd zhcs +$ ls +166883 vtz.bvb +$ cd .. +$ cd .. +$ cd .. +$ cd gzlpvdhd +$ ls +dir ffvz +$ cd ffvz +$ ls +74736 jvb.ppb +$ cd .. +$ cd .. +$ cd htczftcn +$ ls +dir dqbml +149343 gqjgvz +112647 lbcgmm +dir lbm +192438 mpdzgzm +dir nflgvsgz +dir pffdg +dir qtqpw +149952 qtqpw.gdv +dir rcnwghg +134076 rvdsldpf.zqc +dir sglgqlp +dir wrfmf +$ cd dqbml +$ ls +dir bphwp +303757 gglsqjbz.ffb +dir htczftcn +dir hwm +56134 pml.pmq +dir rsv +108298 tzrz.hms +201663 wqqdrml.wsl +$ cd bphwp +$ ls +94931 dngdnvv.qdf +90517 jsgl +118142 pzl +7387 tzrz.hms +$ cd .. +$ cd htczftcn +$ ls +300063 ctfgqld +dir htczftcn +dir jhldlsc +dir nflgvsgz +125403 pffdg +25617 pffdg.zdg +dir qddqn +dir tpmbzslr +$ cd htczftcn +$ ls +dir zzpnff +$ cd zzpnff +$ ls +79133 ssznrqlz.llw +$ cd .. +$ cd .. +$ cd jhldlsc +$ ls +dir swcbqqd +$ cd swcbqqd +$ ls +11202 htczftcn.cjs +111869 htczftcn.nvb +$ cd .. +$ cd .. +$ cd nflgvsgz +$ ls +37140 bffzwn.gqj +dir glmvgr +233206 lpclj +79112 lpqh.ldp +254611 qtqpw +dir rmbwlbt +206666 tgbdwgn +$ cd glmvgr +$ ls +115043 nflgvsgz.jgl +$ cd .. +$ cd rmbwlbt +$ ls +dir pffdg +$ cd pffdg +$ ls +92779 tzrz.hms +$ cd .. +$ cd .. +$ cd .. +$ cd qddqn +$ ls +dir jbc +$ cd jbc +$ ls +268367 cdcs +$ cd .. +$ cd .. +$ cd tpmbzslr +$ ls +dir dbfcp +dir lgsdbjz +$ cd dbfcp +$ ls +23450 nflgvsgz.nsl +$ cd .. +$ cd lgsdbjz +$ ls +248980 cqzqzb.nfh +248463 tzrz.hms +$ cd .. +$ cd .. +$ cd .. +$ cd hwm +$ ls +174410 jbc.rvr +310669 tzrz.hms +$ cd .. +$ cd rsv +$ ls +dir rsdnfh +$ cd rsdnfh +$ ls +276060 dngdnvv.qdf +137576 zsznp.ccq +$ cd .. +$ cd .. +$ cd .. +$ cd lbm +$ ls +201564 pffdg.rpv +$ cd .. +$ cd nflgvsgz +$ ls +dir jbc +dir svmmm +dir zfjdnbs +$ cd jbc +$ ls +dir jbc +dir mzt +dir qzth +dir scwdmwj +$ cd jbc +$ ls +71570 hhdt +dir ldzjsrm +27263 qtqpw.tcg +$ cd ldzjsrm +$ ls +217073 mlmwjq +172121 nflgvsgz +39275 pzrrlgt +$ cd .. +$ cd .. +$ cd mzt +$ ls +130917 tzrz.hms +$ cd .. +$ cd qzth +$ ls +280896 dngdnvv.qdf +6736 jbc.mtm +dir nfsbdfv +293220 nvzjz +dir pffdg +88075 ppmr +$ cd nfsbdfv +$ ls +58157 bzmwfgf.wwp +dir gmhbnffd +65369 gmq.zvb +dir htczftcn +dir qmc +278485 tvs.csj +$ cd gmhbnffd +$ ls +195493 lbcgmm +264234 mvqbqprp +268782 rtqts.zls +$ cd .. +$ cd htczftcn +$ ls +dir lnhjgl +$ cd lnhjgl +$ ls +80056 ffsrvl +$ cd .. +$ cd .. +$ cd qmc +$ ls +29571 hqftnv.vwn +$ cd .. +$ cd .. +$ cd pffdg +$ ls +dir bfdmm +244334 ppf +dir rggmf +$ cd bfdmm +$ ls +296551 nflgvsgz.bch +77180 tzrz.hms +$ cd .. +$ cd rggmf +$ ls +187569 dngdnvv.qdf +$ cd .. +$ cd .. +$ cd .. +$ cd scwdmwj +$ ls +dir fhwnjp +191201 gztswt.cvn +dir jsbdjv +dir nflgvsgz +dir pffdg +55401 qtqpw.hfv +$ cd fhwnjp +$ ls +200583 tqrqsmwt +$ cd .. +$ cd jsbdjv +$ ls +46882 fgjhsb.szs +156238 qtqpw.ctw +$ cd .. +$ cd nflgvsgz +$ ls +216012 nrfchlbs.wlw +75316 qtqpw +218733 vzldr +$ cd .. +$ cd pffdg +$ ls +75020 htczftcn.trw +6370 snnvrrwb.qmm +281520 vwstfbzg.jgq +$ cd .. +$ cd .. +$ cd .. +$ cd svmmm +$ ls +dir bgh +22016 czchmpc +294397 dngdnvv.qdf +14175 gdhtprt +dir nclpsp +dir pffdg +dir qtqpw +dir rwhq +138882 smqdrdjs +174171 vqjztp.zlr +$ cd bgh +$ ls +172183 fhsfhhjn +209572 phpdrzm +$ cd .. +$ cd nclpsp +$ ls +41222 bzmwfgf.wwp +134164 dqbqvg +dir dqtgwjn +dir htczftcn +210868 htczftcn.cjp +dir jbc +185752 lfrdq.wrm +dir pwvbnc +dir qhrtrsvm +235340 rljlr.lfs +$ cd dqtgwjn +$ ls +dir lbft +118196 tpl.qgw +83985 wbjmdmjm +$ cd lbft +$ ls +187172 vrd +$ cd .. +$ cd .. +$ cd htczftcn +$ ls +210604 hzlf +154916 nflgvsgz +115688 pffdg.ptz +$ cd .. +$ cd jbc +$ ls +122033 bzmwfgf.wwp +105912 dngdnvv.qdf +16049 nflgvsgz +43497 slmwmtfn +69357 tcsc.fgf +$ cd .. +$ cd pwvbnc +$ ls +10200 pfvsnqp.fwr +$ cd .. +$ cd qhrtrsvm +$ ls +193675 djmhdr.vcc +108939 qtqpw +$ cd .. +$ cd .. +$ cd pffdg +$ ls +dir dbtmdvq +$ cd dbtmdvq +$ ls +127568 vhnqsm.ghq +$ cd .. +$ cd .. +$ cd qtqpw +$ ls +dir crpzfdn +$ cd crpzfdn +$ ls +135177 lpzrl.qvj +dir qtldnjtd +$ cd qtldnjtd +$ ls +88481 rlbzbjt.rrz +$ cd .. +$ cd .. +$ cd .. +$ cd rwhq +$ ls +87944 bzmwfgf.wwp +70798 dngdnvv.qdf +dir hgqbmgch +dir lrvncpvz +dir nflgvsgz +$ cd hgqbmgch +$ ls +293841 bzmwfgf.wwp +286937 lwpf +dir smfbjhw +dir smqh +103844 vmpqmzf.dnf +$ cd smfbjhw +$ ls +186167 crgrnf.dns +dir htczftcn +$ cd htczftcn +$ ls +11324 gssn.rlt +46905 tzrz.hms +$ cd .. +$ cd .. +$ cd smqh +$ ls +dir pffdg +dir zbg +$ cd pffdg +$ ls +3570 bzmwfgf.wwp +3335 fvpd.bct +$ cd .. +$ cd zbg +$ ls +108877 bzmwfgf.wwp +310302 drhsdtcv.rrw +152250 wfvvsg +$ cd .. +$ cd .. +$ cd .. +$ cd lrvncpvz +$ ls +206419 nflgvsgz.tvr +$ cd .. +$ cd nflgvsgz +$ ls +286461 tzrz.hms +$ cd .. +$ cd .. +$ cd .. +$ cd zfjdnbs +$ ls +dir htczftcn +dir nflgvsgz +dir scvzpf +$ cd htczftcn +$ ls +dir jznspqtr +dir tpz +$ cd jznspqtr +$ ls +86738 hqftnv.vwn +$ cd .. +$ cd tpz +$ ls +126506 nflgvsgz.qnh +$ cd .. +$ cd .. +$ cd nflgvsgz +$ ls +248446 gwjgdb.vrr +$ cd .. +$ cd scvzpf +$ ls +dir fpbbjmjf +173634 gbpql +141796 jzncpqb.pgc +69394 rpvnchs +65500 tzrz.hms +$ cd fpbbjmjf +$ ls +224020 hhrjc +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd pffdg +$ ls +101444 clwdmcz.thc +58211 dngdnvv.qdf +dir mnj +dir ncwh +153413 nflgvsgz +dir qtqpw +141829 rrfs.ffn +$ cd mnj +$ ls +298654 qtqpw +$ cd .. +$ cd ncwh +$ ls +133042 bmthlszz.mtr +dir nflgvsgz +dir nrsqtdz +201720 wqhnfz +$ cd nflgvsgz +$ ls +dir bqqmlffw +115991 hsljpqpf +dir htczftcn +$ cd bqqmlffw +$ ls +49001 wltpcszs.bvj +$ cd .. +$ cd htczftcn +$ ls +264620 sfdssh.dnj +260432 vgvzjl +$ cd .. +$ cd .. +$ cd nrsqtdz +$ ls +258978 htczftcn +dir jbc +dir nsqlmlqp +28767 pffdg.blw +172773 tzrz.hms +$ cd jbc +$ ls +dir ztphfs +$ cd ztphfs +$ ls +dir gpps +$ cd gpps +$ ls +74744 bzmwfgf.wwp +$ cd .. +$ cd .. +$ cd .. +$ cd nsqlmlqp +$ ls +dir zvwvdzlv +$ cd zvwvdzlv +$ ls +218727 hsjm.qgm +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd qtqpw +$ ls +171370 sdmhwctq.gzr +$ cd .. +$ cd .. +$ cd qtqpw +$ ls +dir csqvzqdc +131580 jbc.ppb +126635 jbc.sbm +302398 pbjd +74429 vnpj +dir zhmp +$ cd csqvzqdc +$ ls +150923 jbc.grw +dir lthhrqnn +240950 pffdg.qbt +dir rgzqq +$ cd lthhrqnn +$ ls +123194 czl +17546 pffdg +$ cd .. +$ cd rgzqq +$ ls +156566 jbc.hpw +$ cd .. +$ cd .. +$ cd zhmp +$ ls +291659 dngdnvv.qdf +309738 nflgvsgz.wmc +$ cd .. +$ cd .. +$ cd rcnwghg +$ ls +108285 hvhlggsn +308801 sgstjfqq.hln +$ cd .. +$ cd sglgqlp +$ ls +dir gnvnlrz +dir nchq +dir nlrbnwp +dir zpg +$ cd gnvnlrz +$ ls +62071 lgqrm +dir pvt +dir srdqwtcs +$ cd pvt +$ ls +dir fpfddfw +dir jbc +dir jzrb +$ cd fpfddfw +$ ls +257231 rgccj.dwc +$ cd .. +$ cd jbc +$ ls +118252 dsvsmgm.hdm +$ cd .. +$ cd jzrb +$ ls +157243 gcrfg.svt +86860 pblts.jtd +$ cd .. +$ cd .. +$ cd srdqwtcs +$ ls +267482 bzzghfpq.gmh +dir cbd +dir gwqzndrt +288249 hhdmlslr +286213 lwmhd +dir rfvmgch +121131 vbm.rbp +$ cd cbd +$ ls +238535 jpbzwvd.rrw +246606 wgl.gfg +$ cd .. +$ cd gwqzndrt +$ ls +dir twtpbh +262912 vcmv.qcs +$ cd twtpbh +$ ls +245819 dngdnvv.qdf +295823 ghrnmd +308384 pffdg.ptr +231669 sqhnt.grn +$ cd .. +$ cd .. +$ cd rfvmgch +$ ls +306719 cwr.jsm +6449 hqftnv.vwn +$ cd .. +$ cd .. +$ cd .. +$ cd nchq +$ ls +137003 qtqpw +267253 zrgvq +146047 zww.nrr +$ cd .. +$ cd nlrbnwp +$ ls +91151 tzrz.hms +$ cd .. +$ cd zpg +$ ls +68248 bzmwfgf.wwp +$ cd .. +$ cd .. +$ cd wrfmf +$ ls +dir cdlwfjhp +16673 dsctg +304187 jbc +dir lchrdvm +dir nflgvsgz +dir qtqpw +dir rgdc +306410 tzrz.hms +dir zqzzg +$ cd cdlwfjhp +$ ls +dir clshzcrc +dir lplgpg +$ cd clshzcrc +$ ls +191491 tzrz.hms +$ cd .. +$ cd lplgpg +$ ls +169864 cmhrmh.pjp +$ cd .. +$ cd .. +$ cd lchrdvm +$ ls +149068 chwbr.spd +250029 hqftnv.vwn +23399 jbc +69746 nflgvsgz.nmp +dir pldctfcf +dir vngv +251416 zhf.qtz +$ cd pldctfcf +$ ls +297722 bcpwcn +276738 cspls +dir gghvnc +80690 htczftcn +dir pffdg +97610 qfjs.gps +dir tvc +106070 tzrz.hms +$ cd gghvnc +$ ls +93770 dngdnvv.qdf +$ cd .. +$ cd pffdg +$ ls +180916 bzmwfgf.wwp +$ cd .. +$ cd tvc +$ ls +11724 gtgzwsq +$ cd .. +$ cd .. +$ cd vngv +$ ls +92840 qtqpw.gcl +$ cd .. +$ cd .. +$ cd nflgvsgz +$ ls +dir htczftcn +dir lcjqzrwm +54961 lfn.rmz +dir plvbmb +dir vdfwfg +$ cd htczftcn +$ ls +dir gflz +dir mpp +292374 rzm +$ cd gflz +$ ls +dir qpdn +$ cd qpdn +$ ls +258037 ddqb.jhd +$ cd .. +$ cd .. +$ cd mpp +$ ls +248628 pffdg.spt +$ cd .. +$ cd .. +$ cd lcjqzrwm +$ ls +249155 mbz.gsq +291857 nngm.nft +100136 zwvwlg.hrs +$ cd .. +$ cd plvbmb +$ ls +dir nnrnwp +163552 pffdg +$ cd nnrnwp +$ ls +289041 bzmwfgf.wwp +29165 nvcwzfpr +$ cd .. +$ cd .. +$ cd vdfwfg +$ ls +264391 hqftnv.vwn +309071 htczftcn.mrd +dir wtqrrvvr +$ cd wtqrrvvr +$ ls +230331 swhpd +$ cd .. +$ cd .. +$ cd .. +$ cd qtqpw +$ ls +292434 hbjlsrw +$ cd .. +$ cd rgdc +$ ls +dir hqldlpg +$ cd hqldlpg +$ ls +188809 rvjwsmnz.hqt +$ cd .. +$ cd .. +$ cd zqzzg +$ ls +250923 qtqpw.zrb +$ cd .. +$ cd .. +$ cd .. +$ cd qcqg +$ ls +309875 tzrz.hms +$ cd .. +$ cd qtqpw +$ ls +dir rcnp +$ cd rcnp +$ ls +131725 bzmwfgf.wwp +46663 chwfd +$ cd .. +$ cd .. +$ cd qzcdscbp +$ ls +dir mtqt +$ cd mtqt +$ ls +27367 llbt.pth +dir mcrddwgp +$ cd mcrddwgp +$ ls +77221 bzmwfgf.wwp +37941 lrwlhz +dir tcmrv +85568 tzrz.hms +$ cd tcmrv +$ ls +dir hprvr +$ cd hprvr +$ ls +59831 qbchdjw.gjg +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd rfgvg +$ ls +dir qlg +$ cd qlg +$ ls +142825 dngdnvv.qdf +$ cd .. +$ cd .. +$ cd rzb +$ ls +250575 dngdnvv.qdf +dir jbc +dir lbg +187509 plblzt.zzz +dir qwjlvqdp +237529 rrrqcl.pvt +dir rsjg +$ cd jbc +$ ls +253304 lpdndfn +$ cd .. +$ cd lbg +$ ls +dir fml +$ cd fml +$ ls +106624 shm.fgh +$ cd .. +$ cd .. +$ cd qwjlvqdp +$ ls +dir htczftcn +$ cd htczftcn +$ ls +dir gnnzlzwd +272143 jbc.ldg +dir sztdtpjt +$ cd gnnzlzwd +$ ls +218355 tzrz.hms +$ cd .. +$ cd sztdtpjt +$ ls +53466 tzrz.hms +$ cd .. +$ cd .. +$ cd .. +$ cd rsjg +$ ls +101889 cct.sfg diff --git a/2022/07/solve.py b/2022/07/solve.py new file mode 100644 index 0000000..4217750 --- /dev/null +++ b/2022/07/solve.py @@ -0,0 +1,54 @@ +data = [dat.strip() for dat in open("input").readlines() if dat != ''] + +def sum_dir(d): + s = 0 + for file in d: + s += int(file[1]) + return s + +def solve(): + fs = {"/": []} + path = [] + + i = 0 + while i < len(data): + line = data[i] + i += 1 + if line[0] == "$": + if line[2] == "c": + if line[5:] == "..": + del path[-1] + else: + path.append(line[5:]) + if line[2] == "l": + top = fs["/".join(path)] + if not top: + top = [] + while i < len(data) and data[i][0] != "$": + if data[i][0] == "d": + fs["/".join(path)+"/"+data[i][4:]] = [] + else: + s,n = data[i].split(" ") + fs["/".join(path)].append((n, s)) + i += 1 + + aah = [] + for elem in fs: + s = sum_dir(fs[elem]) + for sub in fs: + if sub != elem and sub.startswith(elem): + s += sum_dir(fs[sub]) + aah.append(s) + + used = aah[0] + total = 70000000-used + to_free = 30000000-total + + to_delete = [] + for elem in aah: + if elem > to_free: + to_delete.append(elem) + + return min(to_delete) + +print(solve()) |