aboutsummaryrefslogtreecommitdiff
path: root/challenge-117/abigail/lua/ch-2.lua
blob: bfe11d74d395b2584ebf88f7ec781169cb68d285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/opt/local/bin/lua

--
-- See ../README.md
--

--
-- Run as: lua ch-2.lua < input-file
--

function steps (x, y, path)
    if   x == 0 and y == 0
    then print (path)
         return
    end
    if  x > 0
    then steps (x - 1, y,     path .. "R")
         steps (x - 1, y + 1, path .. "L")
    end
    if  y > 0
    then steps (x,     y - 1, path .. "H")
    end
end


steps (tonumber (io . read ()), 0, "")