You are provided with two large lists of numbers. The lists each have approx 500,000 numbers, one per line and each number is a positive integer in the range 1.. 231-1. The files will probably not have the same number of numbers in them and they will not be sorted.
Your program should read in both files and compare the numbers and then output the differences. Specifically those numbers in list1.txt that are not in list2.txt and those in list2.txt that are not in list1.txt. There will be no duplicate numbers in each file, i.e. in each file, every number will be unique.
Input Files
There is one zip pc41.zip which holds the two text files list1.txt and list2.txt.
- Download pc41.zip.
The Output
Output a file output.txt in the same location as your exe. The first line should have the average time of a run. A run is the time it takes to generate the differences and should start immediately i.e. include the time taken to read both lists. If your code is lightning fast redo the calculation (including reloading both files- no caching allowed!) so it takes a few seconds. The second line should say how many differences there are. For example
"Average time = 0.87 sec"
There are 146 differences
The rest of the file should be the difference numbers, sorted from smallest to highest and output one per line.
Timing Code
Please time from the start of the run, after reading in the input file until just before the output file is opened for writing. This code below will do high speed timing.
Final Results
Argentian Gustavo Giráldez won with a 0.005 second speed advantage over Belgian Christian Beaumont. Thanks to all who entered. There's been some amazing code written.
- Gustavo Giráldez 18 - C 0.0761
- Christian Beaumont 18 - C # 0.081264Website
- Ypsilon AG 18 - C++ 0.106589
- Patrick de Lang 18 - C #0.135
- Steve N 18 - C++ 0.149353
- Loren Eggert 18 - C++ 0.150713
- Andrey Petrusenko 18 - C++0.17524
- Pedro Graca 18 - C 0.2
- Mike Blaszczak 18 - C++ 0.21705
- James Borden 18 - C# 0.22464383
- Chris Greth 18 - C++ 0.252973
- Jon Drane 18 - C 0.261845
- David Heigl 18 - C++0.264558
- Peter Jansson 18 - C++ 0.312028Website
- Hal Noyes 18 - C# 0.61531967
- Shahin.Barzegar 18 - C++ 0.64
- Scott Hein 18 - C# 0.8954219
- Florian Schaeffler 18 - C# 1.005
- Mario Bellemare 18 - C# 1.1227055
Rules
This is for glory only. About.com does not permit prizes to be given.Please submit your source code and the output file to the cplus.guide@about.com?subject=Programming Contest 41 email address with the subject line Programming Contest 41.
It must compile with Open Watcom, Microsoft Visual C++ 2008/2010 Express Edition/Microsoft Visual Studio 2008/2010 or Borland Turbo C++ Explorer, Microsoft Visual C# 2008/2010 Express Edition or GCC/G++. If it doesn't compile, it can't be run so is automatically disqualified.
Please include your name, age (optional), blog/website url (optional) and country. Your email address will not be kept, used or displayed except to acknowledge your challenge entry. You can submit as many entries as you like before the deadline which is November 30 2010.
The top ten entries will be listed, judged purely on points. A condition of entry is that you allow your source code to be published on this website, with full credits to you as the author.
- An index of Every Past Programming Contest on this site

