This is a series of Java puzzles that put your Java skills to the test, in a challenging and fun way!
A puzzle consists of some given Java code with a line in it that seems to be impossible to reach. It’s up to you to find the hole in it, abuse a subtle behavior of Java to make execution reach that line anyways.
Short version: You must run the program with java -Djava.security.manager the.MainClass
. Any cheating in the content of your .java file is allowed; it is the whole point of the puzzle. Cheating the (compiler or runtime) environment from outside your code is not allowed.
If that's clear, then start puzzling now and forget about the rest. But if that still leaves you in doubt:
-Djava.security.manager
are allowed. The security manager option is there to prevent things such as setAccessible that would spoil the fun. If you like to work from within your IDE, add that option to the JVM arguments of the run configuration. If you don't change any other funky settings you're good to go..java
file. Other files may not be modified, and if any extra steps or tweaks are needed to be able to make it work, it's not a valid solution.You can stay up-to-date on the puzzles by follow this blog or following me on twitter.
Puzzles published so far:
Clowns | (solution) | How can you fit 20 clowns into a Volkswagen? |
Dreams | (solution) | Am I still dreaming? |
Car | (part 2, solution) | Vroom! |
Liquid (includes solution) | Program your way past airport security | |
Ball | (solution) | Play ball! |
Chicken | (solution) | Which was first, the chicken or the egg? |
Cookies | (solution) | Learn how to count down with Count von Count and Cookie Monster |
Square Root | (solution) | Find the square root of a huge number, without even looking at it |
Tweet | (solution) | Exploring the power a superclass has over its subclass |
No Dot | (solution) | Hello World without using a dot, backslash, or semicolon |