Skip to content

Instantly share code, notes, and snippets.

@davidjmemmett
Created October 22, 2017 08:54
Show Gist options
  • Save davidjmemmett/209c006a1c4516bc4c576153cf5e25af to your computer and use it in GitHub Desktop.
Save davidjmemmett/209c006a1c4516bc4c576153cf5e25af to your computer and use it in GitHub Desktop.
from math import sqrt
from time import time
def standup_hash(i):
first_six_dp = str(sqrt(sqrt(sqrt(sqrt(sqrt(i)))))).split('.')[1][:6]
nums = [x for x in first_six_dp]
nums.sort()
return ''.join(nums)
if __name__ == '__main__':
start = time()
for i in range(100):
if standup_hash(i) == '023447':
print 'brute force', (i * 1.0)
print 'time for brute force %.06f' % (time() - start)
#
# /|\b
# / | \
# a/ |--\
# / | |c
# / | e |
# ---------
# d
start = time()
a = sqrt(pow(1, 2) + pow(1, 2))
d = sqrt(2)
e = d - 1
c = 1 - e
b = sqrt(pow(e, 2) + pow(e, 2))
print 'actual result', a + b + c + d
print 'time for real %.06f' % (time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment