Last active
August 29, 2015 14:04
-
-
Save irvingprog/f959ef208fdd41198f4a to your computer and use it in GitHub Desktop.
Hash reversed challenge to developer job position at Trello.com
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
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
# | |
# Copyright 2014 - Irving Prog | |
# License: LGPLv3 (see http://www.gnu.org/licenses/lgpl.html) | |
def hash_reversed(hash_): | |
LETTERS = 'acdegilmnoprstuw' | |
chars = [] | |
while hash_ > 37: | |
for i, letter in enumerate(LETTERS): | |
if (hash_ - i) % 37 == 0: | |
chars.append(letter) | |
hash_ = (hash_ - i) / 37 | |
break | |
return ''.join(reversed(chars)) | |
def main(): | |
hash_ = 910897038977002 | |
print hash_reversed(hash_) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment