The algorithm takes input for a string’s length for **L**, and the number of strings altogether for **X**. The hamming distance is for input **D**. Input **Z** calculates the exact amount of all possible characters in the string besides the permutations for input **D**.

We get a set of **Z** amount of characters. We divide **Z** by **D** which is **S**. We get **B** possible permutations of characters that can be generated in a list of **X** strings. In other words, **Z** divided by **Y** groupings of the same **X** should uniquely have **B** possible permutations within the **Z** characters. (For the center numerical listed string based on hamming?)

If the algorithm is, correct (or I’ve misled). The center of **Z** is at the **S** string which should be the **B** permutation.

NOTE: The concept is to visualize our strings as a number line.

Here the algorithm is written in *Ancient Basic* from a TRS-80 computer.

`0 A=1 1 INPUT "LENGTH OF STRING";L 2 INPUT "X FOR HOW MANY";X 3 INPUT "D FOR HAMMING DISTANCE";D 4 Z = X * X * 1 * L + X * D * D * D 5 S = Z / D 6 B = S / D 7 Y = S / B 8 CL = D * A ≤ X ≤ B * Y 10 P=B*Y 11 PRINT "CLOSEST STRING", CL, "P=", P 12 IF S = S * D / D THEN PRINT"S = S * D / D", S * D / D 13 IF D = Z / S THEN PRINT"D = Z / S", Z / S 15 PRINT"PROOF", P, S `

I also continue with the algorithm to find where the 2nd closest string, 3rd closest, 4th and so on.

`16 PRINT"WOULD YOU LIKE TO FIND CUSTOM CLOSEST STRING?";R$ 17 IF R$ =YES$ THEN GOTO 19 18 IF R$ =NO$ THEN GOTO 19 19 INPUT "ENTER # FOR CLSE STRING";RT 20 GOTO 21 21 PRINT"YOUR CLOSEST STRING"RT, S / RT 90 NQ = S / RT 91 P = RT * NQ 92 IF P = NQ THEN PRINT P, NC, "LUCKY" `