Find which command used
1 view (last 30 days)
Show older comments
What matlab command, or combination of commands (using 25 characters or less), could be used to create the following matrix?
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0
1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0
1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0
1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0
1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0
1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0
1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Hint: Look for a lower triangluar matrix that is repeated many times. First try to produce that lower triangular matrix with as few characters as possible.
8 Comments
Jan
on 6 Mar 2015
I miss Matt Figs the hump-day puzzlers. The assessment method of Cody collide with my personal opinion about nice and efficient code.
Adam
on 6 Mar 2015
Yes, I never go near Cody personally since I found that 'best' solutions to many problems involve some ridiculous use of regexp. Personally my idea of good code doesn't involve using the fewest characters possible!
Answers (1)
Star Strider
on 3 Mar 2015
This looks like a homework assignment, so I’ll direct you to three functions: ones, tril, and repmat.
2 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!