Cody

Problem 2225. Three...is a magic number.

Solution 1233712

Submitted on 18 Jul 2017 by Daniel Meier
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
x=[ 1 2 7 6 7 2 7 7 ; 7 7 5 3 5 3 2 5 ; 1 6 5 4 3 5 7 5 ; 6 6 7 4 6 3 7 1 ; 4 2 4 2 2 5 5 6 ; 2 4 4 7 4 4 2 7 ; 7 4 2 3 6 4 7 1 ; 4 6 4 2 5 5 1 4]; y_correct = 0; assert(isequal(match_three(x),y_correct))

d = 6 5 -2 -3 -2 1 -5 -2 -6 -1 0 1 -2 2 5 0 5 0 2 0 3 -2 0 -4 -2 -4 -3 -2 -4 2 -2 5 -2 2 0 5 2 -1 -3 1 5 0 -2 -4 2 0 5 -6 -3 2 2 -1 -1 1 -6 3 d = 1 0 5 0 -2 2 -3 2 5 -2 -1 1 2 0 -2 -2 -1 -2 -1 -3 -2 3 1 -2 1 2 -1 2 0 -3 3 3 -5 -2 2 -3 3 0 -2 0 5 -1 2 4 0 -2 3 -4 0 3 -2 -6 1 5 -6 3

2   Pass
x=mod(magic(4),4); y_correct = 0; assert(isequal(match_three(x),y_correct))

d = 1 1 -1 -1 0 0 0 0 -1 -1 1 1 d = 2 2 2 2 1 -1 -1 1 -2 -2 -2 -2

3   Pass
x=mod(magic(7),2); y_correct = 1; assert(isequal(match_three(x),y_correct))

d = 0 0 1 0 0 0 1 0 -1 -1 0 0 0 0 1 0 0 0 0 -1 0 0 1 0 0 0 0 -1 0 0 0 0 1 1 0 -1 0 0 0 -1 0 0 d = 1 1 0 -1 0 0 1 -1 0 0 0 -1 -1 -1 1 0 1 1 1 1 1 -1 -1 -1 -1 -1 0 -1 1 1 1 0 0 0 1 -1 0 0 1 0 -1 -1

4   Pass
x=[5 2 3 ; 5 3 2 ; 5 4 1] ; y_correct = 1; assert(isequal(match_three(x),y_correct))

d = 0 1 -1 0 1 -1 d = -3 -2 -1 1 -1 -3

5   Pass
x=[ 3 3 4 2 1 3 1 5 4 3 1 6 1 5 3 6 1 2 3 1 5 3 3 2 5 6 3 1 3 6 5 3 1 5 6 4 2 4 2 4 3 3 2 6 5 1 5 1 4]; y_correct = 1; assert(isequal(match_three(x),y_correct))

d = 2 1 -1 -1 5 -2 4 -2 2 -2 1 -3 0 0 0 -3 1 3 3 2 -4 0 3 3 -2 -5 2 5 1 -4 -1 -1 3 -2 -3 -2 4 1 -1 1 -2 1 d = 0 -1 3 0 3 -2 4 1 -1 -5 -1 -1 2 -1 -2 -2 1 3 -2 -2 -4 -1 5 1 1 -2 2 4 2 -5 -2 -3 4 -1 -4 -2 4 4 -2 1 0 3

6   Pass
x=[ 1 1 1 ; 4 2 3 ; 2 3 4]; y_correct = 1; assert(isequal(match_three(x),y_correct))

d = 3 1 2 -2 1 1 d = 0 -2 1 0 1 1

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

d = 3 3 3 3 3 3 d = 1 1 1 1 1 1

8   Pass
x=[ 1 1 1 1 ; 2 4 6 8 ; 3 6 9 12 ; 4 8 12 16]; y_correct = 1; assert(isequal(match_three(x),y_correct))

d = 1 3 5 7 1 2 3 4 1 2 3 4 d = 0 2 3 4 0 2 3 4 0 2 3 4

9   Pass
x=[ 1 5 7 9 ; 1 5 7 9 ; 2 4 6 8 ; 1 5 7 9]; y_correct = 0; assert(isequal(match_three(x),y_correct))

d = 0 0 0 0 1 -1 -1 -1 -1 1 1 1 d = 4 4 2 4 2 2 2 2 2 2 2 2