Cody

Problem 2644. The Ulam Matrix

Solution 2160691

Submitted on 15 Mar 2020 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
N = 2; y_correct=[4 3; 1 2]; assert(isequal(Ulam(N),y_correct))

a = 1 2 4 3 b = 4 3 1 2

2   Pass
N = 3; y_correct=[5 4 3; 6 1 2; 7 8 9]; assert(isequal(Ulam(N),y_correct))

a = 7 8 9 6 1 2 5 4 3 b = 5 4 3 6 1 2 7 8 9

3   Pass
N = 4; y_correct=[16 15 14 13; 5 4 3 12; 6 1 2 11; 7 8 9 10]; assert(isequal(Ulam(N),y_correct))

a = 7 8 9 10 6 1 2 11 5 4 3 12 16 15 14 13 b = 16 15 14 13 5 4 3 12 6 1 2 11 7 8 9 10

4   Pass
N = 5; y_correct=[17 16 15 14 13; 18 5 4 3 12; 19 6 1 2 11; 20 7 8 9 10; 21 22 23 24 25]; assert(isequal(Ulam(N),y_correct))

a = 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 b = 17 16 15 14 13 18 5 4 3 12 19 6 1 2 11 20 7 8 9 10 21 22 23 24 25

Suggested Problems

More from this Author2