27 lines
562 B
Lua
27 lines
562 B
Lua
|
#!/usr/bin/env luajit
|
||
|
require("utils")
|
||
|
|
||
|
local f = io.open(arg[3])
|
||
|
local fst = string.match(f:read("*l"), "Player 1 starting position: (.*)")
|
||
|
local snd = string.match(f:read("*l"), "Player 2 starting position: (.*)")
|
||
|
f:close()
|
||
|
|
||
|
function rolls()
|
||
|
local i = 0
|
||
|
return function()
|
||
|
i = i + 1
|
||
|
return i
|
||
|
end
|
||
|
end
|
||
|
|
||
|
local r = rolls()
|
||
|
local turn = 0
|
||
|
local fstscore, sndscore = 0, 0
|
||
|
repeat
|
||
|
snd, fst = (fst + r() + r() + r() - 1) % 10 + 1, snd
|
||
|
sndscore, fstscore = fstscore + snd, sndscore
|
||
|
turn = turn + 3
|
||
|
until sndscore >= 1000
|
||
|
|
||
|
print(fstscore, turn, fstscore * turn)
|