Cody

Solution 588127

Submitted on 25 Feb 2015 by Dan Brackmann
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
A = [ ... 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0]; B = [ ... 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 0]; assert(isequal(life(A),B))

ans = -1 -1 1 1 w = 4 z = 4 ans = -1 0 1 1 w = 4 z = 1 ans = -1 1 1 1 w = 4 z = 2 ans = 0 -1 1 1 w = 1 z = 4 ans = 0 0 1 1 ans = 0 1 1 1 w = 1 z = 2 value = 1 ans = 1 -1 1 1 w = 2 z = 4 ans = 1 0 1 1 w = 2 z = 1 ans = 1 1 1 1 w = 2 z = 2 value = 2 ans = -1 -1 1 2 w = 4 z = 1 ans = -1 0 1 2 w = 4 z = 2 ans = -1 1 1 2 w = 4 z = 3 ans = 0 -1 1 2 w = 1 z = 1 value = 1 ans = 0 0 1 2 ans = 0 1 1 2 w = 1 z = 3 ans = 1 -1 1 2 w = 2 z = 1 ans = 1 0 1 2 w = 2 z = 2 value = 2 ans = 1 1 1 2 w = 2 z = 3 ans = -1 -1 1 3 w = 4 z = 2 ans = -1 0 1 3 w = 4 z = 3 ans = -1 1 1 3 w = 4 z = 4 ans = 0 -1 1 3 w = 1 z = 2 value = 1 ans = 0 0 1 3 ans = 0 1 1 3 w = 1 z = 4 ans = 1 -1 1 3 w = 2 z = 2 value = 2 ans = 1 0 1 3 w = 2 z = 3 ans = 1 1 1 3 w = 2 z = 4 ans = -1 -1 1 4 w = 4 z = 3 ans = -1 0 1 4 w = 4 z = 4 ans = -1 1 1 4 w = 4 z = 1 ans = 0 -1 1 4 w = 1 z = 3 ans = 0 0 1 4 ans = 0 1 1 4 w = 1 z = 1 value = 1 ans = 1 -1 1 4 w = 2 z = 3 ans = 1 0 1 4 w = 2 z = 4 ans = 1 1 1 4 w = 2 z = 1 ans = -1 -1 2 1 w = 1 z = 4 ans = -1 0 2 1 w = 1 z = 1 value = 1 ans = -1 1 2 1 w = 1 z = 2 value = 2 ans = 0 -1 2 1 w = 2 z = 4 ans = 0 0 2 1 ans = 0 1 2 1 w = 2 z = 2 value = 3 ans = 1 -1 2 1 w = 3 z = 4 ans = 1 0 2 1 w = 3 z = 1 value = 4 ans = 1 1 2 1 w = 3 z = 2 value = 5 ans = -1 -1 2 2 w = 1 z = 1 value = 1 ans = -1 0 2 2 w = 1 z = 2 value = 2 ans = -1 1 2 2 w = 1 z = 3 ans = 0 -1 2 2 w = 2 z = 1 ans = 0 0 2 2 ans = 0 1 2 2 w = 2 z = 3 ans = 1 -1 2 2 w = 3 z = 1 value = 3 ans = 1 0 2 2 w = 3 z = 2 value = 4 ans = 1 1 2 2 w = 3 z = 3 ans = -1 -1 2 3 w = 1 z = 2 value = 1 ans = -1 0 2 3 w = 1 z = 3 ans = -1 1 2 3 w = 1 z = 4 ans = 0 -1 2 3 w = 2 z = 2 value = 2 ans = 0 0 2 3 ans = 0 1 2 3 w = 2 z = 4 ans = 1 -1 2 3 w = 3 z = 2 value = 3 ans = 1 0 2 3 w = 3 z = 3 ans = 1 1 2 3 w = 3 z = 4 ans = -1 -1 2 4 w = 1 z = 3 ans = -1 0 2 4 w = 1 z = 4 ans = -1 1 2 4 w = 1 z = 1 value = 1 ans = 0 -1 2 4 w = 2 z = 3 ans = 0 0 2 4 ans = 0 1 2 4 w = 2 z = 1 ans = 1 -1 2 4 w = 3 z = 3 ans = 1 0 2 4 w = 3 z = 4 ans = 1 1 2 4 w = 3 z = 1 value = 2 ans = -1 -1 3 1 w = 2 z = 4 ans = -1 0 3 1 w = 2 z = 1 ans = -1 1 3 1 w = 2 z = 2 value = 1 ans = 0 -1 3 1 w = 3 z = 4 ans = 0 0 3 1 ans = 0 1 3 1 w = 3 z = 2 value = 2 ans = 1 -1 3 1 w = 4 z = 4 ans = 1 0 3 1 w = 4 z = 1 ans = 1 1 3 1 w = 4 z = 2 ans = -1 -1 3 2 w = 2 z = 1 ans = -1 0 3 2 w = 2 z = 2 value = 1 ans = -1 1 3 2 w = 2 z = 3 ans = 0 -1 3 2 w = 3 z = 1 value = 2 ans = 0 0 3 2 ans = 0 1 3 2 w = 3 z = 3 ans = 1 -1 3 2 w = 4 z = 1 ans = 1 0 3 2 w = 4 z = 2 ans = 1 1 3 2 w = 4 z = 3 ans = -1 -1 3 3 w = 2 z = 2 value = 1 ans = -1 0 3 3 w = 2 z = 3 ans = -1 1 3 3 w = 2 z = 4 ans = 0 -1 3 3 w = 3 z = 2 value = 2 ans = 0 0 3 3 ans = 0 1 3 3 w = 3 z = 4 ans = 1 -1 3 3 w = 4 z = 2 ans = 1 0 3 3 w = 4 z = 3 ans = 1 1 3 3 w = 4 z = 4 ans = -1 -1 3 4 w = 2 z = 3 ans = -1 0 3 4 w = 2 z = 4 ans = -1 1 3 4 w = 2 z = 1 ans = 0 -1 3 4 w = 3 z = 3 ans = 0 0 3 4 ans = 0 1 3 4 w = 3 z = 1 value = 1 ans = 1 -1 3 4 w = 4 z = 3 ans = 1 0 3 4 w = 4 z = 4 ans = 1 1 3 4 w = 4 z = 1 ans = -1 -1 4 1 w = 3 z = 4 ans = -1 0 4 1 w = 3 z = 1 value = 1 ans = -1 1 4 1 w = 3 z = 2 value = 2 ans = 0 -1 4 1 w = 4 z = 4 ans = 0 0 4 1 ans = 0 1 4 1 w = 4 z = 2 ans = 1 -1 4 1 w = 1 z = 4 ans = 1 0 4 1 w = 1 z = 1 value = 3 ans = 1 1 4 1 w = 1 z = 2 value = 4 ans = -1 -1 4 2 w = 3 z = 1 value = 1 ans = -1 0 4 2 w = 3 z = 2 value = 2 ans = -1 1 4 2 w = 3 z = 3 ans = 0 -1 4 2 w = 4 z = 1 ans = 0 0 4 2 ans = 0 1 4 2 w = 4 z = 3 ans = 1 -1 4 2 w = 1 z = 1 value = 3 ans = 1 0 4 2 w = 1 z = 2 value = 4 ans = 1 1 4 2 w = 1 z = 3 ans = -1 -1 4 3 w = 3 z = 2 value = 1 ans = -1 0 4 3 w = 3 z = 3 ans = -1 1 4 3 w = 3 z = 4 ans = 0 -1 4 3 w = 4 z = 2 ans = 0 0 4 3 ans = 0 1 4 3 w = 4 z = 4 ans = 1 -1 4 3 w = 1 z = 2 value = 2 ans = 1 0 4 3 w = 1 z = 3 ans = 1 1 4 3 w = 1 z = 4 ans = -1 -1 4 4 w = 3 z = 3 ans = -1 0 4 4 w = 3 z = 4 ans = -1 1 4 4 w = 3 z = 1 value = 1 ans = 0 -1 4 4 w = 4 z = 3 ans = 0 0 4 4 ans = 0 1 4 4 w = 4 z = 1 ans = 1 -1 4 4 w = 1 z = 3 ans = 1 0 4 4 w = 1 z = 4 ans = 1 1 4 4 w = 1 z = 1 value = 2

