RosettaCodeData/Task/RPG-attributes-generator/Zkl/rpg-attributes-generator.zkl
2023-07-01 13:44:08 -04:00

10 lines
371 B
Text

reg attrs=List(), S,N;
do{
attrs.clear();
do(6){
abcd:=(4).pump(List,(0).random.fp(1,7)); // list of 4 [1..6] randoms
attrs.append(abcd.sum(0) - (0).min(abcd)); // sum and substract min
}
}while((S=attrs.sum(0))<75 or (N=attrs.filter('>=(15)).len())<2);
println("Random numbers: %s\nSums to %d, with %d >= 15"
.fmt(attrs.concat(","),S,N));