An open API service indexing awesome lists of open source software.

https://github.com/grahammitchell/digits-game-solver

Solver for the NYTimes math puzzle Digits
https://github.com/grahammitchell/digits-game-solver

Last synced: 11 months ago
JSON representation

Solver for the NYTimes math puzzle Digits

Awesome Lists containing this project

README

          

# digits-game-solver

A solver for the NY Times daily math puzzle game [Digits](https://www.nytimes.com/games/digits), currently in beta at time of writing.

Let's say we want to try to compute 69 using the numbers 1, 3, 4, 5, 10 and 25:

```
% ./digits-game-solver.py 69 1 3 4 5 10 25
(- (* 10 (+ 5 4)) (- 25 (+ 3 1)))
(+ (- (* 10 (+ 5 4)) 25) (+ 3 1))
(- (+ (* 10 (+ 5 4)) (+ 3 1)) 25)
... 2000+ more solutions omitted ...
(- (- (* (- 25 10) 5) 4) (- 3 1))
(- (+ (- (* (- 25 10) 5) 4) 1) 3)
(+ (- (- (* (- 25 10) 5) 4) 3) 1)

Shortest is: (- (* 10 (+ 4 3)) 1)
```

Works pretty fast but for some reason lists the same solution multiple times:

```
% ./digits-game-solver.py 69 1 3 4 5 10 25 | wc -l
2463

% ./digits-game-solver.py 69 1 3 4 5 10 25 | sort | uniq | wc -l
972
```

Recursion is hard. 🤷