Probability Puzzle

john's Avatar

john

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.

John

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
  • puzzle26.zip 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

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

Recent Discussions

06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM
30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM

 

30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM
21 Jan, 2025 09:41 AM
21 Jan, 2025 09:36 AM