# I got stuck on blind distance

**URL:** <https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710>\
**Category:** Level Help\
**Created:** [August 28, 2020, 4:43pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710 "2020-08-28T16:43:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 4:43pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/1 "2020-08-28T16:43:58Z")

</div>

```python
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    var (distance = hero.distanceto(enemy):
        if (distance.isready("cleave"):
            hero.cleave(enemy)
        # Say the value of enemyDistance variable.

```

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 5:24pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/2 "2020-08-28T17:24:50Z")

</div>

Hi! This part looks like a salad mixed with different conditions and abilities.

> [@kayden4444](#):
>
> ```python
> if (distance.isready("cleave"):
> hero.cleave(enemy)
> # Say the value of enemyDistance variable.
> 
> ```

Comment ‘’‘# If the enemyDistance is greater than 0: ‘’’ says about zero and there is nothing about it in code line.  
I’ll chek the level and try to show the scheme)

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 6:04pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/3 "2020-08-28T18:04:18Z")

</div>

```python
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    
        # Say the value of enemyDistance variable.
        

```

I don’t know what to do

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 6:24pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/4 "2020-08-28T18:24:25Z")

</div>

Uhm. You don’t need to cleave. Follow the level instructions:  
#It’s an ambush and your only weapon is the old, blind wizard.  
#Your task is to tell him the distance to the coming ogres.  
#Don’t worry about the direction.  
#The wizard’s powers are limited, use them only when see an ogre.  
#This function finds the nearest enemy and returns the distance to it.  
#If there is not enemy, the function returns 0.  
#Call ‘nearestEnemyDistance’ function and save a result in a variable ‘distance’.  
#If ‘distance’ is greater than 0:  
#Say the distance.

So the scheme is smth like this:

```python
def nearestEnemyDistance ():
    [code is precoded so you even dont need to write it] 

while True:
    define enemy
    define distance-to-enemy
    if distance-to-enemy>0:
        say distance-to-enemy

```

The wizard will hear the distance-to-enemy and finish all the job for you)

My solution differs a little bit, but it’s OK.

In fact you need to write two lines of code: condition and say distance.

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 6:45pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/5 "2020-08-28T18:45:01Z")

</div>

```python
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    
    if distance-to-enemy>0:
        
        # Say the value of enemyDistance variable.
        distance = hero.distanceTo(enemy)
        

```

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 8:12pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/6 "2020-08-28T20:12:33Z")

</div>

Looks like you don’t understand basics and only copypaste pieces of code of other players( It won’t let you learn much about coding. Maybe it’s a good idea to step back to previous levels to understand mechanics of operators and conditions.

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 8:29pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/7 "2020-08-28T20:29:41Z")

</div>

Thanks for noooot helping!!

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 8:30pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/8 "2020-08-28T20:30:41Z")

</div>

You’re welcome) Always glad to)

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 8:44pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/9 "2020-08-28T20:44:28Z")

</div>

I’m really sorry I could disappoint you. But.  
I recommended you the most effective and easiest way. Not the fastest, but really working one. Of course you can try other variants. Like get solution from another person, or get subscription and prompt of game stuff, or any else you can imagine).  
I don’t know much about programming, but I have been training/teaching young guys for about 15 years and I know a thing or two about learning. If you want to know something - you need to do it by yourself.  
One more really fast, but hard way to beat this lvl I can give is to try find connections between things in goals, given code and advices of this level.  
As I mentioned only two lines of code should be done. Cmon, look at it as at interesting rebus, puzzle. Not a work or compulsory deadline.  
Good luck!

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [August 28, 2020, 8:46pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/10 "2020-08-28T20:46:35Z")

</div>

Let’s keep it civil please. Alex is actually trying to help, but not by just giving you code.

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 8:50pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/11 "2020-08-28T20:50:48Z")

</div>

You know what I am sorry. I got mad but I been doing this code for at least 2 day.

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 8:52pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/12 "2020-08-28T20:52:52Z")

</div>

```python
    enemy = hero.findNearestEnemy()
    result = 0
    if enemy:
        result = hero.distanceTo(enemy)
    return result

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target)
        # Say the value of enemyDistance variable.
    hero.say(distance)

```

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 28, 2020, 8:56pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/13 "2020-08-28T20:56:40Z")

</div>

```python
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target):
        # Say the value of enemyDistance variable.
        hero.say(target)

```

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 28, 2020, 9:09pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/14 "2020-08-28T21:09:26Z")

</div>

Suddenly you get closer)  
Ok, let’s pretend we need as little work with this lvl as we can.  
You have hints and you successfully did the first step - you made variable

```python
enemyDistance = nearestEnemyDistance()

```

Don’t touch anything else now)  
Look at comments

```python
#If the enemyDistance is greater than 0:
#Say the value of enemyDistance variable.

```

So, turn comment line [If the enemyDistance is greater than 0:] into code with right spelling and operator. Hint - it should be one line of condition code.

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 29, 2020, 9:52am UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/15 "2020-08-29T09:52:34Z")

</div>

As soon as you will be ready to the next step, you’ll need to use variable you created.  
I’d explain it like this: if you got pet, you give it the name. And when you want to call pet, you say its name. The same thing here. You create variable and then your hero should say this variable.

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 29, 2020, 9:59am UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/16 "2020-08-29T09:59:18Z")

</div>

Well @Lydia_Song has been stuck on Restless Dead for 2 months, I’ve been helping her out but she still hasn’t got it yet, but don’t worry you will eventually get past it.

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 29, 2020, 10:00am UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/17 "2020-08-29T10:00:22Z")

</div>

And also Welcome to the Discourse @kayden4444 🥳 🥳

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [August 29, 2020, 10:38am UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/18 "2020-08-29T10:38:36Z")

</div>

Can I see your recent code @kayden4444?

Oh, and I have not been too much active on the forum lately because I have been in a holiday in the mountains for some weeks and I did not had really good signal there, but now I am back!

Andrei

---

<div class="post-metadata">

**Author:** ![kayden4444](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kayden4444/32/13823_2.png) [@kayden4444](https://discourse.codecombat.com/u/kayden4444)\
**Post date:** [August 31, 2020, 2:52pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/19 "2020-08-31T14:52:14Z")

</div>

```python

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target):
        # Say the value of enemyDistance variable.
        hero.say(target)

```

@AnSeDra

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [August 31, 2020, 3:03pm UTC](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710/20 "2020-08-31T15:03:35Z")

</div>

Where did you check if the distance is greater than 0?

[Next page](https://discourse.codecombat.com/t/i-got-stuck-on-blind-distance/23710.md?page=2)
