Current Forum: Homework 5 - Parts 1 and 2 |
Date: Wed Nov 7 2001 8:59 pm |
Author: Abeles, Peter J. <pja@andrew.cmu.edu> |
Subject: Re: 10 lines?? I only needed 3 - That must be some ugly code |
|
|
3 lines? lets say for a second you figure out how to do it in one if statement
if( foo ) DoStuff();
thats 2 lines, but wait you need to go through some sort of loop
for( blah blah blah ) if( foo ) DoStuff();
thats 3 right there. But you are looking for 3 differnt types of objects so one if statement isnt enough. Of course you could do something like this.
for( blah blah blah ) if( foo ) DoStuff();
But I dont consider that one line of code. Perhaps a better way to tell how compact the code is how many decision points there are. In my code there are 8 points (including the for statement) I can most likely make it more compact but I'm not motivated enough to do that right now.
- Peter |
|