# \[SOLVED\]In the level The mighty yak i start of with"ran out of time"

**URL:** <https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997>\
**Category:** Level Help\
**Created:** [January 25, 2021, 7:27pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997 "2021-01-25T19:27:15Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:27pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/1 "2021-01-25T19:27:16Z")

</div>

i just did the level The mighty yak and when I start it says “ran out of time”  
and when I did that I doged 8 yaks and they want 4

---

<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:** [January 25, 2021, 7:28pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/2 "2021-01-25T19:28:21Z")

</div>

Were is this level and post your code plz.

---

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:28pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/3 "2021-01-25T19:28:58Z")

</div>

it is in the dessert and this is my code

```python
# Let yaks get close, then move 10m right to dodge.
# Dodge 4 yaks to complete the level.

while True:
    # Get hero's current x and y position.
    x = hero.pos.x
    y = hero.pos.y
    
    # Find the nearest yak.
    yak = hero.findNearestEnemy()
    
    # If the distanceTo the yak is less than 10:
    if hero.distanceTo(yak) < 10:
        # To move right, add 10 to hero's x position.
        hero.moveXY(25, 30)
        hero.moveXY(35, 30)
        hero.moveXY(52, 30)
        # Use moveXY(x, y) to move!
        hero.moveXY(35, 30)
        hero.moveXY(25, 30)
        hero.moveXY(15, 30)
        hero.moveXY(43, 30)
        hero.moveXY(58, 30)
        pass

```

---

<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:** [January 25, 2021, 7:30pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/4 "2021-01-25T19:30:47Z")

</div>

You didn’t do what the level said, read this.

> [@logan\_jordan](#):
>
> `# To move right, add 10 to hero's x position.`

---

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:31pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/5 "2021-01-25T19:31:28Z")

</div>

i tryed that here let me do it again

---

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:33pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/6 "2021-01-25T19:33:05Z")

</div>

i am still runing out of time

---

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:33pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/7 "2021-01-25T19:33:47Z")

</div>

this is my new code

```python
# Let yaks get close, then move 10m right to dodge.
# Dodge 4 yaks to complete the level.

while True:
    # Get hero's current x and y position.
    x = hero.pos.x
    y = hero.pos.y
    
    # Find the nearest yak.
    yak = hero.findNearestEnemy()
    
    # If the distanceTo the yak is less than 10:
    if hero.distanceTo(yak) < 10:
        # To move right, add 10 to hero's x position.
        hero.moveXY(25, 30)
        hero.moveXY(35, 30)
        hero.moveXY(45, 30)
        hero.moveXY(55, 30)
        # Use moveXY(x, y) to move!
        
        pass
    

```

---

<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:** [January 25, 2021, 7:34pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/8 "2021-01-25T19:34:51Z")

</div>

You still didn’t do what it said do something like this

```python
x = x + 10

```

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [January 25, 2021, 7:35pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/9 "2021-01-25T19:35:33Z")

</div>

yeah do this instead of all the moves

```python
 x=x+10
  // Use moveXY(x, y) to move!
 hero.moveXY(x, y)

```

---

<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:** [January 25, 2021, 7:36pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/10 "2021-01-25T19:36:36Z")

</div>

yeah just do after what I said then you are golden.

```python
hero.moveXY(x, y)

```

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [January 25, 2021, 7:37pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/11 "2021-01-25T19:37:32Z")

</div>

Instead of this

```python
 if hero.distanceTo(yak) < 10:
        # To move right, add 10 to hero's x position.
        hero.moveXY(25, 30)
        hero.moveXY(35, 30)
        hero.moveXY(45, 30)
        hero.moveXY(55, 30)
        # Use moveXY(x, y) to move!
        
        pass

```

do this

```python
x=x+10
 hero.moveXY(x, y)

```

---

<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:** [January 25, 2021, 7:38pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/12 "2021-01-25T19:38:23Z")

</div>

or this to be a little more actuate

```python
        x = x + 10
        # Use moveXY(x, y) to move!
        hero.moveXY(x, y)

```

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [January 25, 2021, 7:39pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/13 "2021-01-25T19:39:34Z")

</div>

thats not how you are supposed to do it  
you have to use moveXY(x,y)

> [@Falcons118](#):
>
> ```python
> x=x+10
> hero.moveXY(x, y)
> 
> ```

---

<div class="post-metadata">

**Author:** ![logan\_jordan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/logan_jordan/32/19353_2.png) [@logan\_jordan](https://discourse.codecombat.com/u/logan_jordan)\
**Post date:** [January 25, 2021, 7:40pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/14 "2021-01-25T19:40:57Z")

</div>

thanks that worked your a life saver

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [January 25, 2021, 7:41pm UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/15 "2021-01-25T19:41:22Z")

</div>

congratulations on passing 🥳

---

<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:** [January 26, 2021, 7:41am UTC](https://discourse.codecombat.com/t/solved-in-the-level-the-mighty-yak-i-start-of-with-ran-out-of-time/26997/16 "2021-01-26T07:41:35Z")

</div>

Closed on January 26, 2021, 7:41am UTC

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