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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:20:39+00:00 2026-05-13T01:20:39+00:00

I need to create a non sequential list of numbers that fit within a

  • 0

I need to create a non sequential list of numbers that fit within a range. For instance i need to a generate a list of numbers from 1 to 1million and make sure that non of the numbers are in a sequential order, that they are completly shuffled. I guess my first question is, are there any good algorithms out there that could help and how best to implement this.

I currently am not sure the best way to implement, either via a c# console app that will spit out the numbers in an XML file or in a database that will spit out the numbers into a table or a set of tables, but that is really secondary to actually working out the best way of “shuffling” the set of numbers.

Any advice guys?

Rob

  • 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-13T01:20:39+00:00Added an answer on May 13, 2026 at 1:20 am

    How “non-sequential” do you want it?

    You could easily generate a list of random numbers from a range with the Random class:

    Random rnd1 = new Random();
    List<int> largeList = new List<int>();
    
    for (int i = 0, i < largeNumber, i++)
    {
      largeList.Add(rnd1.Next(1, 1000001);
    }
    

    Edit to add

    Admittedly the Durstenfeld algorithm (modern version of the Fisher–Yates shuffle apparently) is much faster:

    var fisherYates = new List<int>(upperBound);
    for (int i = 0; i < upperBound; i++)
    {
      fisherYates.Add(i);
    }
    
    int n = upperBound;
    
    while (n > 1)
    {
       n--;
       int k = rnd.Next(n + 1);
       int temp = fisherYates[k];
       fisherYates[k] = fisherYates[n];
       fisherYates[n] = temp;
    }
    

    For the range 1 to 10000 doing a brute force “find a random number I’ve not yet used” takes around 4-5 seconds, while this takes around 0.001.

    Props to Greg Hewgill for the links.

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

Sidebar

Related Questions

From a standard, non-elevated, medium-integrity process, I need to create an instance of Internet
I need to create a configuration file from a data file that looks as
I need to create a non modal Silverlight 4.0 control that would appear (pop
We have a need to create a private key that is seeded from 2
I need to create a custom attribute that is applicable only for non static
I need to create an iPhone/Mac app that is in a non-English language only.
I need to create WebMethod that will get some data from db and return
i need create an email list sending to many emails. what is best solution
I am writing a PHP application targeted at non-geeks, non-programmers. I need to create
I need to create an input form that will allow a user to enter

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.