10
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).
2
Nis a redundant input, may we forego taking it? – Jonathan Allan – 2017-12-23T23:37:31.880May we yield some other non-achievable result (e.g.
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.) – Jonathan Allan – 2017-12-23T23:40:04.4672You may forego the input of N. And yes to the second question. – McLinux – 2017-12-23T23:41:34.437
So, the lowest prime divisor of each number? – totallyhuman – 2017-12-23T23:53:16.090
@totallyhuman not quite - if the input were say
[7,8,8]it would be impossible (since using2for both8results in two4s.) 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. – Jonathan Allan – 2017-12-24T00:01:14.487...And the lowest non-1 divisor of a number is always prime. – totallyhuman – 2017-12-24T00:02:19.250
@JonathanAllan So it's lowest non-1 divisor of each and if the list contains only unique elements. – totallyhuman – 2017-12-24T00:03:44.273
@totallyhuman no - the output for
[7,8,16]may ONLY be[7,2,2]- this list does not only contain unique elements (it's the division results that must be unique). – Jonathan Allan – 2017-12-24T00:08:32.260Why doesn't
{5, 11, 2}work for your example of 3 piles with 7, 8, and 9 coins in each? That gives 24 coins to divide up. Correct? – Edmund – 2017-12-27T22:08:09.357