Mining the Julian coin
Objective
Improve Julia coding skills.
Introduction
Bitcoin is going crazy these days and mining a new coin is becoming more and more difficult. Why chase after the hot stuff? We have something easier here!
Introducing the Julian Coin - it's easy to mine and it's based upon a common hashing algorithm called MD5. Each coin can be discovered from a secret. To start mining, concatenate the secret with a positive integer and run it through the MD5 hashing algorithm. You get the coin by finding the smallest number that gives you a hash code both starting and ending with 3 zeros. (You may use any MD5 library.)
For examples:
- Secret
hello
requires6144434
to get the coin - Secret
julia
requires1436069
to get the coin
We can prove it from a Unix terminal:
$ echo -n "hello6144434" | md5sum
0006a1061ece946b7e95c2af73773000
$ echo -n "julia1436069" | md5sum
000d02cb0a523a25820ea72bb959d000
What to do
Write a function mine_julian_coin(s::String)
that returns the number and the corresponding hash code as a named tuple.
For example:
julia> mine_julian_coin("hello")
(key = 6144434, hash = "0006a1061ece946b7e95c2af73773000")
Can you use your program to mine the Julian Coin with secret super awesome
?
How to submit your solution?
You can publish your code on GitHub in a repository or as a public gist. Include the link in the comments.