Is It the Same Upside Down?

Published by Mubashir Hassan in

The number 6090609 has a special property: if you turn the number upside down (imagine rotating your screen 180 degrees), you get 6090609 again.

Write a function that takes a string on the digits 0, 6, 9 and returns true if the number is the same upside down or false otherwise.

Examples

same_upsidedown("6090609") ➞ true

same_upsidedown("9669") ➞ false
# Becomes 6996 when upside down.

same_upsidedown("69069069") ➞ true

Notes

N/A

Watch a quick demo on how Edabit works.