# Probability Puzzle

Just for fun I used NodeBox to answer the following puzzle, posed on Quora:

**There is a game where you draw 7 numbers. In total there are 36 numbers, which are six ones, six twos, six threes, till six sixes. What are the chances for you to draw a sum of numbers greater or equal to 26?**

This is a bit tricky to figure out. There are 36 choose 7 = 8,347,680 different ways of drawing those 7 numbers (where the order of the 7 numbers doesn't matter). Those 7 numbers can wind up in 786 different forms that sum to totals ranging from 8 to 41. For any one of these forms there are many different ways of drawing the pattern.

For example, if you draw four 2s, two 3s, and a 4 the total sums to 18. But there are 6 choose 4 = 15 different ways of drawing four 2s from the six 2s available. And 15 ways of drawing two of the six 3s. And 6 different 4s you could draw. So there are 15 x 15 x 6 = 1350 different ways of drawing that 2222334 pattern.

This puzzle gave me a chance to use MANY of my library nodes including:

- n_choose_k
- distribution
- concat_list
- products
- percentage
- change_col
- draw_table

The final answer is there are 3,388,062 different ways of drawing numbers that sum to 26 or more, for an overall chance of 40.5869%

Solving puzzles like this is what I call a PONARV, a Project Of No Apparent Redeeming Value. It demonstrates that Nodebox is not just for drawing pictures; you can also use it to think carefully through tricky math problems. Most importantly, I enjoyed making it!

Screenshot and code attached.

John

- puzzle26_screenshot.png 982 KB
- puzzle26.zip 301 KB

# Keyboard shortcuts

### Generic

? | Show this help |
---|---|

ESC | Blurs the current field |

### Comment Form

r | Focus the comment reply box |
---|---|

^ + ↩ | Submit the comment |

You can use `Command ⌘`

instead of `Control ^`

on Mac