Fixes to 2000/primenum

The entry does not do what one might expect so add a note about this.

Fixed commands to try.

Format fixes.

Make main() void again as part of redefinition of INABIAF.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-07 11:25:03 -07:00
1 parent 3e29d777ce
commit 392e82dc85
2 files changed
+18 -20

No files matched your search

+16 -18
View File
@@ -1,8 +1,8 @@
# Best Abuse of CPP: # Best Abuse of CPP:
Raymond Cheong Raymond Cheong
[address subject to change] [address subject to change]
MD, USA MD, USA
## To build: ## To build:
@@ -10,22 +10,20 @@
make make
``` ```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this more
portable by changing the return type of `main()` to be `int` not `void`. Thank
you Cody for your assistance!
## To run: ## To run:
```sh ```sh
./primenum n echo n | ./primenum n
``` ```
NOTE: n is an integer. NOTE: n is an integer.
## Try: ## Try:
```sh ```sh
./primenum 23209 echo IOCCC 23209 | ./primenum 23209
``` ```
## Judges' comments: ## Judges' comments:
@@ -54,7 +52,7 @@ unexpected and confusing output. Clearly, the program contains several
syntax "mistakes" (e.g. LessThanOrEqualTo) and blatant "errors" (e.g. syntax "mistakes" (e.g. LessThanOrEqualTo) and blatant "errors" (e.g.
Zero). This program clearly requires "debugging." Zero). This program clearly requires "debugging."
As a result of these "bugs", the program does not primes at all. 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 Instead, the program reads input from stdin and returns garbled text on
stdout. Fortunately, you can recover the original message simply by stdout. Fortunately, you can recover the original message simply by
running the program a second time. Try: running the program a second time. Try:
@@ -70,19 +68,19 @@ argument, otherwise the "bugs" in the program will cause it to crash!
- The program attempts to mislead the reader into thinking that it - The program attempts to mislead the reader into thinking that it
generates prime numbers. It does this by generates prime numbers. It does this by
o describing a correct algorithm in pseudocode, * describing a correct algorithm in pseudocode,
o using partially correct conversion of pseudocode to real code, * using partially correct conversion of pseudocode to real code,
o using suggestive variable names, and * using suggestive variable names, and
o using a suggestive program name. * using a suggestive program name.
- The program demonstrates a novel method of abusing the C preprocessor. - The program demonstrates a novel method of abusing the C preprocessor.
- How the filter algorithm works is left as an exercise to the reader. - How the filter algorithm works is left as an exercise to the reader.
- OK, so running it through the preprocessor strips away the prime - OK, so running it through the preprocessor strips away the prime
number front. But ye be warned: not a11 variab1es1es are identica1 :-) number front. But ye be warned: not a11 variab1es1es are identica1 :-)
- Other features include - Other features include
o useless variables * useless variables
o useless if * useless if
o a for loop that's used as an if statement * a for loop that's used as an if statement
o dependence on the high bit being 0 * dependence on the high bit being 0
- Try also - Try also
echo THIS MESSAGE IS IN ALL CAPS | ./primenum 32 echo THIS MESSAGE IS IN ALL CAPS | ./primenum 32
+2 -2
View File
@@ -1,8 +1,8 @@
#define BeginProgram int main(int argc, char *argv[]) #define BeginProgram void main(int argc, char *argv[])
#define CloseBrace } #define CloseBrace }
#define CommandLineArgument -1 #define CommandLineArgument -1
#define Declare int i,j,n,Flag=1; #define Declare int i,j,n,Flag=1;
#define EndOfProgram return 0; #define EndOfProgram return;
#define False 0; #define False 0;
#define ForLoop ;for #define ForLoop ;for
#define GetCommandLineArgument n=atoi(argv[1]); #define GetCommandLineArgument n=atoi(argv[1]);