TITLE: Find a ternary $4\times 39$ matrix satisfying the conditions below
QUESTION [8 upvotes]: Can you find a matrix $A_{4\times39}$ with elements from $\{-1,0,1\}$ so that

No column is all zero.
All columns are different.
No column is $-1$ times another column.
Each row consists of $13$ of each of $\{-1,0,1\}$.

How can you do that? Is it possible to generalize this case?

REPLY [2 votes]: Here is a human and fiddling-free approach.
Since  the order cannot be of matter, we fill the top rows with 13 of each in order giving
($-1 \times 13, 0 \times 13, 1 \times 13$) and we call them block-columns A,B,C. Similarly, if we fill the next row using ($-1 \times 13, 1 \times 13, 0 \times 13$) (block-columms D,E,F), we would have already solved the problem completely if it was asking for a $ (4) \times (3 \times 9) $ matrix, because each block-column can then be filled with the $9$ permutations left for the two remaining rows, while satisfying all conditions automatically because of our choice of roots and permutations balancing the digits equally.  
But this is already a good partial result, so we do just that, except that we split D,E,F into (D,D'),(E,E'),(F,F') with D,E,F of size $9$ columns each, and the others of size $13-9=4$ each. We still need to determine how D',E',F' are filled. To avoid negation conflicts, we choose (for the second rows still) ($1 \times 4, 0 \times 4, -1 \times 4$). 
We are done if we fill the last two rows of D',E',F'. E' is guaranteed to be conflict free (except for $(0,0,0,0)$) so we use it as a 'rest collector'. For D',F', their roots being negatives, we simply decide to make the rest two columns equal, and this is indeed possible. We need for each row to use four of each digit (to add up to $13$). So we split $-1$ two for each of D' and F', then we take one $0$ for each and one $1$ for each, putting the rest in E'. We are done.  
The result then looks like this:

(This probably does not generalize easily though.)
.

Addendum  

This general procedure occurred to me. It is very boring and not really elegant; but it can be used to generalize the solution.
The approach is to generate all permutations (not too much to ask for, since we will need half of them anyway) in a specific order. Usually I would generate permutations in an ascending order like this: $$ \pmatrix{-1 \cr -1 \cr -1 \cr -1},\pmatrix{-1 \cr -1 \cr -1 \cr 0},\pmatrix{-1 \cr -1 \cr -1 \cr 1},\pmatrix{-1 \cr -1 \cr 0 \cr -1},\pmatrix{-1 \cr -1 \cr 0 \cr 0},...\pmatrix{1 \cr 1 \cr 1 \cr 1}$$ In this case, it is better to 'interleave the beginning and end', so that each column has its negative directly after it. This happens automatically if we procede like above, but after each column, we add its negative. $$ \pmatrix{-1 \cr -1 \cr -1 \cr -1},\pmatrix{1 \cr 1 \cr 1 \cr 1},\pmatrix{-1 \cr -1 \cr -1 \cr 0},\pmatrix{1 \cr 1 \cr 1 \cr 0},\pmatrix{-1 \cr -1 \cr -1 \cr 1},\pmatrix{1 \cr 1 \cr 1 \cr -1},...\pmatrix{0 \cr 0 \cr 0 \cr 0}$$ The task then becomes clear: From each pair we have to choose only one until the matrix is filled. To do this while respecting the '13 in a row constraint', we simply keep track of how many allowed choices are left for each digit in each row, this needs $12=4 \times 3$ numbers to track. The process will always work, we will never need to backtrack, and we will be very bored.   
But this at least allows generalizing the solution: it works for any matrix of size $(n \times (floor(\dfrac {3^{n-1}} {2}) \times 3)) $, with the $13$ of condition 4) replaced by $floor(\dfrac {3^{n-1}} {2})$.