Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0:000000
- 1:100011
- 2:010111
- 3:110100
- 4:001110
- 5:101101
- 6:011001
- 7:111010
- % code words
- int: n = 8;
- int: d = ceil(log2(n));
- % total bits
- int: t = d + 3;
- array[1..n, 1..t] of var bool: code;
- function var int: hammingDistance(int: a, int: b) =
- sum([code[a, i] != code[b, i]| i in 1..t]);
- constraint forall(i, j in 1..n where j > i) (
- 3 <= hammingDistance(i, j)
- );
- constraint forall(i in 1..n) (
- (1*code[i, 1] + 2*code[i, 2] + 4*code[i, 3]) == (i-1)
- );
- solve satisfy;
- output
- [if j == 1 then "n" ++ show(i) ++ ":" else "" endif ++
- if show(code[i,j]) == "true" then "1" else "0" endif | i in 1..n, j in 1..t] ++
- ["n"];
Add Comment
Please, Sign In to add comment