Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

CorentinLeGuen/le-compte-est-bon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Le Compte est Bon algorithm with Python

What is Le Compte est Bon ?

The goal of the game is to obtain a number (between 101 and 999 included) with basic operators (Add "+", Substract "-", Multiply "*", Divide "/") on natural integers with 6 randomly taken (on this list : 1 to 10, 25, 50, 75 and 100).
We can have multiple times the same number (for example, 6 two times).
If we can't find the exact result, we should find the closest.

Example :

Numbers : 3, 100, 8, 8, 10, 6
Target : 683

Solution :
6 * 100 = 600
8 * 10 = 80
600 + 80 = 680
680 + 3 = 683

Another example :

Numbers : 3, 75, 2, 4, 1, 1
Target : 888

Solution :
75 - 1 = 74
3 * 4 = 12
74 * 12 = 888

Here is a link with game description (in french) : wikipedia article.

Algorithms

There is 3 main algorithms :

  1. Recursive solution : we take two by two the numbers, make the 4 operations on them and reiterate the process.
  2. Search with cache : same as Recursive solution but we store in cache all the calculs made. It's fast but high memory consumption.
  3. Random search : can be effective, it's just the same af Recursive solution but we make everythink randomly.

Application

Py files

To launch the program:

python3 main.py

You should have a result like this :

{'numbers': [50, 3, 7, 100, 75, 6], 'target': 592}
{'operations': ['75 - 7 = 68', '50 * 3 = 150', '150 - 68 = 82', '82 * 6 = 492', '492 + 100 = 592'], 'best': 592}

API

To launch the API:

python3 api/launch.py

You should have 4 endpoints :

  • GET / help
  • GET /new get a new random game
  • GET /solve solve a game (see /new output for this endpoint input)
  • POST /complete get a game and the solution

About

Le Compte est Bon Solver

Resources

Stars

Watchers

Forks

Languages