From deaa7d6db84570653b8352ce04f7ce6dd71820b3 Mon Sep 17 00:00:00 2001 From: Bizcochito Date: Thu, 8 Dec 2022 09:38:07 +0100 Subject: [PATCH] dau 7 done --- day07/input | 1047 +++++++++++++++++++++++++++++++++++++++++++++ day07/src/main.rs | 59 ++- 2 files changed, 1074 insertions(+), 32 deletions(-) create mode 100644 day07/input diff --git a/day07/input b/day07/input new file mode 100644 index 0000000..5532be9 --- /dev/null +++ b/day07/input @@ -0,0 +1,1047 @@ +$ cd / +$ ls +dir dfmhjhd +307728 ghpqs +dir hztjntff +dir rvstq +dir sjt +120579 whhj.pqt +dir wrmm +$ cd dfmhjhd +$ ls +301486 ngtqtf +13488 wfgqtw.sqr +$ cd .. +$ cd hztjntff +$ ls +dir cwsf +288227 ftq.cjn +176977 hwtj +234858 nzdgz.mpw +157857 rhs.mbd +dir sthqhrc +$ cd cwsf +$ ls +dir msr +272534 mvfclz.srm +226182 nldtb +252294 qnwzs +$ cd msr +$ ls +272198 hwtj +$ cd .. +$ cd .. +$ cd sthqhrc +$ ls +45847 vzntwhzl.htf +$ cd .. +$ cd .. +$ cd rvstq +$ ls +9707 bqg +296975 frcqrdm +232225 hztjntff +29794 ldmtcrq.dcs +dir nzdgz +dir vtlj +dir wmjbt +dir wrmm +28366 wrmm.cjh +dir wrsmnpwf +$ cd nzdgz +$ ls +dir fplqm +dir hzpqfj +dir hztjntff +dir jcszc +dir nzwzq +dir prbptvql +117527 sdnvpt +dir tnpshhml +dir tsjsfg +$ cd fplqm +$ ls +dir cwsf +dir cwzstq +216299 mdcnwnng +109253 nzdgz +$ cd cwsf +$ ls +dir fld +$ cd fld +$ ls +dir jdpz +dir trjltfq +$ cd jdpz +$ ls +299969 fvgpbf.lps +$ cd .. +$ cd trjltfq +$ ls +30081 tdzjl.jrw +$ cd .. +$ cd .. +$ cd .. +$ cd cwzstq +$ ls +305925 gjfbqpr.jjv +$ cd .. +$ cd .. +$ cd hzpqfj +$ ls +119289 hwtj +108285 lsb +246049 svttl.bml +dir sztz +75119 zjnll.zjl +200316 zwj +$ cd sztz +$ ls +dir mjmbld +dir nzdgz +dir wrmm +$ cd mjmbld +$ ls +101870 hwtj +$ cd .. +$ cd nzdgz +$ ls +86208 hwtj +$ cd .. +$ cd wrmm +$ ls +242305 wrmm.dlb +$ cd .. +$ cd .. +$ cd .. +$ cd hztjntff +$ ls +124971 flmb +dir hztjntff +152045 lsb +109123 nlwltp.mbg +247323 qvqqw +$ cd hztjntff +$ ls +dir hztjntff +dir tfdnvnn +$ cd hztjntff +$ ls +72064 lsjgcqvl.jtq +138507 rqbjcrpv +$ cd .. +$ cd tfdnvnn +$ ls +108268 vwtj +$ cd .. +$ cd .. +$ cd .. +$ cd jcszc +$ ls +94496 frcqrdm +247067 vmhfdm.lrc +$ cd .. +$ cd nzwzq +$ ls +6875 dbqbstqp +$ cd .. +$ cd prbptvql +$ ls +177069 zjnll.zjl +$ cd .. +$ cd tnpshhml +$ ls +227272 jjdplm.wjb +$ cd .. +$ cd tsjsfg +$ ls +dir fjhjl +215211 hwtj +4695 lsb +250283 lvssbtc.fwq +$ cd fjhjl +$ ls +54983 swqt.jsm +$ cd .. +$ cd .. +$ cd .. +$ cd vtlj +$ ls +103236 cmwpcdrj.zlc +1640 fllj.vfg +155765 frcqrdm +250655 hwtj +dir hztjntff +82919 hztjntff.gzd +dir tzwfnn +dir wrmm +$ cd hztjntff +$ ls +58108 lsb +$ cd .. +$ cd tzwfnn +$ ls +dir grznq +$ cd grznq +$ ls +282278 pwmsds.vzr +$ cd .. +$ cd .. +$ cd wrmm +$ ls +39404 frcqrdm +73284 pnj.rvq +$ cd .. +$ cd .. +$ cd wmjbt +$ ls +dir bpqjsnr +dir bqg +dir cwsf +31392 ths.lpc +dir vlhr +dir wrmm +dir zgljrz +dir zgt +$ cd bpqjsnr +$ ls +dir bqg +132830 fjp +$ cd bqg +$ ls +dir hztjntff +dir jvzn +219730 srrqlqq.fss +285971 tcqwqsgz.vrl +195936 vbmczm.pbn +191537 wrmm.bgq +$ cd hztjntff +$ ls +dir bqg +dir hljm +$ cd bqg +$ ls +188558 bqg.grm +$ cd .. +$ cd hljm +$ ls +dir clblt +$ cd clblt +$ ls +dir qdjj +47245 vzrpqlgs.zng +181205 wpcp.rcw +$ cd qdjj +$ ls +152548 rcjzld.zfv +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd jvzn +$ ls +265757 clvj.bmr +$ cd .. +$ cd .. +$ cd .. +$ cd bqg +$ ls +76100 cwsf +147481 dcmqw +137704 wcflzwbt.vvz +212362 zbqlrscd.nrc +212170 zqlbt.cdf +$ cd .. +$ cd cwsf +$ ls +242327 bqg.mwf +$ cd .. +$ cd vlhr +$ ls +156011 nzdgz.gct +$ cd .. +$ cd wrmm +$ ls +dir cwsf +dir ljpn +dir vzwtzl +dir wjsf +$ cd cwsf +$ ls +dir bstnjc +169487 cwsf +298251 hcsrh.nrb +$ cd bstnjc +$ ls +11588 lsb +$ cd .. +$ cd .. +$ cd ljpn +$ ls +dir cgghhhlf +204262 gzh.gww +171620 lqtbm.zbg +dir qfwrrp +dir smpltb +$ cd cgghhhlf +$ ls +14765 nvbvs.bnv +$ cd .. +$ cd qfwrrp +$ ls +256670 hwtj +$ cd .. +$ cd smpltb +$ ls +dir bgvfj +$ cd bgvfj +$ ls +65336 fprgmh.psg +$ cd .. +$ cd .. +$ cd .. +$ cd vzwtzl +$ ls +53337 fggqjqvs +$ cd .. +$ cd wjsf +$ ls +308476 nzsm.dfd +99153 swhv.ghz +241163 thpzp +$ cd .. +$ cd .. +$ cd zgljrz +$ ls +134867 fmndz.mhf +$ cd .. +$ cd zgt +$ ls +132031 hwtj +218404 zjnll.zjl +$ cd .. +$ cd .. +$ cd wrmm +$ ls +dir clt +257641 cwc.wwg +dir mjpw +dir nlwpspl +dir qwvjnwsf +282920 zjnll.zjl +$ cd clt +$ ls +62449 jlwr.bds +$ cd .. +$ cd mjpw +$ ls +147523 wrmm +$ cd .. +$ cd nlwpspl +$ ls +dir bmmmhnbc +244465 cqbq.qmw +199707 hwtj +dir jjjdlj +45952 lsb +274021 mhprtvb.jnf +dir vctf +$ cd bmmmhnbc +$ ls +dir bldfbzr +dir cwsf +dir dmj +202405 frcqrdm +77128 hnrc.dqv +dir hztjntff +242794 lqslmd +198590 lsb +87647 ngh.ljt +dir wmgwfvq +$ cd bldfbzr +$ ls +dir bqg +224279 frcqrdm +304382 hcfv.jpr +dir nzdgz +24190 psvfl.hlg +dir qjzh +95318 qpb.nzq +$ cd bqg +$ ls +187091 hcfv.jpr +$ cd .. +$ cd nzdgz +$ ls +dir nhmts +dir tqhthh +$ cd nhmts +$ ls +105545 cwhlrfv.rlz +$ cd .. +$ cd tqhthh +$ ls +81739 sfmcss.rps +14262 wmlmfzg.bqt +$ cd .. +$ cd .. +$ cd qjzh +$ ls +162159 cmn.rtc +$ cd .. +$ cd .. +$ cd cwsf +$ ls +dir bqg +dir frc +dir jbgrgz +78485 lsb +102492 nzdgz.psw +79482 phhvggtg.mlj +156154 qrcwwtz.dzn +$ cd bqg +$ ls +269163 hztjntff +$ cd .. +$ cd frc +$ ls +dir wrmm +$ cd wrmm +$ ls +dir ctrbwhpr +dir shmjt +$ cd ctrbwhpr +$ ls +94535 wrmm.fjl +$ cd .. +$ cd shmjt +$ ls +6523 svmsvg.vvc +$ cd .. +$ cd .. +$ cd .. +$ cd jbgrgz +$ ls +152890 bnlprltj +60156 dttwfgs +dir frvlnww +dir qszdtg +$ cd frvlnww +$ ls +297025 cjbnqm +126118 mpnnb.wqb +$ cd .. +$ cd qszdtg +$ ls +286900 fptpmp.fqb +210489 qbpwdhqt.wtw +$ cd .. +$ cd .. +$ cd .. +$ cd dmj +$ ls +dir bqg +60042 gncqrjnr.nrp +dir rhd +106478 smgjczbq.mbh +$ cd bqg +$ ls +223960 wrmm +2863 wrmm.jvg +152468 zjnll.zjl +$ cd .. +$ cd rhd +$ ls +104913 frcqrdm +248815 lsb +$ cd .. +$ cd .. +$ cd hztjntff +$ ls +172094 bqg.nqg +14817 frcqrdm +207015 hcfv.jpr +34358 jjdrw.stq +dir mczrpf +dir mzd +$ cd mczrpf +$ ls +19896 frcqrdm +273870 gvrb.lff +281909 tht.bhc +$ cd .. +$ cd mzd +$ ls +26174 sgbhjft +$ cd .. +$ cd .. +$ cd wmgwfvq +$ ls +130936 gzm.wzc +dir hztjntff +61943 jdp +dir rvwhms +$ cd hztjntff +$ ls +dir bqg +273566 lsb +dir vhdqhfqv +305672 whrsqpc.nwz +dir wrmm +$ cd bqg +$ ls +14092 hcfv.jpr +$ cd .. +$ cd vhdqhfqv +$ ls +193016 qgr +157253 vbrc +$ cd .. +$ cd wrmm +$ ls +62936 bqg.mpb +264687 dswswdzq +dir grlgcgrl +127974 lsb +dir nmm +75041 tfdbrqfw.lbd +dir tlrztbh +$ cd grlgcgrl +$ ls +164027 nzdgz.ptd +$ cd .. +$ cd nmm +$ ls +101722 bqg +$ cd .. +$ cd tlrztbh +$ ls +16955 cwsf +196934 lvdsbss.lpr +$ cd .. +$ cd .. +$ cd .. +$ cd rvwhms +$ ls +314729 bcgphtl.bsc +$ cd .. +$ cd .. +$ cd .. +$ cd jjjdlj +$ ls +dir dnpf +dir mwlvndml +$ cd dnpf +$ ls +129865 pgczcz +128274 zjtv.jml +$ cd .. +$ cd mwlvndml +$ ls +dir nzdgz +255297 vdsmgqdg.sbj +$ cd nzdgz +$ ls +111500 hcfv.jpr +$ cd .. +$ cd .. +$ cd .. +$ cd vctf +$ ls +dir bqg +4316 cwsf.vnq +dir gcgqr +139151 hztjntff +270316 hztjntff.wng +285602 mzzgnztv +299195 nzdgz +dir vbqjbq +$ cd bqg +$ ls +219667 lsb +$ cd .. +$ cd gcgqr +$ ls +71948 wbhbbr.rbg +$ cd .. +$ cd vbqjbq +$ ls +dir sltqnp +$ cd sltqnp +$ ls +5768 nvdmjq +20296 qtb.tcs +303095 zndbj.pgm +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd qwvjnwsf +$ ls +118347 bqg.csn +dir hqlv +107689 hwtj +66314 nzdgz.dmw +94334 sjc +$ cd hqlv +$ ls +250002 qcdpnc +$ cd .. +$ cd .. +$ cd .. +$ cd wrsmnpwf +$ ls +205662 lsb +$ cd .. +$ cd .. +$ cd sjt +$ ls +dir cwsf +dir nzdgz +dir qsd +dir rdzsr +66525 tqqvtzz.gzq +260979 wnbvvz +dir zgrf +dir zmtmr +$ cd cwsf +$ ls +dir dtpf +dir fjtsb +14887 frcqrdm +dir gdnnndj +281647 hztjntff.clc +152053 jbls.grs +dir mfbp +dir nzdgz +dir zclzqz +$ cd dtpf +$ ls +278443 frcqrdm +138750 fslt.mmj +$ cd .. +$ cd fjtsb +$ ls +142873 frcqrdm +230248 lbhs +116760 zjnll.zjl +$ cd .. +$ cd gdnnndj +$ ls +dir sljmpls +dir zhn +$ cd sljmpls +$ ls +dir cnzhjqbm +dir cttgctwb +307652 hwtj +dir rwwmcmt +107266 zjnll.zjl +$ cd cnzhjqbm +$ ls +196818 frcqrdm +$ cd .. +$ cd cttgctwb +$ ls +dir bqg +$ cd bqg +$ ls +270727 hcfv.jpr +$ cd .. +$ cd .. +$ cd rwwmcmt +$ ls +77395 hcfv.jpr +286056 nssl +$ cd .. +$ cd .. +$ cd zhn +$ ls +114122 dbcpsqn +dir mpfvnslm +dir zlqns +$ cd mpfvnslm +$ ls +dir qvtr +$ cd qvtr +$ ls +83650 bqg.qqh +$ cd .. +$ cd .. +$ cd zlqns +$ ls +36937 bgzjvvc.szm +$ cd .. +$ cd .. +$ cd .. +$ cd mfbp +$ ls +199935 qwsb.vcd +$ cd .. +$ cd nzdgz +$ ls +121541 jlncd.vgb +$ cd .. +$ cd zclzqz +$ ls +274497 zjnll.zjl +$ cd .. +$ cd .. +$ cd nzdgz +$ ls +dir qscww +dir tdthnm +$ cd qscww +$ ls +224250 frcqrdm +196936 hcfv.jpr +$ cd .. +$ cd tdthnm +$ ls +dir hmq +dir tcdm +$ cd hmq +$ ls +172261 nhpfqc.tgj +$ cd .. +$ cd tcdm +$ ls +188168 lsb +$ cd .. +$ cd .. +$ cd .. +$ cd qsd +$ ls +dir bqg +dir pbfc +$ cd bqg +$ ls +268716 bdpdlp.sht +253174 jjwlmnd.czs +dir mnrrmcc +261171 nzdgz.rdw +285026 sbfcj.wnh +$ cd mnrrmcc +$ ls +33961 lsb +$ cd .. +$ cd .. +$ cd pbfc +$ ls +dir hwbdld +$ cd hwbdld +$ ls +178868 hztjntff.gql +108145 stqzdh.zdn +$ cd .. +$ cd .. +$ cd .. +$ cd rdzsr +$ ls +45590 zjnll.zjl +$ cd .. +$ cd zgrf +$ ls +dir bqg +dir cbc +dir cclw +dir cwsf +dir fph +258332 hcfv.jpr +dir hvvvv +dir hztjntff +238272 nzwzmlqt.nvh +dir tqqqv +$ cd bqg +$ ls +143934 pgnvtcv.csm +44611 zjnll.zjl +$ cd .. +$ cd cbc +$ ls +119981 bznnrjtt +dir dsmmcjtg +259268 hsgwqqz.lzc +dir wrmm +$ cd dsmmcjtg +$ ls +150156 lmtdgnll.bln +192882 nzdgz.pzz +$ cd .. +$ cd wrmm +$ ls +207747 psmgbf +$ cd .. +$ cd .. +$ cd cclw +$ ls +245438 nzdgz.bdv +$ cd .. +$ cd cwsf +$ ls +314457 hwtj +293169 zrjbrhs +$ cd .. +$ cd fph +$ ls +dir hztjntff +dir mbgv +dir nbzvd +dir tzjtsqlj +313411 vwmsbfd.btp +$ cd hztjntff +$ ls +118509 nwjgfdt.llb +262025 tnvsm.wsj +$ cd .. +$ cd mbgv +$ ls +890 zjnll.zjl +$ cd .. +$ cd nbzvd +$ ls +95080 zvjf.zjq +$ cd .. +$ cd tzjtsqlj +$ ls +224995 frcqrdm +$ cd .. +$ cd .. +$ cd hvvvv +$ ls +dir zrpvfzz +$ cd zrpvfzz +$ ls +dir nlcds +280153 slcjdqw.wms +$ cd nlcds +$ ls +80960 cwsf.qtp +$ cd .. +$ cd .. +$ cd .. +$ cd hztjntff +$ ls +133260 cbl +dir fwmvqhj +179412 hcfv.jpr +dir hnwn +260329 hrwqwc.cbg +60953 lsb +255753 tcl.zrz +dir wrmm +$ cd fwmvqhj +$ ls +dir cwsf +209425 fcf.ncz +139449 gllwzh.dzc +dir hjgpzwf +dir njtbnt +$ cd cwsf +$ ls +309282 nzdgz.bsg +242967 wqzjrpp.pqs +$ cd .. +$ cd hjgpzwf +$ ls +157649 jcw +$ cd .. +$ cd njtbnt +$ ls +dir lvhqrjzn +dir mgtjfhvf +31491 nzdgz.sgc +$ cd lvhqrjzn +$ ls +11465 rrfpsjm.fsd +$ cd .. +$ cd mgtjfhvf +$ ls +dir wmnwrn +$ cd wmnwrn +$ ls +44518 hwtj +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd hnwn +$ ls +265411 bftcf.hdj +dir bqg +$ cd bqg +$ ls +96072 zdh.gpp +$ cd .. +$ cd .. +$ cd wrmm +$ ls +206383 bngf +dir jgdjp +15886 lsb +263238 nzdgz.tgj +183663 ppfr.mzj +dir qzlt +dir tmzgrts +256721 wrmm.dwl +$ cd jgdjp +$ ls +165322 vdpnqwq +$ cd .. +$ cd qzlt +$ ls +44763 cwsf.qqz +dir jcgt +dir vmsnrhb +dir wrmm +$ cd jcgt +$ ls +199928 hnl.chj +$ cd .. +$ cd vmsnrhb +$ ls +dir csvhwb +dir mnwwdf +dir pzwvh +$ cd csvhwb +$ ls +82347 bqg.qlb +76688 dtl.nws +dir hztjntff +151835 nwwdct.qlc +dir prqf +$ cd hztjntff +$ ls +146900 ncgnjp.zqb +123665 zjnll.zjl +$ cd .. +$ cd prqf +$ ls +143916 hcfv.jpr +60506 hztjntff +295807 jqwmltv.dmb +282209 qmzpbn.ntn +$ cd .. +$ cd .. +$ cd mnwwdf +$ ls +161210 nzdgz.mjn +$ cd .. +$ cd pzwvh +$ ls +28510 cwgtzgjd.ghf +dir jbhjjjs +dir lql +25334 lsb +dir wcrsqtz +$ cd jbhjjjs +$ ls +48808 mhshl +$ cd .. +$ cd lql +$ ls +dir tzcjpj +$ cd tzcjpj +$ ls +101686 frcqrdm +$ cd .. +$ cd .. +$ cd wcrsqtz +$ ls +71563 bqg.zmh +270956 qgw +dir rngvpc +$ cd rngvpc +$ ls +220454 smfzwq.qgr +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd wrmm +$ ls +dir mvrqsc +$ cd mvrqsc +$ ls +249653 frcqrdm +257853 nzdgz.qbf +$ cd .. +$ cd .. +$ cd .. +$ cd tmzgrts +$ ls +229931 djssmcdz.nzj +dir jrbjdghc +131107 rjtsdjqt.mht +$ cd jrbjdghc +$ ls +85458 frcqrdm +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd tqqqv +$ ls +162333 bqg.mdz +5054 hcfv.jpr +172441 nzdgz +dir qmwpfp +18969 wrmm +$ cd qmwpfp +$ ls +dir cwsf +dir lndh +dir nvjsvvln +$ cd cwsf +$ ls +18202 ngmsjfj.bvs +124907 snhqbcqc +149910 snj.ltq +253218 vppzwd.ztb +dir wlpcb +$ cd wlpcb +$ ls +280918 vllc.ztt +$ cd .. +$ cd .. +$ cd lndh +$ ls +146958 lvsqcvlr.bcq +286212 vcpgqbl.wbw +$ cd .. +$ cd nvjsvvln +$ ls +288486 hcfv.jpr +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zmtmr +$ ls +18654 cwsf.qpj +89300 fprft.wbq +66999 hwtj +110810 lmtdjgpv +dir sms +dir vdn +dir vdqmtjw +$ cd sms +$ ls +85804 dtsgp +197739 hcfv.jpr +$ cd .. +$ cd vdn +$ ls +159126 tnmhfscw +168030 wrmm.dvb +$ cd .. +$ cd vdqmtjw +$ ls +291828 hztjntff +$ cd .. +$ cd .. +$ cd .. +$ cd wrmm +$ ls +212937 frcqrdm +153487 zjnll.zjl diff --git a/day07/src/main.rs b/day07/src/main.rs index d223ad0..734451a 100644 --- a/day07/src/main.rs +++ b/day07/src/main.rs @@ -4,53 +4,44 @@ use std::collections::HashMap; fn main() { const FILE_PATH: &str = "input"; - println!("Hi this is the sixth day of AOC2022, first we will read the file {}", FILE_PATH); + println!("Hi this is the seventh day of AOC2022, first we will read the file {}", FILE_PATH); let contents = fs::read_to_string(FILE_PATH) .expect("Should have been able to read the file"); -} -#[derive(Debug)] -enum FileSys<'a>{ - File(u32), - Dir(HashMap<&'a str, FileSys<'a>>) + println!("The sum of all dirs less than 100000 is {}", parse(&contents).values().filter(|x| **x<100000).sum::()); + println!("The smallest directory to erase to make the update is {}", get_smaller_dir_for_update(&contents)); } -fn traverse<'a>(root: &'a mut HashMap<&'a str, FileSys<'a>>, ptr: &'a Vec<&'a str>) -> HashMap<&'a str, FileSys<'a>>{ - let mut out = root; - for dir in *ptr{ - out = match out.get_mut(dir).expect("u messed up the dirs") { - FileSys::Dir(x) => x, - _ => panic!("u messed up the dirs, tis a file") - } - }; - *out -} - -fn parse(s: &str) -> HashMap<&str, FileSys>{ - let mut root = HashMap::new(); - let mut s = s.lines(); - s.next(); - let mut ptr: Vec<&str> = vec![]; - for line in s { +fn parse(s: &str) -> HashMap{ + let mut sizes = HashMap::new(); + let mut ptr: Vec = vec![]; + let mut linode: usize = 0; + for line in s.lines() { let mut line = line.split(" "); match line.next().expect("lol") { "$" => if line.next().expect("must have a command") == "cd"{ match line.next().expect("must have a name") { - ".." => ptr.pop(), - name => {ptr.push(name); None}, + ".." => {ptr.pop(); ()}, + _ => {ptr.push(linode); sizes.insert(linode, 0); linode+=1;}, }; }else{continue;}, "dir" =>{ - let root = traverse(&mut root, &ptr); - root.insert(line.next().expect("must have a name"), FileSys::Dir(HashMap::new())); + continue }, size =>{ - let root = traverse(&mut root, &ptr); - root.insert(line.next().expect("must have a name"), FileSys::File(u32::from_str(size).expect("NaN"))); + ptr.iter().for_each(|d| *sizes.get_mut(d).expect("dir must exist")+= u32::from_str(size).expect("NaN")); }, } } - root + sizes +} + +fn get_smaller_dir_for_update(input: &str) -> u32 { + let sol = parse(input); + let target = 30000000 - (70000000 - sol.get(&0).expect("Root must exist")); + let mut sol: Vec<_> = sol.values().collect(); + sol.sort(); + **sol.iter().filter(|x| ***x > target).next().expect("If there is not enough dir that mean the update is already posible dingus") } #[cfg(test)] @@ -80,7 +71,11 @@ $ ls 7214296 k"#; use super::*; #[test] - fn coms1_1() { - dbg!(parse(INPUT)); + fn update1() { + assert_eq!(parse(INPUT).values().filter(|x| **x<100000).sum::(), 95437); + } + #[test] + fn update2() { + assert_eq!(get_smaller_dir_for_update(INPUT), 24933642); } } \ No newline at end of file