Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Did you have the using System; statement?
Was it a build or runtime error? What was the specific error?
Reasons you may have been downvoted include:
This is a 7 kyu kata marked Fundamentals and Arrays; it is not marked for Optimization.
"Avoid premature optimization"; this code is very easy to understand and therefore should be very easy to maintain.
A good sorting algorithm will be O(n ln(n)) versus the O(n) of going through the list once. Yes, sorting is expected to take longer but is it significant?
I wrote a program that
(a) generates N random numbers,
(b) solves by a minimum selection method, and
(c) solves by sorting the array.
For N = 2,000,000 sorting the array was taking about 1/4 second (versus perhaps 30 ms for the other method). Unless I'm looking to run this a lot of times in an outer loop, that time isn't worth fussing over. AND, if I am running it many times I would first ask whether this is important for the overall program. If those 2,000,000 values are coming from a slow hard drive the program will appear slow with either algorithm.
If you're interested, at N = 20,000,000 the sorting took about 2 seconds (versus 80 ms). Here I would look at whether to optimize. Further, it took me a while to find my typo in the faster algorithm, which supports the maintainability aspect mentioned earlier.
Can you provide an example of such a number?
I had a similar first impression, but thinking it through I changed my mind. However, I have not yet proved it to myself.