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 7518579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:46:10+00:00 2026-05-30T01:46:10+00:00

I have a problem with creating a sliding puzzle. I’m trying to make a

  • 0

I have a problem with creating a sliding puzzle. I’m trying to make a method to reset & shuffle all 15 buttons, but the problem is the random numbers are repeated.

When I write bool[] usednum = new bool[array.length]; I get an error, so I increase the length of the usednum array …..

private void reset()
{
    int[] array = { 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
    int count = 0;
    Random r = new Random();
    bool[] usednum = new bool[50];

    for (int i = 0; i < usednum.Length; i++)
        usednum[i] = false;

    while (count < array.Length)
    {
        int temp = array[r.Next(array.Length)];
        if (usednum[temp] == false)
        {
            button1.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }

        temp = array[r.Next(array.Length)];
        if (usednum[temp] == false)
        {
            button2.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }

        temp = array[r.Next(array.Length)];
        if (usednum[temp] == false)
        {
            button3.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }

        temp = array[r.Next(array.Length)];
        if (usednum[temp] == false)
        {
            button4.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }

        temp = array[r.Next(array.Length)];
        if(usednum[temp] == false)
        {
            button5.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }

        temp = array[r.Next(array.Length)];
        if (usednum[temp] == false)
        {
            button6.Text = temp.ToString();
            usednum[temp] = true;
            count++;
        }
        /*.
        . 
        . 
        . to button 15*/
  • 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-30T01:46:10+00:00Added an answer on May 30, 2026 at 1:46 am

    Just shuffle the array: http://en.wikipedia.org/wiki/Shuffling

    A simple shuffle algorithm is (in pseudocode)

    maxIndex = array.Length - 1
    for index in 0 to maxIndex - 1
        swapIndex = random number between index and maxIndex
        swap (array, index, swapIndex)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem when creating JSPs to use with Spring. I put all my
I have a problem creating a custom dialog. But I don't find the failure.
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have an irritating problem, I'm creating an asp.net web service; this service should
i have a small problem, i am creating a edit page in my asp.net
I have run into a strange problem, i am creating a lot of dynamically
I have problem with return statment >.< I want to store all magazine names
I am relatively new to using jQuery and I have a problem with creating
Why I have problem creating a class inheriting from str (or also from int)

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.