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"
return "B"
elif x+y>0:
while x>y:
x = x-1
while y>x:
y = y-1
if x==y: return "E"
x = 2 * x
if x==y: return"F"
return "G"
if x-2>y-4:
x_old = x
x = y * y
y = 2 * x_old
if (x-4)**2>(y-7)**2:
return "C"
return "D"
return "H"



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




Leave a Comment

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