Write a Python script for a ‘fill’ functionality.
Script reads ascii files like below:
10 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 1 1 1 0 1 1 1 0
0 0 0 0 0 1 1 1 0 0 1 1 1 0
0 0 0 0 1 1 1 0 0 1 1 1 0 0
0 0 0 1 1 0 0 0 0 1 1 0 0 0
0 0 1 1 1 0 0 0 1 1 0 0 0 0
0 0 1 1 0 1 0 0 0 1 1 1 1 0
0 0 0 1 1 1 1 1 1 1 1 1 0 0
0 0 0 0 0 1 1 0 0 0 0 0 0 0
Script outputs a filled version of the image data:
10 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 1 1 1 1 1 1 1 0
0 0 0 0 0 1 1 1 1 1 1 1 1 0
0 0 0 0 1 1 1 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 1 1 1 0 0 0
0 0 1 1 1 1 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 1 1 1 1 1 1 1 1 1 0 0
0 0 0 0 0 1 1 0 0 0 0 0 0 0
16
Where the last number is the amount of positions filled in.