3 ms·
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.
- jellicle 15y agohttp://www.ioccc.org/ http://www.ioccc.org/ I'm not responsible for damage to your mind.
- cd34 15y agohttp://www.ioccc.org/ http://www.ioccc.org/ is one such site, but, for C perlmonks: http://www.perlmonks.org/?node=Obfuscated%20Code http://www.perlmonks.org/?node=Obfuscated%20Code You could play with eyedrops: http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops....
- Tangaroa 15y agoUse a pencil and paper. Make a column for each variable. As the values change, record the new value in a new row. That will get you through the test questions as long as you read the code correctly. 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.
- Donito 15y agoIt doesn't sound like you're looking for "obfuscated" code, which is what the links below show. But rather real code that's more complicated than slide examples. I would look for random code people wrote, for example on github: https://github.com/search?utf8=%E2%9C%93&q=sort&repo=&langOverride=&start_value=1&type=Code&language=Java 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/6b836bcb0770d23c4471f490bea50b9141d1909e/org.erlide.core/src/org/erlide/core/common/Util.java https://github.com/erlide/erlide/blob/6b836bcb0770d23c4471f4... Hope this helps