DIRS=:;:a=:'ne n nw sw s se'
('a'~)=. 1ad30 1ad90 1ad150 1ad210 1ad270 1ad330
count_steps=: 3 :0
position=. +/(". ::])y
h=. ne,n,nw,sw,s,se
path=. 0j0
p=. 0$<''
while. 0.2<|position-{:path do.
i=. (=<./)|position-,h+/{:path
path=.path,({:path)+h#~i
p=. p,<i#DIRS
end.
(;~#)p
)
count_steps se,sw,se,sw,sw
┌─┬───┬──────┬────┐
│3│┌─┐│┌──┬─┐│┌──┐│
│ ││s│││sw│s│││sw││
│ │└─┘│└──┴─┘│└──┘│
└─┴───┴──────┴────┘
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
This step counting verb uses lengths of equilateral hexagonal grid,
taking that step or apparently quantum tunneling pair of optimal steps.
I have not tried to understand it, but it works.
- Re: [Jprogramming] AoC Day 11 - so... Brian Schott
- Re: [Jprogramming] AoC Day 11 - so... Raul Miller
- Re: [Jprogramming] AoC Day 11 - so... Brian Schott
- Re: [Jprogramming] AoC Day 11 - so... Brian Schott
- Re: [Jprogramming] AoC Day 11 - so... Raul Miller
- Re: [Jprogramming] AoC Day 11 - so... Brian Schott
- Re: [Jprogramming] AoC Day 11 - so... Henry Rich
- Re: [Jprogramming] AoC Day 11 - so... Jimmy Gauvin
- Re: [Jprogramming] AoC Day 11 - so... Raul Miller
- Re: [Jprogramming] AoC Day 11 - something is wrong Raul Miller
- Re: [Jprogramming] AoC Day 11 - something is wrong David Lambert
- Re: [Jprogramming] AoC Day 11 - something is wrong David Lambert
