21 lines
572 B
Text
21 lines
572 B
Text
local fmt = require "fmt"
|
|
|
|
local vals = {}
|
|
while true do
|
|
for i = 1, 6 do
|
|
local rns = {}
|
|
for j = 1, 4 do rns[j] = math.random(1, 6) end
|
|
local sum = rns:reduce(|acc, n| -> acc + n)
|
|
rns:sort()
|
|
vals[i] = sum - rns[1]
|
|
end
|
|
local total = vals:reduce(|acc, n| -> acc + n)
|
|
if total >= 75 then
|
|
local fifteens = #vals:mapped(|n| -> n >= 15)
|
|
if fifteens >= 2 then
|
|
fmt.print("The six values are: %,s", vals)
|
|
fmt.print("Their total is: %d", total)
|
|
break
|
|
end
|
|
end
|
|
end
|