0
$\begingroup$

Apple Sack Reconstruction Puzzle

Problem Statement:

You have an apple tree that can produce apples of four colors: red, yellow, green, and blue. Imagine that you collect all these apples and place them in a sack. The sack contains a total of 8 apples, and their order is important.

Now, you are given four pieces of information to help you reconstruct the original order of the apples in the sack. The given data is as follows:

From the TypeCount, we know the number of each colored apple in the original sack.

  • Number of red apples: Indicates the count of red apples in the sack.
  • Number of yellow apples: Indicates the count of yellow apples in the sack.
  • Number of green apples: Indicates the count of green apples in the sack.
  • Number of blue apples: Indicates the count of blue apples in the sack.

In addition to this data, you are also provided with the sum of the indices (IndexSum) of the apples in the original sack. The index refers to the position of the apple in the sack, starting from 0. For example, if the first apple in the original sack is green, the value of IndexSum would increment by 0 for green apples. If the second apple is blue, the value of IndexSum would increment by 1 for blue apples, and so on until the end of the sack.

Your objective is to reconstruct the original sack of apples, determining the number and order of red, yellow, green, and blue apples in the sack.

  • TypeCount = (Green: 1, Red: 2, Yellow: 1, Blue: 4)
  • indexSum = (Green: 2, Red: 12, Yellow: 4, Blue: 10)

Taking into account that the sack contains a total of 8 apples


Attribution from a comment by OP:

This question is completely original.

$\endgroup$
1
  • 2
    $\begingroup$ "A blue apple in the 4th position of the sack" doesn't quite hit the bullseye as far as real life settings for math problems go. $\endgroup$
    – Bass
    Commented Apr 21 at 20:03

1 Answer 1

3
$\begingroup$

The answer is:

BBGBYRBR

Here is how to find it:

First info we can infer is position of the green and yellow apples. Since there is one of each, their indexSum give their position, in 3rd and 5th respectively. Then we turn our attention to the red apples, for which the sum must be equal to 12. Looking at the remaining positions, the only way to make 12 as the sum of 2 numbers is by having them in 6th and 8th positions (don't forget to substract 1 to the indexes when you want to calculate the indexSum). Placing the blue apples in the remaining spots, 1st, 2nd, 4th and 7th indeed give an indexSum of 10.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.