This is a command-line tool that solves the Hit & Blow game.
It is a heuristic solver and does not provide a complete analytical solution.
The solving method is based on the approach by B. Landy described on page 3 of the following paper (in Japanese):
https://www.tanaka.ecc.u-tokyo.ac.jp/ktanaka/papers/gpw96.pdf
To install the CLI tool, run the following command:
go install github.com/ponyo877/hit-and-blow-solver@v1.0.1
The tool assumes a 3-digit Hit & Blow game using digits from 0-9.
If you want to change the number of digits or the range of digits, you can edit the beginning of the main
method in main.go
directly.
// main.go: main
disit := 3
numbers := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
The tool will prompt you through the following steps:
- [Automatic] A suitable guess sequence will be displayed.
- [You] Submit the guess sequence from step 1 to your opponent.
- [Automatic] A list of possible feedback options for the guess sequence will be displayed.
- [You] Select the actual feedback from your opponent.
β― hit-and-blow-solver
estimate: [6 9 8]
Use the arrow keys to navigate: β β β β and / toggles search
Feedbacks?
1H1B
0H2B
2H0B
π 1H2B
3H0B
0H3B
0H1B
1H0B
0H0B
β― hit-and-blow-solver
estimate: [5 3 2]
π 0H1B
You choose Feedback: 0H1B
estimate: [0 1 3]
π 0H2B
You choose Feedback: 0H2B
estimate: [2 5 0]
π 0H1B
You choose Feedback: 0H1B
estimate: [4 6 7]
π 1H0B
You choose Feedback: 1H0B
You win!: [3 0 7]