My version for day 9:

NB. Read in data, convert to array

i =: (+ |:) 0 ,~ 0 ,. |."1 |.@:((0&".)@>)/./ |: (0 _1&{)@;:;._2 }: wd 'clippaste'

NB. Find shortest path

<./ (i.@! ([: +/ i (<"1@[ { ])~ 2 ]\ A.)"0 _ i.) #i


NB. Part 2, find longest path

>./ (i.@! ([: +/ i (<"1@[ { ])~ 2 ]\ A.)"0 _ i.) #i


Henry Rich

On 12/9/2015 3:36 PM, 'Pascal Jasmin' via Programming wrote:
amV=: (0 {:: [)`(1 {:: [)`]}
reduce=:1 : '<"_1@[ ([: u (&.>)/(>@:) ,) <@:]'
perm =: i.@! A. i.
in =. 0 2 4 {"1 ;:"1 a =. > cutLF wd 'clippaste'
m =. ((". each {:"1 in) ,. (<@<"1 l i. 2{."1 in)) amV reduce  8 8 $ 0

i =. +/@:(2 (m {~ <@/:~)\ ])"1 perm 8  NB. All possible distance paths.
<./ i  NB. minimum

something useful for dealing with and visualizing graphs, is the m matrix I 
created.

m
0 66 28 60  34  34   3 108
0  0 22 12  91 121 111  71
0  0  0 39 113 130  35  40
0  0  0  0  63  21  57  83
0  0  0  0   0   9  50  60
0  0  0  0   0   0  27  81
0  0  0  0   0   0   0  90
0  0  0  0   0   0   0   0

to get this with labels and pretty boxes,

(~.@,@:(2&{."1) in) ((a:,[) ,. ,) <"0 m

which to me seems more informative than graph drawings.  Though with advent 7, 
it would be an extremely large table.  There was a graphviz drawing posted to 
reddit/r/adventofcode.  The table approach would require less scrolling, and 
possibly easier to find links.


was graphviz a J6 utility?  What is the general nature of the breakage?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to