![]() |
![]() |
|
home—info—labs—exams—hws
—D2L—MediaSamples/—breeze (snow day)—tutor/PIs
Consider the following problem: At a bakery, you can order either donuts, or fritters:
def test(): print( "0 donuts:" ) print( "Actual: " + str(orderPrice( "donuts", 0 )) ) print( "Desired: " + str(...) ) print( "1 donut:" ) print( "Actual: " + str(orderPrice( "donuts", 1 )) ) print( "Desired: " + str(...) ) print( "2 donuts:" ) print( "Actual: " + str(orderPrice( "donuts", 2 )) ) print( "Desired: " + str(...) ) print( "10 donuts:" ) print( "Actual: " + str(orderPrice( "donuts", 10 )) ) print( "Desired: " + str(...) ) print( "100 donuts:" ) print( "Actual: " + str(orderPrice( "donuts", 100 )) ) print( "Desired: " + str(6175) ) # 6500¢ less 5% (325¢) print( "0 fritters:" ) print( "Actual: " + str(orderPrice( "fritter", 0 )) ) print( "Desired: " + str(...) ) print( "1 fritter:" ) print( "Actual: " + str(orderPrice( "fritter", 1 )) ) print( "Desired: " + str(...) ) print( "2 fritters:" ) print( "Actual: " + str(orderPrice( "fritter", 2 )) ) print( "Desired: " + str(...) ) print( "4 fritters:" ) print( "Actual: " + str(orderPrice( "fritter", 4 )) ) print( "Desired: " + str(...) ) print( "100 fritters:" ) print( "Actual: " + str(orderPrice( "fritter", 100 )) ) print( "Desired: " + str(...) ) |
YOUR TASK:
Note: You may adjust the exact conditions to your taste, if you think that would help the result look better. In particular, the first condition is perhaps a bit too lax, to just detect high-redness!
Note: The above description is intentionally a bit high-level — e.g. “set a pixel to black” might require three statements that we've used before.
1 A pixel's brightness is the sum of its red,green,blue channels divided by three (to bring it back into the range [0,256)). ↩
home—info—labs—exams—hws
—D2L—MediaSamples/—breeze (snow day)—tutor/PIs
©2014, Ian Barland, Radford University Last modified 2014.Apr.18 (Fri) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |