Question: C++ Need Guidance on this assignment using Stacks Psuedocode/Explanations are FINE if well written I am meant to create a program that can solve a

C++ Need Guidance on this assignment using Stacks

Psuedocode/Explanations are FINE if well written

I am meant to create a program that can "solve" a 2048 game with a given N x N grid and output what can solve it in the least amount of instructions. "Solve" as in merge all possible numbers.

Instructions for movement represented by numbers:

1: up 2: right 3: down 4: left

My main problem is that Stacks must be used. Stacks can be implemented as either array or as linked lists (preferably either) but if you use Stacks provided by #include , that is also fine as I can implement stacks as array or linked lists myself. Just what is the best way to use stacks for a program like this?

Let's say I have the given input file that has the matrix for the game:

4 //Size of Matrix. Matrix will always be N x N 2 4 0 0 2 0 0 0 0 0 0 0 0 0 8 0

Output (Smallest sequence of instructions to merge all possible values): 122

What would be the best way to implement Stacks into a program like this? I'm not asking for full code, just that psuedocode/guidance will be greatly appreciated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!