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

In summary: I am a nerd.In summary, the game is similar to the show Countdown where players look at license plates and try to come up with the sum of the numbers in the same order as they appear. For example, if the license plate is 212614, 2+1+2*6*1*4 would be 120. There is no solution for all the plates, but a small program could be written to check if there is one for a particular plate. There may be a better algorithm available, but I doubt it. The game could be played on either a mobile or PC, and the options for apps are many.
  • #1
uzi kiko
22
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
  • #2
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.
 
  • #3
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.
 
  • #4
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)?
 
  • #5
Thanks a lot for your answers.

The purpose of the question was mainly for my education...
 

1. What is a "not brute force algorithm"?

A not brute force algorithm refers to a method of problem-solving that does not rely on exhaustive search or trial and error. Instead, it uses a more efficient approach, often based on mathematical or logical principles, to find a solution.

2. How does a "not brute force algorithm" differ from a brute force algorithm?

A brute force algorithm involves trying every possible solution to a problem, while a not brute force algorithm uses a more strategic and targeted approach. This can lead to faster and more accurate results, especially for complex problems.

3. What are some common examples of "not brute force algorithms"?

Some common examples include sorting algorithms such as quicksort and mergesort, graph traversal algorithms like Dijkstra's algorithm, and optimization algorithms like simulated annealing. These algorithms are designed to find solutions efficiently, without going through every possible option.

4. What are the benefits of using a "not brute force algorithm"?

Using a not brute force algorithm can save time and resources, as it typically requires less computational power and can find solutions faster. It also allows for more complex problems to be solved, as brute force approaches may be impractical for larger or more complicated data sets.

5. Are there any drawbacks to using a "not brute force algorithm"?

While not brute force algorithms can be more efficient, they may also be more complex and require a deeper understanding of the problem at hand. Additionally, there is no guarantee that they will always provide the optimal solution, so it is important to carefully consider the trade-offs before choosing a specific algorithm for a problem.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Programming and Computer Science
Replies
29
Views
3K
Replies
2
Views
887
  • Programming and Computer Science
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
10
Views
4K
  • Programming and Computer Science
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
13
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top