Created
December 17, 2014 10:42
-
-
Save santanor/620c2dcde7f3589549d2 to your computer and use it in GitHub Desktop.
PhoneNumbers
This file contains 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
private static Random random = new Random(DateTime.Now.Millisecond); | |
static void Main(string[] args) | |
{ | |
string[] numbers = new string[1000000]; | |
string[] offsets = new string[1000000]; | |
for (int i = 0; i < numbers.Length; i++) | |
numbers[i] = getNumber(); | |
Array.Sort(numbers); | |
System.IO.File.WriteAllLines("phones.txt", numbers); | |
offsets[0] = numbers[0]; | |
for (int i = 1; i < offsets.Length; i++) | |
offsets[i] = (long.Parse(numbers[i]) - long.Parse(numbers[i - 1])).ToString(); | |
System.IO.File.WriteAllLines("phonesOffsets.txt", offsets); | |
} | |
private static string getNumber() | |
{ | |
StringBuilder sb = new StringBuilder(); | |
for (int i = 0; i < 11; i++) | |
sb.Append(random.Next(0, 9)); | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment