Flawless Pairs Help Needed


I am stuck on the Flawless Pairs problem with Python. My character gets stuck at the first moveXY. I am not sure if it a problem with my code, my browser, or possibly the level.
Here is the revelant part of my code:
hero.moveXY(gemPair[0].pos.x, gemPair[0].pos.y)
hero.moveXY(gemPair[1].pos.x, gemPair[1].pos.y)



Could you post the whole your code?


Yes. Here it is below. Thanks!

[removed as a solution]


Hm, your code works fine for me. I suppose it’s an equipment problem or unlucky seed or a bug. Could you say your codecombat username and I’ll research the problem for your case.


Thanks. It is Balengar.


Hm. I see a problem. It’s a pet, I’m not sure how, but it affects on the level. It’s definitely a bug, however, you can pass this level by removing the pet (while I trying to fix the problem with a pet).


Thanks! That is an odd error, but at least we know how to get around it now.


I fixed that problem. Now it should work with pets.


I used your code and it doesn’t work


I can’t get the haste. Do you know why?


I can’t get haste either. What I did was instead of moving to the X, I moved somewhere closer to the gems so I could do the level faster.


I couldn’t get haste either so I used the moved the Y method (closer to gems) but you can also change characters to one with more speed. I used Tharin at first and failed miserably so then I changed to Pender Spellbane and Arryn Stonewall and both of those completed the level without the haste spell. It didn’t matter about the Pet. I do have fast boots (boots of Leaping +2M/S).


Thanks! I’ve fixed the problem. Now the hero gets “haste”.


My code isn’t working. For some reason My character is just moving around on the spot. I cannot figure out how to fix that. Can you please help me debug it? Here is my non-working code and a photo of the items that I am using. Thanks in advance.

# Collect 4 pairs of gems.
# Each pair must contain equal valued gems.

# This function returns two items with the same value.
def findValuePair(items):
    # Check each possible pair in the array.
    # Iterate indexes 'i' from 0 to the last one.
    for i in range(len(items)):
        itemI = items[i];
        # Iterate indexes 'j' from 0 to the last.
        for j in range(len(items)):
            # If it's the same element, then skip it.
            if i == j:
            itemJ = items[j];
            # If we found a pair with two equal gems, then return them.
            if itemI.value == itemJ.value:
                return [itemI, itemJ]
    # Return an empty array if no pair exists.
    return None

while True:
    gems = hero.findItems()
    gemPair = findValuePair(gems)
    # If the gemPair exists, collect the gems!
    if gemPair:
        gemA = gemPair[0]
        gemB = gemPair[1]
        # Move to the first gem.
        # Return to get the haste from the wizard.
        hero.moveXY(40, 44)
        # Then move to the second gem.
        # Return to get the haste from the wizard.
        hero.moveXY(40, 44)

My code.
My equipment.
Please Help!


You shouldn’t use the move method here. Just use moveXY. When you use the moveXY method, the code will have the hero move to the target position and it will not do anything else until it arrives there. When you use the move method, the code has the hero take a single step in the direction of the target, and then checks to see if there’s anything else that it can be doing, in this case that means checking the next line of code, which is the moveXY method.

Just stick to the moveXY method and the code will work.


Thanks for the help. Here’s the thing… I finished that level already :grinning:!