Wednesday, October 28, 2009

The babbling imbecile is just making up words, he is.

Weird. I am sure I have an elegant solution but now I have an unreachable code error and a dead code warning. Even weirder the hints seem to have directed me away from this elegant solution: … that still has the problem, err… umm… oh duh, else if doesn’t belong where two conditionals might be satisfied and you really don’t feel like spelling it out in Java’s version of combinatorical L… err… umm… this stuff:

(n%3==0 && !(n%3==0 && n%5==0) && !(n%3==0 && n%7==0) && !(n%3==0 && n%5==0 && n%7==0))

Which basically says n is a multiple of 3, but not 3 and 5, and not 3 and 7, and most certainly not 3 and 5 and 7. Yeah… getting rid of the else if, really simplified the code.

No comments:

Post a Comment