Geohash Generator
Python 2, 129 bytes
import md5
d,q,c=input()
h=md5.new(d+'-'+q).hexdigest()
print map(lambda p,o:o+'.'+`float.fromhex('.'+p)`[2:8],(h[:16],h[16:]),c)
Input is given in the form '2005-05-26','10458.68',('37','-122')
(using the example).
Computes the MD5 hash with md5.new().hexdigest()
, then performs the necessary transforms. I could save five bytes by using h
instead of h[:16]
, but I'm not sure if that would affect the six most significant digits in the decimal conversion.
Ideone it! (substituting an eval()
call for the input()
)