Old article, but still! I wrote the FizzBuzz app in about two minutes, including waiting for VS 2010 to open! I find it crazy that most CS graduates can't do it. Even more so that "Senior Programers" take 10-15 minutes? I should be paid more...

/me waits for someone to point out that my solution uses more lines of code and is therefore less efficient than the version that i'm criticizing.

Note: I'm assuming that the mod calculation is more expensive than simply tracking two ints. This is not always the case and the code could be made more obvious by using the modulus operation instead. It is the logic that I'm trying to improve on rather than the arithmetic. Doing 4 comparisons in every loop is a waste when most iterations of the loop require only two.

We both know that fewer lines isn't necessarily better... we just had that discussion

But, I wonder what the difference is. I am not sure there is any really good information on it... or that it is measurable. I suppose it would depend how it (mod) is implemented. I honestly can't say that I know the algorithm for it.

Resources are so trivial though, but I would guess your solution uses a tiny bit more memory and mine and the criticized (thanks, ass ) one a few cpu cycles?

Old article, but still! I wrote the FizzBuzz app in about two minutes, including waiting for VS 2010 to open! I find it crazy that most CS graduates can't do it. Even more so that "Senior Programers" take 10-15 minutes? I should be paid more...

I've seen some "senior programmers" that weren't pile crap... but I don't think that I've ever come across anyone that couldn't code something this simple (this would be the easiest of easy TopCoder problems). Honestly, I can't explain how many of them managed to find employment (beside at McD's) and retain it long enough to have "senior" in front of their name.

The second persons assertion that most applicants can't tell you what comes after A or F in hex or use recursion surprises me less. With all of these stupid "software engineering" programs churning out mindless dimwits quoting design pattern books and software metrics... and never having written anything of interest. Sometimes I really wish that I was old enough to have been employed during the 60's or 70's.

Yes. Your code is ugly. When are you going to start using a language that resembles mathematical poetry?!

Personally, I think that checking for the "five" inside the "three" condition is probably not buying you any speed (and costing you a bit in cleanliness) -- the thing that is going to suck up all the time is the output to the console (of course) -- the "speed up" would probably amount to less than the noise created by other processes on the system.

Problem variation: Given a value max, compute the sum of the integers from 1 to max unless the number is a multiple of both 3 and 5. Test and time your solution with a max value of 100 million.

CrashTECH wrote:

I suppose it would depend how it (mod) is implemented. I honestly can't say that I know the algorithm for it.

I'm not sure how it is implemented on standard hardware either. I know that there are quite a few algorithms extending back a number of years and probably over a hundred variations due to algorithms used in various crypto systems.

Yes. In this case, I knew the LCM in advance, so I simply plugged the value in as a magic number (bad Gadget!). Computing the LCM is relatively inexpensive (ie < O(n) keeping things simple...) and can be found using:

LCM(m,n) = (m*n) / GCD(m,n)

Adding m and n as parameters and using the built-in CL LCM function...

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum