a single-player puzzle game created by Gabriele Cirulli1. It is played on a 4×4 grid that contains integers ≥2 that are powers of 2. The player can use a keyboard arrow key (left/up/right/down) to move all the tiles simultaneously. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile 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 carefully in all Sample Inputs and Outputs. Input

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter4: Making Decisions
Section: Chapter Questions
Problem 8E: In the game Rock paper Scissors, two players simultaneously choose one of three options: rock,...
icon
Related questions
Question

2048 is a single-player puzzle game created by Gabriele Cirulli1. It is played on a 4×4 grid that contains integers ≥2

that are powers of 2. The player can use a keyboard arrow key (left/up/right/down) to move all the tiles simultaneously. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile 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 carefully in all Sample Inputs and Outputs.

Input

The input is always a valid game state of a 2048 puzzle. The first four lines of input, that each contains four integers, describe the 16 integers in the 4×4

grid of 2048 puzzle. The j-th integer in the i-th line denotes the 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 0 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 the new state of the 4×4

grid of 2048 puzzle. Again, integer 0 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
2 0 0 2 4 16 8 2 2 64 32 4 1024 1024 64 0 0 4 0 0 0 4 16 8 2 2 64 32 4 2048 64 0 0
Sample Input 2 Sample Output 2
2 0 0 2 4 16 8 2 2 64 32 4 1024 1024 64 0 1 2 16 8 4 4 64 32 4 2 1024 64 0 1024 0 0 0
Sample Input 3 Sample Output 3
2 0 0 2 4 16 8 2 2 64 32 4 1024 1024 64 0 2 0 0 0 4 4 16 8 2 2 64 32 4 0 0 2048 64
Sample Input 4 Sample Output 4
2 0 0 2 4 16 8 2 2 64 32 4 1024 1024 64 0 3 2 0 0 0 4 16 8 0 2 64 32 4 1024 1024 64 4
Sample Input 5 Sample Output 5
2 2 4 8 4 0 4 4 16 16 16 16 32 16 16 32 0 4 4 8 0 8 4 0 0 32 32 0 0 32 32 32 0
Sample Input 6 Sample Output 6
2 2 4 8 4 0 4 4 16 16 16 16 32 16 16 32 2 0 4 4 8 0 0 4 8 0 0 32 32 0 32 32 32

IN C++ PLEASE.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT

Expert Answers to Latest Homework Questions

Q: I need help with this problem and an explanation for the solution described below (Vector-Valued…
Q: The deflection of a particle beam depends on the charge to mass ratio: (D ~ q / m).   An electron…
Q: The deflection of a particle beam depends on the charge to mass ratio: (D ~ q / m).   An electron…
Q: Naturally occurring lithium consists of 6Li (6.0151 u) and 7Li (7.0160 u). What is the relative…
Q: What is the average atomic mass of halfnium if, out of every 100 atoms, 5 have mass 176.0, 19 have…
Q: A particle with mass m and charge –q is suspended when the electrical force field E balances the…
Q: The deflection of a particle beam depends on the charge to mass ratio: (D ~ q / m).   An electron…
Q: The gold nucleus has a mass of 3.27 × 10–25 kg. What is the density of the nucleus (in g cm–3)?…
Q: The gold nucleus has a mass of 3.27 × 10–25 kg. What is the density of the nucleus (in g cm–3)?…
Q: From experiments on alpha particle scattering from thin films of gold, the nuclear centers of gold…
Q: D ile Edit View History Bookmarks Profiles Tab Window Help gle Search X M Chapter 2 Quiz - Connect…
Q: 1. Name some of the challenges marketers encounter when developing advertising and promotional…
Q: Which set of examples only represents chemical changes? Dissolving of sugar in water, mold growing…
Q: Weston Corporation just paid a dividend of $2.75 a share (i.e., D0 = $2.75). The dividend is…
Q: 1.A stock is expected to pay a dividend of $2.75 at the end of the year (i.e., D1 = $2.75), and it…
Q: 1. Maxwell Mining Company's ore reserves are being depleted, so its sales are falling. Also, because…
Q: 1. Farley Inc. has perpetual preferred stock outstanding that sells for $44 a share and pays a…
Q: 1. Tresnan Brothers is expected to pay a $1.00 per share dividend at the end of the year (i.e., D1 =…
Q: Discuss how Teleological ethical and Deontological ethical philosophies would respond to a company's…
Q: D rome File Edit View History Bookmarks Profiles Tab Window Help bjs- Google Search M Chapter 2 Quiz…
Q: Hawaiian Annexation One of the main jobs of historians is to interpret the past by reviewing…