https://adventofcode.com/2021/day/25

This is the end of the advent of code series for last year. It was a
quick wrap up.

Here, the puzzle was about waiting for sea cucumbers to get out of the
way so you could land your submarine and launch santa's sleigh (which
makes about as much sense as santa, but whatever...).

sample=:];._2 {{)n
v...>>.vv>
.vv>>.vv..
>>.>v>...v
>>v>>.>.v.
v>v.vv.v..
>.>>..v...
.vv..>.>v.
v.v..>>v.v
....v..v.>
}}

For this, I just built a quick step function, ran it until it stopped
and counted the steps:

stepEast=: {{
  '>' stepHalf y
}}

stepSouth=: {{
  |:'v' stepHalf|:y
}}

stepHalf=: {{
  b=. }:"1 (x,'.') E."1 y,.{."1 y
  I=. I.,b
  I2=. I.,_1 |."1 b
  ($y)$ '.' I} x I2} ,y
}}

step=: {{
  N=:N+1
  chk=. #/.~,'.>v',,y
  r=.stepSouth r0=.stepEast y
  assert. chk-:#/.~,'.>v',,r0
  assert. chk-:#/.~,'.>v',,r
}}

a25=: {{
  N=:0
  step^:_ y
  N
}}

Crude, of course, but perhaps appropriately silly?

Anyways... that wraps it up. The second part of the puzzle was to
finish up all the other days and then remotely start the sleigh.

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to