RPG attributes generator: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Extracted constants, added names.)
m (→‎{{header|zkl}}: formatting)
Line 467: Line 467:
attrs.clear();
attrs.clear();
do(6){
do(6){
abcd:=(4).pump(List(),(0).random.fp(1,7)); // list of 4 [1..6] randoms
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
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);
}while((S=attrs.sum(0))<75 or (N=attrs.filter('>=(15)).len())<2);
println("Random numbers: %s\nSum to %d, number over 15: %d"
println("Random numbers: %s\nSums to %d, with %d >= 15"
.fmt(attrs.concat(","),S,N));</lang>
.fmt(attrs.concat(","),S,N));</lang>
{{out}}
{{out}}
<pre>
<pre>
Random numbers: 16,16,13,14,16,11
Random numbers: 15,15,7,17,10,13
Sum to 86, number over 15: 3
Sums to 77 with 3 >= 15
</pre>
</pre>