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 combin

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Question

Please 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 (note: these can only be: B, G, D, I, S, and C).
Sample Input 2
GDGDDDDGSB
Sample Output 2
D
Sample Input 3
CBGCCSS
Sample Output 3
Transcribed Image Text:Sample Input 2 GDGDDDDGSB Sample Output 2 D Sample Input 3 CBGCCSS Sample Output 3
Output
A single capital letter representing the extract in the bottom cell (B, G, D, I, S, C,
or T).
Sample Input i
CBGCCSD
Sample Output 1
T
Sample Output 1 Explanation
The input row we get is CBGCCSD. To generate the next row, we mix each pair of
neighbouring extracts in row 1. So our next row will be: TSTCGT (C+B, B+G, G+C,
C+C, C+S, S+D). The third row will be: SSCTG (T+S, S+T, T+C, C+G, G+T). The fourth
row will be: SGCG (S+S, S+C, C+T, T+G). The fifth row will be: TTT (S+G, G+C, C+G).
The sixth row will be: TT. And our final row will be: T.
Transcribed Image Text:Output A single capital letter representing the extract in the bottom cell (B, G, D, I, S, C, or T). Sample Input i CBGCCSD Sample Output 1 T Sample Output 1 Explanation The input row we get is CBGCCSD. To generate the next row, we mix each pair of neighbouring extracts in row 1. So our next row will be: TSTCGT (C+B, B+G, G+C, C+C, C+S, S+D). The third row will be: SSCTG (T+S, S+T, T+C, C+G, G+T). The fourth row will be: SGCG (S+S, S+C, C+T, T+G). The fifth row will be: TTT (S+G, G+C, C+G). The sixth row will be: TT. And our final row will be: T.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY