Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Problem for Programming challenge October
branch: master

This branch is 16 commits ahead of josephwilk:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


eregon’s solution to RPCFN#14: Japanese Mosaic

I use a three-state cells system, managed in a Mosaic (grid), tracking Cell changes while running the 3 algorithms.
If the algorithms cannot solve it, brute-force is used on the unknown cells.

The code use and redefine many operators, to make it short and expressive.

Japanese Mosaic Logic Puzzle

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

We will use these Examples to drive the development of your solution.

1 Prerequisites

The acceptance tests for these examples require Ruby and Cucumber.

So we need the following installed:

  1. Git (and a github account:
  2. Ruby (or JRuby whatever floats your boat)
  3. Rubygems (

2 Setup

  1. Fork my repository on Github (
  2. git clone your repository
  3. gem install bundler
  4. 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.

3 Coding

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.

4 First steps

bin/mosaic file:

#!/usr/bin/env ruby
filename = ARGV[0] # The first argument is the filename with the input table string do |f|
  string_input_table =
  input_array = string_input_table.split("\n").map{|row| row.split("|")[1..-1]}

puts “I should output the solution here.”

Something went wrong with that request. Please try again.