[Code]
pairs <- t(combn(4, 2))
H <- sapply(seq_len(nrow(pairs)), function(e) as.integer(1:4 %in% pairs[e, ]))
H
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 1 1 1 0 0 0
#> [2,] 1 0 0 1 1 0
#> [3,] 0 1 0 1 0 1
#> [4,] 0 0 1 0 1 1
colSums(H)
#> [1] 2 2 2 2 2 2
rowSums(H)
#> [1] 3 3 3 3
words <- as.matrix(expand.grid(rep(list(0:1), 6)))
is_codeword <- apply(words, 1, function(y) all((H %*% y) %% 2 == 0))
sum(is_codeword)
#> [1] 8