Created
August 12, 2014 05:42
-
-
Save irvingprog/a7098069c401607dacab 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
package main | |
import ("fmt" | |
"strings") | |
func main() { | |
var letters string = "acdegilmnoprstuw" | |
var chars = []string{} | |
var hash int64 = 956446786872726 | |
var reverse_chars = []string{} | |
for i := 1; i<10; i++ { | |
for i, char := range letters { | |
if int64((hash - int64(i))) % 37 == 0 { | |
chars = append(chars, string(char)) | |
hash = int64((hash - int64(i))) / 37 | |
break | |
} | |
} | |
} | |
for i:= len(chars)-1; i>=0 ;i-- { | |
reverse_chars = append(reverse_chars, string(chars[i])) | |
} | |
fmt.Println(strings.Join(reverse_chars, "")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment