HI all,
this AOC challenge is great for trying out J cool features, like sparse
arrays which I haven't used to date.
For part 1 I decided to try transitive closure on a sparse matrix.
Initializing the sparse array went ok but the transitive closure produced a
big bang and J just died on me, 8-(
So I went for a brute force approach : visiting all predecessors to node.
d12=: <&;:;.(_2) 1!:1 <'/day12inp'
d12c=:".&; each 4}. each d12
nodto =: 3 : 0
~. y , ; y { d12c
)
$nodto ^:_ (0)
169
There must be a nicer way to write this code.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm