Skip to content

Instantly share code, notes, and snippets.

@mz0
Last active January 15, 2019 18:50
Show Gist options
  • Save mz0/32de99688d50248baa43dc36e720fca6 to your computer and use it in GitHub Desktop.
Save mz0/32de99688d50248baa43dc36e720fca6 to your computer and use it in GitHub Desktop.
"Programming pearls" problem 1 test data: unsorted "phone number" file generator.
#!/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