Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-269

Confusing Number Check

Problem

Return True if rotating the number 180 degrees produces a valid but different number, and False otherwise.

Digits 0, 1 and 8 stay the same, 6 and 9 swap, and any other digit makes the rotation invalid. A number that rotates to itself, such as 11 or 0, is not confusing.

Hint

Reversing the digits before mapping mirrors the 180-degree rotation.

Test cases

case 1
in: [6]
expected: true
case 2
in: [89]
expected: true
case 3
in: [11]
expected: false
case 4
in: [25]
expected: false
case 5
in: [0]
expected: false
case 6
in: [8000]
expected: true
Starter codePython
def is_confusing_number(n):
    # Your code here
    pass

6 test cases · run your code against them in the editor