Any integer is either odd or even. An even number is a number which divides by 2 without leaving any remainder. All other numbers are odd. We can create an arithmetic that deals with addition and multiplication of odd and even numbers. For example, the sum of two even numbers will also be an even number, but the sum of an odd and an even number must be an odd number. Here is the list of all possible sums and products in this arithmetic:
EVEN + EVEN = EVEN
EVEN + ODD = ODD
ODD + ODD = EVEN
EVEN * EVEN = EVEN
EVEN * ODD = EVEN
ODD * ODD = ODD
A list of integers is chosen. For each unique pair of numbers in the list we record their sum and product. Given the final contents of String[] sums and String[] products, where each element is either "ODD" or "EVEN", return the number of odd and even numbers in the original list. The corresponding elements in sums and products are NOT necessarily calculated from the same pair of numbers. Your return must be formatted as "EVEN <x> ODD <y>" where <x> is the number of evens and <y> is the number of odds. If the original list cannot be constructed then return "IMPOSSIBLE".
|