# Binary Codes and its distance [closed]

Find n binary codes of length n such that distance between each pair is n/2 , where n is a even number , if possible?How to generate all codes? for example if n=4 we have 1110,1101,1011,0111 each pair have distance 2. Distance between a pair of code means number of different bits in both code words. For example 1110 and 1101 ,only last two bits are different so distance between this pair is 2.Here n<=100.

## closed as off-topic by Will Jagy, Stefan Kohl, Stopple, Ryan Budney, Boris BukhSep 10 '15 at 1:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about research level mathematics within the scope defined in the help center." – Will Jagy, Stefan Kohl, Stopple, Ryan Budney, Boris Bukh
If this question can be reworded to fit the rules in the help center, please edit the question.

• Can give some link about details how to generate Hadamard matrices for any n? – subrat singh Sep 9 '15 at 21:59
• @subratsingh Have you seen these yet?wolfram,wiki – Henry.L Sep 10 '15 at 0:35

Hadamard code is indeed the answer you want. Hadamard matrices are conjectured to exist for all n which are multiples of 4. This is very hard to prove and a longstanding open problem. Sylvester Hadamard matrices can be explicitly constructed for all n which are positive integer powers of 2.

Well I would have commented, but I don't have 50 reputation so I have to post an answer :(

Notice that the distance is always half the block length, as required.
As explained under the "Construction" category, the generator matrix for the Hadamard code of rank is constructed by listing all the binary strings of length k in lexicographical order as column vectors.
The example for k=3 is given in the wiki, and for k=4 you get

G =
| 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 |
| 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 |
| 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 |
| 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 |

Hope this helps :)

• I don't think this answers the question as the OP was looking for a square matrix. – Anthony Quas Sep 9 '15 at 23:08
• Well, using the generating matrix you can construct the code- Had(x) = x*G. So, if you go over all strings binary x of length k and multiply by G (of rank k), you will get the actual code. – mikibest2 Sep 10 '15 at 8:42
• what the... I'm trying to help, how is this spam? I would have commented, but I don't have enough reputation so I'm forced to answer instead. BTW, my answer here is in the same direction as the other answer given, just more explanatory, and I actually posted it 2 minutes after the first guy because I didn't notice. – mikibest2 Sep 10 '15 at 23:14
• @Arul: I don't think this is spam at all. I think in the end that the answer is not helpful because it constructs matrices of size $n\times 2^n$, whereas the OP wanted $n\times n$ matrices, but who hasn't given a wrong answer at some point? Also calling people spammers in public is probably not a good idea on a public forum. (Maybe you could delete your comment?) – Anthony Quas Sep 11 '15 at 0:09
• ok sorry I will remove – user76479 Sep 11 '15 at 0:37