Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I really like this kata. I would like to suggest some edits to the instructions to make them more grammatical in English:
Problem
There are n apples that need to be divided into four piles. We need two mystery numbers x and y. Let the size of the first pile equal x+y, the size of the second pile equal x-y, the size of the third pile equal x*y, and the size of the fourth pile equal x/y. We need to calculate how many apples there are in each pile.
Of course, there won't be so many unknowns. We know the total number of apples (n) and the second mystery number (y).
For example: there are 48 apples that need to be divided into four piles. y=3. That is, the size of the 1st pile should be x+3, the size of the 2nd pile should be x-3, the size of the 3rd pile should be x*3, and the size of the 4th pile should be x/3. Do you know the value of x? x should be 9, because:
(9 + 3) + (9 - 3) + (9 * 3) + (9 / 3) = 12 + 6 + 27 + 3 = 48
So, 48 apples should be divided into 12, 6, 27, 3.
Task
Complete the function fourPiles()/four_piles() that accepts two arguments n and y, and returns an array containing the sizes of the four piles. Each element in the result array should be a positive integer. In cases where division is not possible, please return [].