Cody

Solution 2188712

Submitted on 2 Apr 2020 by Atsushi Ueno
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 = [4 3 2 1 0 1 2 3 4 3 3 2 1 0 1 2 3 3 2 2 2 1 0 1 2 2 2 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 2 2 2 1 0 1 2 2 2 3 3 2 1 0 1 2 3 3 4 3 2 1 0 1 2 3 4]; assert(isequal(abelian_sandpile_2(4),x))

ans = 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ans = 4 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 4 ans = 4 3 2 2 2 2 2 3 4 3 3 2 2 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 2 2 2 2 2 3 3 4 3 2 2 2 2 2 3 4 ans = 4 3 2 1 1 1 2 3 4 3 3 2 1 1 1 2 3 3 2 2 2 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 2 2 2 3 3 2 1 1 1 2 3 3 4 3 2 1 1 1 2 3 4 ans = 4 3 2 1 0 1 2 3 4 3 3 2 1 0 1 2 3 3 2 2 2 1 0 1 2 2 2 1 1 1 1 0 1 1 1 1 0 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