You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and the amount of money given to each person must be different in each pile.
Input: N, B1, B2, ..., BN (The amount of coins in each individual pile).
Output: NP1, NP2, ..., NPN with NP being the number of people(prime number) receiving the coins. If this is impossible then yield some unachievable result (like 0
, -1
, None
, []
, or "impossible"
) or raise an error.
Example:
3
7 8 9
Output: 7 2 3
Because 7 is the only prime number that can divide 7 evenly, the same for 8 and 2 and 9 and 3. Also, notice that (7 / 7 = 1) ≠ (8 / 2 = 4) ≠ (9 / 3 = 3).
N
is a redundant input, may we forego taking it? \$\endgroup\$0
, an empty list, a string like "impossible", or raise an error) for impossible cases? (I'd actually recommend only valid input, or allowing undefined behaviour in such cases, but it's up to you.) \$\endgroup\$[7,8,8]
it would be impossible (since using2
for both8
results in two4
s.) Furthermore, if the input were say[7,30,30]
then[7,2,2]
would be invalid but[7,2,3]
and[7,3,2]
amongst others would work. \$\endgroup\$