Skip to content

Instantly share code, notes, and snippets.

@olafurw
Last active January 12, 2016 08:49
Show Gist options
  • Save olafurw/24d336dc162678d0a76f to your computer and use it in GitHub Desktop.
Save olafurw/24d336dc162678d0a76f to your computer and use it in GitHub Desktop.
The A4 Paper Puzzle
# This is regarding https://www.youtube.com/watch?v=SOgn6J12NWE
import math
def FiveSquareRoot(aNumber):
return math.sqrt(math.sqrt(math.sqrt(math.sqrt(math.sqrt(aNumber)))))
def FirstSix(aString):
decimalStr = aString.split(".")[1]
return decimalStr[:6]
def RemoveZero(aNumber):
return str(aNumber).translate(None, "0")
def SortCharacters(aString):
return ''.join(sorted(aString))
def StandupHash(aNumber):
return SortCharacters(FirstSix(RemoveZero(FiveSquareRoot(aNumber))))
# For hilarity (and testing)
if StandupHash(42) != "123789":
print "Wrong!"
for i in range(0, 10000000):
if StandupHash(i) == "234477":
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment