From ac949a735db3694805145820efffb06c7e57469a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 27 May 2023 04:30:19 -0700 Subject: [PATCH] Fix 1988/litmaath/README.md + add alt code There was no 'To build' or 'To run' section. The alt code is that which the judges suggested to try and understand the code a bit more. As it was fun output and it seems instructive I decided to add it as an alt version. Updated .gitignore. --- 1988/litmaath/.gitignore | 1 + 1988/litmaath/Makefile | 4 ++-- 1988/litmaath/README.md | 32 ++++++++++++++++++++++++++++---- 1988/litmaath/litmaath.alt.c | 16 ++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 1988/litmaath/litmaath.alt.c diff --git a/1988/litmaath/.gitignore b/1988/litmaath/.gitignore index 5722bebf5..ef2cc4b0f 100644 --- a/1988/litmaath/.gitignore +++ b/1988/litmaath/.gitignore @@ -1 +1,2 @@ litmaath +litmaath.alt diff --git a/1988/litmaath/Makefile b/1988/litmaath/Makefile index 08b070b99..370e7cbc0 100644 --- a/1988/litmaath/Makefile +++ b/1988/litmaath/Makefile @@ -111,8 +111,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/1988/litmaath/README.md b/1988/litmaath/README.md index e776052d5..0e801e4ca 100644 --- a/1988/litmaath/README.md +++ b/1988/litmaath/README.md @@ -1,18 +1,42 @@ # Best small program Maarten Litmaath -Free University (VU) Amsterdam -Department of computer science -Uilenstede 72 -1183 AK Amstelveen The Netherlands +## To build: + +```sh +make +``` + +## To run: + +```sh +./litmaath some text +``` + +There is an alternate version provided. See the Alternate code section below. + ## Try: ```sh ./litmaath eschew obfuscation ``` +### Alternate code: + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) added the +[litmaath.alt.c](litmaath.alt.c) which we described in our remarks below. To +use: + +```sh +make alt +``` + +Use `litmaath.alt` as you would `litmaath` above. + +Thank you Cody! + ## Judges' remarks: diff --git a/1988/litmaath/litmaath.alt.c b/1988/litmaath/litmaath.alt.c new file mode 100644 index 000000000..a08e45ea2 --- /dev/null +++ b/1988/litmaath/litmaath.alt.c @@ -0,0 +1,16 @@ +#include +main(argc, argv) +int argc; +char **argv; +{ + while (*argv != argv[1] && (*argv = argv[1]) && (argc = 0) || (*++argv + && (**argv && ((++argc)[*argv] && (**argv <= argc[*argv] || + (**argv += argc[*argv] -= **argv = argc[*argv] - **argv)) && + --argv || putchar(**argv) && ++*argv--) || putchar(10)))) + fprintf(stderr, + "argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n", + (long) argv, (long) *argv, *argv && **argv ? **argv : '@', + (long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc); + + ; +}