Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 6.2: By now, hopefully you were able to produce the pixel drawing from a given 2D List. This question is about trying to perform
Question 6.2: By now, hopefully you were able to produce the pixel drawing from a given 2D List. This question is about trying to perform it backwards! If you haven't completed the previous part don't worry - you can still work on this problem separately, as it is not dependent on the previous part. The same rules as the previous part apply for this question. This time your function will receive a pixel image in the form of a single string. Each line of the input string will be separated by a new line character ' ', as mentioned in the previous part. Your task in this function is to return the encoded 2D List that represents the pixel art. Notice that here you do not have to write the 2D List into a file, you should just return it. Note: If pixel ', return an empty list [ ]. Example >>> pixel0="0 00 0000 00 0\ " #Sequence: B W BB W BBBB W BB W B >>> pixel_to_matrix(pixel0) [ [0, 1, 1, 2, 1, 4, 1, 2, 1, 1] >>> pixel1="o 00\ O O" #Sequence: B W BB W B WB >>> pixel_to_matrix(pixel1) [ [0, 1, 1, 2] [1, 1, 1, 1] ] Hint: A quick way of validating your result: every row of your matrix should add up to the same value
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started