Author:
- Name: Adar Zeitak
Location: IL - State of Israel (Israel)
To build:
make
There is an alternate version that is slightly deobfuscated. See alternate code below.
To use:
./zeitak < file
where file
is the file to be checked for nesting errors. For example, you may
try incorrect.1.quote.c and the program itself. You may also run it on
text files that are not code.
Try:
./try.sh
NOTE: the program prints an error and exits on the first nesting error so it will not detect multiple issues.
Alternate code:
The alternate code, zeitak.alt.c, is a version that was slightly deobfuscated by the author. You may find reading it helpful in your attempt to understand this extremely subtle entry.
Alternate build:
make alt
Alternate use:
Use zeitak.alt
as you would zeitak
above.
Judges’ remarks:
This is an extremely subtle and twisted piece of Gold award winning code!
The judges spent a considerable amount of time analyzing this entry. At one point we spent 18 minutes just to understand 18 key characters of this code.
NOTE: if you use vim to view the code, make sure to do:
:set tabstop=4
in command mode, before looking at the code, to see the correct layout.
For more help, see the FAQ on “tabstops”.
Author’s remarks:
Nesting Errors Detector
What does it do
As you have probably understood by looking at the source*, this program has
something to do with parenthesis (and equality of opening and closing
parenthesis, if you look close enough). It goes over the file given to it and
checks that every opening (
, [
, or {
has a matching closing one and
vice versa. It also checks that every "
or '
is closed.
If an error is detected, an error message will be printed. If the problem is a superfluous closing bracket, it will even print a few characters around it’s position.
* Make sure you view the source with 4 spaces tab width.
Features
- Ignores parenthesis inside strings or character constants, so no errors will be detected in the following line:
printf(")");
- Doesn’t get confused by the 1984/anonymous entry!
Mis-Features
- Escapes (e.g.
\"
) are ignored, so the following line will produce an error:
printf("\"");
Obfuscation
IOCCC entries already contain entries without digits, control-flow keywords and certain operators in their source. This entry has an even more limited source, that is:
- Without any digits.
- Without any character constants.
- Without using functions from headers other than
stdio
. - Without any control-flow keywords (not even the
?:
operator). - Without any arithmetic or logic operators!
So, what’s left? Parenthesis, and lots of them, as looking at the source will reveal immediately. The main obfuscation is building the whole algorithm using only function calls, typecasts, array lookups and pointer operators.
Additional obfuscations include:
- Extensive reuse of identifiers: Macros share names with variables, inner curly braces scopes contain variables with names identical to those in the outer scopes and some of the variables have different uses in different parts of the program. Even the large array has more than one use.
- A complicated data structure with “unused” fields.
- Mostly one-letter identifiers.
- Complex recursion: A function might call itself once, twice, or not at all.
Compilation/Portability/Running Notes
The program requires
char
to be one byte and pointers to be at least two bytes long.The program was tested on the following platforms:
- Ubuntu 9.04 32-bit with GCC
- Windows 7 32-bit with GCC
- Windows 7 32-bit with OpenWatcom
Inventory for 2012/zeitak
Primary files
- zeitak.c - entry source code
- Makefile - entry Makefile
- anonymous.alt.c - alternate source code
- anonymous.c - 1984/anonymous fixed for macOS source
- zeitak.alt.c - alternate source code
- zeitak.orig.c - original source code
- try.sh - script to try entry
- correct.java - example Java source with correct brace (supposedly :-) )
- incorrect.1.quote.c - example C source with incorrect quotation marks
- incorrect.3.quotes.c - example C source with incorrect quotation marks
- incorrect.brace.c - example C source with incorrect braces
- incorrect.bracket.c - example C source with incorrect brackets
- incorrect.java - example Java source with incorrect braces
- incorrect.paren.c - example C source with incorrect parentheses
- incorrect.quote-esc.c - example C source with incorrect quotation mark escaped
- incorrect.single.quote.c - example C source with incorrect single quotation mark
- incorrect.txt - example text file with unmatched quote
Secondary files
- 2012_zeitak.tar.bz2 - download entry tarball
- README.md - markdown source for this web page
- .entry.json - entry summary and manifest in JSON
- .gitignore - list of files that should not be committed under git
- .path - directory path from top level directory
- index.html - this web page