Question: github.co 7. Colour trio def colour_trio (colours) : This problem was inspired by the Mathologer video Secret of Row 10. To start, assume the


github.co 7. Colour trio def colour_trio (colours) : This problem was inspired

github.co 7. Colour trio def colour_trio (colours) : This problem was inspired by the Mathologer video "Secret of Row 10". To start, assume the exis- tence of three values called "red", "yellow" and "blue". These names serve as colourful (heh) mnemonics and could as well have been 0, 1, and 2, or "foo", "bar" and "baz"; no connection to actual physical colours is implied. Next, define a rule to mix such colours so that mixing any colour with itself gives that same colour, whereas mixing any two different colours always gives the third colour. For example, mixing blue to blue gives that same blue, whereas mixing blue to yellow gives red, same as mixing yellow to blue, or red to red. Given the first row of colours as a string of lowercase letters, this function should construct the rows below the first row one row at the time according to the following discipline. Each row is one element shorter than the previous row. The i:th element of each row comes from mixing the colours in positions i and i + 1 of the previous row. Rinse and repeat until only the singleton element of the bottom row remains, returned as the final answer. For example, starting from 'rybyr' leads to 'brrb', which leads to 'yry', which leads to 'bb', which leads to 'b' for the final answer, Regis. When the Python virtual machine laughs and goes 'brrrrr', that will lead to 'yrrrr', 'brrr', 'yrr', and 'br' for the final answer 'y' for "Yes, please!" colours 'y' 'bb' 'rybyry' 'brybbr' 'rbyryrrbyrbb' 'yrbbbbryyrybb' Expected result 'y' 'b' r' r' 'y' 'b' (Today's five-dollar power word to astonish your friends and coworkers is "quasigroup".)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!