# \[SOLVED\] Grid Minefield Help CodeCombat

**URL:** <https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079>\
**Category:** Uncategorized\
**Created:** [June 29, 2018, 8:35am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079 "2018-06-29T08:35:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![totodej](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/totodej/32/8437_2.png) [@totodej](https://discourse.codecombat.com/u/totodej)\
**Post date:** [June 29, 2018, 8:35am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/1 "2018-06-29T08:35:37Z")

</div>

![53](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/7/763c1fb0eecbad088f27a4a3bde215d748e6864c.png)

Hello, I didn’t find the solution. Do you have the solution ?

Thank you  
😉

---

<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:** [June 29, 2018, 8:42am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/2 "2018-06-29T08:42:50Z")

</div>

Sorry, but I’m afraid we don’t give solutions on this forum as it defeats the point of the game entirely,  
We can help you get your code right though, post your code into the discourse as the forum [FAQ - Check Before Posting](https://discourse.codecombat.com/t/faq-check-before-posting/1027) says and say what’s happening and what you can’t do / understand. Thanks! 😁

---

<div class="post-metadata">

**Author:** ![totodej](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/totodej/32/8437_2.png) [@totodej](https://discourse.codecombat.com/u/totodej)\
**Post date:** [June 29, 2018, 8:52am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/3 "2018-06-29T08:52:47Z")

</div>

Yes, I have a problem with my code.  
I feel that everything is good.  
But it doesn’t work.  
Can you help me ?

```python
for (var x = 12; x < 12 + 8 * 6; x += 8) {
  
    for (var y = 12; y < 12 + 8 * 7; y += 8) {
        
        hero.buildXY("fire-trap", x, y);     
    }
    
    hero.moveXY(hero.pos.x +8, hero.pos.y);
}

while (true) {
    var enemy = hero.findNearestEnemy();
    if (enemy && hero.distanceTo(enemy) <= 20) {
        hero.moveXY(x, y);
    } 
}

```

---

<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:** [June 29, 2018, 8:54am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/4 "2018-06-29T08:54:19Z")

</div>

Yeah, I’ll try, I normally do python but I think I can help you.  
I’ll just work out what the problem is.

---

<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:** [June 29, 2018, 9:12am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/5 "2018-06-29T09:12:38Z")

</div>

All you need to change is:

> [@totodej](#):
>
> hero.moveXY(x, y);

to : hero.moveXY(52, 51) so you blow up the ogres.

---

<div class="post-metadata">

**Author:** ![totodej](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/totodej/32/8437_2.png) [@totodej](https://discourse.codecombat.com/u/totodej)\
**Post date:** [June 29, 2018, 9:14am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/6 "2018-06-29T09:14:38Z")

</div>

Thank you very much for your help.

You are the best 😉

---

<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:** [June 29, 2018, 9:15am UTC](https://discourse.codecombat.com/t/solved-grid-minefield-help-codecombat/15079/7 "2018-06-29T09:15:06Z")

</div>

That’s fine, sorry for the delay. 😁
