What is the level 3 Google Foobar challenge?
Not even to mention finding a solution yet. It’s already difficult to understand the problem. There are 3 challenges at this level. The time is still the same. And I’m starting to get paranoid!
readme.txt:
challenge I  Doomsday Fuel:
Making fuel for the LAMBCHOP’s reactor core is a tricky process because of the exotic matter involved. It starts as raw ore, then during processing, begins randomly changing between forms, eventually reaching a stable form. There may be multiple stable forms that a sample could ultimately reach, not all of which are useful as fuel.
Commander Lambda has tasked you to help the scientists increase fuel creation efficiency by predicting the end state of a give n ore sample. You have carefully studied the different structures that the ore can take and which transitions it undergoes. It appears that, while random, the probability of each structure transforming is fixed. That is, each time the ore is in 1 state, it has the same probabilities of entering the next state (which might be the same state). You have recorded the observed transitions in a matrix. The others in the lab have hypothesized more exotic forms that the ore can become, but you haven’t seen all of them.
Write a function solution(m) that takes an array of array of nonnegative ints representing how many times that state has gone to the next state and return an array of ints for each terminal state giving the exact probabilities of each terminal state, represented as the numerator for each state, then the denominator for all of them at the end and in simplest form. The matrix is at most 10 by 10. It is guaranteed that no matter which state the ore is in, there is a path from that state to a terminal state. That is, the processing will always eventually end in a stable state. The ore starts in state 0. The denominator will fit within a signed 32bit integer during the calculation, as long as the fraction is simplified regularly.
For example, consider the matrix m:


So, we can consider different paths to terminal states, such as:


Tracing the probabilities of each, we find that


So, putting that together, and making a common denominator, gives an answer in the form of
[s2.numerator, s3.numerator, s4.numerator, s5.numerator, denominator]
which is[0, 3, 2, 9, 14]
.


challenge II  The Grandest Staircase Of Them All:
With the LAMBCHOP doomsday device finished, Commander Lambda is preparing to debut on the galactic stage – but in order to make a grand entrance, Lambda needs a grand staircase! As the Commander’s personal assistant, you’ve been tasked with figuring out how to build the best staircase EVER.
Lambda has given you an overview of the types of bricks available, plus a budget. You can buy different amounts of the different types of bricks (for example, 3 little pink bricks, or 5 blue lace bricks). Commander Lambda wants to know how many different types of staircases can be built with each amount of bricks, so they can pick the one with the most options.
Each type of staircase should consist of 2 or more steps. No two steps are allowed to be at the same height  each step must be lower than the previous one. All steps must contain at least one brick. A step’s height is classified as the total amount of bricks that make up that step.
For example, when N = 3, you have only 1 choice of how to build the staircase, with the first step having a height of 2 and the second step having a height of 1: (# indicates a brick)
2  1 

#  
#  # 
When N = 4, you still only have 1 staircase choice:
3  1 

#  
#  
#  # 
But when N = 5, there are two ways you can build a staircase from the given bricks. The two staircases can have heights (4, 1) or (3, 2), as shown below:
4  1 

#  
#  
#  
#  # 
3  2 

#  
#  # 
#  # 
Write a function called solution(n) that takes a positive integer n and returns the number of different staircases that can be built from exactly n bricks. n will always be at least 3 (so you can have a staircase at all), but no more than 200, because Commander Lambda’s not made of money!


challenge III  Fuel Injection Perfection:
Commander Lambda has asked for your help to refine the automatic quantum antimatter fuel injection system for the LAMBCHOP doomsday device. It’s a great chance for you to get a closer look at the LAMBCHOP – and maybe sneak in a bit of sabotage while you’re at it – so you took the job gladly.
Quantum antimatter fuel comes in small pellets, which is convenient since the many moving parts of the LAMBCHOP each need to be fed fuel one pellet at a time. However, minions dump pellets in bulk into the fuel intake. You need to figure out the most efficient way to sort and shift the pellets down to a single pellet at a time.
The fuel control mechanisms have three operations:
 Add one fuel pellet
 Remove one fuel pellet
 Divide the entire group of fuel pellets by 2 (due to the destructive energy released when a quantum antimatter pellet is cut in half, the safety controls will only allow this to happen if there is an even number of pellets)
Write a function called solution(n) which takes a positive integer as a string and returns the minimum number of operations needed to transform the number of pellets to 1. The fuel intake control panel can only display a number up to 309 digits long, so there won’t ever be more pellets than you can express in that many digits.
For example:
 solution(4) returns 2:
4 > 2 > 1
 solution(15) returns 5:
15 > 16 > 8 > 4 > 2 > 1


How did I solve the level 3 Google Foobar challenge?
challenge I  Doomsday Fuel:
Do you understand the challenge? I’m not š
How would it be in this infinity loop case:
s0 > s1 > s0 > s1 > s0 > s1 > .... > s0 > s1 ....
or we don’t need to list them all? Not being able to list all the possible cases is the purpose of the challenge? I don’t know. š
I know this challenge is related to Markov Chains:
 Thailand Islands is a Markov Chains math example.
 But it’s not similar to our challenge:
 Thai Islands example has a limit:
3day trip
 Our challenge isn’t
 Maybe I should dig into Markov chains examples
 Thai Islands example has a limit:
 But it’s not similar to our challenge:
 Thailand Islands is a Markov Chains math example.
Shit, this challenge is too much math, I’m not a math junkie. I ended this pain by copying from this source instead š³ļø
challenge II  The Grandest Staircase Of Them All:
After going through the pain of the previous challenge, I was like a girl who lost her virginity. Looking for the answer no longer makes me torment myself. So I did it again secretly with Mr. Google Search. Then the submitted code was the result of a sneaky love affair. I renamed the variables to make it appear that the code is my own with Google Foobar. But actually, poor Google Foobar has been cuckolded by me, this result is the biological son of his brother. š
challenge III  Fuel Injection Perfection:
Seems to realize that the relationship is about to fall apart. Google Foobar seems gentler to me than he used to be. So I decided to play with him again.
I thought the recursive
position would make both of us happy, I tried this pose with Google Foobar, but sadly we don’t get along.
Google Foobar wants skill, I only have strength. The fun thus quickly ended with a RecursionError: maximum recursion depth exceeded
error.
Sad that my needs weren’t met, I returned to Mr. Google Search.
He knew his brother very well, then he taught me this trick to make Google Foobar happy.


solution.py:
challenge I  Doomsday Fuel:


challenge II  The Grandest Staircase Of Them All:


challenge III  Fuel Injection Perfection:

