Company: Wipro_14march
Difficulty: medium
You're given a string S of length N that holds a non-negative number V written in binary. Two kinds of steps can be applied to bring its value down: if V is odd, subtract 1 from it; if V is even, divide it by 2. These steps repeat until V reaches 0. For instance, take S = "011100", whose starting value V is 28. V evolves like this: V = 28, which is even: divide by 2 to obtain 14; V = 14, which is even: divide by 2 to obtain 7; V = 7, which is odd: subtract 1 to obtain 6; V = 6, which is even: divide by 2 to obtain 3; V = 3, which is odd: subtract 1 to obtain 2; V = 2, which is even: divide by 2 to obtain 1; V = 1, which is odd: subtract 1 to obtain 0. It took seven steps to bring V down to 0. Write a function: def solution(S) that, given a string S of N characters holding the binary form of the starting value V, returns how many steps it takes for V to reach 0. Examples: Given S = "011100", the function should return 7. String S represents the number 28, which becomes 0 after seven ope