RosettaCodeData/Task/RPG-attributes-generator/Pluto/rpg-attributes-generator.pluto
2026-04-30 12:34:36 -04:00

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