I'm a software engineer, get me out of here: Difference between revisions

Content added Content deleted
m (→‎J Part 2: need patched version of fingers which type </syntaxhighlight> rather than </lang>)
m (→‎J Extra Credit: restore full definition of HQ)
Line 749: Line 749:
Locations are generally represented by a pair of indices (row, column) into the above structures. But for the floyd warshall algorithm we need a distance graph. To translate between the graph format and the map data structure, we have a list of cells. Cells are a base 23 representation of the row,column indices (In other words 9 represents row 0, column 9, while 23 represents row 1, column 0, and HQ has a cell value of (23*11)+11).)
Locations are generally represented by a pair of indices (row, column) into the above structures. But for the floyd warshall algorithm we need a distance graph. To translate between the graph format and the map data structure, we have a list of cells. Cells are a base 23 representation of the row,column indices (In other words 9 represents row 0, column 9, while 23 represents row 1, column 0, and HQ has a cell value of (23*11)+11).)


<syntaxhighlight lang=J>Q=: cells i.($map)#.11 11 NB. HQ as a graph index
<syntaxhighlight lang=J> HQ=: cells i.($map)#.11 11 NB. HQ as a graph index
\:~ ~. HQ{graph NB. all path lengths starting at HQ
\:~ ~. HQ{graph NB. all path lengths starting at HQ
_ 6 5 4 3 2 1
_ 6 5 4 3 2 1