Skip to content

2014-6: Roll The Dice

Write a dfn that takes an integer vector representing the sides of a number of dice and returns a 2 column matrix of the number of ways each possible total of the dice can be rolled.

Examples:

      (your_function) 6 6 ⍝ 2 six-sided dice
2 1
3 2
4 3
5 4
6 5
7 6
8 5
9 4
10 3
11 2
12 1
      (your_function) 6 4 ⍝ a six-sided and a four-sided die
2 1
3 2
4 3
5 4
6 4
7 4
8 3
9 2
10 1
      (your_function) 3 ⍝ a single 3-sided die
1 1
2 1
3 1
      (your_function) ⍬ ⍝ no dice
0 1
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub