Java for the ladies
Published by peter July 26th, 2006 in java.My wife doesn't really like coding, she can find her way around HTML, CSS en some Javascript... but only if I really don't feel like doing it for her. Can't blame her, she is a designer.
She does however like making puzzles, specifically numerical puzzles like sudoku.
While preparing for the upcoming exam I stumbled over the following question, which I asked her to try and figure out.
Place the fragments into the code to produce the output 33. Note, you MUST use each fragment exactly once
JAVA:
class Incr{ public static void main(String ... args){ Integer x = 7; int y = 2; x __ __ ; __ __ __; __ __ __; __ __ __; System.out.println(x); } }
The allowed fragments:
| y | y | y | y |
| y | x | x | |
| -= | *= | *= | *= |
After introducing her to some basic concepts ( x *= x could be written x = x*x) she got to work, and managed to come up with the answer. Can you?




















Piece of cake!
Yeah right, and the answer is? Did you mail that to Peter?