I get this: try1 ts ┌─┐ │2│ └─┘ try ts ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐ │0│0│0│0│0│0│0│0│0│0│0│1│1│1│1│2│2│ └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ JVERSION Engine: j903/j64/darwin Release-a: commercial/2021-12-16T15:16:37 Library: 9.03.08 Platform: Darwin 64 Installer: J903 install InstallPath: /users/rauldmiller/applications/j903 Contact: www.jsoftware.com
Also note that padrifshort pads not only on the right but on the left 4 5 padrifshort 6 2000000000 6 2000000000 Is that what you intended? Thanks, -- Raul On Thu, Jan 6, 2022 at 2:39 PM Jan-Pieter Jacobs <[email protected]> wrote: > > I was trying to debug my implementation of Dijkstra's algorithm and ran > into this J crash: > > (AoC Day 15 spoiler ahead -- well sort off, the solution is not entirely > correct, hence the debugging :p) > > ts is a snaking path of 0's from 0 0 to 9 9, and try1 (should) implement > Dijkstra's algorithm for finding a path with a minimal sum of the nodes > crossed. Something in my implementation is wrong (hints welcome), but the J > bug turned up when I wanted to debug this approach by adding a \ to keep > intermediate results, which causes a bus error: > > try=: [: ([ + 2 <./\ padrifshort)&.>/\@|. [: </. 0 (<0 0)} ] > ts =: 0 1 0 0 0 1 0 0 0, (7 9$9$0 1), (0 0 0 1 0 0 0 1 0) > try1=: [: ([ + 2 <./\ padrifshort)&.>/@|. [: </. 0 (<0 0)} ] > max=: 2e9 > padrifshort=: ]`(max (,,[) ])@.(>&#) > try1 ts NB. "works" no crash, but result is wrong. > ┌─┐ > │2│ > └─┘ > try ts > Bus error > NB. J crashed. > > For an explanation of the code, see ( > http://www.jsoftware.com/pipermail/programming/2022-January/059538.html). > > My J version: > JVERSION > Engine: j903/j32/android > Release-a: commercial/2021-12-17T11:10:19 > Library: 9.03.08 > Platform: Android 32 (armeabi-v7a) > Installer: unknown > InstallPath: /mnt/sdcard/Android/data/com.jsoftware.j.android/files > Contact: www.jsoftware.com > > Jan-Pieter > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
