Nonogram Encode
I believe you love the picture logic puzzles called nonograms and have solved many of them. This mission is the opposite: you already have a binary image, formed by strings of equal length, where a background empty cell contains whitespace and a picture cell contains 'X'.
Your goal is to create a nonogram based upon the image: write number clues for solving the image like it was hidden. Your function
should return a list of two lists. The first one consists of
lists with numbers for the columns' clues and the second one
contains the same for the rows' clues. All lists of the columns' clues, as well as of
the rows' clues, should be of the same 'depth' (complemented with 0). Let's see an example:
example = [' X X ', 'X X X', ' X X ']Example with solution to see the whole idea:
columns clue 01010 11111 rows clue 0 1 1 ' X X ' 1 1 1 'X X X' 0 1 1 ' X X 'So, for this example your function should return the following:
result = [[[0, 1, 0, 1, 0], [1, 1, 1, 1, 1]], [[0, 1, 1], [1, 1, 1], [0, 1, 1]]] # the same, non formatted view [[[0, 1, 0, 1, 0], [1, 1, 1, 1, 1]], [[0, 1, 1], [1, 1, 1], [0, 1, 1]]]
Input: List of strings.
Output: List of 2 lists.
Examples:
assert nonogram_encode([" X X ", "X X X", " X X "]) == [ [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1]], [[0, 1, 1], [1, 1, 1], [0, 1, 1]], ] assert nonogram_encode(["X"]) == [[[1]], [[1]]]
How it’s used: Helps you when you decide to create your own type of picture logic puzzle.
Preconditions:
- len(data[i]) == len(data[0]);
- set(data[i]) == set([' ', 'X']);
- for lists in output: len(list[i]) == len(list[0]).
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
checkio sync
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.