Guest User

Untitled

a guest
Mar 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. 0:000000
  2. 1:100011
  3. 2:010111
  4. 3:110100
  5. 4:001110
  6. 5:101101
  7. 6:011001
  8. 7:111010
  9.  
  10. % code words
  11. int: n = 8;
  12. int: d = ceil(log2(n));
  13.  
  14. % total bits
  15. int: t = d + 3;
  16.  
  17. array[1..n, 1..t] of var bool: code;
  18.  
  19. function var int: hammingDistance(int: a, int: b) =
  20. sum([code[a, i] != code[b, i]| i in 1..t]);
  21.  
  22. constraint forall(i, j in 1..n where j > i) (
  23. 3 <= hammingDistance(i, j)
  24. );
  25.  
  26. constraint forall(i in 1..n) (
  27. (1*code[i, 1] + 2*code[i, 2] + 4*code[i, 3]) == (i-1)
  28. );
  29.  
  30. solve satisfy;
  31.  
  32. output
  33. [if j == 1 then "n" ++ show(i) ++ ":" else "" endif ++
  34. if show(code[i,j]) == "true" then "1" else "0" endif | i in 1..n, j in 1..t] ++
  35. ["n"];
Add Comment
Please, Sign In to add comment