+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
c203ef0
master
1#!/usr/bin/env jconsole 2load '../util.ijs' 3 4lines =: <;._2 in 5gap =: a:i.~lines 6art =: >gap take lines 7cols =: >:4*i.4%~>:#>{: art 8stacks =: |.@deb each <"1 |: }: cols {"1 art 9original =: stacks 10steps =: >a:-.~"1".each ;:>lines drop~>:gap 11 12move =: {{ NB. smoutput 'moving ',(":m),' from ',(":x),' to ',":y 13 'tmp new' =. (-m)split x pick stacks 14 stacks =: stacks x}~ <new 15 stacks =: stacks y}~ <tmp,~y pick stacks 16 y }} 17run =: {{ 'times from to' =: y 18 (<:from) 1 move ^:times <: to }}"1 19 20run steps 21ans > {: each stacks 22 23stacks =: original 24run =: {{ 'num from to' =: y 25 (<:from) num move <:to }}"1 26 27run steps 28ans > {: each stacks 29 30exit''