Talk:Seven-sided dice from five-sided dice: Difference between revisions

Content added Content deleted
(→‎J solution seems ugly: instructive version)
m (→‎J solution seems ugly: simplify code)
Line 30: Line 30:
dice5=: [: >: ] ?@$ 5: NB. makes a y shape array of 5s, "rolls" the array and increments.
dice5=: [: >: ] ?@$ 5: NB. makes a y shape array of 5s, "rolls" the array and increments.
rolltwice=: [: dice5 2 ,~ ] NB. rolls dice5 twice for each desired dice7 roll (y rows, 2 cols)
rolltwice=: [: dice5 2 ,~ ] NB. rolls dice5 twice for each desired dice7 roll (y rows, 2 cols)
base5to10=: 5&#.@:<: NB. decrements and converts rows from base 5 to 10
base5to10=: 5 #. <: NB. decrements and converts rows from base 5 to 10
keepgood=: #~ 21&> NB. compress out values not less than 21
keepgood=: #~ 21&> NB. compress out values not less than 21
groupsof3=: [: >. >: % 3: NB. increments, divides by 3 and takes ceiling
groupsof3=: [: >. >: % 3: NB. increments, divides by 3 and takes ceiling