# I need help with Slalom (Python)

**URL:** <https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868>\
**Category:** Uncategorized\
**Created:** [May 12, 2015, 12:03pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868 "2015-05-12T12:03:10Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 12, 2015, 12:03pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/1 "2015-05-12T12:03:10Z")

</div>

Here is the code im using:

[code]gems = self.findItems()

while self.pos.x \< 20:  
self.move({‘x’: 20, ‘y’: 35})

while self.pos.x \< 25:  
gem0 = gems[0]  
self.move(gem0.pos)

while self.pos.x \< 30:  
self.move({‘x’: 30, ‘y’: 35})

while self.pos.x \< 35:  
gem1 = gems[1]  
self.move(gem1.pos)

while self.pos.x \< 40:  
self.move({‘x’: 40 , ‘y’:35 })

while self.pos.x \< 45:  
gem2 = gems[2]  
self.move(gem2.pos)

while self.pos.x \< 50:  
self.move({‘x’:50 , ‘y’:35})

while self.pos.x \< 55:  
gem3 = gems[3]  
self.move(gem3.pos)[/code]

I honestly dont know what im doing wrong, help please (new to this)

---

<div class="post-metadata">

**Author:** ![ChristianKl](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/christiankl/32/2543_2.png) [@ChristianKl](https://discourse.codecombat.com/u/ChristianKl)\
**Post date:** [May 12, 2015, 1:39pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/2 "2015-05-12T13:39:35Z")

</div>

If you execute that code, what does your hero do? What do you think he should do instead?

---

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 12, 2015, 4:23pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/3 "2015-05-12T16:23:34Z")

</div>

He collects one of the gems and then he just stops moving.

---

<div class="post-metadata">

**Author:** ![ChristianKl](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/christiankl/32/2543_2.png) [@ChristianKl](https://discourse.codecombat.com/u/ChristianKl)\
**Post date:** [May 12, 2015, 4:25pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/4 "2015-05-12T16:25:46Z")

</div>

Your code doesn’t give a new `move` command after `gem3` has been picked up.

---

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 12, 2015, 4:29pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/5 "2015-05-12T16:29:21Z")

</div>

But it wont even get to gem3. The code stops working “while self.pos.x \< 35:” My hero just stays on the X.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 12, 2015, 8:38pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/6 "2015-05-12T20:38:00Z")

</div>

Does it give you an “unexpected indent” error 'cause it seems like it should.

make all your indents the same, ESPECIALLY, in the same area of code).

```python
while self.pos.x < 35:
    gem1 = gems[1]
    self.move(gem1.pos)

```

(if you look at the code you posted, they aren’t lined up)

Otherwise, you must not be getting to “35.000000001” so you never leave that loop. You could try “\< 34”.

---

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 13, 2015, 11:30am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/7 "2015-05-13T11:30:03Z")

</div>

My code appears to be lined up 😕 … this is the error its giving me. ![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2585/1272563a492988ed.PNG)

---

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 13, 2015, 11:44am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/8 "2015-05-13T11:44:16Z")

</div>

Also, when I click the “help” button, the pop up window stays blank, so i’m not sure if its a glitch.(@nick) ![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2586/7fca402fab81c8f3.PNG) edit: i finally passed but probably not the right way. Here is a look at my code if anybody needed help. Not the most efficient but it works.

```python
gems = self.findItems()
while self.pos.x < 20:
	self.move({'x': 20, 'y': 35})

while self.pos.x < 25:
	gem0 = gems[0]
	self.move(gem0.pos)

while self.pos.x < 30:
    self.move({'x': 30, 'y': 35})
self.buildXY("fence", 35, 19)
self.buildXY("fence", 40, 41)
self.buildXY("fence", 45, 19)
self.buildXY("fence", 50, 41)
self.buildXY("fence", 56, 22)
```

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [May 15, 2015, 3:25am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/9 "2015-05-15T03:25:55Z")

</div>

Looks like we haven’t written a guide yet for that level, which is why it’s blank; hope to get that filled in soon.

I wasn’t easily able to reproduce the infinite loop problem, but what happens if you change your x thresholds lower and lower, like 34, 33, 32 instead of 35–does it eventually get you there?

---

