I've tried to implement the Open Location Code algorithm as identified in the open-location-code github page, however I found the guide confusing as it works from smallest-to-largest, multiplying by various numbers and taking the modulus of the numbers at each iteration.
I found it much easier to work from largest-to-smallest, i.e. left to right. The 'algorithm' I've used is as follows:
define table[2,3,4,5,6,7,8,9,C,F,G,H,J,M,P,Q,R,V,W,X]
Calculating the most significant 10 digitsAdd 90 to the latitude - lat = lat + 90Add 180 to the longitude - lon = lon + 180Divide latitude by 20 - lat = lat / 20Divide longitude by 20 - lon = lon / 20Lookup Integer of Latitude in table for first output character - print table[int(lat)]Lookup Integer of Longitude in table next output character - print table[int(lon)]Loop 4 times:If on 4th loopAdd plus as next output character - print '+'Multiply remainder of Latitude by 20 - lat = 20 * (lat - int(lat))Multiply remainder of Longitude by 20 - lon = 20 * (lon - int(lon))Lookup Integer of Latitude for next output character - print table[int(lat)]Lookup Integer of Longitude for next output character - print table[int(lon)]Calculating the least significant 5 digitsLoop up to 5 times:Multiply remainder of Latitude by 5 - lat = 5 * (lat - int(lat))Multiply remainder of Longitude by 4 - lon = 4 * (lon - int(lon))Lookup Integer of Lat*4 + Integer of Lon for next output character - print table([4*int(lat)+int(lon)]