# \[SOLVED\] The Hunt Begins-need help!

**URL:** https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696
**Category:** Level Help
**Created:** [June 13, 2017, 3:05pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696 "2017-06-13T15:05:13Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 13, 2017, 3:05pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/1 "2017-06-13T15:05:13Z")

</div>

I really need help on The Hunt Begins.

```python
# Senick is trying to find the elusive Burleous Majoris!
# But he doesn't know how big a Burleous Majoris would be...
# Find the average size of this burl population to use as a baseline!

# This function returns average size of all the burls in an array.
def averageSize(burls):
    sum = sumSize(burls)
    # Remember the average is the sum of the parts divided by the amount!
    return sum / burls.length

# This function should return the sum of all the burls sizes.
def sumSize(burls):
    # Implement the sum function using the burls 'size':
    s = burls.sum
    
    return s

while True:
    # Find the average size of the burls by calling the 'averageSize' function.
    q = averageSize(burls)
    # Say the average size of the seen burls!
    hero.say(q)

```

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 13, 2017, 3:05pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/2 "2017-06-13T15:05:42Z")

</div>

It tells me burls is undefined

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 13, 2017, 3:07pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/3 "2017-06-13T15:07:00Z")

</div>

burls is obviously undefined, but how do I make the hero only look at burls?

---

<div class="post-metadata">

### Author: ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)
#### Post date: [June 13, 2017, 5:47pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/4 "2017-06-13T17:47:56Z")

</div>

Are you trying to find a list of all the burls?

If so,

```python
burls = hero.findByType("burl")

```

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 13, 2017, 7:23pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/5 "2017-06-13T19:23:23Z")

</div>

Thank you! Now it does not give me any errors, but the hero does the functions before the burls come out, and therefore says “0” to Senick.  
Here is my updated code:

```python
# Senick is trying to find the elusive Burleous Majoris!
# But he doesn't know how big a Burleous Majoris would be...
# Find the average size of this burl population to use as a baseline!

# This function returns average size of all the burls in an array.
def averageSize(burls):
    
    sum = sumSize(burls)
    # Remember the average is the sum of the parts divided by the amount!
    return sum / burls.length

# This function should return the sum of all the burls sizes.
def sumSize(burls):
    # Implement the sum function using the burls 'size':
    sum = sum(burls.size)
    
    return sum

while True:
    # Find the average size of the burls by calling the 'averageSize' function.
    burls = hero.findByType("burl")
    q = averageSize(burls)
    # Say the average size of the seen burls!
    hero.say(q)

```

@_TD_RodYT, I cannot find a way to make my hero say the average size _after_ the burls come by.  
Do you know a way? And if so, could you tell me what it is?

---

<div class="post-metadata">

### Author: ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)
#### Post date: [June 13, 2017, 9:22pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/6 "2017-06-13T21:22:17Z")

</div>

The instructions for this level are not really clear so I’ll make it more clear. When we pass `burls`, we are passing a list of all the burls on the screen. You do not have to worry about your hero starting too early because you put the code inside a while loop.

Now, inside the sumSize function, you want to loop the code in a for loop.

1. Define “sum” in sumSize. You can set it to 0. (Outside of the loop)
2. Inside the for loop you want to keep on adding the burl’s size to sum:

```python
for burl in burls
   sum = sum + burl.size;

```

Now that you have to total size of all the burls combined, you will divide it by burls’ length in averageSize to find the average weight. I usually don’t give away free code like this but the goal of the level was unclearly stated in the Hints.

---

<div class="post-metadata">

### Author: ![reesylou](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@reesylou](https://discourse.codecombat.com/u/reesylou)
#### Post date: [June 13, 2017, 9:47pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/7 "2017-06-13T21:47:39Z")

</div>

You want to make sure that there are burls (that the variable burls is not empty) before calling your averageSize function. You will have done this check MANY times before now - think back to basic levels on attacking.

---

<div class="post-metadata">

### Author: ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)
#### Post date: [June 13, 2017, 10:02pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/8 "2017-06-13T22:02:23Z")

</div>

This should not be a problem since there is a constant stream of burls in this level but @reesylou is correct.

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 14, 2017, 3:01pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/9 "2017-06-14T15:01:49Z")

</div>

Righhhhhhhhhhht. Thanks for refreshing my memory, @reesylou and @_TD_RodYT

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 14, 2017, 3:11pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/10 "2017-06-14T15:11:11Z")

</div>

This does not work for _all_ the burls, because I don’t know what to compare `burls.length` to.

```python
# Senick is trying to find the elusive Burleous Majoris!
# But he doesn't know how big a Burleous Majoris would be...
# Find the average size of this burl population to use as a baseline!

# This function returns average size of all the burls in an array.
def averageSize(burls):
    
    sum = sumSize(burls)
    # Remember the average is the sum of the parts divided by the amount!
    return sum / burls.length

# This function should return the sum of all the burls sizes.
def sumSize(burls):
    # Implement the sum function using the burls 'size':
    if burls.length > 15:
        
        sum = sum(burls.size)
    
    return sum

while True:
    # Find the average size of the burls by calling the 'averageSize' function.
    burls = hero.findByType("burl")
    
    q = averageSize(burls)
    # Say the average size of the seen burls!
    hero.say(q)

```

---

<div class="post-metadata">

### Author: ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)
#### Post date: [June 14, 2017, 6:55pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/11 "2017-06-14T18:55:06Z")

</div>

Make sure you read my last post.

In sumSize, you will need to create a for loop to find the total of every burl’s size **combined**.

```python
sum = 0
for burl in burls:
     sum = sum + burl.size

```

Then, in averageSize, the function will divide the total size by the amount of burls. (to find the average size)

(I don’t give out free code, but this level is a little confusing. I will delete this post when the devs change the Hints.)

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 15, 2017, 2:54pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/12 "2017-06-15T14:54:20Z")

</div>

Thank you! I agree, the hints did not make sense.

---

<div class="post-metadata">

### Author: ![adwertsushi](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adwertsushi](https://discourse.codecombat.com/u/adwertsushi)
#### Post date: [June 15, 2017, 2:58pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/13 "2017-06-15T14:58:10Z")

</div>

That worked! Thanks for the help, @reesylou and @_TD_RodYT!

---

<div class="post-metadata">

### Author: ![James\_D94](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@James\_D94](https://discourse.codecombat.com/u/James_D94)
#### Post date: [September 21, 2017, 2:12pm UTC](https://discourse.codecombat.com/t/solved-the-hunt-begins-need-help/11696/14 "2017-09-21T14:12:26Z")

</div>

def averageSize(burls):  
sum = sumSize(burls)  
return sum / len(burls)

def sumSize(burls):

```
sum = 0
for i in range(len(burls)):
    burl = burls[i]
    sum += burl.size
return sum

```

While True:  
burls = hero.findEnemies()  
avgSize = averageSize(burls)  
hero.say(avgSize)

Can someone help out and tell me why this doesn’t work?  
thanks