<div class="post-metadata">

**Author:** ![Eventous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eventous/32/2636_2.png) [@Eventous](https://discourse.codecombat.com/u/Eventous)\
**Post date:** [May 18, 2015, 11:30am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/10 "2015-05-18T11:30:53Z")

</div>

Umm…nope, that did not seem to work either 😕 He still just stays on the 2nd red “X” and gives me the same error.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 18, 2015, 8:56pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/11 "2015-05-18T20:56:06Z")

</div>

When I use the code you provided, I don’t get “hard limit”, I get the slow-infinite code error.

If I close and reopen the level, I get stuck in different places, sometimes I can get passed the 2nd redX sometimes I don’t even make it to the first gem…???..

Personally, I am inclined to blame the “move” command since it is not blocking, the code runs ahead.

Quasi-side note: We need to change the default code . . . as we are teaching a bad thing…  
Honestly, I should have complained about this ages ago, but I didn’t care back then…

```python
while x<35:
    gem1 = gems[1]
    move to gem1

```

Why are we teaching people to set gem# (which won’t change) inside the while loop??

Move these outside the while-loops and I stop getting the error. (yes, it is pseudo code)

```python
gem1 = gems[1]
while x<35:
    move to gem1

```

If the “slow/inf code error” is codecount-time based then it makes sense, since it removes lines of code from the count and would also effect “hard limit”.

Did something change? 'cause it shouldn’t hit either limit with the expected solution…

---

<div class="post-metadata">

**Author:** ![junglywood](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/junglywood/32/3643_2.png) [@junglywood](https://discourse.codecombat.com/u/junglywood)\
**Post date:** [January 20, 2016, 12:05am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/12 "2016-01-20T00:05:16Z")

</div>

that is the same error that i get to.

---

<div class="post-metadata">

**Author:** ![AdrianCgw](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@AdrianCgw](https://discourse.codecombat.com/u/AdrianCgw)\
**Post date:** [January 20, 2016, 12:19am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/13 "2016-01-20T00:19:17Z")

</div>

1. Moving the gem assignment outside the while loop makes the code more efficient, but it is not the main error cause

```python
while x<35
      move to gem1

```

If you set gem1 to the wrong value (if gem1.x \< 35) then your hero will never move past x=35 and your code will loop forever (or until hard execution limit is reached :))

---

<div class="post-metadata">

**Author:** ![Navtej\_pathipati](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/navtej_pathipati/32/15505_2.png) [@Navtej\_pathipati](https://discourse.codecombat.com/u/Navtej_pathipati)\
**Post date:** [October 14, 2020, 7:26am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/14 "2020-10-14T07:26:55Z")

</div>

I solved by building fences

AS WE CANT MOVE TO BUILD FENCE I HAVE TO MOVE THERE I REPLACED X = NUM  
Y = NUM  
AND COLLECTED GEMS

@buildXY “fire-trap”, 20, 39  
@buildXY “fire-trap”, 25, 21  
@buildXY “fire-trap”, 30, 35  
@buildXY “fire-trap”, 40, 23  
@buildXY “fire-trap”, 40, 35  
@buildXY “fire-trap”, 50, 24  
@buildXY “fire-trap”, 53, 37  
@buildXY “fire-trap”, 57, 20

IT SHOW’S SUCCESS

---

<div class="post-metadata">

**Author:** ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)\
**Post date:** [October 14, 2020, 8:38am UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/15 "2020-10-14T08:38:51Z")

</div>

Hi Navtej\_pathipati,

It’s nice that you’re trying to help these people, but they were posting about this topic 5 years ago. Please could you check the date on a topic, and only reply to recent posts.

Thanks,

Jenny

---

<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:** [October 14, 2020, 2:28pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/16 "2020-10-14T14:28:33Z")

</div>

I agree with Jenny, and could you remove the correct code so others won’t try and cheat? This is a learning forum, not a place to look for answers.  
Thanks,  
Lydia

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 18, 2020, 11:37pm UTC](https://discourse.codecombat.com/t/i-need-help-with-slalom-python/3868/18 "2020-12-18T23:37:47Z")

</div>

Hi Ryan, I’m sorry but we can’t post sulotions on the forum cna you please delete your post?
