-2

I'm on a mac, and trying to dumb every possible 8 digit number from 0-9, with repetitions allowed, to a file, which would be 100 000 000 numbers.

I've tried

jot -r 100000000 00000000 99999999

That just gives me 100 000 000 random numbers with duplicates, and not all are 8 digits. I can't figure out if there's a switch in jot that does what I want to do, or if jot is even able to do what I to do. How can I do this?

I need every possible 8 digit serial number for 10^8, which is 100 000 000 number. I don't know what program can generate these numbers.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Is this a python question? Can you write a basic python for loop that goes from 0 to 100,000,000, and for each element it formats the number with leading zeros (or whatever format you want) and prints it to a file line by line? – Mr. Fegur May 01 '22 at 06:17
  • Nota, this will take about 9 GB on your disk. Do you have to store those numbers or you can issue them on the fly until they have been exhausted? – jlandercy May 01 '22 at 06:30
  • no it's not a python question, I mistakenly tagged python. I'm looking for a program or a way to generate 10^8 8 digit serial numbers. jlandercy, I need all the numbers at once for now. – icantlearnprogramming May 01 '22 at 18:17
  • The connection with [tag:serialization] escapes me. – user207421 May 03 '22 at 04:11

1 Answers1

0

what you are asking for is equivalent to counting from 0 to 10^8. If you want random order and still guarantee hitting every number, you can do this:

import numpy as np
numbers = np.random.choice(10**8, size=10**8, replace=False).astype(str)
numbers = list(map(lambda s: s.zfill(8), numbers))
with open('out.txt', 'w') as file:
    file.write("\n".join(numbers))
elbashmubarmeg
  • 330
  • 1
  • 9
  • Are you sure about your boundaries. `8**10` is something different of `10e8`. Additionally you may need to format numbers to have leading zero and ensure the format. – jlandercy May 01 '22 at 06:32
  • Excuse me you are correct, it is 10e8. I will correct that in the answer and handle the leading zeros case. – elbashmubarmeg May 01 '22 at 06:44
  • I'm sorry, it was not suppose to be a python question, I don't know how to work with python. I don't want to count from zero, I want to make every possible 0-9 8 digit number with repetitions. For ex 44657333, 10022358, 01171100, etc. I tried using numbergenerator.org, but it freezes when i input 10^8 – icantlearnprogramming May 01 '22 at 18:23