Company: Goldman Sachs OA
Difficulty: medium
2048 Game Grid Analysis Rakesh is playing a game called \"2048\". In this game, a 4x4 cell grid is given, where each cell can either be empty (denoted by having the value 0), or can have a value of 2k where k is any number between 1 and 11. The aim of the game is to win by arriving at a value of 2048 by repeatedly moving in one of four directions: up (U), down (D), right (R), or left (L). When one of these four direction buttons is pressed, all the cells in the grid try to move in that direction. During this movement: If any adjacent cells (adjacent in the direction of the movement) have the same value, then they merge and add up. For example, if there are adjacent cells in a row with values 4 and 4, and the R button is pressed, the left cell moves right and gets added to the right cell, and itself becomes empty, so \"4 4\" becomes \"0 8\". Similarly \"16 16\" becomes \"0 32\" However \"2 4\" remains as \"2 4\" since the values are different and no merging takes place. If the adjacent