Input blood type: "B+" Input list of available blood types: ["A-", "B+", "AB+", "O+", "B+", "B-"] Output survivability: True
You will learn about: blood types and complex branching statements
Each person has different blood depending on which antibodies and antigens bind to the surface of their red blood cells. They can be categorized in many different ways, but the two most important are the ABO group system (with four groups: A, B, AB, O) and the Rh blood group system (with two groups: +, -). The chart below shows how you can determine whether blood is suitable for transfusion.
Hospitals have blood banks that collect blood donations and store them until they're needed by patients. Every time a patient needs a blood transfusion, the hospital needs to check that they have some suitable blood that can be accepted by the patient's body. Given a patient's blood type and a list of available blood types figure out if the patient will survive.
Input: The person's blood type as a string, and a list of strings with available blood types.
Output: True if the person can be saved, and false otherwise.
|Maximum runtime||60 s||Max. memory usage||250 MiB|
|Function signature||survive(blood_type, available_blood_types)|
Write a function that accepts the input as function parameters and returns the correct output. Make sure to read the description above to produce the correct output in the correct format and use the correct function signature so we can run your code. A good first step is to try reproducing the example(s). Your code must not take longer than the maximum runtime to run and must not use more memory than the allowed limit.
You must be logged in to view your submissions.
Let us know what you think about this problem! Was it too hard? Difficult to understand? Also feel free to discuss the problem, ask questions, and post cool stuff on Discourse. You should be able see a discussion thread below. Feel free to post your solutions but if you do please organize and document your code well so others can learn from it.