Company: Goldman Sachs OA
Difficulty: medium
Binary Conversion from Even-Odd Pattern Write a program that reads a numeric string nstr as input, generates a binary number by replacing the digits which are even with \'1\' and the digits which are odd with \'0\', and then prints the decimal equivalent of the resulting binary number. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings anywhere in the program, as these contribute to the standard output, and test cases will fail. Constraints Length of the numeric string nstr <= 25 Only numeric digits are allowed in nstr. Input Format A single line of input contains a numeric string nstr. Output Format A single output line should contain an integer denoting the decimal equivalent of the binary number. Examples Sample Test Case 1 Input: 232466 Output: 47 Explanation: Given numeric string nstr is \"232466\" For each digit in the given nstr: If the digit is even (0, 2, 4, 6, 8), it is replaced with \'1\' If the digit is odd (1, 3, 5, 7, 9), it is rep