Ctrl K

Upside-Down Number

Easy
A cloakroom tag can easily get hung upside down. Turned 180°, the digits 0, 1 and 8 stay the same, 6 becomes 9 and 9 becomes 6. The digits 2, 3, 4, 5 and 7 cannot be read upside down. You get a number number. Return True if every digit is still readable after the turn and the result is a **different** number, and False otherwise. Leading zeros after the turn are dropped: 1000 becomes 0001, which is just 1.
Example 1
number=86 → True

Turning 86 over makes the 6 a 9, keeps the 8, and swaps their places: 98, a different number.

Example 2
number=609 → False

Turned over, 609 still reads 609, so the number is unchanged.

Example 3
number=17 → False

The digit 7 is unreadable upside down, so the answer is no.

Constraints
  • 0 ≤ number ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Number That Reads Both Ways EasyValue of a Roman Numeral EasyAdd One to a Digit Array EasySum of Binary Strings EasyWhole Square Root Easy
loading Python…
Input
number=86
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.