Freelance Projects

All freelance projects at One Location


Writing 13 Text Files  10.08.08

Write 13 text files containing 5.7 million codes. The text files will have 1 code per line, no quotes or dressing.

The codes will be formatted in the following way:

A0A0A0A0A0A

Where “A” is any capital letter A-Z (26 Options) and “0” is any letter 0-9 (10 Options).

One of the codes could look like G4P2K8U1D2Z . They will be randomly generated codes. It’s very important that there are NO

duplicates within the database.

Although there are 5.7 million unique codes, they will be grouped into 13 text files. The quantities will be as follows:

=======================================================

Group1.txt – # of Codes = 1,715,000
Group2.txt – # of Codes = 326,000
Group3.txt – # of Codes = 170,000
Group4.txt – # of Codes = 191,000
Group5.txt – # of Codes = 392,000
Group6.txt – # of Codes = 146,000
Group7.txt – # of Codes = 920,000
Group8.txt – # of Codes = 72,000
Group9.txt – # of Codes = 19,000
Group10.txt – # of Codes = 628,000
Group11.txt – # of Codes = 95,000
Group12.txt – # of Codes = 845,000
Group13.txt - # of Codes = 200,000

You can program this using any system you want. PHP, Visual Basis, Flash, etc. The important part for me is the text files

themselves. However, it would be nice if you included the source files you used for my learning benefit.

Building each code is easy. Just have two strings - “ABCDEFGHIJKLMNOPQRSTUVWXYZ” and “0123456789″. Then create a TempCode variable

as “” and then add a random character from the alpha string, add a random selection from the numeric string, add an alpha, add a

number, etc until you have an 11 digit code formatted similar to A0A0A0A0A0A. Then you check the codes array to see that it’s

unique. If it is, add it to the codes array.

You can nest this code building section between two loops:

Define 2 arrays (AllCodes and GroupCodes)
Define another array holding GroupQuantities (171500,326000,etc)

AllCodesNum=0 // variable to track next position in AllCodes Array
Group=1 to 13 // cycle through the groups
GroupIndex=1 to GroupQuantities(Group) // Where GroupQuantities are 1715000, 326000, etc
INSERT CODE HERE THAT BUILDS THE STRIng
CHECK WHETHER THE CODE IS ALREADY IN THE AllCodes array.
KEEP LOOPING IT UNTIL THE CODE IS UNIQUE
AllCodesNum=AllCodesNum+1
AllCodes(AllCodesNum)=TempCode // put into allcodes array - makes easier to check for duplicates
GroupCodes(Group, GroupIndex)=TempCode // put into 2 dimensional array that tracks codes by group
End Loop
End Loop

//The write to text files

Group=1 to 13
TempFile=”"
GroupIndex=1 to GroupQuantities
Keep adding codes (one per line) to TempFile
End Loop
Create a TempFileName (”Group”+Group+”.txt”)
Write Tempfile to a file called TempFileName
end loop



If you liked this project, make sure you
Subscribe to Freelance Projects RSS feed!




    • Your Ads Here
    • Your Ads Here