If Confusion in Python

What is the output of this code snippet?

 

def ifConfusion(x,y):
    if x>y:
        if x-5>0:
            x = y
            if y==y+y:
                return "A"
            else:
                return "B"
        elif x+y>0:
            while x>y:
                x = x-1
            while y>x:
                y = y-1
            if x==y: return "E"
        else:
            x = 2 * x
            if x==y: return"F"
            return "G"
    else:
        if x-2>y-4:
            x_old = x
            x = y * y
            y = 2 * x_old
            if (x-4)**2>(y-7)**2:
                return "C"
            else:
                return "D"
        return "H"
    
print(ifConfusion(3,7))

Now it is getting interesting!
When I made this puzzle, I thought that it might be too simple. But look at the numbers: only 36% of our users solved it. An interesting observation is that the puzzle has still a low Elo rating. This indicates that finxters with higher Elo can solve it with very low error rates and push it downwards the Elo latter. But finxters with lower Elo ratings struggle with the puzzle.

First of all, never let the sheer mass of code intimidate you. You simply start below with the function call ifConfusion(3,7), so x=3 and y=7. Then you do what the interpreter does. As x>y is false, you can skip the whole upper part of the function. Similarly, you can skip the if branch for x-2>y-4, so the function returns ‘H’.

 


Are you a master coder?
Test your skills now!

 

Related Video

Solution

H

 

Leave a Comment

Your email address will not be published. Required fields are marked *