Why isn't the result  0 0 0 0 0 1 0 0 ?

A=:'^<v>'
   B=:'<V>^'
   f=: 13 :'((|.|:|.4|+/~i.4),4|+/~i.4){y'
   f A
v<^>
<^>v
^>v<
>v<^
^<v>
<v>^
v>^<
>^<v
   B-:"1 f A
0 0 0 0 0 0 0 0

Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Lambert
Sent: Thursday, December 3, 2015 9:40 AM
To: programming <[email protected]>
Subject: [Jprogramming] adventofcode day 3

Say P is a rank 2 list of 2D coordinates
    4{.P
  0 0
  0 1
  0 2
_1 2

Let's map the flight.

NB. shift moves origin making minimum coordinates independently 0 NB. use:
shift COORDINATES
shift=: -"1 <./

NB. grid generates an array of zeros large enough for only the positive
coords NB. use: grid COORDS
grid=: 0 $~ >:@:(>./)

NB. COORDS draw GRID  NB. color by number
draw=: (i.@#@[)`(;/@:[)`]}

load'viewmat'
flight =: viewmat @: (draw grid) @: shift

flight P

----------------------------------------------------------------------
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