Project

nonograms

0.0
No release in over 3 years
Low commit activity in last 3 years
solve the puzzle game nonograms.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.10.0
 Project Readme

Nonograms

Solve the puzzle game nonograms.

Installation

Add this line to your application's Gemfile:

gem 'nonograms'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nonograms

Usage

For example:

          2           1
      1   1   1       1
    +---+---+---+---+---+
  1 |   |   |   |   |   |
    +---+---+---+---+---+
2 1 |   |   |   |   |   |
    +---+---+---+---+---+
  1 |   |   |   |   |   |
    +---+---+---+---+---+
1 1 |   |   |   |   |   |
    +---+---+---+---+---+

We should get result

          2           1
      1   1   1       1
    +---+---+---+---+---+
  1 |   | # |   |   |   |
    +---+---+---+---+---+
2 1 |   | # | # |   | # |
    +---+---+---+---+---+
  1 | # |   |   |   |   |
    +---+---+---+---+---+
1 1 |   | # |   |   | # |
    +---+---+---+---+---+

in line result should be "01000"+"01101"+"10000"+"01001"

You can solve this example when you write the code below

> require "nonograms"

> vertical = [[1], [2, 1], [1], [], [1, 1]]
> horizontal = [[1], [2, 1], [1], [1, 1]]
> @nonograms = Nonograms.new(horizontal, vertical)
> @nonograms.solve #=> ["01000"+"01101"+"10000"+"01001", ...]

Check whether entered data are properly

> @nonograms.properly_data_entered? #=> true

Display result on the console

> @nonograms.display

#=> result: 0
#=>      1 2 1   1
#=>        1     1
#=>      ----------
#=> 1   |  ■
#=> 2 1 |  ■ ■   ■
#=> 1   |■
#=> 1 1 |  ■     ■

#=> result: 1
#=>      1 2 1   1
#=>        1     1
#=>      ----------
#=> 1   |  ■
#=> 2 1 |■ ■     ■
#=> 1   |    ■
#=> 1 1 |  ■     ■