Challenge Results - Fastest Delphi Unique Random Number Generator
Here's the list of the accepted entries. 13 entries were accepted before initial results were published.
The winner (for the moment) is Patrick van Logchem with the fastest entry! 10 fame and glory points!!
Read the full article to find out who (you?) submitted accepted entries: Fastest Unique Random Number Generator Delphi Challenge Results
Here's an interesting comment sent by Jim McKeeth
Notes about the contest:
Judging criteria:
- Solve problem
- No memory leaks
- Clean and simple
- No unnecessary code lines
- Speed
- Subjective judgment of code
Observations:
- The article provides the array length and max value even though the procedure signature allows for variable lengths and values.
- Is this (length=100 & maxValue=1000) the only test case?
- Can we optimize for these parameters?
- Do we need to test for incorrect parameters?
- Can we eliminate the Int64 for Integer since the test case does not require it, thus improving performance?
- No unnecessary code lines is rather subjective. Possible meanings:
- The extreme would be putting all code on one line.
- Eliminate all tests and unlikely code paths.
- No blank lines?
- Favor simplicity over robustness & ease of readability?
- How random is random?
- The randomness is not specified, nor the method to use.
- Is Delphi's built in random generation system sufficient?
- Is building our own random algorithm necessary or even allowed?
- Is previously generated random numbers sufficient?
- How is speed measured?
- Is the runtime calculated through code analysis?
- Will the target system have multiple cores? (Should we thread?)
- What the time vs. space trade-offs can be made for better speed?
- Pre-generate random tables based on the constant nature of test?
Here's mine (short) reply:
1) Yes, the array is an open array, but the size of the array is determined by the "preparation" code presented in the challenge call.
2) "No unnecessary code lines" basically means that if you have a section of code that can be turned into a function or a procedure - do it.
3) Delphi Randomize and Random functions are random enough.
4) Speed is measured using the high precision timing class, TStopWatch, all entries tested on the same machine.
In general, Delphi code challenges are designed with the "having fun" idea in mind - for beginners to learn something by exploring code made by those that are no longer beginners :)
Related:


Comments
No comments yet. Leave a Comment