-
Notifications
You must be signed in to change notification settings - Fork 0
/
07B-solution.basic
142 lines (133 loc) · 11.9 KB
/
07B-solution.basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
DIM dir$(185):DIM size(185)
dirs=0:path$="/":dir$(0)="/"
REPEAT
READ line$
fc$=LEFT$(line$,1)
IF fc$="." THEN path$=FNretreat(path$):P. ;dirs;" ";path$
IF fc$="c" THEN d$=RIGHT$(line$,LEN(line$)-3):path$=FNappend(path$,d$):PROCdirectory(path$)
IF fc$>="0" AND fc$<="9" THEN PROCfile(line$)
UNTIL line$="*"
answer=0
tfs=70000000:req=30000000
all=FNscan("/")
smallestCandidate=70000000
FOR I=0 TO 185
path$=dir$(I):P. CHR$(131);"Scan:";CHR$(135);path$
dirsize=FNscan(path$)
P. CHR$(130);"=";dirsize
wouldMakeAvailable=tfs-(all-dirsize)
IF wouldMakeAvailable >= req THEN P. CHR$(133);"Candidate."
IF wouldMakeAvailable >= req AND dirsize<smallestCandidate THEN smallestCandidate=dirsize
NEXT
P. 'CHR$(129);smallestCandidate
END
DEFFNscan(path$)
dirsize=0
FOR J=0 TO 185
IF path$<>"" AND LEFT$(dir$(J),LEN(path$))=path$ THEN dirsize=dirsize+size(J)
NEXT
=dirsize
DEFPROCfile(line$)
n$=LEFT$(line$,INSTR(line$," ")-1)
P. CHR$(132);"File:";CHR$(135);n$
size(dirs)=size(dirs)+VAL(n$)
ENDPROC
DEFPROCdirectory(d$)
dirs=dirs+1
P. CHR$(134);"Dir ";dirs;":";CHR$(135);d$
dir$(dirs)=d$
ENDPROC
DEFFNappend(p$,d$)
=p$+d$+"/"
DEFFNretreat(p$)
=LEFT$(p$, FNpenultimate(p$,"/"))
DEFFNpenultimate(in$,find$)
scratch$=LEFT$(in$, LEN(in$)-1):P%=0
REPEAT
F%=INSTR(scratch$, find$, P%+1)
IF F%>0 THEN P%=F%
UNTIL F%=0
=P%
D. "dir bsnqsfm","dir dtqvbspj","dir hhhtrws","dir ldmsq","307337 pnm.slh","dir pqcndb","dir pwtqzwv","212421 zcrfndg.cms","cd bsnqsfm",
D. "179236 lccnhn","..","cd dtqvbspj","221336 gdjfp.mfp","273114 jjgpvcqv.jlq","..","cd hhhtrws","dir gcbg","dir jjgpvcqv","dir mgvdbtl",
D. "1606 mgvdbtl.ztt","dir qhv","27538 wprqtd.wph","cd gcbg","dir bgcwh","dir bsnqsfm","dir jjgpvcqv","186683 lccnhn","dir rqbnd","32944 zjfs.mdf",
D. "cd bgcwh","211273 nvns","..","cd bsnqsfm","dir bsnqsfm","210022 dtqvbspj","dir gpcpgfh","189603 pnm.slh","199755 rcsffv.gbt","cd bsnqsfm",
D. "292856 bsnqsfm.vww","..","cd gpcpgfh","177703 jrr.jnj","..","..","cd jjgpvcqv","233963 bsnqsfm.fnn","127603 gpcpgfh.gtw","dir jjgpvcqv",
D. "48213 jrs.bdw","172974 pnm.slh","cd jjgpvcqv","dir bqnctqvn","dir bsnqsfm","dir gpcpgfh","254570 qpmnqwvl","258040 rrvjrv.zbp","cd bqnctqvn","106211 bsnqsfm.pql",
D. "299973 dtqvbspj","dir nzrst","cd nzrst","dir whtfvrl","cd whtfvrl","12412 vzdrqs.rwt","..","..","..","cd bsnqsfm",
D. "293832 bggllqhj.dvb","..","cd gpcpgfh","196159 jrr.jnj","..","..","..","cd rqbnd","97630 ddjrjp","56378 rsb",
D. "..","..","cd jjgpvcqv","89238 bsnqsfm.mgf","dir dvsst","dir gpcpgfh","dir jjgpvcqv","dir mhrzj","164176 pnm.slh","dir tmh",
D. "dir vmwz","cd dvsst","286924 dtqvbspj","252366 hcnqdmg.zst","266562 wgfdmgmh.ptw","..","cd gpcpgfh","91199 jrs.bdw","78761 rspd.vmj","dir tbrbw",
D. "dir vvm","dir wplf","cd tbrbw","195696 bjd.csj","56063 lccnhn","193863 pnm.slh","121918 qpd.dtq","209757 rcsffv.gbt","dir rmqlpvq","cd rmqlpvq",
D. "dir gjgfvt","255533 lhdqqbg.fgm","68413 qltvgnrp.gfd","dir wqfcnlzq","cd gjgfvt","242867 zqbdmpb","..","cd wqfcnlzq","dir vhhscrvb","cd vhhscrvb",
D. "62647 rcsffv.gbt","..","..","..","..","cd vvm","281698 dscllv.qwl","14348 rmgpnprq","..","cd wplf",
D. "44465 jjgpvcqv","248434 vpsfbjh.zsj","..","..","cd jjgpvcqv","dir dhfcbc","dir jjgpvcqv","dir ltclg","dir ptbsgmlr","cd dhfcbc",
D. "224134 lccnhn","197124 tns","..","cd jjgpvcqv","126322 jrr.jnj","280287 jrs.bdw","..","cd ltclg","dir fdfn","47501 jrr.jnj",
D. "dir mgvdbtl","24374 mgvdbtl.gll","227751 pnm.slh","286088 wvsfr","cd fdfn","32987 hmt","..","cd mgvdbtl","201629 pnm.slh","246591 whtcjvh",
D. "..","..","cd ptbsgmlr","239257 rcsffv.gbt","..","..","cd mhrzj","279222 mgvdbtl.rzf","214102 rvjnddbr","..",
D. "cd tmh","152958 rcsffv.gbt","..","cd vmwz","131525 bsnqsfm.djc","122342 jrs.bdw","..","..","cd mgvdbtl","24916 tcsltrml",
D. "..","cd qhv","dir hncvrlbw","153239 jwdg.wbg","cd hncvrlbw","178499 clmwn.ztj","297967 jrr.jnj","30359 sntbnf.whh","..","..",
D. "..","cd ldmsq","dir jngnzc","dir psgrjgr","dir rgwp","dir rtsmnzm","dir wsd","cd jngnzc","dir dzlcq","dir gpcpgfh",
D. "dir rlwwwngc","dir swrlvd","cd dzlcq","70984 lccnhn","..","cd gpcpgfh","288159 hztmtp.fpj","..","cd rlwwwngc","173335 bsnqsfm.rtr",
D. "292723 jrr.jnj","175123 lccnhn","..","cd swrlvd","69589 fwrt","..","..","cd psgrjgr","283186 dtqvbspj.hjw","dir fcvqsp",
D. "104691 jrs.bdw","286657 lccnhn","258194 rcsffv.gbt","cd fcvqsp","209758 fzqmqlvs.hsc","..","..","cd rgwp","11060 nwg.qcg","..",
D. "cd rtsmnzm","dir rdv","dir sdwmbsz","dir tjwht","cd rdv","189234 nngdwngf.jpm","102320 qbq","..","cd sdwmbsz","dir dfzw",
D. "dir jbnsvcv","dir jjgpvcqv","140827 jjgpvcqv.cvz","cd dfzw","168631 dhbfr","..","cd jbnsvcv","dir bsnqsfm","20840 lsgnjrn","83537 lvtbqlh",
D. "dir qfmj","cd bsnqsfm","74345 jrr.jnj","..","cd qfmj","dir bfvwng","dir jjgpvcqv","cd bfvwng","dir qzdpp","cd qzdpp",
D. "dir jjgpvcqv","cd jjgpvcqv","207083 rchw.lgb","..","..","..","cd jjgpvcqv","273755 dqmb","..","..",
D. "..","cd jjgpvcqv","190922 dtqvbspj.rww","59784 lccnhn","293765 mwvpgtzm","dir vtbln","dir wph","cd vtbln","19558 jrs.bdw","72791 lccnhn",
D. "262803 pnm.slh","40575 sbdz","..","cd wph","174151 jrr.jnj","..","..","..","cd tjwht","dir mgvdbtl",
D. "136586 rcsffv.gbt","cd mgvdbtl","dir gtmbf","cd gtmbf","61244 jvs.gvw","269474 rcsffv.gbt","..","..","..","..",
D. "cd wsd","275247 dtqvbspj.mjl","dir gpcpgfh","dir jdnfsqzd","88516 jrr.jnj","77096 lccnhn","dir lspqh","dir pfcmb","120975 tqzmlsz","215518 zvzhjd.ggw",
D. "cd gpcpgfh","217225 lccnhn","dir qtnqzql","cd qtnqzql","242800 rzfvcjvh","..","..","cd jdnfsqzd","293894 ppdh","310316 rcsffv.gbt",
D. "..","cd lspqh","dir pspghgw","cd pspghgw","105894 gpcpgfh.zht","20657 nccmrdjv.tml","241440 nrb.zrj","..","..","cd pfcmb",
D. "64751 cfnptz","dir dmlsqf","dir dtqvbspj","288252 nfcdscgz","309178 pnm.slh","cd dmlsqf","82960 czhbvv.fvc","238189 dtqvbspj.mqp","232175 lccnhn","..",
D. "cd dtqvbspj","dir fpq","99045 jrs.bdw","cd fpq","98034 bnbvjg.nfq","..","..","..","..","..",
D. "cd pqcndb","dir dtqvbspj","dir fvrtmdg","dir gpcpgfh","dir jjgpvcqv","dir mgvdbtl","dir pftswtnl","302354 rcsffv.gbt","dir zwph","cd dtqvbspj",
D. "134541 mgvdbtl.gbr","..","cd fvrtmdg","dir gpcpgfh","231704 gpcpgfh.cgh","304822 jrr.jnj","cd gpcpgfh","64193 ztqztct.ctr","..","..",
D. "cd gpcpgfh","dir cmg","129101 hqcjs.fsf","dir jjgpvcqv","dir lmb","dir lzgc","dir nqvzvfb","dir rbh","149226 tzgn.sqv","257657 zbjzcn",
D. "cd cmg","54041 bbrbwdw.mtf","233793 dtqvbspj.hjj","227618 jjgpvcqv.sls","36553 rcsffv.gbt","dir vsjs","cd vsjs","199262 bsnqsfm","dir dqpqvsfn","dir ghw",
D. "73538 jrs.bdw","20726 mtfzjhc","cd dqpqvsfn","91215 ppfmvz","..","cd ghw","dir bwhn","307330 jrr.jnj","25726 pnm.slh","cd bwhn",
D. "dir gpcpgfh","cd gpcpgfh","61301 mhchvsnp.lpv","..","..","..","..","..","cd jjgpvcqv","281936 zjfrwg",
D. "..","cd lmb","dir mmqr","cd mmqr","60362 mbjdfmf.wfh","..","..","cd lzgc","211543 rcsffv.gbt","..",
D. "cd nqvzvfb","288538 lccnhn","224852 rcsffv.gbt","..","cd rbh","dir cwgc","dir gpcpgfh","dir hdmmgms","dir jwqdv","75165 mgvdbtl.rdd",
D. "dir mzt","cd cwgc","254910 ghsbvcw.wgh","..","cd gpcpgfh","8668 lccnhn","145750 mcpd","265522 rcsffv.gbt","..","cd hdmmgms",
D. "dir dtqvbspj","dir gpcpgfh","203642 jrs.bdw","19047 rcsffv.gbt","215131 tbdf","dir tgqbtw","cd dtqvbspj","46484 hjztnq","14784 tmmf.ggs","..",
D. "cd gpcpgfh","123990 jrs.bdw","52381 mgvdbtl","130292 rrqp.pmz","..","cd tgqbtw","dir bsnqsfm","dir nnn","cd bsnqsfm","279305 mgvdbtl.mhc",
D. "..","cd nnn","181320 jjgpvcqv.zcn","..","..","..","cd jwqdv","306471 jjgpvcqv.jbv","..","cd mzt",
D. "159120 wcfjbfsb.vlq","..","..","..","cd jjgpvcqv","dir drmmqldt","dir jjgpvcqv","235210 jjnbtgh","116214 lccnhn","dir mzj",
D. "dir qcclcdd","dir rtnnjct","dir trgbfqb","cd drmmqldt","dir bsnqsfm","dir gpcpgfh","dir jjgpvcqv","cd bsnqsfm","200217 gpcpgfh.bmf","..",
D. "cd gpcpgfh","183548 jjgpvcqv.cgs","119367 rcsffv.gbt","..","cd jjgpvcqv","dir bzhsjfq","dir lptnp","cd bzhsjfq","37713 pnm.slh","..",
D. "cd lptnp","150154 jjgpvcqv.jpt","..","..","..","cd jjgpvcqv","dir csvpf","cd csvpf","96915 bdsqr.ptg","15712 gpcpgfh.hbw",
D. "13419 pnm.slh","23191 vhzngpw.bdp","..","..","cd mzj","216100 fblqpwgd.rmb","..","cd qcclcdd","67202 bdz.flj","51451 dtqvbspj",
D. "dir mgvdbtl","36642 rhc.qtg","252808 slqzl.hgz","cd mgvdbtl","dir dtqvbspj","cd dtqvbspj","142184 pnm.slh","..","..","..",
D. "cd rtnnjct","dir bsnqsfm","dir dtqvbspj","dir ftlr","dir grpln","dir wtjfbzjq","cd bsnqsfm","dir gbp","cd gbp","dir gpcpgfh",
D. "cd gpcpgfh","157447 msdhpv","..","..","..","cd dtqvbspj","dir fbpz","dir mgvdbtl","cd fbpz","118001 zzffss.qdv",
D. "..","cd mgvdbtl","dir gtbpnhhm","dir rvjdhdvf","cd gtbpnhhm","115199 mgvdbtl.zhd","307710 pbqqz.dvg","..","cd rvjdhdvf","192704 lccnhn",
D. "49374 qsv.nzw","dir vnlq","cd vnlq","dir zwtwvdb","cd zwtwvdb","99356 cqfppfg.cwl","..","..","..","..",
D. "..","cd ftlr","dir fdm","cd fdm","dir pdzbthz","cd pdzbthz","dir gmpzrfv","286299 gmvg","32579 jrr.jnj","cd gmpzrfv",
D. "44930 tfwc.sjb","76143 wtwpz","..","..","..","..","cd grpln","dir thsbgczd","dir vdmt","cd thsbgczd",
D. "231385 lccnhn","..","cd vdmt","dir qzwzwlpr","cd qzwzwlpr","119862 qbpglhp.pmz","..","..","..","cd wtjfbzjq",
D. "308656 cvjrn.mmz","107735 mgvdbtl.pjv","..","..","cd trgbfqb","59890 jrr.jnj","dir mhhbp","cd mhhbp","dir bsnqsfm","dir hvjtmr",
D. "cd bsnqsfm","80555 trsl.zjm","..","cd hvjtmr","78682 cgjqlrw","..","..","..","..","cd mgvdbtl",
D. "85693 bsnqsfm.jft","dir gpcpgfh","136814 gvfz","243282 jjgpvcqv.phc","23472 mrq","dir tdnhp","188849 ztrvjzw.gjj","cd gpcpgfh","dir bfjb","172798 blt",
D. "dir dtqvbspj","dir lwtj","cd bfjb","9385 fhgqhrnq","..","cd dtqvbspj","dir zrtpvzh","cd zrtpvzh","115949 gjcpswqv.tqg","..",
D. "..","cd lwtj","269246 dtqvbspj.tmv","106980 jrr.jnj","20735 ldjswqtb.plp","..","..","cd tdnhp","25816 lccnhn","..",
D. "..","cd pftswtnl","60146 blg.vhz","dir cjzl","dir mgvdbtl","165072 mgvdbtl.cvq","dir rdhdqvm","dir swgdh","dir tgwws","101085 wtvlsbbf",
D. "139565 zfhlb.fmg","cd cjzl","51636 hmwmvgg","..","cd mgvdbtl","dir dtlr","118691 pjjfwhwj","74684 rcsffv.gbt","253814 rgmn.csn","cd dtlr",
D. "43065 dtqvbspj","..","..","cd rdhdqvm","103093 bsnqsfm.rjd","5514 lccnhn","..","cd swgdh","dir dwznjd","230643 jjgpvcqv",
D. "296232 ltnlhbln.bqp","dir mgvdbtl","dir nbpdfrv","199830 rcsffv.gbt","cd dwznjd","138849 jrs.bdw","240327 mgvdbtl","..","cd mgvdbtl","293382 dgrzgpr",
D. "218657 jjgpvcqv.lwt","dir pbw","125455 rcsffv.gbt","cd pbw","242621 tnt.zbl","..","..","cd nbpdfrv","297826 nfqbq.zfg","183227 qvr",
D. "148665 rcsffv.gbt","..","..","cd tgwws","dir bhr","dir gpcpgfh","cd bhr","dir wfjfvb","cd wfjfvb","dir jgfbpwjh",
D. "13720 lwnz","38140 wrgb.ntr","cd jgfbpwjh","207048 cbtdqb","176591 mgvdbtl","311612 nwflw.mmp","92978 pwrrz","273467 rnzzs.wrr","dir vsmgcv","cd vsmgcv",
D. "dir dpdmspz","cd dpdmspz","dir bsnqsfm","cd bsnqsfm","197093 wzqlhhpv.lgb","..","..","..","..","..",
D. "..","cd gpcpgfh","98093 lccnhn","208835 llplrrr.jrp","..","..","..","cd zwph","dir cmznd","cd cmznd",
D. "dir zhhm","cd zhhm","204738 rjh.qjf","..","..","..","..","cd pwtqzwv","21382 gbcccm.jdc","dir hthq",
D. "dir jcsmcf","dir jjgpvcqv","262556 mgvdbtl.vrm","dir twrjfd","dir zzclqz","cd hthq","dir dtqvbspj","dir mgvdbtl","dir wgcss","cd dtqvbspj",
D. "35525 gpcpgfh.wpc","4808 jjgpvcqv","dir lrvftwzb","dir nzvbpcwd","cd lrvftwzb","92705 rcsffv.gbt","33209 wvthcng.qlf","..","cd nzvbpcwd","dir tzvclhw",
D. "cd tzvclhw","251094 gpcpgfh.bpj","..","..","..","cd mgvdbtl","229319 hvzhcpr.dbc","301679 lrvlp.bnl","157154 pjq","129501 sgqsjl",
D. "..","cd wgcss","37019 fpmmqmv","286113 gpcpgfh.mrm","dir jjgpvcqv","132664 lccnhn","194995 pnm.slh","cd jjgpvcqv","116833 pnm.slh","..",
D. "..","..","cd jcsmcf","146144 jjgpvcqv.jvj","..","cd jjgpvcqv","dir gdrqbn","dir nwbqdd","cd gdrqbn","149865 bsnqsfm.zjh",
D. "1714 jjgpvcqv.lwq","..","cd nwbqdd","14359 bsnqsfm","77969 dpqt.lph","285861 dtqvbspj.svq","dir gpcpgfh","156597 hhsfwctl.hng","15497 mgvdbtl","cd gpcpgfh",
D. "275833 gpcpgfh.hdd","..","..","..","cd twrjfd","302115 gpcpgfh.zcb","dir gqlqnpvm","20848 rcsffv.gbt","cd gqlqnpvm","123135 gpcpgfh",
D. "57433 gpcpgfh.zfp","..","..","cd zzclqz","217719 vcq.flg","*"