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

Reply via email to