Skip to content

Instantly share code, notes, and snippets.

@maxwellnewage
Last active March 13, 2025 15:42
Show Gist options
  • Save maxwellnewage/2b87957bbd8f6a378a3c9b951d1a70c6 to your computer and use it in GitHub Desktop.
Save maxwellnewage/2b87957bbd8f6a378a3c9b951d1a70c6 to your computer and use it in GitHub Desktop.
Weekly Challenge - Hidden Calculator Words
"""
At school, we used to play with our calculators and send each other secret messages.
The trick was to enter a special number and turn the calculator upside-down.
Like saying hello, you’d type in the calculator 07734 and turn it upside down.
Given a number, create a function that converts it into a word by turning the integer 180 degrees around.
"""
number_letter_list = [
"I", "Z", "E", "H", "S", "G", "L", "B", "-", "O"
]
def turn_calc(number: str): # String type on number because we have zero
number = number.replace(".", "") # ignore dots
number_list = list(reversed(number)) # turn 180 degrees around
word_map = map(lambda n: number_letter_list[int(n) - 1], number_list) # list starts at 0, so (7-1) = L
print("".join(word_map))
if __name__ == '__main__':
turn_calc("707") # LOL
turn_calc("5508") # BOSS
turn_calc("3045") # SHOE
turn_calc("07734") # HELLO
turn_calc("0.7734") # HELLO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment