Statement of Completion#4e71e6a7
Fun and Puzzles
easy
Simple Nonograms in Python
Resolution
Activities
Project.ipynb
Complete the empty function below and check your activity:
In [1]:
!uname -a
Linux 8d03298f6145 6.8.0-1026-gcp #28~22.04.1-Ubuntu SMP Wed Mar 5 17:26:10 UTC 2025 x86_64 GNU/Linux
In [5]:
def nonogram_sequence(binary_array):
sequence = []
counter = 0
for num in binary_array:
if num == 1:
counter += 1
elif counter != 0:
sequence.append(counter)
counter = 0
if counter:
sequence.append(counter)
return sequence
When you're ready, use the Check Activity button to check your function.
Test the function by yourself..
In [ ]:
example_1 = [1, 1, 1, 0, 1, 1]
example_2 = [1, 0, 1, 1, 1, 1]
example_3 = [1, 1, 1, 1, 1, 1]
example_4 = [1, 0, 1, 0, 1, 1]
example_5 = [0, 0, 0, 0, 0, 0]
In [ ]:
nonogram_sequence(example_1)
In [ ]:
In [ ]:
nonogram_sequence(example_2)
In [ ]:
In [ ]:
nonogram_sequence(example_3)
In [ ]:
In [ ]:
nonogram_sequence(example_4)
In [ ]:
In [ ]:
nonogram_sequence(example_5)
In [ ]: