Given n and s, return a n-by-n matrix a of integers such that

 sum(sum(a == rot90(a))) 

is equal to exactly s. The integers should be chosen from the set 1 to n.

So for instance, if n is 2, and s is 2, you could return

 a = [ 1 1 
       2 2 ] 

since rot90(a) matches a in exactly one place.

For any n and s, a is of course not unique. I'm only checking to make sure the conditions are true.

Solution Stats

42 Solutions

13 Solvers

Last Solution submitted on Feb 04, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers13

Suggested Problems

More from this Author54

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!