Skip to content

samsvp/Blackjack-Math-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Blackjack-Math-Solver

A solver for the game "Blackjack Math"

Usage

Example 1

Let's say we have the following level:

J + -6 - A
-
3 + -A

Create a list of the numbers and letters contained in the level e.g.

numbers = ['J',-6,'A','3','-A'] # You can list the numbers as a string or as an integer

Then create a list of the operators used in each of the expressions in the level e.g.

# First expression 11 + 3 - 10
# Second expression -6 + -11
o = [['+','-'],['+']] 

In case of more than one expression then pass the join operator e.g.

# J + -6 - A
# - # <- join operator
# 3 + -A
join_op = ['-'] 

Then pass it to the solver

solve(n, o, 21, join_op)

You can also pass constants to the solver: constants -> tuple of constants to be insert and after which char. (e.g if constants is [("2",")",1)] then the number "2" will be inserted after the first ")") constant_op -> operator that precedes the constant

e.g.

solve(n, o, 21, join_op)

More complex example

Let's try an example with constants. If we have the equation

A         -K          -9
/  [/6]*   -  [4*]+    +
8         -3          -7

The numbers between "[]" are constants which we can not move. First we make a list of the number and of each operator in the expressions, as well as the operators that join the expression:

n = ['A',8,'-K',-3,-9,-7]
o = [['/'],['-'],['+']]
join_op = ['*','+']

We then list the constants giving their position and their operators. In this case we woulde do it like this:

c = [(6, 1), (4, 2)]
c_op = ['/', '*']

We then run the following line to solve the problem:

solve(n,o,21,join_op,c,c_op)

About

A solver for the game "Blackjack Math"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages