Help me get hired - C# ASP .Net exercise

I'm an experienced software developer, but new at C# ASP .Net. I applied for a junior level position with a company, and they gave me a programming exercise. It looks pretty simple, but I'd like to get some feedback on my approach, as well as suggestions of things to add to make it more impressive.

Here's the assignment:
------------------------
Please write a program that generates a list of 10,000 numbers in random order each time it is run. Each number in the list must be unique and be between 1 and 10,000 (inclusive).
The most important success factor is to produce the best solution you can to solve the problem. There are many aspects to consider within that context – efficiency, performance, documentation, etc. Code to perform the algorithm is the minimum requirement. Your deliverable should contain enough to give us a glimpse into your analysis, your approach, your skills, or anything else that will demonstrate your ability as a software developer. We will be looking for a good approach, a glimpse into your thought process, things you can do to impress us, and clean and efficient code. We’re your potential customer for this assignment, show us what you’ve got.

Your deliverable will be something that we can compile and run (to test the results), written in C# along with whatever explanation of the code/program that you feel is necessary. (Note: A standalone .exe file is not required nor recommended to be included alongside your solution.) Your deadline is one week from today.

We will be choosing candidates to interview based upon the successful completion and evaluation of the submitted solutions to this problem.
------------------------

I plan on doing something like this to generate my numbers:
- Create an array of numbers.
- Select one at random.
- Add it to a new array.
- Remove it from the old array.
- Rinse / repeat.
Is this a good approach?

What's the best way to show a large list of 10k numbers? Should I use a paged ListView?

I'm thinking of adding a feature to allow the user to save the generated lists to files... and maybe reload them.

I probably need some sort of explanation of what this app is doing. Maybe in a Help link/page?

What else can I do to impress the client with my app?

Thanks in advance. (I let my blue lapse, or else I'd post a "thank you" pic.)

I'm about a half notch above legally retarded, so surely you don't want my input on this. Do you?

Maybe create some kind of app that can take pictures...and instantly share them with your friends...not Instagram...this is different Phone Post 3.0

All greek to me...but TTT. 

One random thought that might set you apart...create a little sample functionality that allows the ap to host ads.  You could probably just fake it, or if you wanted to go crazy, find a simple plugin. 

You could tell them..."Even though I focus on code/programming, revenue and customer orientation are always in top of mind." 

 

 

you cheatin bro

the best solution means the most efficient and most logical, using the least amount of code. if you really want i might return to this and give you a logical walkthrough.

I cant help you Im learning Java right now as we speak and I wanna kill myself.

no dont use the array use a generator

a generator is very very interesting computer science concept by the way !!!


if you want to be super impressive try create your own generator but thats advanced you can probably find a good efficient one the efficiency may be important but generator can also deal with accuracy, its quite interesting


actually, ive re read it and yes, it sounds like they want you to create your own generator and basically use it 10000 times. this is actually quite challenging. this project is going to be 50% research time and 50% work because i would suggest immediately begin reading all about different forms of RNG programs

Why not write some algorithm that takes the current time (in seconds since midnight) and makes it into a number 1-10,0000.

You can repeat this 10,000 times.

Each time run it should be different unless you happen to run it the next day at the same exact time down to the second.

Isn't that how most random number generators work, using the time in seconds since midnight?

Thanks, Nero. I hadn't heard of generators before. I did a quick search, and they sound interesting. They also sound a bit complex, though. Can a generator keep track of numbers that have already been generated? Keep in mind that the list of numbers must be unique. (I basically need to shuffle the numbers 1 through 10,000.)


Elgringo. I don't think this would be very efficient, since the random numbers must be unique. This approach would be fast at first, but I believe it would slot down after half way, because the algorithm will find it harder and harder to find an unused number.

i like gringos i think i may have heard of this before however your process must make it random and this is going to tie in a lot of fields because even with your doubles values for example there will be a cutoff point somewhere i think it would be good to have an understanding of this concept i would suggest reading from expert on the web wikipedia has one to begin yes i missed for keeping unique

your array idea is the best for this id think but there will/can still be a generator to pull the number although it will be easier for the array location as far as the accuracy goes (this is a debated thing with the generator, to understand it will be beneficial to the overall question) in the end haha i dont know fortunately you must do it hahaha maybe try a few things the array is good youre right ! and i would still use a generator in there ! combined is probably the best !

Get things working before you get fancy. Use system.Random for your generator. Use HashSet to ensure each item in the collection is unique.

Then get fancier. Make a nice GUI. Integrate help. Write unit tests.

Thanks, RocG. That's good advice.

I hadn't heard of HashSet before. According to this website (http://blog.goyello.com/2013/01/30/6-more-things-c-developers-should-not-do/), iterating through 10,000 integers in a List can take over 28 seconds, but a HashSet only takes about 0.002 seconds.

I've already been thinking about unit testing. I'm still kind of new at it. From what I've read, it can be tricky to test a set of random numbers, because it is not repeatable. You can set the random seed and see if you receive the expected set, but that tests the repeatability of the function, not the randomness. Do you have any insight into this or know what else I should test?

Sub Phone Post

S Phone Post

SirPrize - Thanks, RocG. That's good advice.

I hadn't heard of HashSet before. According to this website (http://blog.goyello.com/2013/01/30/6-more-things-c-developers-should-not-do/), iterating through 10,000 integers in a List can take over 28 seconds, but a HashSet only takes about 0.002 seconds.

I've already been thinking about unit testing. I'm still kind of new at it. From what I've read, it can be tricky to test a set of random numbers, because it is not repeatable. You can set the random seed and see if you receive the expected set, but that tests the repeatability of the function, not the randomness. Do you have any insight into this or know what else I should test?


For starters if you just show that you're thinking about unit tests they will be happy.



Use HashSet.ToList() (or whatever function exports it as a list). Then the things you can test easily are the size of the set generated and uniqueness. To test for uniqueness I'd probably sort the list and run through to make sure that the same value doesn't show up twice in a row.



You could test the randomness of the random number generator, but that's getting more involved for not so much gain. But it would probably be the most fun thing to work on.



Actually the idea of setting the seed for the random generator and making sure you get the same output each time is a valid test too. Sometimes unit tests test things that seem too simple. But when you work on a large code base sometimes you break things that aren't seemingly related to what you were working on. A unit test can tell you that you screwed something up right away.



Another thing that might impress them is if you can show that you used version control during development.



BTW, the downside to using HashSet is memory usage, but that's rarely a problem in modern C# development.

SirPrize - Thanks, Nero. I hadn't heard of generators before. I did a quick search, and they sound interesting. They also sound a bit complex, though. Can a generator keep track of numbers that have already been generated? Keep in mind that the list of numbers must be unique. (I basically need to shuffle the numbers 1 through 10,000.)


Elgringo. I don't think this would be very efficient, since the random numbers must be unique. This approach would be fast at first, but I believe it would slot down after half way, because the algorithm will find it harder and harder to find an unused number.


ahh ok, that makes sense

Ive used a similar approach to the one I described before, but it was to generate just a few random numbers, not even close to 10,000

Good luck to you!

Maybe I'm missing something here but generating numbers and then checking to see if they have already been generated seems silly IMO. When you get down to the last number x are you really going to keep generating random numbers from 1-10,000 until you generate x?

I assume the solution will involve generating a random number (using an existing pseudo random number generator) from 1-10,000, then generating a random number from 1-9,9999, and so on (obviously the number generated would be a pointer to your "random number" and not the number itself). Testing for duplicates would fall under unit testing.

go with the card shuffling algo that i think yabadaba is  suggesting, google it, the code is out there..

if they would have worded it as 1 - x, instead of 1 - 10 000  then i would have  spent some time on something that might scale better..

they're trying to get you to over think a simple solution..

 

 

MarsMan - Here's dome pseudo code written on a phone:

1- generate an array with 10000 positions and populate it with the nembers 1 to 10000.

You will have array[0] =1, array[1] = 2....array[9999]=10000.

2- loop until array.Length=0

2.1 sort a random number between 0 and array.length

2.2 pick the value in array[randomNumber] and add it to a list (or file stream or whatever).

2.3 remove array[randomNumber] from the array

3 - end of loop

4 - display your list, or write your file stream to a file. Phone Post

Exactly what I was thinking.

Or, potato. Phone Post