From 26c4717ad4219a1b9c0c5d30db362a1d8329f8af Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 11 Dec 2023 09:38:46 -0800 Subject: [PATCH] Add 2018/hou/try.sh + format/typo checks --- 2018/hou/README.md | 13 ++++--------- 2018/hou/try.sh | 41 +++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100755 2018/hou/try.sh diff --git a/2018/hou/README.md b/2018/hou/README.md index ad7b1fb97..76f60206f 100644 --- a/2018/hou/README.md +++ b/2018/hou/README.md @@ -28,15 +28,10 @@ View `output.html` in a browser. ### Try: ```sh -grep -e '[-?+*/^&|.<>=]' prog.c - -(cd ..; ls -lS */prog.c) | \ -awk 'BEGIN { print "["; } { print "{\"winner\":\"",$9,"\", \"size\":",$5,"},"} END { print "]"}' \ -> ioccc.json -./prog < ioccc.json > ioccc.html +./try.sh ``` -View `output.html` in a browser. +As the script says, open `output.html` in a browser. What's not right with the output? How can one fix it? @@ -44,7 +39,7 @@ What's not right with the output? How can one fix it? ## Judges' remarks: This entry exhibits a way of obfuscation we haven't seen before, we think. -The rulez of programming in an imperative language are violated, aren't they? +The `rulez` of programming in an imperative language are violated, aren't they? Try figuring out how to increase the number of different colors, if you can. @@ -58,7 +53,7 @@ to generate an HTML page from a JSON feed. This entry takes such decadence to an extreme. It just calls a bunch of libraries to generate an HTML page from a JSON feed, literally. There is no variable (function parameters included), no operator, no flow control statements -except a few decorative returns. In compliance to production coding standards, +except a few decorative `return`s. In compliance to production coding standards, the code is littered with fashionable jargon, doxygen comment, and license text. As one would expect from such an approach, this program is much more resource diff --git a/2018/hou/try.sh b/2018/hou/try.sh new file mode 100755 index 000000000..da3625d5c --- /dev/null +++ b/2018/hou/try.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2018/hou +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +read -r -n 1 -p "Press any key to run: grep -e '[-?+*/^&|.<>=]' prog.c (space = next page, q = quit): " +echo 1>&2 +grep -e '[-?+*/^&|.<>=]' prog.c | less -EXF +echo 1>&2 + +# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# ^-- SC1083 (warning): This { is literal. Check expression (missing ;/\n?) or quote it. +# ^-- SC1083 (warning): This } is literal. Check expression (missing ;/\n?) or quote it. +# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# shellcheck disable=SC2140 +# shellcheck disable=SC1083 +echo "(cd ..; ls -lS -- */prog.c) | \ +awk 'BEGIN { print "["; } { print "{\"winner\":\"",\$9,"\", \"size\":",\$5,"},"} END { print "]"}' \ +> ioccc.json" + +(cd ..; ls -lS -- */prog.c) | \ +awk 'BEGIN { print "["; } { print "{\"winner\":\"",$9,"\", \"size\":",$5,"},"} END { print "]"}' \ +> ioccc.json +./prog < ioccc.json > ioccc.html + +echo 1>&2 +echo "Now open ioccc.html in your browser." 1>&2 + +exit 0 diff --git a/thanks-for-help.md b/thanks-for-help.md index ab3e352e8..cb075d74b 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3974,6 +3974,8 @@ that's probably true: let's just say that for the IOCCC I'm (Cody) a weasel! :-) [Cody](#cody) added explicit linking of libm (`-lm`) for systems that do not do this (Linux doesn't seem to but macOS does). +Cody also added the [try.sh](/2018/hou/try.sh) script. + ## [2018/vokes](/2018/vokes/prog.c) ([README.md](/2018/vokes/README.md))