diff options
author | sterni <sternenseemann@systemli.org> | 2023-01-04T12·29+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-22T14·36+0000 |
commit | 2b308c64b94a14592f928a7d2511fc74c8846eb3 (patch) | |
tree | 2eb9f0268883a3a3fae24359ab1c8d649266ece2 /users/sterni/exercises/aoc/2022 | |
parent | 8eeb5d3bccf831681b2cad5c3b322e6a08f596df (diff) |
feat(sterni/aoc/2022): day16 part 1 k solution r/5731
Change-Id: I4d141e0d911157ae17f12066b859297836d4858b Reviewed-on: https://cl.tvl.fyi/c/depot/+/7897 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises/aoc/2022')
-rw-r--r-- | users/sterni/exercises/aoc/2022/16/16.k | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/2022/16/16.k b/users/sterni/exercises/aoc/2022/16/16.k new file mode 100644 index 000000000000..40d5ace60e84 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/16/16.k @@ -0,0 +1,21 @@ +/ parsing +(f;r;t):+{x[1 4],,9_x^'","}'" "\' 0:"input" +(f;t):`s$''(f;t) +r:f!{`I$x[&(x<58)&47<x]}' r +g:f!t + +/ total flow scoring +tf: {+/+\{x,(30-#x)#0}((r.)'x)*`XX=':x} + +/ valves to open +vto: f^(=r).0; + +/ paths to keep after each step +best: {x[(1000&#x)#>tf'x]} + +p:{[n;ps] + ms:ps[&~fin:(#vto)={#?x[&`X=':x]}'ps]; + rt: best[ps[&fin],(ms[w],'(,*|)'ms[w:&{(0|/vto=l)&~|/0&':x=l:*|x}'ms]),,/{x,/:,'g[*|x]}' ms]; + $[n>1;o[n-1;rt];rt]} + +*tf'p[29;,,`AA] |