Sunday, June 21, 2009

Puzzle 34 - Solution.

This is one of the most restrictive puzzles till now. With no new semi-colons being allowed it's pretty difficult add any additional code. The other restriction on line 10 & 12 leave no choice but to target line 11 which is the only line left!

In Java we can initialize variables even if they are part of an expression. This mean we can assign a value of 42 to the question at line 11 and our problem would be solved.

So here is the one line solution to this puzzle!

int theAnswer = (theQuestion=42)*9;

For all you Douglas Adams fans out here there is another puzzle based on Hitchhiker's Guide to the Galaxy coming up soon! Keep watching this space for more ...

@Sebastian - Still trying to figure out your answer :)!

No comments:

Post a Comment

Solution for this question?