Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 301295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:59:33+00:00 2026-05-12T06:59:33+00:00

I’m a relative novice at C# and am thoroughly stuck! For a school assignment

  • 0

I’m a relative novice at C# and am thoroughly stuck! For a school assignment I need to make a sliding puzzle where numbered tiles are to be rearranged in order by using a blank space, i.e.

[1] [2] [3]

[4] [5] [6]

[7] [8] [ ] 

I have no idea where to start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:59:33+00:00Added an answer on May 12, 2026 at 6:59 am

    Regardless on how the application will be used (Winforms UI, Console, Web or whatever) you need to focus on how to build such an application. So start by considering what you will need to do:

    You’ll need

    • an engine that manages the state of the puzzle
      • the engine must be able to reset the puzzle
      • the engine must be able to scramble the puzzle without going into an unsolvable state
      • the engine must be able to perform moves
      • the engine must be able to detect whether the puzzle is solved
    • a user interface (Console, Web or Desktop) that
      • fetches the state from the engine and displays it
      • offers the user to start over
      • offers the user to perform a move
      • shows wheter the puzzle is solved (and congratulates the user if so).

    At beginner level I’d start with the engine. You will want to write a C# class that holds the data. Consult a C# tutorial on info how to use the language, I’ll focus on the problem here:

    The enigne needs to hold the puzzle. We have 9 fields and 8 tiles. So we might just use a fixed array of length 9. Each entry in the array is a number that describes a tile. 1 is tile one, 2 is tile two and so on up to tile 8. We use 0 to describe the empty tile.

    Then you need to implement methods for the moves. At any time you can try to move tile into the empty slot from up, right, bottom or left. Which one is the empty tile? The entry in our array that contains 0.

    So let’s write four methods up, down, left, right to implement the moves. Let’s focus on “up” that moves a tile from the upper slot into the empty slot. We can assume our array maps to the puzzle as follows:

    0 1 2
    3 4 5
    6 7 8

    So if the array contains “7 6 5 3 0 1 2 4 8” the puzzle would look

    7 6 5
    3 _ 1
    2 4 8

    The up methods now needs to find the “0” in the array and exchange it with the value in the row above:

    If the “0” is in the upper row (array index 0, index 1 or index 2) there is no upper row and “up” throws an exception. It can’t work.

    If “0” is on another index i the index “above” i will be index i-3. So we exchange the values of index i and index i-3 in the array.

    You’d implement the “left”, “right” and “bottom” methods similarily. Have a look at so called “unit-testing” software on how to write test cases for your software. (Nunit, MBUnit)

    At last build a method or property in your puzzle class that checks whether the contents of the array are in the correct order “1 2 3 4 5 6 7 8 0” when it is solved.

    Now you have a puzzle class that implements the logic.

    As a last (but nevertheless big step) you now need to read a Winforms or WPF tutorial on how to build a UI. But now you SHOULD have learned enough about C# to find & read a tutorial and follow it through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.