Files
adventofcode/src/pladcl/2024/day14/part1.pdl
2024-12-15 09:44:05 -05:00

97 lines
1.6 KiB
Plaintext

interrupt program_start
`101sw`
`103sh`
`lw2/sm` # width middle
`lh2/sM` # height middle
`100s.`
# 7890 are outputs
end
state read
adjust_index(2) # go past p=
read_number()
`sx` # x position
adjust_index(1) # go past ,
read_number()
`sy`
adjust_index(3) # go past " v="
read_number()
`s1` #dx
adjust_index(1) # go past ","
read_number()
`s2`
#adjust_index(1) # go past newline
`[x=]nlxn[ y=]nlyn[ 1=]nl1n[ 2=]nl2n10an`
`lxl1l.*+lw%sx`
`lyl2l.*+lh%sy`
if `lx` < 0 then
`lxlw+sx`
end
if `ly` < 0 then
`lylh+sy`
end
`[nx=]nlxn[ ny=]nlyn10an`
if `lx` < `lm` then
if `ly` < `lM` then
`[quadrant 1]n10an`
`l71+s7`
end
if `ly` > `lM` then
`[quadrant 3]n10an`
`l91+s9`
end
end
if `lx` > `lm` then
if `ly` < `lM` then
`[quadrant 2]n10an`
`l81+s8`
end
if `ly` > `lM` then
`[quadrant 4]n10an`
`l01+s0`
end
end
end
interrupt program_end
`[w=]nlwn[ h=]nlhn[ m=]nlmn[ M=]nlMn10an`
`[7=]nl7n[ 8=]nl8n[ 9=]nl9n[ 0=]nl0n10an`
`l7l8l9l0***p`
end
function read_number
# does no error checking
`1` # sign
if `ln` == '-' then
`2-` # negative
adjust_index(1)
end
`0` # c num
while `ln` >= '0' and `ln` <= '9' do
`10*`
`ln48-+` # add in number
adjust_index(1)
end
#adjust_index(-1)
`*`
end