=048 is a single-player puzzle game created by Gabriele irulli'. It is played on a 4 × 4 grid that contains integers > 2 that are powers of 2. The player can use a keyboard 2048 SCORE BEST 18876 21008 rrow key (left/up/right/down) to move all the tiles Join the numbers and get to the 2048 tile! New Game imultaneously. Tiles slide as far as possible in the hosen direction until they are stopped by either another ile or the edge of the grid. If two tiles of the same 2 umber collide while moving, they will merge into a tile vith the total value of the two tiles that collided. The esulting tile cannot merge with another tile again in the ame move. Please observe this merging behavior 4 16 8. arefully in all Sample Inputs and Outputs. Input 64 32 4 he input is always a valid game state of a 2048 puzzle. he first four lines of input, that each contains four ntegers, describe the 16 integers in the 4 x 4 grid of c048 puzzle. The j-th integer in the i-th line denotes the 64 1024 1024 ontent of the cell located at the i-th row and the j-th ell. For this problem, all integers in the input will be ither {o, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}. Integer screenshot taken from http://gabrielecirulli.github.io/2048/ •means an empty cell. he fifth line of input contains an integer o, 1, 2, or 3 that denotes a left, up, right, or down move executed by the layer, respectively. Dutput Dutput four lines with four integers each. Two integers in a line must be separated by a single space. This describes he new state of the 4 × 4 grid of 2048 puzzle. Again, integer o means an empty cell. Note that in this problem, you an ignore the part from the 2048 puzzle where it introduces a new random tile with a value of either 2 or 4 in an empty spot of the board at the start of a new turn. Sample Input 1 Sample Output 1 20 0 2 4 0 0 0 4 16 8 2 4 16 8 2 2 64 32 4 2 64 32 4 1024 1024 64 0 2048 64 00 Sample Input 2 Sample Output 2 20 0 2 2 16 8 4 4 16 8 2 4 64 32 4 2 64 32 4 2 1024 64 0 1024 1024 64 0 1024 0 0 0 Sample Input 3 Sample Output 3 20 0 2 0 0 0 4 4 16 8 2 4 16 8 2 2 64 32 4 2 64 32 4 1024 1024 64 0 0 0 2048 64 Sample Input 4 Sample Output 4 20 0 2 20 0 0 4 16 8 2 4 16 8 0 2 64 32 4 2 64 32 4 1024 1024 64 0 1024 1024 64 4 3

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

IN C++. show CODE PLEASE.

