« first day (954 days earlier)      last day (581 days later) » 

1:58 AM
any thoughts on speeding up this code for AOC 2017 p5?
input: .'0:"input5"
while:{x[1]~0|x[1]&-1+y}[;#input]

next:{(@[x;y;1+];y+x[y];z+1)}.
:/while next/(input;0;0)

next:{(@[x;y;((-1 1)3>x[y])+];y+x[y];z+1)}.
:/while next/(input;0;0)
 
 
10 hours later…
ngn
11:53 AM
@chrispsn a little faster:
a:`I$0:"input5"
-1+#(</(0,#a)>){-1+x+a[x]+:1}\0
a:`I$0:"input5"
-1+#(</(0,#a)>){a[x]+:-1+2*3>v:a x;x+v}\0
 
12:31 PM
@ngn is it faster to keep the offsets list as a global (like you did) rather than a sublist of a 'state' list (like I did)?
I wonder if incrementing a counter in a global would be faster than keeping intermediate results and measuring the length
 
 
3 hours later…
ngn
3:28 PM
@chrispsn there isn't much difference. with your method it's easier to spot if the big array is reffed and unreffed properly so all amendments are in-place. mine is just easier to code and a bit shorter. i think the improvement comes mostly from the other tricks i applied - particularly the simpler "while" condition
 
 
2 hours later…

« first day (954 days earlier)      last day (581 days later) »