Cody

Solution 423385

Submitted on 27 Mar 2014 by Tim
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
1
ans = 1
2   Pass
%% o=opponents(1,1); assert(isequal(o,[0 1;1 0])) 2
ans = 2
3   Pass
%% o=opponents(2,1); assert(isequal(o,[0 1 0 0;1 0 0 0;0 0 0 1;0 0 1 0])) 3
ans = 3
4   Pass
%% o=opponents(2,2); assert(isequal(o,[0 0 1 1;0 0 1 1;1 1 0 0 ;1 1 0 0])) 4
ans = 4
5   Pass
%% for w=1:5 N=randi(5); R=randi(N); o=opponents(N,R); assert(isequal(size(o),[2^N 2^N])) for v=1:10; i=randi(2^N); j=randi(2^N); q=dec2bin([i;j]-1,N)-'0'; % i might face j in round R if they are identical % in the leftmost N-R bits, but differ in the (N-R+1)th bit assert(o(i,j)==(1==polyval(abs(diff(q(:,1:N-R+1))),2))) end end