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
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers13
Suggested Problems
-
3403 Solvers
-
360 Solvers
-
Program an exclusive OR operation with logical operators
750 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
559 Solvers
-
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
254 Solvers
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!
In the problem description, you say "The integers should be chosen from the set 1 to n." However, in your example for a 2x2 matrix, you have a 3 as one of the terms. Am I missing something?
function a = match_rot(n)
The problem says given n and s.
However, only n is provided.
Are we allowed to set s?
s=feval(@evalin,'caller','s');
Lack of s input solved
Sorry guys. Sloppy problem creation on my part. Unfortunately my signature change will invalidate all the solutions up to this point, but yes it should be match_rot(n,s)
"since rot90(a) matches a in exactly _two_ places" for the example in the problem statement?