It seems to me that if the line is, for example, 'a' * 10000, then the complexity will be 10000 * 36 where 36 is the number of letters. I think this solution is not entirely suitable for lines with a lot of repeating characters.
My advice is to break the while statemnt over several lines and add a statement that displays the result of each iteration. The patterns show what happens.
To answer the question: true until there is nothing left to replace. Then it ends.
It seems to me that if the line is, for example, 'a' * 10000, then the complexity will be 10000 * 36 where 36 is the number of letters. I think this solution is not entirely suitable for lines with a lot of repeating characters.
Lol, I tried my best to have the shortest answer possible and I almost went with this solution...
The rescue is really handy there!
Nope, this is not O(n^2). Just O(n) with a large coefficient (36, when corrected for digits).
Could you explain how this is O(n^2)?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
But its less readable. Nice trade to discuss hahaha
I feel so outmatched right about now
clever-girl.gif
My advice is to break the while statemnt over several lines and add a statement that displays the result of each iteration. The patterns show what happens.
To answer the question: true until there is nothing left to replace. Then it ends.
This comment is hidden because it contains spoiler information about the solution
I can't parse line 3. What's the condition that 'while' is checking, and what code does it execute if true?
This is amazing solution. First time in CW I meat
rescue
. I'll save this snippet. Great. Thank youYou don't need the return here :)
Loading more items...