Given a date, the current Dow Opening, and your current coordinates as a rounded integer, produce a "geohash."
Input through any reasonable means (STDIN, function argument, flag, etc.) the following:
- The current date. This does necessarily have to be the date of the system's clock, so assume that the input is correct.
- The most recent Dow Opening (must support at least 2 decimal places)
- The floor of your current latitude and longitude.
To make input easier, you can input through any reasonable structured format. Here are some examples (you may create your own):
["2005","05","26","10458.68","37",-122"] 2005-05-26,10458.68,37,-122 05-26-05 10458.68 37 -122
Given your arguments, you must perform the "geohash" algorithm illustrated in the comic. The algorithm is as follows.
- Format the date and Dow Opening in this structure:
YYYY-MM-DD-DOW. For example, it might look like
- Perform an md5 hash on the above. Remove any spacing or parsing characters, and split it in to two parts. For example, you might have these strings:
- Append each string to
0.and convert to decimal. Using the above strings, we get the following:
0.8b672cb305440f97, which is converted to decimal as aproximately
0.5445430695592821056. You must truncate it down the the first 8 characters, producing
- Combine the coordinates given through input and the decimals we just produced:
- To prevent the code from being unbearably long, you may use a built-in for the md5 hash.
- Standard loopholes (hardcoding, calling external resource) are forbidden.