Cody

Solution 822108

Submitted on 8 Feb 2016 by Alexander
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
%% board = [ ... 0 0 0 2 0 0 4 4 0 0 0 16 0 0 0 16]; dir = 'up'; newBoard = [ ... 0 0 4 2 0 0 0 4 0 0 0 32 0 0 0 0 ]; assert(isequal(nextMove(board,dir),newBoard))

a = Empty matrix: 0-by-1 a = Empty matrix: 0-by-1 a = 4 a = 16 16 4 2

2   Pass
%% board = [ ... 0 2 128 4 0 16 4 32 0 8 0 0 0 0 2 0 ]; dir = 'right'; newBoard = [ ... 0 2 128 4 0 16 4 32 0 0 0 8 0 0 0 2 ]; assert(isequal(nextMove(board,dir),newBoard))

a = 2 128 4 a = 16 4 32 a = 8 a = 2

3   Pass
%% board = [ ... 0 8 0 4 2 64 16 2 2 8 8 16 4 2 2 4 ]; dir = 'left'; newBoard = [ ... 8 4 0 0 2 64 16 2 2 16 16 0 4 4 4 0 ]; assert(isequal(nextMove(board,dir),newBoard))

a = 4 8 a = 2 16 64 2 a = 16 8 8 2 a = 4 2 2 4

4   Pass
%% board = [ ... 0 4 4 4 4 4 4 0 2 2 2 2 0 0 0 0 ] dir = 'left' newBoard = [ ... 8 4 0 0 8 4 0 0 4 4 0 0 0 0 0 0 ]

board = 0 4 4 4 4 4 4 0 2 2 2 2 0 0 0 0 dir = left newBoard = 8 4 0 0 8 4 0 0 4 4 0 0 0 0 0 0