Ask HN: Are there any sites that help you practice reading obfuscated code?
I'm taking a java programming class this semester. Our quizzes and tests usually revolve around a chunk of code that is hard to understand, uses lots of nested loops, broken switch statements, etc.
The professor doesn't provide any material to prepare for the tests and the too easy to prepare for the test.
I'm looking for some sort of resource to practice reading hard to understand code, particularly java. Does HN have any suggestions?
Books/websites/videos/etc are all welcome.
EDIT:: The examples below are a little too hard. I'm looking for something that is entry level stuff.
4 comments
[ 19.0 ms ] story [ 15.2 ms ] threadI'm not responsible for damage to your mind.
perlmonks: http://www.perlmonks.org/?node=Obfuscated%20Code
You could play with eyedrops: http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops....
Think about what could cause loops to behave in unexpected ways. Consider off-by-one loop errors like >= where > was needed and vice versa, or a loop condition being assignment (x=y where y is nonzero, so it resolves to true) instead of testing for equality (x == y). Write code for long enough and you will make these errors yourself and debug them so you will become very good at recognizing them. Also be aware of the break, continue, return, and finally keywords.
I would look for random code people wrote, for example on github:
https://github.com/search?utf8=%E2%9C%93&q=sort&repo...
And then just look at the code and try to understand how it works. This result for example seems to implement basic functions and is well commented:
https://github.com/erlide/erlide/blob/6b836bcb0770d23c4471f4...
Hope this helps