OFFSET
1,2
COMMENTS
This is the distance 4 lexicode over the decimal alphabet.
LINKS
J. H. Conway, Integral lexicographic codes, Discrete Mathematics 83.2-3 (1990): 219-235.
J. H. Conway and N. J. A. Sloane, Lexicographic codes: error-correcting codes from game theory, IEEE Transactions on Information Theory, 32:337-348, 1986.
MAPLE
# Hamming distance in base b
Hammdist:=proc(m, n, b) local t1, t2, L1, L2, L, d, i;
t1:=convert(m, base, b); L1:=nops(t1);
t2:=convert(n, base, b); L2:=nops(t2); L:=L1;
if L2<L1 then for i from 1 to L1-L2 do t2:=[op(t2), 0]; od;
elif L1<L2 then for i from 1 to L2-L1 do t1:=[op(t1), 0]; od; L:=L2;
fi;
d:=0;
for i from 1 to L do if t1[i]<>t2[i] then d:=d+1; fi; od;
d; end;
# Build lexicode with min distance D in base b, search up to M
# C = size of code found, tooc = 1 means too close to code
unprotect(D);
lexicode := proc(D, b, M) local cod, v, i, tooc, C;
cod:=[0]; C:=1;
# can we add v ?
for v from 0 to M do
tooc:=-1;
for i from 1 to C do
if Hammdist(v, cod[i], b)<D then tooc:=1; break; fi;
od:
if tooc = -1 then C:=C+1; cod:=[op(cod), v]; fi;
od:
cod;
end;
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Jul 20 2021
STATUS
approved