Solving Math Puzzles with data.tree

I got a note from Karim Lahrichi, who even thinks about math when he’s supposed to be drinking beer. The bar puzzle they were trying to solve goes like this: Using all of the numbers 1, 3, 4, 6 exactly once, and any combination of: addition, subtraction, multiplication and division (and parenthesis to group operations however you like), arrive at the number: 24.

Sounds easy, right? Until you try to find the answer…

Luckily, he remembered the puzzle the next morning, and had a systematic go at it. He used data.tree to do a brute force solution. Read all about it on RPubs.

Based on his code, it would also be straight forward to answer such world-shaking questions as: how many different ways to combine the numbers are there? Is there more than one solution to the puzzle? If yes, how many? Why are we looking for 24, shouldn’t we rather be looking for 42?

Anyway, if you like that sort of thing, make sure you check out this post too: solving Tic-Tac-Toe.

2 thoughts on “Solving Math Puzzles with data.tree”

Leave a Reply