2   Pass
%% A = [ ... 0 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0]; B = [ ... 1 0 1 1 1 0 0 0 0 0 1 1 0 1 1 0]; assert(isequal(life(A),B))

ans = -1 -1 1 1 w = 4 z = 4 ans = -1 0 1 1 w = 4 z = 1 ans = -1 1 1 1 w = 4 z = 2 ans = 0 -1 1 1 w = 1 z = 4 ans = 0 0 1 1 ans = 0 1 1 1 w = 1 z = 2 value = 1 ans = 1 -1 1 1 w = 2 z = 4 ans = 1 0 1 1 w = 2 z = 1 value = 2 ans = 1 1 1 1 w = 2 z = 2 value = 3 ans = -1 -1 1 2 w = 4 z = 1 ans = -1 0 1 2 w = 4 z = 2 ans = -1 1 1 2 w = 4 z = 3 ans = 0 -1 1 2 w = 1 z = 1 ans = 0 0 1 2 ans = 0 1 1 2 w = 1 z = 3 value = 1 ans = 1 -1 1 2 w = 2 z = 1 value = 2 ans = 1 0 1 2 w = 2 z = 2 value = 3 ans = 1 1 1 2 w = 2 z = 3 value = 4 ans = -1 -1 1 3 w = 4 z = 2 ans = -1 0 1 3 w = 4 z = 3 ans = -1 1 1 3 w = 4 z = 4 ans = 0 -1 1 3 w = 1 z = 2 value = 1 ans = 0 0 1 3 ans = 0 1 1 3 w = 1 z = 4 ans = 1 -1 1 3 w = 2 z = 2 value = 2 ans = 1 0 1 3 w = 2 z = 3 value = 3 ans = 1 1 1 3 w = 2 z = 4 ans = -1 -1 1 4 w = 4 z = 3 ans = -1 0 1 4 w = 4 z = 4 ans = -1 1 1 4 w = 4 z = 1 ans = 0 -1 1 4 w = 1 z = 3 value = 1 ans = 0 0 1 4 ans = 0 1 1 4 w = 1 z = 1 ans = 1 -1 1 4 w = 2 z = 3 value = 2 ans = 1 0 1 4 w = 2 z = 4 ans = 1 1 1 4 w = 2 z = 1 value = 3 ans = -1 -1 2 1 w = 1 z = 4 ans = -1 0 2 1 w = 1 z = 1 ans = -1 1 2 1 w = 1 z = 2 value = 1 ans = 0 -1 2 1 w = 2 z = 4 ans = 0 0 2 1 ans = 0 1 2 1 w = 2 z = 2 value = 2 ans = 1 -1 2 1 w = 3 z = 4 ans = 1 0 2 1 w = 3 z = 1 ans = 1 1 2 1 w = 3 z = 2 ans = -1 -1 2 2 w = 1 z = 1 ans = -1 0 2 2 w = 1 z = 2 value = 1 ans = -1 1 2 2 w = 1 z = 3 value = 2 ans = 0 -1 2 2 w = 2 z = 1 value = 3 ans = 0 0 2 2 ans = 0 1 2 2 w = 2 z = 3 value = 4 ans = 1 -1 2 2 w = 3 z = 1 ans = 1 0 2 2 w = 3 z = 2 ans = 1 1 2 2 w = 3 z = 3 value = 5 ans = -1 -1 2 3 w = 1 z = 2 value = 1 ans = -1 0 2 3 w = 1 z = 3 value = 2 ans = -1 1 2 3 w = 1 z = 4 ans = 0 -1 2 3 w = 2 z = 2 value = 3 ans = 0 0 2 3 ans = 0 1 2 3 w = 2 z = 4 ans = 1 -1 2 3 w = 3 z = 2 ans = 1 0 2 3 w = 3 z = 3 value = 4 ans = 1 1 2 3 w = 3 z = 4 ans = -1 -1 2 4 w = 1 z = 3 value = 1 ans = -1 0 2 4 w = 1 z = 4 ans = -1 1 2 4 w = 1 z = 1 ans = 0 -1 2 4 w = 2 z = 3 value = 2 ans = 0 0 2 4 ans = 0 1 2 4 w = 2 z = 1 value = 3 ans = 1 -1 2 4 w = 3 z = 3 value = 4 ans = 1 0 2 4 w = 3 z = 4 ans = 1 1 2 4 w = 3 z = 1 ans = -1 -1 3 1 w = 2 z = 4 ans = -1 0 3 1 w = 2 z = 1 value = 1 ans = -1 1 3 1 w = 2 z = 2 value = 2 ans = 0 -1 3 1 w = 3 z = 4 ans = 0 0 3 1 ans = 0 1 3 1 w = 3 z = 2 ans = 1 -1 3 1 w = 4 z = 4 ans = 1 0 3 1 w = 4 z = 1 ans = 1 1 3 1 w = 4 z = 2 ans = -1 -1 3 2 w = 2 z = 1 value = 1 ans = -1 0 3 2 w = 2 z = 2 value = 2 ans = -1 1 3 2 w = 2 z = 3 value = 3 ans = 0 -1 3 2 w = 3 z = 1 ans = 0 0 3 2 ans = 0 1 3 2 w = 3 z = 3 value = 4 ans = 1 -1 3 2 w = 4 z = 1 ans = 1 0 3 2 w = 4 z = 2 ans = 1 1 3 2 w = 4 z = 3 ans = -1 -1 3 3 w = 2 z = 2 value = 1 ans = -1 0 3 3 w = 2 z = 3 value = 2 ans = -1 1 3 3 w = 2 z = 4 ans = 0 -1 3 3 w = 3 z = 2 ans = 0 0 3 3 ans = 0 1 3 3 w = 3 z = 4 ans = 1 -1 3 3 w = 4 z = 2 ans = 1 0 3 3 w = 4 z = 3 ans = 1 1 3 3 w = 4 z = 4 ans = -1 -1 3 4 w = 2 z = 3 value = 1 ans = -1 0 3 4 w = 2 z = 4 ans = -1 1 3 4 w = 2 z = 1 value = 2 ans = 0 -1 3 4 w = 3 z = 3 value = 3 ans = 0 0 3 4 ans = 0 1 3 4 w = 3 z = 1 ans = 1 -1 3 4 w = 4 z = 3 ans = 1 0 3 4 w = 4 z = 4 ans = 1 1 3 4 w = 4 z = 1 ans = -1 -1 4 1 w = 3 z = 4 ans = -1 0 4 1 w = 3 z = 1 ans = -1 1 4 1 w = 3 z = 2 ans = 0 -1 4 1 w = 4 z = 4 ans = 0 0 4 1 ans = 0 1 4 1 w = 4 z = 2 ans = 1 -1 4 1 w = 1 z = 4 ans = 1 0 4 1 w = 1 z = 1 ans = 1 1 4 1 w = 1 z = 2 value = 1 ans = -1 -1 4 2 w = 3 z = 1 ans = -1 0 4 2 w = 3 z = 2 ans = -1 1 4 2 w = 3 z = 3 value = 1 ans = 0 -1 4 2 w = 4 z = 1 ans = 0 0 4 2 ans = 0 1 4 2 w = 4 z = 3 ans = 1 -1 4 2 w = 1 z = 1 ans = 1 0 4 2 w = 1 z = 2 value = 2 ans = 1 1 4 2 w = 1 z = 3 value = 3 ans = -1 -1 4 3 w = 3 z = 2 ans = -1 0 4 3 w = 3 z = 3 value = 1 ans = -1 1 4 3 w = 3 z = 4 ans = 0 -1 4 3 w = 4 z = 2 ans = 0 0 4 3 ans = 0 1 4 3 w = 4 z = 4 ans = 1 -1 4 3 w = 1 z = 2 value = 2 ans = 1 0 4 3 w = 1 z = 3 value = 3 ans = 1 1 4 3 w = 1 z = 4 ans = -1 -1 4 4 w = 3 z = 3 value = 1 ans = -1 0 4 4 w = 3 z = 4 ans = -1 1 4 4 w = 3 z = 1 ans = 0 -1 4 4 w = 4 z = 3 ans = 0 0 4 4 ans = 0 1 4 4 w = 4 z = 1 ans = 1 -1 4 4 w = 1 z = 3 value = 2 ans = 1 0 4 4 w = 1 z = 4 ans = 1 1 4 4 w = 1 z = 1