From fcb19507a82ca72caa650afd8e5014aaac832199 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 14 Apr 2023 05:57:04 -0700 Subject: [PATCH] Add alt code to 1989/ovdluhe + update README.md The alt code is based on the author's remarks. It allows one to more easily redefine the macro they refer to (P) in a way that lets them try it out without having to modify the code. Updated .gitignore. Format fixes in README.md. --- 1989/ovdluhe/.gitignore | 1 + 1989/ovdluhe/Makefile | 7 +++++-- 1989/ovdluhe/README.md | 41 +++++++++++++++++++++++++++----------- 1989/ovdluhe/ovdluhe.alt.c | 26 ++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 1989/ovdluhe/ovdluhe.alt.c diff --git a/1989/ovdluhe/.gitignore b/1989/ovdluhe/.gitignore index 14b8483be..e3366e267 100644 --- a/1989/ovdluhe/.gitignore +++ b/1989/ovdluhe/.gitignore @@ -1 +1,2 @@ ovdluhe +ovdluhe.alt diff --git a/1989/ovdluhe/Makefile b/1989/ovdluhe/Makefile index 597aede89..34f9f9ef7 100644 --- a/1989/ovdluhe/Makefile +++ b/1989/ovdluhe/Makefile @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -138,6 +138,9 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + # data files # data: ${DATA} diff --git a/1989/ovdluhe/README.md b/1989/ovdluhe/README.md index 2c0dbb685..3182ad944 100644 --- a/1989/ovdluhe/README.md +++ b/1989/ovdluhe/README.md @@ -1,14 +1,16 @@ ## Most humorous output - Oskar von der Luehe - Institut fuer Astronomie - ETH - Zentrum - 8092 Zuerich - Switzerland +Oskar von der Luehe +Institut fuer Astronomie +ETH - Zentrum +8092 Zuerich +Switzerland ## To build: - make all +```sh +make all +``` To get this to compile with a modern CPP, we had to replace `#D` with `#define`. @@ -16,19 +18,34 @@ To get this to compile with a modern CPP, we had to replace `#D` with `#define`. Run the program this way: - ./ovdluhe < textfile +```sh +./ovdluhe < textfile +``` The program stops when it reaches the end of the template buffer by chance or is killed. ## Try: - ./ovdluhe < ./ovdluhe.c - ./ovdluhe < ./ovdluhe.c +```sh +./ovdluhe < ./ovdluhe.c +./ovdluhe < ./ovdluhe.c - ./ovdluhe < README.md - ./ovdluhe < README.md +./ovdluhe < README.md +./ovdluhe < README.md +``` +### Alternate code: + +The author suggested that one varies the definition of `P` from 2 through 10. As +it's a `#define` it's easy to set up which [Cody Boone +Ferguson](/winners.html#Cody_Boone_Ferguson) did for us. To use try: + +```sh +make CFLAGS="-DP=9" clobber alt +``` + +Use `ovdluhe.alt` as you would `ovdluhe`. ## Judges' remarks: @@ -38,7 +55,7 @@ recommended. You will get different output each time you run it. -## Selected notes from the author: +## Author's remarks: This program implements an "Eddington ape" - it generates random text from a supplied template. The template text file diff --git a/1989/ovdluhe/ovdluhe.alt.c b/1989/ovdluhe/ovdluhe.alt.c new file mode 100644 index 000000000..9aad1945e --- /dev/null +++ b/1989/ovdluhe/ovdluhe.alt.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +typedef char ape; +#define EA register +#define EP unsigned +#define A 1 +#define AP (A<>A) +#define APE {EA EP ape,ea=AE;while(ea--) e[ea]=E;} +PA(); +;ape a[PE+A],ap,*ae,p[P+A],e[AE]; +main(){ape pe,*ep=a;srand((EP)time((long)E)); +while(((*(ep++)=getchar())!=-A)&&((ep-a)