Probability Puzzle

john's Avatar


23 Feb, 2024 10:02 AM

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.


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • puzzle26_screenshot.png 982 KB
  • 301 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? 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

Recent Discussions

23 Apr, 2024 07:54 PM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM
16 Apr, 2024 04:23 AM
08 Apr, 2024 01:28 AM


07 Apr, 2024 11:50 PM
05 Apr, 2024 11:47 PM
05 Apr, 2024 12:30 AM
25 Mar, 2024 08:48 PM
14 Mar, 2024 07:40 PM
14 Mar, 2024 07:38 PM