Is there a more efficient algorithm for solving license plate math game?

  • Thread starter Thread starter uzi kiko
  • Start date Start date
  • Tags Tags
    Algorithm Force
AI Thread Summary
The discussion revolves around a family game that involves using the numbers from a car's license plate to reach a target number of 120 using basic arithmetic operations. The user seeks to create a program that can determine if a solution exists for any given license plate. While a brute force algorithm could check all possible combinations of operators and digits, the user is looking for a more efficient method. The conversation touches on programming options for different platforms, including Android and iOS, and mentions specific development environments like APDE and Pythonista. There is also a clarification needed regarding the use of parentheses in calculations, as the example provided initially led to confusion about the correct interpretation of the arithmetic operations. Overall, the focus is on finding an effective algorithm for this mathematical challenge.
uzi kiko
Messages
22
Reaction score
3
Hi
We have a family game when we are stuck in traffic similar to https://en.wikipedia.org/wiki/Countdown_(game_show)
(I know I am a nerd )

In the game we are looking at license plate of the car in front and trying to get 120 using the 4 arithmetic operators (+-*/) and the numbers in the license plate in the same order as they appear there.
For example:
If the license plate is 212614
2+1+2*6*1*4=120.

Obviously there is no solution for all the plates, but I would like to write a small program to find the solution (if exist) to check myself.

I can write a brute force algorithm that will go through all the options, but I wonder if there is a better algorithm.

Can you suggest a better solution?
 
Last edited by a moderator:
Technology news on Phys.org
I can't think of an algorithm off-hand other than trying all combinations which I think is 4^5 (1024) combinations for 6 digits/4 operators given that the digits are known.

Were you planning on doing this by PC or mobile?

Android has some apps like APDE (Android Processing Developers Environment) which could work well here. You'd be writing the app in Java on Android and running it on Android. For iOS there's Pythonista where you'd do the same but would be using Python. On the PC you could use the Processing IDe and write it in Java, Javascript or Python your choice.

There are other apps available but these are the ones I'm familiar with.
 
Better in what way? Faster?

For comparison, with 6 digits, 5 operator places and 4 operators, a simple brute force algorithm would have to check 1024 combinations which should be no problem on even very modest hardware. If you allow digits to be read as multiple digits you end up with 3125 combinations, still well within reach of brute force.
 
uzi kiko said:
I can write a brute force algorithm that will go through all the options, but I wonder if there is a better algorithm.

I'd be surprised if there were. I'm a bit confused about the rules though given your example:
2+1+2*6*1*4=120

2+1+2*6*1*4 is 51. However, (2+1+2)*6*1*4 = 120. So are you counting with any possible way of putting the brackets or do you mean something more specific (e.g., keeping a sort of running total)?
 
Thanks a lot for your answers.

The purpose of the question was mainly for my education...
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top