|Programming Project 2|
First, we re going to write a function to check when a pixel is inside the image of a number. Since we want to
keep this project simple, we'll use very small 3x4 images, and think of them as grids. We'll say that a grid is made up
of tiles. The
We will define the five images of the numbers "one" through "five" as the following:
IMPORTANT: To make this problem more reasonable than just using a "brute force" algorithm (which would require more code and potentially take much longer to write), and to practice some of the boolean logic constructs we've discussed, your code should not use more than four boolean operators with any conditional statement. For example, the following conditional:
uses the maximum four boolean operators allowed (and, or, or, and).
This conditional conditional:
uses five boolean operators, and is disallowed.
Remember that simply putting operators on different lines in python (we have not learned how to do this, but it is possible), does NOT count as reducing the number of operators, as your conditional still requires the same amount of operators. In addition, your function should be less than 25 lines of code, otherwise it's easy to just brute-force the solution.
For the second function, we're going to write a very specific function to identify empty pixels for just the number three.
How do you know what other shapes of three look like? Here are some rules:
checkTileand one test case of
isEmptyOnThree. Each test case is two lines long: the first line contains the name of the function, followed by a space, followed by all of the arguments to the function, each separated by a single space, and terminated by a newline. Then, on the next line, you should provide the expected answer for that function call, terminated by a newline. In your tests, make sure you include spaces where they need to be, otherwise they will not pass on Marmoset. Make sure to include a newline (blank line) after your last test case.
project2.py(and remember the link to the template for this file above).
returnstatement to get your functions to return a value - DO NOT use the
Please log in again to view this part of the page.
ywhen you run the driver.