Question: Question 1 (30 marks) Apply C language to program a puzzle game The puzzle involves arranging a set of thirty- six numbers in an ascending



Question 1 (30 marks) Apply C language to program a puzzle game The puzzle involves arranging a set of thirty- six numbers in an ascending order. The numbers are displayed in a 6x6 grid. These numbers are randomly generated and therefore are not sorted initially. The player has to sort these numbers by swapping two adjacent numbers one at a time. A number can be swapped with another number on its right, left, top or bottom. A number cannot be swapped with a number that is diagonally adjacent to it. Figure Q1(i) shows a sample initial screen of the game with the 36 randomly generated numbers arranged in a 6x6 grid. 37 2579 2151 453 9978||871 2118|18 |2733|| S6 732 5397 5461 8345 5368 1472 457 95 213 6078 7593 5339 Inter the two adjacent location to ap Figure Q1i For example, if the number 5461 is to be moved, then it can be swapped with either the number 2118 (top), 218 (bottom), 5397 (left), or 8145 (right). Any illegal swapping will result in an error message being displayed. Figure Q1(ii) shows the result of player swapping the numbers 5461 and 218 in a partially sorted manner
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
