({{a, b}, {c, d}})

a, b, c and d are Lists of 300 length. Their first 4 elements must specify their position in the column (1 column, 2 column, etc) and the following 4 elements the position in the line (1 line, 2 line, etc) but this must be made in binary code and not a 2x2 Table but a 10x10. Also, they must only contain -1, 0 or 1.

I was thinking about creating the vector with a smaller length and use AppendTo to put the position based on the table index and converting it to binary but couldn't find a final solution.

  • $\begingroup$ That had something wrong in it. Sorry. Is it better to understand now? Or still confusing? $\endgroup$ – André F. Jun 18 '14 at 23:29
  • 1
    $\begingroup$ Let me try and paraphrase this, tell me if I'm correct: You want a 10X10 matrix. Each entry is a 300 length vector, first 4 elements represent the second dimension position in binary, second 4 elements the first dimension, and the rest of the list is randomly (based on post before edits) selected elements from {-1,0,1}. Is that it? $\endgroup$ – ciao Jun 18 '14 at 23:43

This does what you're after, I believe (see my comment question) - if not, I'll delete this answer:

result=Partition[Join @@@ Transpose[{Join @@@ Reverse /@ Tuples[IntegerDigits[Range@10, 2, 4], {2}], 
       RandomChoice[{-1, 0, 1}, {100, 292}]}], 10]
  • $\begingroup$ Your comment says exactly what I'm after for. Sorry for my bad English on explanation. It this code do that than is exactly what I want $\endgroup$ – André F. Jun 18 '14 at 23:49
  • $\begingroup$ @AndréF.: try it, tell me if it's what you intended... $\endgroup$ – ciao Jun 18 '14 at 23:49
  • $\begingroup$ I can't check all results but from what I could see that's exactly it. Thank you @rasher $\endgroup$ – André F. Jun 18 '14 at 23:53
  • 1
    $\begingroup$ @AndréF.: Cool. Glad to help. $\endgroup$ – ciao Jun 18 '14 at 23:53
  • 1
    $\begingroup$ @AndréF.: Do you mean as an actual array? Just use result[[i,j]] or result[[i]][[j]] (note double brackets - that is correct array part specification syntax) $\endgroup$ – ciao Jun 19 '14 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.