Jump to content
  • Advertisement
Sign in to follow this  
lakers34kb

Random number generator

This topic is 3051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to generate a random 6 digit number, but only using the numbers 1,2,3,4,5,6 and not having it repeat any numbers within. Example: 345621 124356 453216 1,2,3,4,5,6 has to be used once, so its basically scrambling the 6 numbers

Share this post


Link to post
Share on other sites
Advertisement
Though your programming language may have a library function to do so out of the box. Ex: for C++ look up the random_shuffle() function.

Share this post


Link to post
Share on other sites
I just though of something.

I guess I want to scramble the number 123456, kind of like word scrambler where you take comfort and make it trofocm

I want to do the same thing with 123456, but have a whole list of it.

Share this post


Link to post
Share on other sites
Again, if you want all the permutations of a set your programming language may have a library function to do it. Ex: for C++ look up the next_permutation() function.

Share this post


Link to post
Share on other sites
#include <iostream>
#include <algorithm>

int main() {
char s[]="123456";

do {
std::cout << s << '\n';
} while (std::next_permutation(s,s+6));
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!