Question: Nonogram Maker 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

Nonogram Maker

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 0 and 1s 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 do not need to check for numbers other than 0 or 1 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])

00110101

Output:

1 1 2 (most recent is first)

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

Example:

0000000

Output:

0

Sample Nonogram Input:

6 4

011110

100001

100001

011110

Output:

X:

4

1

1

1

1

4

Y:

2

1

1

1

1

1

1

1

1

2

Example 2:

7 6

0000000

0111110

0110010

0111110

0110000

0110000

Output:

X:

0

5

1

2

5

2

2

Y:

0

5

5

1

1

1

1

3

0

If no width or height (or width and/or height are <= 0) are specified then the program should output that it cannot decode the image

Cannot decode

When a height or width is specified but the image itself doesn't match those specifications your program should output

Invalid image data

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!