[Jprogramming] Advent of code, Day 5 (spoilers probable)

Ric Sherlock tikkanz at gmail.com
Tue Dec 5 22:05:13 UTC 2017


Did anyone come up with a nice Jish solution for this?

Mine (see below) ended up being very scalar.













countJumps=: 3 :0

  count=. idx=. 0

  offsets=. y

  while. (0 <: idx) *. (idx < #offsets) do.

    count=. count + 1

    idx_new=. idx ([ + {) offsets

    offsets=. idx (1 + {)`[`]} offsets

    idx=. idx_new

  end.

count;idx;offsets

)


   countJumps 0 3 0 1 _3

5


More information about the Programming mailing list