You are tasked with writing a program that will create a nonogram puzzle (https:wikipedia.org/wiki/Nonogram) from a binary image.

You are tasked with writing a program that will create a nonogram puzzle (https://en.wikipedia.org/wiki/Nonogram) from a binary image. The image is given as a series of values between 0 and 255 from standard input (stdin). You will need to translate this input and extract the runs for each column and row from the image. Each row and column has a collection of runs and the length of each run is listed in sequence from last run to first run.

  • Width and Height are > 0
  • You need to support numbers between 0 or 255 in the image
  • The image width and height needs to match the given width and height
  • If no width and height are given the program should not attempt to read in the data
  • If an error occurs reading input from stdin the program should terminate with 1.
  • Depending on what property is associated with causing the error the relavent error message should be display. Check invalid input examples
  • In the case of invalid input it is based on first seen, So if there is two or more input that are invalid, the first one seen is what is considered the cause.
  • When the end of a file is reached an EOF character is provided. Your program should not hang after the file has been read in.

You will be given a width and height on the first line of standard input denoted like so:

6 7

Which is width and height respectively.

If we were to consider the runs on row 0 (x[0])

0 0 1 1 0 1 0 1

Output:

2 1 1

If a row or column has no runs then it has the value of 0

Example:

0 0 0 0 0 0 0

Output:

0

Sample Nonogram Input:

6 40 1 1 1 1 01 0 0 0 0 11 0 0 0 0 10 1 1 1 1 0

An example of a binary nonogram image:

(https://en.wikipedia.org/wiki/Nonogram#/media/File:Nonogram2.jpg)

This may help with understanding how nonograms work:

Example 1:

Input

6 40 1 2 2 1 01 0 0 0 0 11 0 0 0 0 10 1 1 1 1 0

Output:

X:

Show more







Calculate Your Essay Price
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 10% with the coupon code: best10