Is there any good way to generate 100,000 unique 13-bit pure numeric strings?

Source: Internet
Author: User
Is there any good way to generate 100,000 non-repeated 13-bit pure numeric strings? is there any good way to generate 100,000 non-repeated 13-bit pure numeric strings?

Reply content:

Is there any good way to generate 100,000 unique 13-bit pure numeric strings?

One by one. Starting from 13 0, add 1 at a time...

It can be generated by time stamps, or a random number is added later.

Package com. xtl. demo; import java. util. hashSet; import java. util. random; import java. util. set; /*** generate 20 non-repeated 13-digit random numbers * @ author xiatianlong ** @ date 11:44:57 on April 9, October 8, 2016 */public class CreatRandomNumber {public static void main (String [] args) {Set
  
   
NumberSet = new HashSet
   
    
(); While (true) {// if (numberSet. size ()> 20) {break;} String randomNumber = createRandomNumber (13); numberSet. add (randomNumber);} for (String string: numberSet) {System. out. println (string) ;}}/*** generate a random number of specified digits * @ param length * The number of digits generated * @ return */public static String createRandomNumber (int length) {String number = ""; for (int I = 0; I
    
   
  

Performance is not considered...

You can encrypt characters in one direction and add salt to them. you can only get 13 characters.

Available in pythonrandom.sample:

random.sample(range(10**12, 10**13), 10**5)

Python2xrangeIf you want to start from scratchformat.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.