Reindeer Wakeup Bug


#1
# This array contains the 'asleep' or 'awake' status for each reindeer.
deerStatus = [ 'asleep', 'asleep', 'asleep', 'asleep', 'asleep' ]

# And this array contains our reindeer.
friends = hero.findFriends()

# Loop through all the reindeer and see which ones are awake.
for deerIndex in range(len(friends)):
    reindeer = friends[deerIndex]
    if reindeer.pos.y > 30:
        deerStatus[deerIndex] = "awake"
    # If the reindeer's Y position is greater than 30, it's out of its pen.
    # If this is the case, set the reindeer's entry in the deerStatus array to 'awake'.
# Loop through statuses and report to Merek.
for statusIndex in range(len(deerStatus)):
    # Tell Merek the reindeer index and whether it's asleep or awake.
    # Say something like "Reindeer 2 is asleep" or "Reindeer 4 is awake"
#    if deerStatus[statusIndex] == "asleep":
        speech = "Reindeer " + statusIndex + " is " + deerStatus[statusIndex]
        hero.say(speech)
    pass

#2

Could you describe a problem more careful?


#3

Sure,

I execute my code properly, and it goes through each stall, telling the NPC which reindeer are asleep, and which are awake. The npc wakes the reindeer up, as they are supposed to, but the level still times out for me. Please see the attached screenshot.


#4

Yes, I got the same. Thanks. We will fix it ASAP.


#5

This should now be fixed. Let us know if those reindeer give you any more trouble!


#6

I’ve got this bug in Safari, but in Firefox everything works good!


#7

‘Overview’ body

javascript
var a = [ null, “one”, “two” ];
hero.say(a[1]); // Says "one"
hero.say(a[2]); // Says "two"
hero.say(a[0]); // Says nothing
hero.say(a[3]); // Error! Array starts at 0 and ends at 2.


#8

It errors because you have no “3”. The computer starts counting at 0 so a 3 to the computer is basically a 4 to us. For example, 0 is null. 1 is “one”, and 2 is “two”. a[0] says nothing because you passed null.


#9

Error is here:
hero.say(a[0]); // Says nothing is not correct


#10

Because you set 0 to null. The computer counts starting from 0, so the first array item is 0, the second is 1, and the third is 2. Also, you only have 3 objects in the array, so hero.say(a[3]) is invalid.


#11

This is not my code:

hero.say(a[0]); // Is Error too!


#12

The reason a[0] is null is because the first item in the array is null. Type null is not a string, therefore, you can no pass it off as an item in an array. Also, a[3] is intentionally wrong, you’ll have to remove the line.


#13

I repeat :
This is not my program, this is documentation! Hint 2 about hero.say(a[0]) is misleading.


#14

your code is okay. it worked with mine page