DIGIT - EDITORIAL

Difficulty: Easy - Medium

Pre-requisites: String manupulation, Digits manupulation

Problem link:

Contest problem link

Practice problem link

Problem:

Given two numbers of equal length, and an operator (either multiplication or divison), output the number % 10 for each position of the input numbers in words.

Explanation:

Two numbers, A and B are given, both of equal length. From both the numbers pick the left most digit, which can be done by performing the following operation:

x=A/10log10(A)

y=B/10log10(B)

perform the required operation on x and y and output the result in words. Repeat the procedure on the next digit to the right till the last digit is reached.

An easier approach is to store the numbers A and B in strings. Fetch the element at index A.length() and B.length(), perform the operation on both of them. Repeat the procedure for the next element to the right till the last element is reached.

Problem setter’s solution: SOLUTION

//