From ce9bfca9c7d7d5f3e07214baa7a2a731d6d7fd76 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:55:41 -0700 Subject: [PATCH] Fix 2000/natori and add alt code The author suggested alternate code for those in the southern hemisphere which the natori.alt.c now has. --- 2000/natori/.gitignore | 1 + 2000/natori/Makefile | 4 ++-- 2000/natori/README.md | 18 ++++++++++++++++-- 2000/natori/natori.alt.c | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 2000/natori/natori.alt.c diff --git a/2000/natori/.gitignore b/2000/natori/.gitignore index c2f12625e..3a5d1f9c4 100644 --- a/2000/natori/.gitignore +++ b/2000/natori/.gitignore @@ -1 +1,2 @@ natori +natori.alt diff --git a/2000/natori/Makefile b/2000/natori/Makefile index 5f99c6a47..c2709255c 100644 --- a/2000/natori/Makefile +++ b/2000/natori/Makefile @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/2000/natori/README.md b/2000/natori/README.md index 94bae75e3..ca67af85f 100644 --- a/2000/natori/README.md +++ b/2000/natori/README.md @@ -29,6 +29,20 @@ compile at all (gcc and clang respectively). Thank you Cody for your assistance! echo "Do or do not. There is no try." ``` +### Alternate code: + +The author noted that those in the southern hemisphere might want to change +`acos(l/2)` into `acos(-l/2)`. Cody went ahead and made an alt version to do +this. + +To run: + +```sh +make alt +``` + +Use `natori.alt` as you would `natori`. + ## Judges' remarks: Here is a nice compact program that changes with the phase of the moon. @@ -46,8 +60,8 @@ This program outputs a rough image of the moon in its current phase. The main obfuscation of this entry is its complicated double recursion (without any loop or conditional statement). -People living in the southern hemisphere may want to change acos(l/2) -into acos(-l/2). +People living in the southern hemisphere may want to change `acos(l/2)` +into `acos(-l/2)`. ## Copyright and CC BY-SA 4.0 License: diff --git a/2000/natori/natori.alt.c b/2000/natori/natori.alt.c new file mode 100644 index 000000000..ce74329cd --- /dev/null +++ b/2000/natori/natori.alt.c @@ -0,0 +1,4 @@ +double l; +int moon(int _, int o, int O){ +return putchar((_--+22&&_+44&&main(_,-43,_),_&&(int)o)?(main(-43,(int)++o,(int)O),((l=((int)o+21)/sqrt(3-(int)O*22-(int)O*(int)O),l*l<4&&(fabs(((time(0)-607728)%2551443)/405859.-4.7+acos(-l/2))<1.57))[" #"])):10);} +main(int _,char**o,char**O){return moon(_, (int)o, (int)O); }