For rules and examples of the Japanese Mosaic problem you should take a look at the Cucumber acceptance tests.
If you’re not sure what Cucumber is take a quick peek here https://cukes.info/
We will use these Examples to drive the development of your solution.
The acceptance tests for these examples require Ruby and Cucumber.
So we need the following installed:
- Git (and a github account: https://github.com)
- Ruby (or JRuby whatever floats your boat)
- Rubygems (https://rubygems.org/pages/download)
- Fork my repository on Github (https://github.com/josephwilk/japanese-mosaic-logic-puzzle)
- git clone your repository
- gem install bundler
- cd japanese-mosaic-logic-puzzle && bundle install
We can now run that Cucumber specification:
cucumber features/mosaic.feature
You should be greeted with lots of fails. Right here the work starts, work your way down the scenarios getting each to pass in turn.
You have to ensure that executing “bin/mosaic” prints the solution on the command line.
The file “bin/mosaic” will be executed with a filename which will contain the input string.
bin/mosaic file:
#!/usr/bin/env ruby filename = ARGV[0] # The first argument is the filename with the input table string File.open(filename) do |f| string_input_table = f.read input_array = string_input_table.split("\n").map{|row| row.split("|")[1..-1]} end
puts “I should output the solution here.”