2025-12-04 07:41:00 +00:00

37 lines
708 B
XML

sample = 10 10 rho "..@@.@@@@.@@@.@.@.@@@@@@@.@.@@@.@@@@..@.@@.@@@@.@@.@@@@@@@.@.@.@.@.@@@@.@@@.@@@@.@@@@@@@@.@.@.@@@.@."
op ch pad g =
(g, (((rho g)[2]) rho ch)) ,% ((1 + (rho g)[1]) rho ch)
op adj g =
(1 rot g) + (-1 rot g) + (1 flip g) + (-1 flip g) + (1 rot 1 flip g) + (-1 rot 1 flip g) + (1 rot -1 flip g) + (-1 rot -1 flip g)
op solve g =
gx = 0 pad (g=="@")
fx = gx and 4 > adj gx
+/ ,fx
op remove g =
next = g - (g and 4 > adj g)
and/, g == next: g
remove next
op solve2 g =
gx = 0 pad (g=="@")
rx = remove gx
+/,(gx - rx)
x = "@" == "." pad sample
x
adj x
""
x and 4 > adj x
solve sample
solve2 sample
) get "input.ivy"
solve input
solve2 input