Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for C programming class. Please do as much as you can, but if you finish it that would be great, and I will

This is for C programming class. Please do as much as you can, but if you finish it that would be great, and I will make sure to write a good review for you! Thank you again!!!image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

The slider puzzle (also called the Gem Puzzle or the Mystic Square) consists of a square board filled with numbered square tiles in random order, with one of the tiles missing. The object of the puzzle is to place the numbered tiles in order by making sliding moves that use the empty space. If the size of the board is 3 3 or 4 4, the slider puzzle is often called the 8-puzzle or the 15-puzzle, respectively For example, shown below is the 15-puzzle in a random initial state and in the solved state: 13 23 12 9 11 1 10 6 4 14 15 8 75 1 2 34 5 6 78 9 10 |11 12 13 14 15 Your goal in this problem is to write a C program, called slider.c, that implements the slider puzzle. The size of the puzzle's board is determined by the symbolic constant SIZE. The program should first generate a random initial state of the puzzle, print the resulting board, and then prompt the user to enter a move. When printing the board, the empty space should be displayed as the char- acter #. For example if SIZE is 3, then the program might begin with the following output /home/userxYZ/ECE15/Final> slider Welcome to the slider puzzle! 6 8 2 #14 Please enter a move [u/d/l/r]: The user can ask to move up (which means sliding the tile above the empty space into the empty space, so that the # character effectively moves up), down (which means swapping # with the tile below it, so that # moves down), left (which means swapping # with the tile to the left of it, so that # moves left), or right (which means swapping # with the tile to the right of it, so that # moves right) Thus valid user input is one of the four characters u, d, 1, or r. Any input other than these four char- acters should lead to an appropriate message, repeated in a loop. Here is an example Please enter a move [u/d/1/r]: !24576&idw Incorrect input, try again! Please enter a move [u/d/l/r]: move up Incorrect input, try again! Please enter a move [u/d/l/r]: U Incorrect input, try again! Please enter a move [u/d/l/r]: Observe that valid user input u, d. 1, or r does not always lead to a valid move. For instance, in the initial state of the board shown above, it is not possible to move down or left, since this would slide

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

Students also viewed these Databases questions