# \[SOLVED\] Help on Gem by Gem

**URL:** <https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920>\
**Category:** Level Help\
**Created:** [July 11, 2020, 10:28am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920 "2020-07-11T10:28:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mumbo\_6](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mumbo_6/32/14166_2.png) [@Mumbo\_6](https://discourse.codecombat.com/u/Mumbo_6)\
**Post date:** [July 11, 2020, 10:28am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/1 "2020-07-11T10:28:03Z")

</div>

Hi, sorry for the ongoing interruption,  
could anyone help me with the level gem by gem? Im really stuck  
here is my code:

```python
# Connect gems to a linked list to open the door.

# Use that gems a base for the list.
baseGem = hero.findByType("root-gem")[0]
# Those gems are not linked yet.
freeGems = hero.findByType("gem")

# Use the property "next" to link elements to the list.
# Append an element before the base gem.
freeGems[0].next = baseGem
# And one more at the new head of the list:

# Next add more gems at the end.
baseGem.next = freeGems[2]
# Add two more gems one by one:

while True:
    if hero.isPathClear(hero.pos, {"x": 76, "y": 34}):
        hero.moveXY(76, 34)

```

Thanks,  
Mumbo\_6

---

<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:** [July 11, 2020, 10:45am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/2 "2020-07-11T10:45:31Z")

</div>

You did not change the base code I see. Would you like for me to explain to you the logic of this level?

Andrei

---

<div class="post-metadata">

**Author:** ![Mumbo\_6](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mumbo_6/32/14166_2.png) [@Mumbo\_6](https://discourse.codecombat.com/u/Mumbo_6)\
**Post date:** [July 11, 2020, 10:51am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/3 "2020-07-11T10:51:42Z")

</div>

yes please @AnSeDra (20 characters)

---

<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:** [July 11, 2020, 10:53am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/4 "2020-07-11T10:53:55Z")

</div>

Can you show me the link to the level?

Andrei

---

<div class="post-metadata">

**Author:** ![Mumbo\_6](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mumbo_6/32/14166_2.png) [@Mumbo\_6](https://discourse.codecombat.com/u/Mumbo_6)\
**Post date:** [July 11, 2020, 10:54am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/5 "2020-07-11T10:54:17Z")

</div>

sure thing  
here you go: [https://codecombat.com/play/level/gem-by-gem](https://codecombat.com/play/level/gem-by-gem)?

---

<div class="post-metadata">

**Author:** ![Mumbo\_6](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mumbo_6/32/14166_2.png) [@Mumbo\_6](https://discourse.codecombat.com/u/Mumbo_6)\
**Post date:** [July 11, 2020, 10:57am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/6 "2020-07-11T10:57:32Z")

</div>

Im also new here so i might not know how some stuff works

---

<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:** [July 11, 2020, 10:58am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/7 "2020-07-11T10:58:39Z")

</div>

Ok then.

> [@Mumbo\_6](#):
>
> `baseGem.next = freeGems[2]`

This means that we have the elements in this order:  
baseGem, freeGems.  
You should have this order in order to complete the level:  
freeGems[1], freeGems[0], baseGem, freeGems[2], freeGems[3], freeGems[4].  
Do you understand?

Andrei

---

<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:** [July 11, 2020, 11:00am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/9 "2020-07-11T11:00:18Z")

</div>

So do you need any more help?

Andrei

---

<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:** [July 11, 2020, 11:01am UTC](https://discourse.codecombat.com/t/solved-help-on-gem-by-gem/22920/11 "2020-07-11T11:01:25Z")

</div>

Can you show me your recent code @Mumbo_6?

Andrei
