Cody

# Problem 2265. 2048 Next Move

Solution 433362

Submitted on 17 Apr 2014 by George Berken
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
%% 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))

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))

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))

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!