Day 2: Lua: Less syntactic salt
This commit is contained in:
parent
d6bf929fc8
commit
91c74473a8
2 changed files with 4 additions and 4 deletions
|
@ -8,8 +8,8 @@ function up(val) v = v - val end
|
|||
function forward(val) h = h + val end
|
||||
|
||||
for line in io.lines("input.txt") do
|
||||
cmd, val = line:gmatch("(%S+) (%S+)")()
|
||||
cmd, val = string.match(line, "(%S+) (%S+)")
|
||||
_G[cmd](val)
|
||||
end
|
||||
|
||||
print(("Answer: %d"):format(h * v))
|
||||
print(string.format("Answer: %d", h * v))
|
||||
|
|
|
@ -9,8 +9,8 @@ function up(val) aim = aim - val end
|
|||
function forward(val) h = h + val; v = v + aim * val end
|
||||
|
||||
for line in io.lines("input.txt") do
|
||||
cmd, val = line:gmatch("(%S+) (%S+)")()
|
||||
cmd, val = string.match(line, "(%S+) (%S+)")
|
||||
_G[cmd](val)
|
||||
end
|
||||
|
||||
print(("Answer: %d"):format(h * v))
|
||||
print(string.format("Answer: %d", h * v))
|
||||
|
|
Loading…
Reference in a new issue