How to Get Away with Candy Hoarding

Logic Level 4

There are 9 houses in Spookytown which gives out candies to children for Trick or Treat. Each house gives a distinct number of candies, such that the number of candies the houses give form a consecutive progression. That is, if one house gives 42 candies, another gives 43, and so on.

Four children, Wes, Michaela, Laurel, and Connor went to ask for candies at this village. Each went to four houses. Surprisingly, each of the children went and asked for candies in such fashion:

  1. No two children went to the same four houses.

  2. No child went to a house that gave candies whose number was 1 more or 1 less to the house that gave them before.

  3. No house gave out candies more than twice.

Meanwhile, Asher the bully was waiting for these kids to get their candies so that he could hoard them all. Wes, having the most candies, received 112. If the house giving the most and the house giving the second least number of candies were only visited once, how many candies will Asher have all in all?


The answer is 431.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Nguyen Minh
Nov 17, 2020

Let denote the candies each house give equal to a a , a + 1 a+1 , .... , a + 8 a+8 .

A house can be visited twice at most and the 2 houses a + 8 a+8 and a + 1 a+1 are only visited once each only. 4 kids will visit 9 houses for a total of 16 times. However, we observe that if the maximum number of visits to the 7 houses a a , a + 2 a+2 , a + 3 a+3 , a + 4 a+4 , a + 5 a+5 , a + 6 a+6 , a + 7 a+7 is 2 7 = 14 2*7 = 14 , plus 2 for house a + 8 a+8 and a + 1 a+1 which is 16. Hence, all the houses a a , a + 2 a+2 , a + 3 a+3 , a + 4 a+4 , a + 5 a+5 , a + 6 a+6 , a + 7 a+7 are visited twice each.

Therefore, the total number of candies is a 2 + ( a + 1 ) + ( a + 2 ) 2 + ( a + 3 ) 2 + ( a + 4 ) 2 + ( a + 5 ) 2 + ( a + 6 ) 2 + ( a + 7 ) 2 + ( a + 8 ) = 16 a + 63 a*2 + (a+1) + (a+2)*2 + (a+3)*2 + (a+4)*2 + (a+5)*2 + (a+6)*2 + (a+7)*2 + (a+8) = 16a+63

The number of candies that Wes have is 4 a + x 4a + x where x x is the sum of 4 distinct numbers picked from 0 to 8. That also means, x must be divisible by 4 since 112 is divisible by 4.

Each kid will visit 4 houses, and the difference between the numbers of candies each house give must be larger than 1. Given that the lowest number of candies the kid received is a + t a + t , then the the second least number of candies he/she also receives should be at least a + t + 2 a + t+2 , the third least should be at least a + t + 4 a + t+4 and the most should be at least a + t + 6 a + t+6 .

Hence, a kid will receive 4 a + 4 t + 12 4 a + 12 4a + 4t + 12 \geq 4a + 12 candies. The maximum number of candies a kid can receive can be found to be ( a + 8 ) + ( a + 6 ) + ( a + 4 ) + ( a + 2 ) = 4 a + 20 (a+8) + (a+6) + (a+4) + (a+2) = 4a+20 . The number of candies that Wes can take, therefore, can only be 4 a + 16 4a+16 or 4 a + 20 4a+20 .

If Wes takes only 4 a + 16 4a+16 candies, then the maximum total number of candies is 4 a + 16 + ( 4 a + 15 ) 3 = 16 a + 61 4a+16 +(4a+15)*3 = 16a+61 , which is smaller than our total number of candies 16 a + 63 16a+63 .

Therefore, Wes has 4 a + 20 4a+20 candies

To prove that 4a + 20 is the right number of candies for Wes, we can find the houses each kid visits as below.

Wes a+8 a+6 a+4 a+2
Connor a+6 a+4 a+2 a
Laurel a+7 a+5 a+3 a+1
Michaela a+7 a+5 a+3 a

We have 4 a + 20 = 112 a = 23 4a+20 = 112 \Rightarrow a = 23

16 a + 63 = 431 \Rightarrow 16a+63 = 431

Asher takes 431 candies in total
Jonas Mantek
May 27, 2019

In isolation, there are 15 ways that a child could visit four houses without visiting two adjacent houses, or the same one twice. I expressed the paths as length-9 arrays and randomly added four of them together repeatedly in python, finding only one combination that adds up to one visit to houses 2 and 9, and two visits to each other house: c 0 : [ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 ] c0: [1, 0, 1, 0, 1, 0, 1, 0, 0] c 1 : [ 1 , 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ] c1: [1, 0, 0, 1, 0, 1, 0, 1, 0] c 2 : [ 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ] c2: [0, 1, 0, 1, 0, 1, 0, 1, 0] c 3 : [ 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ] c3: [0, 0, 1, 0, 1, 0, 1, 0, 1]

You can then consider that the houses each have the lowest candy value x plus i, where i is the index of the house (0 to 8). Hence, each path has the value of 4x plus the dot product of the path vector and [0, 1, ... , 8]. The dot products are: [ 12 , 15 , 16 , 20 ] [12, 15, 16, 20] , and we know that the highest amount of candy is 112, therefore: 112 = 4 x + 20 112 = 4x + 20 x = 23 x = 23 Using this, one can just add 16x to the above values, making the total 431.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...