Error in example at Problem 60

Back to General discussions forum

MPadilla     2016-07-04 06:25:25
User avatar

Shouldn't the sweet count for the first case of the example input data be 47 instead of 48?

Quandray     2016-07-04 09:34:36
User avatar

11 + 17 + 13 + 7 = 48

MPadilla     2016-07-04 20:30:49
User avatar

Thanks.

This modifies my approach to the problem, as I initially thought of it as just evaluation the next two possible outcomes. Any reading to give me a hint on the reasoning for this?

mooninvader     2017-12-24 19:39:38

must he start at the first isle or can he begins at the second??

mooninvader     2017-12-24 19:48:20

for this example :

3 12 7 13 12 4 5 13 11 17 16 6 13 5 19 15 7 7 7 6 8 here are the steps [3, 12, 10, 16, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 0, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 0, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 0, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 0, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 0, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 0, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 0, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 101, 0] [3, 12, 10, 16, 24, 20, 29, 37, 40, 54, 56, 60, 69, 65, 88, 84, 95, 95, 102, 101, 110] i found 110 but the annwser must be 108 !!

Quandray     2017-12-24 21:34:40
User avatar

He must start from the first isle. I think 108 is 3->7->12->5->11->16->13->19->7->7->8.

WakeMeAtThree     2017-12-24 21:42:09
User avatar

Hi mooninvader, the rabbit starts from the first isle (Marked X). Let's take the first four numbers from your example. Rabbit can jump from first isle to either a or b:

3 12  7  13 ... 8
X     a   b

Since this is a dynamic programming problem, it might help to instead visualize it as:

0 0 3 12  7  13 ... 8
  a b     X
  -------->

0 0 3 12  7  13 ... 8
    a b      X
    --------->

EDIT: Oops, Graeme answered before me! It is indeed 3+7+12+5+11+16+13+19+7+7+8

mooninvader     2017-12-25 20:59:21

thanks a lot so the value of the second isle is never used.. i replaced it with the value of the first added two zeros at the begenning of the array and it works fine now.

thank you WakeMeAtThree and Quandray

Please login and solve 5 problems to be able to post at forum