Last active
January 15, 2019 18:50
-
-
Save mz0/32de99688d50248baa43dc36e720fca6 to your computer and use it in GitHub Desktop.
"Programming pearls" problem 1 test data: unsorted "phone number" file generator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
""" | |
print 9,999,999 unique unordered "phone numbers" - 7-digit sequences | |
""" | |
m = 9999999 # max number | |
s = 1046527 # Carol prime: 7, 47, 223, 3967, 16127, 1046527, ... | |
l = len(str(m)) | |
ni= 5 # initial number | |
n = 1 # number 0..0 (all zeroes) is not used | |
while n <= m: | |
ni = ni-m if m < ni else ni | |
# print(f'{ni:0{l}}', end=" ") | |
print(f'{ni:0{l}}') | |
ni = ni + s | |
n = n + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment