-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path07.q
More file actions
37 lines (29 loc) · 628 Bytes
/
07.q
File metadata and controls
37 lines (29 loc) · 628 Bytes
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
// --- Day 7: No Space Left On Device ---
lines:1 _ read0 `:input/07.txt
dirs:enlist[1#`]!enlist 0
cwd:`
isls:0b
while[count line:first lines;
if[line like "$ cd*";
isls:0b;
dir:`$last " " vs line;
cwd:$[dir~`$"..";
-1_ cwd;
cwd,dir
];
];
if[isls;
if[not "dir"~first split:" " vs line;
size: "J"$ first split;
{dirs[enlist[x]]+:y}[;size] each ,\[cwd] // yuck
];
];
if[line like "$ ls";
isls:1b;
];
lines: 1 _ lines;
];
sum (value dirs) where (value dirs) < 100000
/1084134
min dirs where dirs > 30000000 - 70000000 - dirs[enlist `]
/6183184