# Ogre Gorge Gouger Help

**URL:** <https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887>\
**Category:** Level Help\
**Created:** [March 11, 2021, 7:37am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887 "2021-03-11T07:37:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZACHARIAH\_UMBERGER](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zachariah_umberger/32/21038_2.png) [@ZACHARIAH\_UMBERGER](https://discourse.codecombat.com/u/ZACHARIAH_UMBERGER)\
**Post date:** [March 11, 2021, 7:37am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/1 "2021-03-11T07:37:24Z")

</div>

i haven’t been able to pass this level for about a week and i am in need of some help

```python
while (hero.time < 20) or (hero.gold:60):
    #Collect coins
    hero.say("I should pick up a coin")
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    if hero.time>20 and hero.gold:60:
        break
    

while hero.time>22:
    hero.moveXY(16, 37)
    hero.buildXY("fence", 21, 37)

```

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [March 11, 2021, 11:23am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/2 "2021-03-11T11:23:37Z")

</div>

Your code is slightly more complicated than it needs to be.  
For the first while loop, what you want to check is if hero.gold \< 60. That’s all. You don’t need to check time, and : doesn’t work, you need to use \< (less than).  
You also don’t need this:

> [@ZACHARIAH\_UMBERGER](#):
>
> ```python
> if hero.time>20 and hero.gold:60:
> break
> 
> ```

Because while loops automatically break when their condition is satisfied (e.g. when you have more than 60 gold).  
You also don’t need this:

> [@ZACHARIAH\_UMBERGER](#):
>
> `while hero.time>22:`

Because moveXY and buildXY don’t need to be looped. They will work fine without a loop.  
You also don’t need this:

> [@ZACHARIAH\_UMBERGER](#):
>
> `hero.say("I should pick up a coin")`

I realise it may be for debugging purposes, but once you’ve made the above changes that I’ve mentioned, you won’t need it.  
Danny

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [March 11, 2021, 4:11pm UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/3 "2021-03-11T16:11:27Z")

</div>

> [@ZACHARIAH\_UMBERGER](#):
>
> ```python
> while (hero.time < 20) or (hero.gold:60):
> #Collect coins
> hero.say("I should pick up a coin")
> item = hero.findNearestItem()
> if item:
> hero.moveXY(item.pos.x, item.pos.y)
> if hero.time>20 and hero.gold:60:
> break
>     
> 
> ```

This first while-loop. should be `while hero.gold < 60:`  
And then in this, delete these two:

> [@ZACHARIAH\_UMBERGER](#):
>
> `hero.say("I should pick up a coin")`

> [@ZACHARIAH\_UMBERGER](#):
>
> ```python
> if hero.time>20 and hero.gold:60:
> break
>     
> 
> ```

> [@ZACHARIAH\_UMBERGER](#):
>
> ```python
> while hero.time>22:
> hero.moveXY(16, 37)
> hero.buildXY("fence", 21, 37)
> 
> ```

In this while-loop, the start should be `while hero.time > 16`  
Then move behind the fence (exact coordinates are 15,37)  
And then outside of all while-loops, and under all. Build a fence at 21,37  
Lydia  
P.S. Comments really help!

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [March 11, 2021, 7:57pm UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/4 "2021-03-11T19:57:54Z")

</div>

Your first while loop should be:

```python
while hero.time < 20:

```

Delete your `hero.say()` statement. Delete your if statement with the break. Then, delete you second while loop. You don’t need it. Just move behind the fence wall, and build a fence to protect yourself.

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [March 11, 2021, 8:49pm UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/5 "2021-03-11T20:49:04Z")

</div>

You got everything right but this. Delete this and you are good to go.

> [@ZACHARIAH\_UMBERGER](#):
>
> ```python
> hero.say("I should pick up a coin")
> 
> ```

---

<div class="post-metadata">

**Author:** ![ZACHARIAH\_UMBERGER](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zachariah_umberger/32/21038_2.png) [@ZACHARIAH\_UMBERGER](https://discourse.codecombat.com/u/ZACHARIAH_UMBERGER)\
**Post date:** [March 12, 2021, 7:26am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/6 "2021-03-12T07:26:06Z")

</div>

it still says ran out of time, let me know if this looks correct to you.

```python
while (hero.gold<60):
    #collect coins
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    
hero.moveXY(16, 37)
hero.buildXY("fence", 21, 37)

```

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [March 12, 2021, 8:22am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/7 "2021-03-12T08:22:00Z")

</div>

That code works perfectly for me. It must be your equipment… Please could you post a screenshot of your equipment and of the level screen.  
Danny

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [March 12, 2021, 3:30pm UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/8 "2021-03-12T15:30:48Z")

</div>

While your time is less than 20, collect coins until a certain time, then retreat. The sixty is just a bonus to get within the time.

---

<div class="post-metadata">

**Author:** ![ZACHARIAH\_UMBERGER](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zachariah_umberger/32/21038_2.png) [@ZACHARIAH\_UMBERGER](https://discourse.codecombat.com/u/ZACHARIAH_UMBERGER)\
**Post date:** [March 15, 2021, 6:07am UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/9 "2021-03-15T06:07:55Z")

</div>

![Screenshot 2021-03-14 at 23.07.13](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/0/b/0b4d7da9f299857f38db0be2b4b98dcd2032137e.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [March 15, 2021, 6:08pm UTC](https://discourse.codecombat.com/t/ogre-gorge-gouger-help/27887/10 "2021-03-15T18:08:25Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