2048 is a single-player puzzle game created by Gabriele
2048
SCORE
BEST
Cirulli'. It is played on a 4 x 4 grid that contains integers
18876
21008
> 2 that are powers of 2. The player can use a keyboard
arrow key (left/up/right/down) to move all the tiles
Join the numbers and get to the 2048 tile!
New Game
simultaneously. Tiles slide as far as possible in the
chosen direction until they are stopped by either another
ile or the edge of the grid. If two tiles of the same
number collide while moving, they will merge into a tile
with the total value of the two tiles that collided. The
resulting tile cannot merge with another tile again in the
same move. Please observe this merging behavior
4
16
8
carefully in all Sample Inputs and Outputs.
Input
64 32
4
The input is always a valid game state of a 2048 puzzle.
The first four lines of input, that each contains four
ntegers, describe the 16 integers in the 4 x 4 grid of
2048 puzzle. The j-th integer in the i-th line denotes the
1024
1024
64
content of the cell located at the i-th row and the j-th
cell. For this problem, all integers in the input will be
either {0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}. Integer
screenshot taken from http://gabrielecirulli.github.io/2048/
O means an empty cell.
The fifth line of input contains an integer 0, 1, 2, or 3 that denotes a left, up, right, or down move executed by the
player, respectively.
Output
Output four lines with four integers each. Two integers in a line must be separated by a single space. This describes
he new state of the 4 x 4 grid of 2048 puzzle. Again, integer o means an empty cell. Note that in this problem, you
can ignore the part from the 2048 puzzle where it introduces a new random tile with a value of either 2 or 4 in an
empty spot of the board at the start of a new turn.
Sample Input 1
Sample Output 1
20 0 2
4 0 0 0
4 16 8 2
4 16 8 2
2 64 32 4
2 64 32 4
1024 1024 64 0
2048 64 00
Sample Input 2
Sample Output 2
20 0 2
2 16 8 4
4 16 8 2
4 64 32 4
2 64 32 4
2 1024 64 0
1024 1024 64 0
1024 0 0 0
1
Sample Input 3
Sample Output 3
20 0 2
0 0 0 4
4 16 8 2
4 16 8 2
2 64 32 4
2 64 32 4
1024 1024 64 0
0 0 2048 64
Sample Input 4
Sample Output 4
2 0 0 2
20 0 0
4 16 8 2
4 16 8 0
2 64 32 4
2 64 32 4
1024 1024 64 0
1024 1024 64 4
3
Sample Input 5
Sample Output 5
4 4 8 0
8 4 0 0
2 2 4 8
4 0 4 4
16 16 16 16
32 32 0 0
32 16 16 32
32 32 32 0
Sample Input 6
Sample Output 6
0 4 4 8
0 0 4 8
0 0 32 32
2 2 4 8
4 0 4 4
16 16 16 16
32 16 16 32
O 32 32 32
2
Transcribed Image Text:2048 is a single-player puzzle game created by Gabriele 2048 SCORE BEST Cirulli'. It is played on a 4 x 4 grid that contains integers 18876 21008 > 2 that are powers of 2. The player can use a keyboard arrow key (left/up/right/down) to move all the tiles Join the numbers and get to the 2048 tile! New Game simultaneously. Tiles slide as far as possible in the chosen direction until they are stopped by either another ile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move. Please observe this merging behavior 4 16 8 carefully in all Sample Inputs and Outputs. Input 64 32 4 The input is always a valid game state of a 2048 puzzle. The first four lines of input, that each contains four ntegers, describe the 16 integers in the 4 x 4 grid of 2048 puzzle. The j-th integer in the i-th line denotes the 1024 1024 64 content of the cell located at the i-th row and the j-th cell. For this problem, all integers in the input will be either {0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}. Integer screenshot taken from http://gabrielecirulli.github.io/2048/ O means an empty cell. The fifth line of input contains an integer 0, 1, 2, or 3 that denotes a left, up, right, or down move executed by the player, respectively. Output Output four lines with four integers each. Two integers in a line must be separated by a single space. This describes he new state of the 4 x 4 grid of 2048 puzzle. Again, integer o means an empty cell. Note that in this problem, you can ignore the part from the 2048 puzzle where it introduces a new random tile with a value of either 2 or 4 in an empty spot of the board at the start of a new turn. Sample Input 1 Sample Output 1 20 0 2 4 0 0 0 4 16 8 2 4 16 8 2 2 64 32 4 2 64 32 4 1024 1024 64 0 2048 64 00 Sample Input 2 Sample Output 2 20 0 2 2 16 8 4 4 16 8 2 4 64 32 4 2 64 32 4 2 1024 64 0 1024 1024 64 0 1024 0 0 0 1 Sample Input 3 Sample Output 3 20 0 2 0 0 0 4 4 16 8 2 4 16 8 2 2 64 32 4 2 64 32 4 1024 1024 64 0 0 0 2048 64 Sample Input 4 Sample Output 4 2 0 0 2 20 0 0 4 16 8 2 4 16 8 0 2 64 32 4 2 64 32 4 1024 1024 64 0 1024 1024 64 4 3 Sample Input 5 Sample Output 5 4 4 8 0 8 4 0 0 2 2 4 8 4 0 4 4 16 16 16 16 32 32 0 0 32 16 16 32 32 32 32 0 Sample Input 6 Sample Output 6 0 4 4 8 0 0 4 8 0 0 32 32 2 2 4 8 4 0 4 4 16 16 16 16 32 16 16 32 O 32 32 32 2
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education