CODE IN PYTHON In an alternate reality, chemistry Professors Hodge and Sibia have teamed up to design a chemical compound X such that when X is added to Dan’s favorite food (saltine crackers), it’ll make him despise it. For this, they are working with 6 kinds of extracts: Singleton Extracts: berries (B), green veggies (G), dairy (D) Combination Extracts: icecream (I), salad (S), and cheese sauce (C) Like regular food, mixing two extracts of the same kind will result in an extract of the same kind (eg. mixing berries B with berries B will result in berries B). Mixing two singleton extracts will result in a combination extract, using these rules: Berries (B) + Green Veggies (G) = Salad (S) Berries (B) + Dairy (D) = Icecream (I) Green Veggies (G) + Dairy (D)= Cheese Sauce (C) Mixing two combination extracts will result in a singleton extract closest to them. For example, Icecream (I) + Salad (S) is closest to Berries (B) since both Icecream and Salad extracts require using Berry extracts according to the rules above. Mixing any singleton extract with a combination extract will result in a Tasteless (T) extract. Combining the Tasteless extract with any extract will result in that extract. For example: Tasteless (T) + Salad (S) will result in Salad (S). In the lab of cool chemicals, extracts are organized into an upside-down triangle, with each row containing one fewer extract than the row above. The top row has a capital letter in each cell representing the first letter of the extract stored there. Each of the cell extracts in the next row is found by mixing the extracts in the two cells above. For example, the first cell is the result of mixing the first two cells from the row above, the second cell is the result of mixing the second and third cells from the row above, and so on. This process continues until the bottom row. Given a string of letters for the top row, output the first letter of the extract in the bottom cell as an uppercase letter. Input The first (and only) line will contain characters representing the extracts in the top row. (note: these can only be: B, G, D, I, S, and C). Output A single capital letter representing the extract in the bottom cell (B, G, D, I, S, C, or T). Sample Input 1 CBGCCSD Sample Output 1 T
CODE IN PYTHON
In an alternate reality, chemistry Professors Hodge and Sibia have teamed up to design a chemical compound X such that when X is added to Dan’s favorite food (saltine crackers), it’ll make him despise it. For this, they are working with 6 kinds of extracts:
- Singleton Extracts: berries (B), green veggies (G), dairy (D)
- Combination Extracts: icecream (I), salad (S), and cheese sauce (C)
Like regular food, mixing two extracts of the same kind will result in an extract of the same kind (eg. mixing berries B with berries B will result in berries B).
Mixing two singleton extracts will result in a combination extract, using these rules:
- Berries (B) + Green Veggies (G) = Salad (S)
- Berries (B) + Dairy (D) = Icecream (I)
- Green Veggies (G) + Dairy (D)= Cheese Sauce (C)
Mixing two combination extracts will result in a singleton extract closest to them. For example, Icecream (I) + Salad (S) is closest to Berries (B) since both Icecream and Salad extracts require using Berry extracts according to the rules above.
Mixing any singleton extract with a combination extract will result in a Tasteless (T) extract. Combining the Tasteless extract with any extract will result in that extract. For example: Tasteless (T) + Salad (S) will result in Salad (S).
In the lab of cool chemicals, extracts are organized into an upside-down triangle, with each row containing one fewer extract than the row above. The top row has a capital letter in each cell representing the first letter of the extract stored there. Each of the cell extracts in the next row is found by mixing the extracts in the two cells above. For example, the first cell is the result of mixing the first two cells from the row above, the second cell is the result of mixing the second and third cells from the row above, and so on. This process continues until the bottom row. Given a string of letters for the top row, output the first letter of the extract in the bottom cell as an uppercase letter.
Input
- The first (and only) line will contain characters representing the extracts in the top row. (note: these can only be: B, G, D, I, S, and C).
Output
A single capital letter representing the extract in the bottom cell (B, G, D, I, S, C, or T).
Sample Input 1
CBGCCSD
Sample Output 1
T
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images