Q3: Cool Chemicals In an alternate reality, chemistry Professors Hodge and Sibia have teamed up to design a chemical compound X such that when Xis 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 (0) • Combination Extracts: icecream (1), salad (5), 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 8 with berries B will result in berries 8). Mixing two singleton extracts will result in a combination extract, using these

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Help for number 3?

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 (3, 6, D, 1, S, C, or
T).
Sample Input 1
CBGCCSD
Sample Output 1
T
Sample Output 1 Explanation
The input row we get is ceGCCso. To generate the next row, we mix each pair of
neighbouring extracts in row 1. So our next row will be: TSTCGT (C+3, 8+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.
Sample Input 2
GDGDDDDGSB
Sample Output 2
D
Sample Input 3
CBGCCSS
Sample Output 3
Transcribed Image Text: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 (3, 6, D, 1, S, C, or T). Sample Input 1 CBGCCSD Sample Output 1 T Sample Output 1 Explanation The input row we get is ceGCCso. To generate the next row, we mix each pair of neighbouring extracts in row 1. So our next row will be: TSTCGT (C+3, 8+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. Sample Input 2 GDGDDDDGSB Sample Output 2 D Sample Input 3 CBGCCSS Sample Output 3
Q3: Cool Chemicals
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 (0)
Combination Extracts: icecream (1), 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 e will result in berries 8).
Mixing two singleton extracts will result in a combination extract, using these
rules:
• Berries (3) + Green Veggies (G) = Salad (s)
• Berries (3) + Dairy (D) = Icecream (1)
• Green Veggies (G) + Dairy (0)= Cheese Sauce (c)
Mixing two combination extracts will result in a singleton extract closest to them.
For example, Icecream (1) + Salad (5) is closest to Berries (3) 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.
Filename
Your filename for this question must be q3. py.
Transcribed Image Text:Q3: Cool Chemicals 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 (0) Combination Extracts: icecream (1), 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 e will result in berries 8). Mixing two singleton extracts will result in a combination extract, using these rules: • Berries (3) + Green Veggies (G) = Salad (s) • Berries (3) + Dairy (D) = Icecream (1) • Green Veggies (G) + Dairy (0)= Cheese Sauce (c) Mixing two combination extracts will result in a singleton extract closest to them. For example, Icecream (1) + Salad (5) is closest to Berries (3) 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. Filename Your filename for this question must be q3. py.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Lower bounds sorting algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education