https://github.com/petertseng/kakurasu
Kakurasu solver
https://github.com/petertseng/kakurasu
Last synced: 3 months ago
JSON representation
Kakurasu solver
- Host: GitHub
- URL: https://github.com/petertseng/kakurasu
- Owner: petertseng
- License: apache-2.0
- Created: 2017-07-09T19:48:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-03T09:58:59.000Z (over 6 years ago)
- Last Synced: 2025-01-13T03:09:59.992Z (4 months ago)
- Language: Crystal
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kakurasu
[](https://travis-ci.org/petertseng/kakurasu)
A simple Kakurasu solver.
Just iterates all columns/rows looking for subsets.
I got tired of doing these by hand.
A good source of Kakurasu puzzles is http://www.janko.at/Raetsel/Kakurasu.
# Usage
`kakurasu.cr` assumes the board is square (this assumption is not present in the code) and takes the first half of ARGV as the column sums, and the second half of ARGV as the row sums. Use `-` for undefined.
```
$ crystal build --release kakurasu.cr
$ ./kakurasu 5 6 1 2 3 7 1 2
Col 1 (6): possible (2) [[1, 2, 3], [2, 4]]. In every: [2], in none: []
5 6 1 2
3 ? ? ? ?
7 ? X ? ?
1 ? ? ? ?
2 ? ? ? ?
Col 2 (1): possible (1) [[1]]. In every: [1], in none: [2, 3, 4]
5 6 1 2
3 ? ? X ?
7 ? X . ?
1 ? ? . ?
2 ? ? . ?
Col 3 (2): possible (1) [[2]]. In every: [2], in none: [1, 3, 4]
5 6 1 2
3 ? ? X .
7 ? X . X
1 ? ? . .
2 ? ? . .
Row 0 (3): possible (1) [[]]. In every: [], in none: [1, 2]
5 6 1 2
3 . . X .
7 ? X . X
1 ? ? . .
2 ? ? . .
Row 1 (7): possible (1) [[1]]. In every: [1], in none: []
5 6 1 2
3 . . X .
7 X X . X
1 ? ? . .
2 ? ? . .
Row 2 (1): possible (1) [[1]]. In every: [1], in none: [2]
5 6 1 2
3 . . X .
7 X X . X
1 X . . .
2 ? ? . .
Row 3 (2): possible (1) [[2]]. In every: [2], in none: [1]
5 6 1 2
3 . . X .
7 X X . X
1 X . . .
2 . X . .
```# Future directions
* Instead of scanning all rows + all columns each time, only scan where anything changed in the last pass (is speedup worth the extra code?).
* Initially, could immediately eliminate large values for the small sums (speedup probably not worth the extra code?).
* Allow non-square boards in ARGV (the code probably already allows it).