Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

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
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question