This chapter does not have automatically graded exercises like other ones. Instead, it includes a series of open-ended questions and prompts for further exploration.
Given two blood types like AB+ and O-, we want to determine if the first blood type can donate to the second blood type and if the second can donate to the first.
Blood that has type A antibodies (A or AB) can only be given to people with an A or AB blood type. Blood that has type B antibodies (B or AB) can only be given to people with a B or AB blood type. Blood that has type O antibodies can be given to anyone.
AB+ can donate to O-: false
O- can donate to AB+: true
Using either top-down or bottom-up design, design some functions that might be useful for solving this problem. Donβt worry about doing the math or writing code, just focus on what tasks need to get done. For each function, write:
We would like to calculate blends of HTML colors in the format #RRGGBB where RR, GG, and BB are two-digit hexadecimal numbers. (See Welcome to CS - Hex Data & Colors for more details).
Our input will be lines of text like #406000 #AAFFBB 80% that have two colors and a percentage. The percentage will describe how much of the second color to use. So #406000 #AAFFBB 80% would mean to give the color #AAFFBB 80% weight and the color #406000 20% weight. We should print a new string in the format #RRGGBB that represents the blended color.
Using either top-down or bottom-up design, design some functions that might be useful for solving this problem. Donβt worry about doing the math or writing code, just focus on what tasks need to get done. For each function, write: