From c06ac5088840c4aea0bbbc46246460768b1c3901 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:35:31 -0800 Subject: [PATCH] Add 2020/endoh3/run_clock.alt.sh for alt code The alt code provided by the author back in 2020 uses Unicode but there wasn't a script for it (the script run_clock.sh which I made some fixes in last year was added by the judges but no version for the alt code was added). The scripts also have another fix in them: make clock or make clock.alt first as if not and the program does not exist the script will happily overwrite the C files and prevent it from being compiled. They use 'make -B' just to be sure that it's compiled. --- 2020/endoh3/.gitignore | 2 ++ 2020/endoh3/Makefile | 12 ++++++++++-- 2020/endoh3/README.md | 8 ++++++++ 2020/endoh3/run_clock.alt.sh | 9 +++++++++ 2020/endoh3/run_clock.sh | 1 + thanks-for-help.md | 8 ++++++++ 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 2020/endoh3/run_clock.alt.sh diff --git a/2020/endoh3/.gitignore b/2020/endoh3/.gitignore index 022c5af38..1914fcb60 100644 --- a/2020/endoh3/.gitignore +++ b/2020/endoh3/.gitignore @@ -1,6 +1,8 @@ # # sort with: sort -d -u clock +clock.alt +clock.alt.c clock.c *.dSYM indent diff --git a/2020/endoh3/Makefile b/2020/endoh3/Makefile index fc213a1c5..8c6841dfa 100644 --- a/2020/endoh3/Makefile +++ b/2020/endoh3/Makefile @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} clock # -ALT_OBJ= ${PROG}.alt.o -ALT_TARGET= ${PROG}.alt +ALT_OBJ= ${PROG}.alt.o clock.alt.o +ALT_TARGET= ${PROG}.alt clock.alt ################# @@ -146,6 +146,14 @@ alt: data ${ALT_TARGET} ${PROG}.alt: ${PROG}.alt.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} +clock.alt: clock.alt.c + +clock.alt.c: ${PROG}.alt.c + @${RM} -f $@ + ${CP} -f $< $@ + + + # data files # data: ${DATA} diff --git a/2020/endoh3/README.md b/2020/endoh3/README.md index e54527e4a..38b255e8b 100644 --- a/2020/endoh3/README.md +++ b/2020/endoh3/README.md @@ -41,6 +41,14 @@ make alt Use `prog.alt` as you would `prog` above. +### Alternate try: + +```sh +./run_clock.alt +# And watch closely for 15-20 seconds +``` + + ## Judges' remarks: You may be tempted to use a mirror. Resist the temptation! Try figuring out how diff --git a/2020/endoh3/run_clock.alt.sh b/2020/endoh3/run_clock.alt.sh new file mode 100755 index 000000000..f4bbeaf50 --- /dev/null +++ b/2020/endoh3/run_clock.alt.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +make -B clock.alt || exit 1 +while true; do + cc -std=c11 -Wall -Wextra -pedantic -O3 clock.alt.c -o clock.alt + clear + ./clock.alt | tee clock.alt.c + sleep 5 +done diff --git a/2020/endoh3/run_clock.sh b/2020/endoh3/run_clock.sh index 702da8b07..f83f6d8ca 100755 --- a/2020/endoh3/run_clock.sh +++ b/2020/endoh3/run_clock.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +make -B clock || exit 1 while true; do cc -std=c11 -Wall -Wextra -pedantic -O3 clock.c -o clock clear diff --git a/thanks-for-help.md b/thanks-for-help.md index 2886a8801..2c96a47fd 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4737,6 +4737,10 @@ What was wrong? A typo in the shebang which had `/usr/bin/end` instead of `/usr/bin/env`. Anyone who knows Cody would know that he'd zoom in on that quite quick. +Also if `clock` did not exist and one tried to run the script it would make an +invalid `clock.c` which meant it could not compile so it now runs `make clock` +first. + Cody also reported (during the preview period of 2020) for some systems (at some point?) like macOS the use of `make clock` would not work due possibly to a timing issue so [Yusuke](#yusuke) changed it to compile the @@ -4748,6 +4752,10 @@ that if someone moves something of his even a millimetre from where it was he knows it so he might be called unusual (and he argues, with pride, eccentric :-) ) :-) +Cody also added the [run_clock.alt.sh](/2020/endoh3/run_clock.alt.sh) script +which is analogous to the [run_clock.sh](/2020/endoh3/run_clock.sh) but for the +alt code provided by the author, Yusuke. + ## [2020/ferguson1](/2020/ferguson1/prog.c) ([README.md](/2020/ferguson1/README.md))