I never said it matters. It doesn't. It's just interesting to find out how short you can make a bit of code. In terms of efficiency, it's usually horrible (though the short-circuiting there is nice).

Before getting into your solution, I'm Gadget -- nice to meet you!

Alright, I see a few problems with your solution...

1) In order for you to print a numeral, the entire conditional must be true which only occurs when a number is both a multiple of 3 and 5 (ie a multiple of 15). If the current number is a multiple of 5, but not 3, you won't ever print "Buzz" due to short-circuiting of the and statement (note: I believe that C# does short-circuiting... I could be wrong).

2) If a number is a multiple of 3, you will print "Fizz", but you will follow it with a 3 or 6 or ...

3) You're going to have newline errors. For example, you can either print a newline after "fizz" which works for multiples of 3 (minus issue #1 above), but it will print "fizz\nbuzz\n" for a multiple of 15. Some languages will allow you to use a conditional inside of a print statement, but I doubt that C# supports this functional style of programming (see example below).

Im a double major Computer/Electrical Engineering and Computer Science

and we sit in class and learn that material and then are left to our own devices for programming projects.

In ECE they actually have discussed optimization but thats low level(MIPS,SPARC,IA32,BASIC), and programming projects for some of those classes stipulate solving a problem in a certain number of instructions, which does directly correlate with efficiency most of the time.

CSC courses you only get direct assistance with code if you cant get it working, no regards to optimizing.

If thats the state of the industry i feel a good deal better although real optimization in anything high level is on the list of things i wish i knew.

We did a bit of algorithmic analysis(Big O, Big Theta) etc and when I took the programming languages course we did talk in decent detail about how language designs play into efficiency(Eager vs Lazy evaluation). I think we might have a course named Optimization but i dont think it is even requisite for the Software Engineering concentration. I have yet to take the Compiler course which I imagine will include some of notions.

Ill have to dig up some supplemental instruction(a book) on the topic.

Who is online

Users browsing this forum: No registered users and 1 guest

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