Last active
August 29, 2015 14:23
-
-
Save llasram/058e5f43074c2390ac4a to your computer and use it in GitHub Desktop.
J implementation of Dijkstra's algorithm on a square grid (Project Euler #83)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mask =: _~:] | |
moves =: 1 :'(0 1, 0 _1, 1 0,: _1 0) |.!.m"1 2 ]' | |
step =: [:<./ ], (* +./@:(0 moves)@:mask) +"2 (_ moves)@:] | |
init =: * $ $!._ 1: | |
costs =: step^:_ init | |
M =: ([:".(;._1)',',])(;._1)_1|.(1!:1)<'p083_matrix.txt' | |
] p83 =: {:{: costs M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment