https://github.com/jsok/symbolsum-solver
SymbolSum newspaper problem solver
https://github.com/jsok/symbolsum-solver
Last synced: about 1 year ago
JSON representation
SymbolSum newspaper problem solver
- Host: GitHub
- URL: https://github.com/jsok/symbolsum-solver
- Owner: jsok
- Created: 2013-01-29T00:36:42.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-02-09T03:54:16.000Z (over 13 years ago)
- Last Synced: 2025-01-30T03:15:19.289Z (over 1 year ago)
- Language: Python
- Size: 652 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
SymbolSum Solver
================
I haven't figured out how to do these by hand yet, but who cares, let Python do
the job!
Problem
-------
You are given an arithmetic problem where the numbers have been replaced with
symbols. Your job is to determine the number values of the symbols.
The numbers are single digits, i.e. [0-9] and all unique.

Usage
-----
For the above problem, enter it as:
```
# List of symbols that appear in the problem
all_symbols = ['star', 'circle', 'hexagon', 'plus', 'triangle']
# Direct translation of symbols
# If you know a number, e.g. 0, leave it in and it will help speed things up
operand1 = [ 'triangle', 'plus', 'plus', 'hexagon', 'hexagon' ]
operand2 = [ 0, 'plus', 'star', 'circle', 'star' ]
result = [ 'star', 'circle', 'hexagon', 'circle', 'star' ]
# Instatiate a SymbolSumSolver
solver = SymbolSumSolver(all_symbols)
# You can use the operator's in the standard python operator module
import operator
solver.solve(operand1, operator.sub, operand2, result)
```
Output:
```
Found 1 solutions:
53388
- 03494
49894
Therefore: {'plus': 3, 'circle': 9, 'hexagon': 8, 'triangle': 5, 'star': 4}
```