2048 is a game where you need to slide numbered tiles (natural powers of 2) up, down, left or right on a square grid to combine them in a tile with the number 2048.
The sliding procedure is described by the following rules:
Sliding is done almost the same for each direction and for each row/column of the grid, so your task is to implement only the left slide for a single row.
LeftSlide(new int[] { 2, 2, 2, 0 }) ➞ int[] { 4, 2, 0, 0 }
// Merge left-most tiles first.
LeftSlide(new int[] { 2, 2, 4, 4, 8, 8 }) ➞ int[] { 4, 8, 16, 0, 0, 0 }
// Only merge once.
LeftSlide(new int[] { 0, 2, 0, 2, 4 }) ➞ int[] { 4, 4, 0, 0, 0 }
LeftSlide(new int[] { 0, 2, 2, 8, 8, 8 }) ➞ int[] { 4, 16, 8, 0, 0, 0 }