From 08351a2d9ee3806794e48f1dbe3cceb73916ec39 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 7 Dec 2022 15:55:46 +0100 Subject: [PATCH] day 7 --- d07.cc | 162 +++++++ d07_input.txt | 1108 ++++++++++++++++++++++++++++++++++++++++++++++++ d07_output.txt | 2 + template.cc | 2 +- 4 files changed, 1273 insertions(+), 1 deletion(-) create mode 100644 d07.cc create mode 100644 d07_input.txt create mode 100644 d07_output.txt diff --git a/d07.cc b/d07.cc new file mode 100644 index 0000000..f65c674 --- /dev/null +++ b/d07.cc @@ -0,0 +1,162 @@ +#include +#include +#include + +using namespace std; + +enum FsNodeType { + NODE_DIR, + NODE_FILE +}; + +struct FsNode { + FsNodeType type; + string name; + unsigned size; +}; + +struct FsFile : FsNode { +}; + +struct FsDir : FsNode { + FsDir *parent; + map entries; +}; + +void print_node(FsNode *node, unsigned depth = 0) +{ + for (unsigned i = 0; i < depth; i++) clog << " "; + clog << "- " << node->name << " ("; + switch (node->type) { + case NODE_DIR: clog << "dir"; break; + case NODE_FILE: clog << "file"; break; + } + clog << ", "; + clog << "size=" << node->size; + clog << ")" << endl; + + if (node->type == NODE_DIR) { + FsDir *dir = (FsDir *)node; + for (auto e : dir->entries) print_node(e.second, depth + 1); + } +} + +unsigned calc_size(FsDir &dir) +{ + unsigned size = 0; + for (auto e : dir.entries) { + FsNode *node = e.second; + + if (!node->size && node->type == NODE_DIR) calc_size(*(FsDir *)node); + size += node->size; + } + dir.size = size; + return size; +} + +FsDir parse() +{ + FsDir root; + root.type = NODE_DIR; + root.name = "/"; + root.parent = NULL; + + FsDir *dir = &root; + for (string line; getline(cin, line);) { + if (line.at(0) != '$' || line.at(1) != ' ') { + unsigned split = line.find(' '); + string first = line.substr(0, split); + string name = line.substr(split + 1); + + if (first == "dir") { + FsDir *newdir = new FsDir; + newdir->type = NODE_DIR; + newdir->name = name; + newdir->size = 0; + newdir->parent = dir; + dir->entries[name] = newdir; + } else { + unsigned size = stoi(first); + FsFile *newfile = new FsFile; + newfile->type = NODE_FILE; + newfile->name = name; + newfile->size = size; + dir->entries[name] = newfile; + } + } + + if (line.substr(2, 3) == "ls") { + // derp? + } else if (line.substr(2, 3) == "cd ") { + string name = line.substr(5); + if (name == "/") { + dir = &root; + } else if (name == "..") { + if (dir->parent) dir = dir->parent; + } else { + auto it = dir->entries.find(name); + if (it != dir->entries.end()) { + FsNode *node = it->second; + if (node->type == NODE_DIR) { + dir = (FsDir *)node; + } + } + } + } + } + + calc_size(root); + //print_node(&root); + return root; +} + +unsigned p1(const FsDir &dir) +{ + unsigned count = 0; + if (dir.size <= 100000) count += dir.size; + for (auto e : dir.entries) { + FsNode *node = e.second; + if (node->type == NODE_DIR) count += p1(*(FsDir *)node); + } + return count; +} + +unsigned p2(const FsDir &dir, unsigned target = 0) +{ + if (!target) target = dir.size - 40000000; + + unsigned smallest = 30000000; + if (dir.size >= target && dir.size < smallest) smallest = dir.size; + + for (auto e : dir.entries) { + FsNode *node = e.second; + if (node->type == NODE_DIR) { + unsigned size = p2(*(FsDir *)node, target); + if (size >= target && size < smallest) smallest = size; + } + } + return smallest; +} + +void free_input(FsDir &dir) +{ + for (auto e : dir.entries) { + FsNode *node = e.second; + if (node->type == NODE_DIR) { + FsDir *dir = (FsDir *)node; + free_input(*dir); + delete dir; + } else if (node->type == NODE_FILE) { + FsFile *file = (FsFile *)node; + delete file; + } + } +} + +int main() +{ + auto input = parse(); + cout << p1(input) << endl; + cout << p2(input) << endl; + free_input(input); +} diff --git a/d07_input.txt b/d07_input.txt new file mode 100644 index 0000000..5eac444 --- /dev/null +++ b/d07_input.txt @@ -0,0 +1,1108 @@ +$ cd / +$ ls +dir fpljqj +171526 ghtzhjwf.nls +dir gsdsbld +dir hbmjtb +296801 mjfjqw.ccv +dir nfn +dir qmrsvfvw +102565 qqjnqb.chd +dir svgbqd +$ cd fpljqj +$ ls +153563 ghtzhjwf.nls +243252 gsvjgj.jsm +154134 hghnrbqg.rzb +$ cd .. +$ cd gsdsbld +$ ls +dir npmncvhh +dir qmrsvfvw +dir sqtnlr +dir vzndpc +$ cd npmncvhh +$ ls +81366 dwbgr.ztr +144577 fzjmcq +dir mphhrqf +dir rnmvggfd +276454 zfl.ghv +$ cd mphhrqf +$ ls +dir qlcfs +111207 shmcrf.wlr +dir zwsnwvnv +$ cd qlcfs +$ ls +283904 fpljqj.pdw +83520 hsclcqqt.pff +dir htwl +dir lqjhfdch +5842 mdjzmbc.qtv +dir nqfdhlcg +120167 twgqhvft.cgw +186998 zclhcr +dir zfl +dir zlqgr +$ cd htwl +$ ls +268134 hmwnn.htq +$ cd .. +$ cd lqjhfdch +$ ls +21479 tpdsgf.hgd +$ cd .. +$ cd nqfdhlcg +$ ls +dir dhjfqv +203675 ghtzhjwf.nls +39527 qfwdmzfv.ggd +$ cd dhjfqv +$ ls +135074 dqs.wht +$ cd .. +$ cd .. +$ cd zfl +$ ls +17334 wlsd +$ cd .. +$ cd zlqgr +$ ls +dir crs +dir whrm +dir zfl +$ cd crs +$ ls +220281 szft.bjb +$ cd .. +$ cd whrm +$ ls +279796 pcnl +dir pjzpqs +$ cd pjzpqs +$ ls +dir smz +192921 sqtst.lcz +21397 trst +154861 vtgdsnmv +$ cd smz +$ ls +249693 mjfjqw.ccv +dir tdwqpg +$ cd tdwqpg +$ ls +157907 wjv.rth +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zfl +$ ls +dir hwlhshtr +$ cd hwlhshtr +$ ls +90468 srrv.jst +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zwsnwvnv +$ ls +209371 ctmcqlz.nwh +154262 nqngjf +$ cd .. +$ cd .. +$ cd rnmvggfd +$ ls +dir czzrdvc +203540 dnwtwzd +dir fcsjqg +dir fwdprwpq +74582 qlnqwnzp.ttz +dir tvglfb +$ cd czzrdvc +$ ls +dir blplbjpw +$ cd blplbjpw +$ ls +2835 zfl.zvw +$ cd .. +$ cd .. +$ cd fcsjqg +$ ls +81548 ghtzhjwf.nls +$ cd .. +$ cd fwdprwpq +$ ls +11156 gsvjgj.jsm +75010 rgscvjq.zlw +122327 szft.bjb +dir zfl +268883 zpgcwvjf +$ cd zfl +$ ls +dir sphpbjt +$ cd sphpbjt +$ ls +31414 qfwdmzfv.ggd +$ cd .. +$ cd .. +$ cd .. +$ cd tvglfb +$ ls +118050 gsvjgj.jsm +265116 sdmldsd.hhm +$ cd .. +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +dir fpljqj +203965 szft.bjb +dir zcgfg +$ cd fpljqj +$ ls +dir gqvmv +$ cd gqvmv +$ ls +175614 mjfjqw.ccv +$ cd .. +$ cd .. +$ cd zcgfg +$ ls +110104 ddzcbm.qtb +dir fpglbth +148639 nqfdhlcg.fsz +dir pfjz +166120 wjrmgl +$ cd fpglbth +$ ls +58850 qlggch.tng +$ cd .. +$ cd pfjz +$ ls +197076 wplpj +$ cd .. +$ cd .. +$ cd .. +$ cd sqtnlr +$ ls +189086 gsvjgj.jsm +dir ngr +210016 pmprhlg.rsg +277979 szft.bjb +282202 tfqcnn.hlf +$ cd ngr +$ ls +dir fdhd +dir hwsqqt +dir qmrsvfvw +$ cd fdhd +$ ls +7384 fhhp +dir fpljqj +91732 nqfdhlcg.gwf +69137 ptcrmc.wwr +$ cd fpljqj +$ ls +282109 rtfhcbc.pqj +$ cd .. +$ cd .. +$ cd hwsqqt +$ ls +174820 zvmgv.tcd +$ cd .. +$ cd qmrsvfvw +$ ls +228739 qfwdmzfv.ggd +$ cd .. +$ cd .. +$ cd .. +$ cd vzndpc +$ ls +183360 fpljqj.nbh +$ cd .. +$ cd .. +$ cd hbmjtb +$ ls +219988 hlvjdg +dir lndmtm +107247 rtpvh.srl +dir sgt +dir tgjszvsg +166122 zrshs.phz +dir ztrvv +$ cd lndmtm +$ ls +dir fpljqj +dir hscwh +dir wjv +$ cd fpljqj +$ ls +102717 qmrsvfvw +$ cd .. +$ cd hscwh +$ ls +dir qgz +dir qmrsvfvw +$ cd qgz +$ ls +281901 szft.bjb +$ cd .. +$ cd qmrsvfvw +$ ls +102781 fpljqj.gtv +197014 gsvjgj.jsm +174895 pvz +$ cd .. +$ cd .. +$ cd wjv +$ ls +dir fpljqj +295195 mjfjqw.ccv +214886 qfwdmzfv.ggd +dir qmrsvfvw +72164 vncjvfhh +$ cd fpljqj +$ ls +dir fpljqj +dir fzbppql +dir jpqqr +dir lzq +dir pjjbmllm +dir qmrsvfvw +$ cd fpljqj +$ ls +260943 ghtzhjwf.nls +$ cd .. +$ cd fzbppql +$ ls +29399 wjv +$ cd .. +$ cd jpqqr +$ ls +45275 zcwbrvd +$ cd .. +$ cd lzq +$ ls +180833 szft.bjb +$ cd .. +$ cd pjjbmllm +$ ls +64063 mjfjqw.ccv +183683 vrfd.wlw +$ cd .. +$ cd qmrsvfvw +$ ls +226047 szft.bjb +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +dir bzcfzh +272794 lnzpvhj +dir vsrgqmlt +dir zbthlb +$ cd bzcfzh +$ ls +63095 mjfjqw.ccv +45335 nqfdhlcg +162307 vqqt.vbg +$ cd .. +$ cd vsrgqmlt +$ ls +dir nqfdhlcg +$ cd nqfdhlcg +$ ls +dir wjv +$ cd wjv +$ ls +81528 cslzgjtp.qzg +$ cd .. +$ cd .. +$ cd .. +$ cd zbthlb +$ ls +dir hjp +dir twfw +dir zfl +$ cd hjp +$ ls +20745 pvjwrzsl.pmg +$ cd .. +$ cd twfw +$ ls +dir csmmbjhp +$ cd csmmbjhp +$ ls +165998 nlsd +109132 vbjlnqt.lsd +$ cd .. +$ cd .. +$ cd zfl +$ ls +227633 jcs.vhj +dir tvfhvbp +$ cd tvfhvbp +$ ls +116169 lgv +175862 qfwdmzfv.ggd +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd sgt +$ ls +151135 nqfdhlcg +226449 nqfdhlcg.sqp +148179 wjv.fgc +$ cd .. +$ cd tgjszvsg +$ ls +98354 szft.bjb +$ cd .. +$ cd ztrvv +$ ls +163992 blmmm.gcf +dir fghl +dir fpljqj +226325 nqfdhlcg +dir qmrsvfvw +284965 vhbffmcg.fwt +$ cd fghl +$ ls +dir lgpwpmzp +dir sqjqg +$ cd lgpwpmzp +$ ls +dir ctr +dir nqfdhlcg +279439 zfl.npd +$ cd ctr +$ ls +64805 jfflsd.gbc +163058 zbvpc.znm +$ cd .. +$ cd nqfdhlcg +$ ls +40180 jsqtwpt.qtq +87408 rmpbprz.lwr +$ cd .. +$ cd .. +$ cd sqjqg +$ ls +140444 bsglv +214121 crzdv.dcc +$ cd .. +$ cd .. +$ cd fpljqj +$ ls +56575 gqw.dzr +293957 gsvjgj.jsm +272507 jvd +dir tgfvcpp +178972 vndshbth.mzw +dir zwtz +$ cd tgfvcpp +$ ls +dir bhq +$ cd bhq +$ ls +111454 gvq +$ cd .. +$ cd .. +$ cd zwtz +$ ls +39290 nqfdhlcg +140517 qfwdmzfv.ggd +dir tcnv +177429 zlzsq.fph +$ cd tcnv +$ ls +286997 fpljqj.phd +$ cd .. +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +252862 jbznh +$ cd .. +$ cd .. +$ cd .. +$ cd nfn +$ ls +dir fqw +dir mpz +dir qmrsvfvw +dir zfl +$ cd fqw +$ ls +144372 ghtzhjwf.nls +100013 mqwwjbvz.scd +95547 vspwhq.dwn +$ cd .. +$ cd mpz +$ ls +dir gntjg +dir jfbhz +7835 nqfdhlcg +dir vpgpz +dir zfl +$ cd gntjg +$ ls +dir hdq +dir hvcdpzr +dir lth +27002 mjfjqw.ccv +dir qmrsvfvw +dir scncl +$ cd hdq +$ ls +dir jwhnt +$ cd jwhnt +$ ls +153428 fswqv.jpf +$ cd .. +$ cd .. +$ cd hvcdpzr +$ ls +dir fpljqj +135000 fpljqj.smw +275125 hrqwfjjz.rdj +dir pmcpnqrr +58960 qljhbczf.qfn +222912 szft.bjb +dir wvvzbt +$ cd fpljqj +$ ls +282896 nqfdhlcg.bjm +$ cd .. +$ cd pmcpnqrr +$ ls +dir nwjzld +dir tfdcg +dir vwlbtgnh +$ cd nwjzld +$ ls +74948 wjv.psf +$ cd .. +$ cd tfdcg +$ ls +77925 gsvjgj.jsm +dir lcdfdmlj +dir pthwnf +227063 qfwdmzfv.ggd +293860 qmwr.csp +154426 scwd.mdc +$ cd lcdfdmlj +$ ls +52503 mjfjqw.ccv +$ cd .. +$ cd pthwnf +$ ls +176935 fgcwjjz +$ cd .. +$ cd .. +$ cd vwlbtgnh +$ ls +dir nqfdhlcg +$ cd nqfdhlcg +$ ls +dir lnwtl +$ cd lnwtl +$ ls +252540 cgj.pdg +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd wvvzbt +$ ls +25603 bvhd +24426 qzwgj.bmb +$ cd .. +$ cd .. +$ cd lth +$ ls +dir dmbf +60608 ghtzhjwf.nls +dir ndbcrvw +dir shsgqzn +27467 zfl.tdf +$ cd dmbf +$ ls +dir zpggmccr +$ cd zpggmccr +$ ls +238504 hqsgz.jfh +$ cd .. +$ cd .. +$ cd ndbcrvw +$ ls +289441 bwbdc +dir zfl +84967 zhwz +$ cd zfl +$ ls +95245 mjfjqw.ccv +$ cd .. +$ cd .. +$ cd shsgqzn +$ ls +184543 gqrthw.gwf +61456 wzbbsqrp +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +dir bql +247487 szvbjdjl +58312 wjv +241150 wjv.ltm +$ cd bql +$ ls +93199 fpljqj +$ cd .. +$ cd .. +$ cd scncl +$ ls +13092 clgmqlfl +dir dcldv +dir fsrznscl +21910 nqfdhlcg.lld +dir prcgb +$ cd dcldv +$ ls +271970 nqfdhlcg.dgv +$ cd .. +$ cd fsrznscl +$ ls +dir bcdrv +$ cd bcdrv +$ ls +96252 fpljqj.cdr +154325 tvf.vhv +$ cd .. +$ cd .. +$ cd prcgb +$ ls +69766 lnsvgqq.psj +$ cd .. +$ cd .. +$ cd .. +$ cd jfbhz +$ ls +286498 ssbmgts +$ cd .. +$ cd vpgpz +$ ls +63751 gsvjgj.jsm +220526 vvlvcs.dpc +$ cd .. +$ cd zfl +$ ls +dir fpljqj +182996 ghtzhjwf.nls +dir jcffb +dir jzl +dir nzlv +6752 snwmlr.glp +$ cd fpljqj +$ ls +dir btsdth +dir fwdw +dir nqfdhlcg +dir qmrsvfvw +203470 svsvcgj +$ cd btsdth +$ ls +176953 szft.bjb +$ cd .. +$ cd fwdw +$ ls +95939 crffczjt.gsq +dir mbgzf +dir rqdnjfdq +296397 zfl.fjb +$ cd mbgzf +$ ls +179220 mjfjqw.ccv +$ cd .. +$ cd rqdnjfdq +$ ls +204152 qmrsvfvw +$ cd .. +$ cd .. +$ cd nqfdhlcg +$ ls +194439 gwc.wdp +167934 qfwdmzfv.ggd +151571 sczw +$ cd .. +$ cd qmrsvfvw +$ ls +dir dwc +103919 gfzgg +6816 shpch.chl +$ cd dwc +$ ls +17813 gsvjgj.jsm +80522 hbhlv.pqh +dir htpt +dir hwg +dir nslrrrfg +dir psgw +231148 sdfvzdwm.wlz +102460 szft.bjb +dir wjlfgt +$ cd htpt +$ ls +162107 wjv +$ cd .. +$ cd hwg +$ ls +dir gslvrbt +dir qmrsvfvw +$ cd gslvrbt +$ ls +dir fjwn +107757 gsvjgj.jsm +$ cd fjwn +$ ls +268653 qptczjlq.prv +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +10557 nqfdhlcg +$ cd .. +$ cd .. +$ cd nslrrrfg +$ ls +112961 gsvjgj.jsm +dir hjgbgq +dir jctqdpq +dir qgfb +dir zfl +$ cd hjgbgq +$ ls +124947 mjfjqw.ccv +$ cd .. +$ cd jctqdpq +$ ls +203489 vgfhrl +$ cd .. +$ cd qgfb +$ ls +33980 nqfdhlcg.pqs +$ cd .. +$ cd zfl +$ ls +193098 gsvjgj.jsm +dir vmzghf +26070 zfnppjsz +$ cd vmzghf +$ ls +235035 szft.bjb +$ cd .. +$ cd .. +$ cd .. +$ cd psgw +$ ls +55808 gsvjgj.jsm +214300 wjv +$ cd .. +$ cd wjlfgt +$ ls +201399 qfwdmzfv.ggd +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd jcffb +$ ls +81815 szft.bjb +$ cd .. +$ cd jzl +$ ls +155651 gsvjgj.jsm +dir shrf +$ cd shrf +$ ls +57545 fpljqj.pcb +$ cd .. +$ cd .. +$ cd nzlv +$ ls +115992 bmmnj.ghw +100862 ghtzhjwf.nls +dir qwjpjw +dir rhbtbjp +dir rlmzs +60695 szft.bjb +3260 vzgwmrnc +dir wwnnj +17546 zdstndwj.lms +$ cd qwjpjw +$ ls +dir dpwp +dir fzdcjr +173669 gsvjgj.jsm +dir nmnbv +dir nqfdhlcg +dir plzdzdnm +135543 qfwdmzfv.ggd +246217 qmrsvfvw +dir sgpcqqm +141900 wvt.rfz +$ cd dpwp +$ ls +214058 wjv.zqs +94614 zrtbln +$ cd .. +$ cd fzdcjr +$ ls +236058 jcn.fzn +$ cd .. +$ cd nmnbv +$ ls +215145 lllgsbb +$ cd .. +$ cd nqfdhlcg +$ ls +61644 ghtzhjwf.nls +238094 qfwdmzfv.ggd +183057 szft.bjb +17501 wjv.pln +$ cd .. +$ cd plzdzdnm +$ ls +243979 fpljqj.lnj +$ cd .. +$ cd sgpcqqm +$ ls +262759 hjffwcls +100893 mvs.cgz +dir nzhlcl +170443 szft.bjb +dir zfl +$ cd nzhlcl +$ ls +dir wcfl +$ cd wcfl +$ ls +24502 mjfjqw.ccv +145029 zfl.lpp +$ cd .. +$ cd .. +$ cd zfl +$ ls +176653 ghtzhjwf.nls +$ cd .. +$ cd .. +$ cd .. +$ cd rhbtbjp +$ ls +dir nqfdhlcg +232788 pmj.cmm +dir zfvbc +$ cd nqfdhlcg +$ ls +72379 gqpcrtpw.nsm +$ cd .. +$ cd zfvbc +$ ls +19204 dqbs.ddg +$ cd .. +$ cd .. +$ cd rlmzs +$ ls +232862 fpljqj.rps +5558 lmgss.dtf +$ cd .. +$ cd wwnnj +$ ls +260417 cwjsrptm.hlm +216130 gsvjgj.jsm +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +dir fpljqj +dir hllbt +dir nqfdhlcg +$ cd fpljqj +$ ls +dir qmrsvfvw +dir tdnp +dir vhtwd +dir wnlzd +dir ztttgd +$ cd qmrsvfvw +$ ls +218325 fpljqj.zhj +220402 qfwdmzfv.ggd +$ cd .. +$ cd tdnp +$ ls +46936 fmgz +dir gdsqdtw +dir tpcbjc +dir zfl +$ cd gdsqdtw +$ ls +128812 cnfpsb.qjr +185390 ghtzhjwf.nls +147220 qfwdmzfv.ggd +$ cd .. +$ cd tpcbjc +$ ls +188075 szft.bjb +243171 zdprcqs.qwf +$ cd .. +$ cd zfl +$ ls +dir nnschfl +dir qmrsvfvw +dir szlbls +109443 wjv +$ cd nnschfl +$ ls +139948 szft.bjb +$ cd .. +$ cd qmrsvfvw +$ ls +dir bdn +dir fpljqj +168508 fpljqj.ljd +dir hwgbwqmm +dir nwhl +224059 qfwdmzfv.ggd +$ cd bdn +$ ls +179118 jdrdjf.ppn +74443 lpp +$ cd .. +$ cd fpljqj +$ ls +125033 mtfgm.pjf +$ cd .. +$ cd hwgbwqmm +$ ls +133673 vrvhgbz.ttb +$ cd .. +$ cd nwhl +$ ls +187017 fpljqj +149238 mjfjqw.ccv +dir mqzrmjr +dir vdjgqfc +dir zfzfbq +$ cd mqzrmjr +$ ls +dir fpljqj +131712 jmnsst.bmv +289722 ppdhjswn +dir qmrsvfvw +30641 zfl.trb +$ cd fpljqj +$ ls +286985 lwmfmsr.tln +253325 mjfjqw.ccv +194077 vgb.glm +38905 wjv.vgs +$ cd .. +$ cd qmrsvfvw +$ ls +87468 nngbnwds.qcn +$ cd .. +$ cd .. +$ cd vdjgqfc +$ ls +122025 rnvwf.mrp +261944 wdwgml +$ cd .. +$ cd zfzfbq +$ ls +dir bwmrf +dir zfl +$ cd bwmrf +$ ls +222502 gsvjgj.jsm +$ cd .. +$ cd zfl +$ ls +10297 ghtzhjwf.nls +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd szlbls +$ ls +10968 bqbclc.nfl +$ cd .. +$ cd .. +$ cd .. +$ cd vhtwd +$ ls +188024 dgz +$ cd .. +$ cd wnlzd +$ ls +201028 gsvjgj.jsm +dir mcnnsv +dir mctpdbs +47879 szft.bjb +dir tjqfts +164406 zpdmdrw +$ cd mcnnsv +$ ls +dir lclgj +dir sjdbnbqw +dir tlj +dir wjv +$ cd lclgj +$ ls +192605 fgpjczr.grp +65758 hhrf.fgg +$ cd .. +$ cd sjdbnbqw +$ ls +89058 ghtzhjwf.nls +191742 rlmwjg.dpl +179479 zswc.snt +$ cd .. +$ cd tlj +$ ls +183447 fpljqj.fgf +$ cd .. +$ cd wjv +$ ls +1517 pbwr +189647 szft.bjb +$ cd .. +$ cd .. +$ cd mctpdbs +$ ls +120327 szft.bjb +$ cd .. +$ cd tjqfts +$ ls +dir crvw +$ cd crvw +$ ls +289523 lcshtlgf.lrv +169176 szft.bjb +$ cd .. +$ cd .. +$ cd .. +$ cd ztttgd +$ ls +247914 sqqv.cvm +$ cd .. +$ cd .. +$ cd hllbt +$ ls +298155 cqnb.fgc +224277 hjf +220312 jhnpv +7421 qmrsvfvw +dir qsg +$ cd qsg +$ ls +dir drm +dir fpljqj +dir wjv +$ cd drm +$ ls +dir fhzr +$ cd fhzr +$ ls +dir nqfdhlcg +$ cd nqfdhlcg +$ ls +125578 nqfdhlcg +$ cd .. +$ cd .. +$ cd .. +$ cd fpljqj +$ ls +dir jmfqmdcm +dir nqfdhlcg +48942 qfwdmzfv.ggd +dir swrdzl +18483 szft.bjb +254012 zjcnz.pls +$ cd jmfqmdcm +$ ls +130015 bvrmp.vwg +157978 gsvjgj.jsm +54571 hmhldqr.ctt +169263 qgccqrqs +261388 szft.bjb +$ cd .. +$ cd nqfdhlcg +$ ls +213466 fpljqj.wbp +31434 jhsb.lbb +144357 qfwdmzfv.ggd +$ cd .. +$ cd swrdzl +$ ls +dir fgmtnt +dir pnmz +280186 qmrsvfvw.mrb +$ cd fgmtnt +$ ls +95823 gsvjgj.jsm +127258 qmrsvfvw +$ cd .. +$ cd pnmz +$ ls +110479 ghtzhjwf.nls +$ cd .. +$ cd .. +$ cd .. +$ cd wjv +$ ls +51754 jpwhctfd +174007 mgqplvv.hlt +45041 mtrfs.bhj +153169 vhjw.vbg +$ cd .. +$ cd .. +$ cd .. +$ cd nqfdhlcg +$ ls +dir htnw +280499 tdwzsgqh.zsh +$ cd htnw +$ ls +203521 ggfpmb.pmz +$ cd .. +$ cd .. +$ cd .. +$ cd zfl +$ ls +36860 mlbcw +dir rgvgqqd +239962 rpv.qhp +64500 zfl.mvw +$ cd rgvgqqd +$ ls +26778 qnhpfr +$ cd .. +$ cd .. +$ cd .. +$ cd qmrsvfvw +$ ls +290013 gsvjgj.jsm +$ cd .. +$ cd svgbqd +$ ls +69927 bjc.vdh diff --git a/d07_output.txt b/d07_output.txt new file mode 100644 index 0000000..b59c370 --- /dev/null +++ b/d07_output.txt @@ -0,0 +1,2 @@ +1783610 +4370655 diff --git a/template.cc b/template.cc index 06f8930..45e26ef 100644 --- a/template.cc +++ b/template.cc @@ -25,7 +25,7 @@ unsigned p2(const Input &input) int main() { - Input input = parse(); + auto input = parse(); cout << p1(input) << endl; cout << p2(input) << endl; }