Last active
January 12, 2016 08:49
-
-
Save olafurw/24d336dc162678d0a76f to your computer and use it in GitHub Desktop.
The A4 Paper Puzzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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