We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Note that the function should never invoke KillTheWorld function.
I don't see how it won't, given the example input, unless you're lucky enough to not get way = 1.
At the start, energy = 0, because that's what we pass in.
If way = 1, score is added to.
Then it checks if energy > 0, which it is not.
So we will invoke the "KillTheWorld" function.
What am I missing?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Robot
You are viewing a single comment's thread. Return to all comments →
I don't see how it won't, given the example input, unless you're lucky enough to not get way = 1. At the start, energy = 0, because that's what we pass in. If way = 1, score is added to. Then it checks if energy > 0, which it is not. So we will invoke the "KillTheWorld" function.
What am I missing?