Amazon Online Assessment (OA) - Compare Product

The following function accepts an integer number and returns true if the product at the odd digits and the product at the even digits of number is equal; otherwise it returns false.

Examples

Example 1:

Input: 4
Output: false
Explanation: There is only one digit in 4, so the product at odd digits is 4, and the product at even digits is 0. 4 does not equal to 0.

Example 2:

Input: 2421
Output: true
Explanation: The product at odd digits is 4 * 1 = 4, and the product at even digits is 2 * 2 = 4. They are equal.

The current implementation of the function compiles successfully but does not return the correct result consistently. Please fix the code so that it passes all test cases.

Try it yourself

Solution

Title

Script

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

  >>> a = [1, 2, 3]
  >>> a[-1]
  3

Get premium for instant access to all content and solutions

Upgrade