What's a good way to generate 100,000 non-repeating 13-bit pure numeric strings

Source: Internet
Author: User
What's a good way to generate 100,000 non-repeating 13-bit pure numeric strings

Reply content:

What's a good way to generate 100,000 non-repeating 13-bit pure numeric strings

Come on. Starting from 13 0, add 1 at a time ...

Available timestamps to be generated, or followed by random numbers

Package Com.xtl.demo;import Java.util.hashset;import Java.util.random;import java.util.set;/** * Generates 20 groups of 13-digit random numbers that are not duplicated * @ Author Xiatianlong * * @date October 8, 2016 morning 11:44:57 */public class Creatrandomnumber {public static void main (S Tring[] (args) {Set
  
   
    numberset = new HashSet 
    
     ();            while (true) {//Quantity greater than 20 is the end if (Numberset.size () >20) {break;            } String Randomnumber = Createrandomnumber (13);        Numberset.add (Randomnumber);        } for (string string:numberset) {System.out.println (string); }}/** * Generates a random number of digits * @param length * The number of bits generated * @return * */public static Strin        G Createrandomnumber (int length) {String number = ""; for (int i = 0; I 
     
      < code="">
      
 
     

   
  

没怎么考虑性能。。。

Random one-way encryption characters and add salt, take 13 bit not on the line.

Python available random.sample :

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

Python2 with xrange , if you want to start with format from zero.

  • 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.