Files
ioccc/2000/primenum
Landon Curt Noll f29b37e49a improve HTML menus, add social.html, prep for IOCCC28 winners
Prepare for the winners of **IOCCC28**.

> However these are not the 2024 droids you are looking for.  :-)

The HTML menu (both JavaScript and non-JavaScript) has been updated.

The `Status -> Rules and guidelines' have been replaced with two
separate menus `Status -> IOCCC rules` and `Status -> IOCCC guidelines`.

Added a new top level `social.html` page: built from a new `social.md`.

Sorted rules for building specific web pages in the top level `Makefile`.
Added `make social` to make the `social.html` page from `social.md`.

The `bin/gen-top-html.sh` now is able to process a argument of **social**
to process the new top level `social.html` page.

Changed `bin/gen-top-html.sh` VERSION from "2.0.0 2025-03-13"
to "2.0.1 2025-07-25".

Below `About -> Home page` a new `About -> IOCCC social media` menu item
as added.

Because the menu change touched every HTML file, we changed the general
copyright date range for HTML files from "1984-2024" to "1984-2025"
due to the extensive changes made for **IOCCC28**.

Those markdown files that were modified in 2025 had their copyright date
range also changed from "1984-2024" to "1984-2025".

Rebuilt tarballs and sitemap due to the extensive HTML rebuilding.

Ran `make update` to perform the above.
2025-07-26 13:06:29 -07:00
..
2023-07-06 21:49:38 -07:00

To build:

    make

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please DO NOT fix

For more detailed information see 2000/primenum in bugs.html.

To use:

    echo n | ./primenum n

NOTE: n is an integer.

Try:

    ./try.sh

Judges' remarks:

Just stop and read the program; it won't take long. Once you've figured out what it does, run it. It may surprise you.

This entry won, not because the obfuscation is impenetrable, but because it successfully fooled half of the judges, including me.

NOTICE to those who wish for a greater challenge:

If you want a greater challenge, don't read any further: just try to understand the program via the source.

If you get stuck, come back and read below for additional hints and information.

Author's remarks:

Description

For 15 years, IOCCC entries have obfuscated programs using esoteric, difficult-to-interpret, confusing algorithms. This entry finally bucks that trend and obfuscates in the most "obvious" way possible: by painstakingly describing the algorithm in clear pseudocode. Even novice programmers will recognize that the program should find and print prime numbers up to a given number (as specified on the command line).

But novice programmers especially know that mistakes are often made in translating pseudocode to real code, often resulting in programs with unexpected and confusing output. Clearly, the program contains several syntax "mistakes" (e.g. LessThanOrEqualTo) and blatant "errors" (e.g. Zero). This program clearly requires "debugging."

As a result of these "bugs", the program does not calculate primes at all. Instead, the program reads input from stdin and returns garbled text on stdout. Fortunately, you can recover the original message simply by running the program a second time. Try:

    ./primenum n < textfile | ./primenum n > textfile2
    diff textfile textfile2

where n is the same number (modulo 64). So, the prime number generator is actually a simple text encoder/decoder! Of course, don't forget that argument, otherwise the "bugs" in the program will cause it to crash!

Features

  • The program attempts to mislead the reader into thinking that it generates prime numbers. It does this by:

    • describing a correct algorithm in pseudocode;
    • using partially correct conversion of pseudocode to real code;
    • using suggestive variable names; and
    • using a suggestive program name.
  • The program demonstrates a novel method of abusing the C preprocessor.

  • Determining how the filter algorithm works is left as an exercise to the reader.

  • OK, so running it through the preprocessor strips away the prime number front. But ye be warned: "not a11 variab1es1es are identica1" :-)

  • Other features include

    • useless variables
    • useless if
    • a for loop that's used as an if statement
    • dependence on the high bit being 0
  • Try also echo THIS MESSAGE IS IN ALL CAPS | ./primenum 32