Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Help on Gem by Gem

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

# 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

1 Like

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

Andrei

1 Like

yes please @AnSeDra (20 characters)

1 Like

Can you show me the link to the level?

Andrei

1 Like

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

2 Likes

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

2 Likes

Ok then.

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

1 Like

So do you need any more help?

Andrei

1 Like

Can you show me your recent code @Mumbo_6?

Andrei

2 Likes