Skyscraper Solver solves skyscraper puzzle using Breadth-First Search and Exhaustive Search Algorithm.
Breadth-First Search algorithm is implemented inside process
function using queue.
Exhaustive Search Algorithm is implemented inside exhaustive_scan
function using recursion.
- Ruby 3.1.2
- Bundler 2.3.20
bundle install
bundle binstub --all
TBD
This program receives clues in an array of size
* 4 items. The clues are in the array around the clock. This program outputs the solution in an array of size
* size
items to stdout
. For more detailed explanation read this codewars kata article.
main.rb <input_file.txt>
for example:
ruby main.rb input/4x4.sample.txt
ruby main.rb input/6x6.sample.txt
4x4.sample.txt
4
4 3 2 1 1 2 2 2 2 2 2 1 1 2 3 4
4x4.sample.txt
output
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
Solved in 1 iteration(s)
6x6.sample.txt
6
0 0 0 2 2 0 0 0 0 6 3 0 0 4 0 0 0 0 4 4 0 3 2 2
6x6.sample.txt
output
5 6 1 4 3 2
4 1 3 2 6 5
2 3 6 1 5 4
6 5 4 3 2 1
1 2 5 6 4 3
3 4 2 5 1 6
Solved in 3 iteration(s)
This program has 100% test coverage, which you can check by running:
bin/rspec
open coverage/index.html
You need to install dependencies first, then run this:
bin/rubocop lib spec -A