I need a script for a puzzle based on the user’s IP address, but I just can’t wrap my head around how to do it. The user is trying to solve for partial map coordinates presented to them as a formula. The variables for the puzzle itself would be in the form of ABC.DEF.GHI.JKL where each letter would be associated with the corresponding digit in their IP addy and a formula returned as an image.
The user is trying to solve for partial map coordinates. For the steps listed below, let’s say the correct answer is N 35 54.374 W 084 01.829 and the user’s IP is 75.36.25.58. The user is provided with the beginning of both longitude and latitude but must figure out the rest (N 35 54.??? W 084 01.???) but does not know the formula is based on their IP.
Essentially, when the visitor loads the page these processes happen:
(1) Obtain visitor’s IP address.
(2) Pad each section of IP addy with leading zeroes if less than 3 digits; i.e., if IP is 75.36.25.58 then reformat to render 075.036.025.058.
(3) Initiate loops to generate formula based on IP to produce needed digits (3,7,4,8,2,9). Loop (a) use a single letter if possible, otherwise loop (b) two letters added or subtracted if possible, otherwise loop © a number added to or subtracted to/from a letter
(4) Return formula displayed as text or as an image
So, in our example, if the user’s IP address is 75.36.25.58 and the six missing digits are 3 7 4 8 2 9 then…
(1) obtain IP 75.36.25.58
(2) Pad to render 075.036.025.058 (
ABC.DEF.GHI.JKL)
(3a) Apply loop (a) to assign 3=E, 7=B, (no 4 available), 8=L, 2=H, (no 9 available).
(3b) Apply loop (b) trying addition to render missing digits; 4 can’t be formed through addition but it can through subtraction with 6-2=F-H or 7-3=B-E. 9 can be formed with 7+2=B+H or 6+3=F+E (as well as 2+7 and 3+6).
(3c) Invoke loop ©; unnecessary here.
(4) Return final puzzle formula as text or image: N 35 54. (E) (B) (F - H) W 084 01. (L) (H) (B + H)
Whatever I use as the final correct answer will not change and be the same for all users; only the puzzle formula would differ for each user as it would be based on their IP at the moment.
Any help here would be greatly appreciated. Thanks!
Gary