diff --git a/2019/ciura/Makefile b/2019/ciura/Makefile index f8694d79f..7d91c408b 100644 --- a/2019/ciura/Makefile +++ b/2019/ciura/Makefile @@ -112,8 +112,8 @@ OBJ= ${PROG}.o DATA= de.sh en.sh fr.sh getwords.sh it.sh pl.sh ru.sh wrapprog.py TARGET= ${PROG} # -ALT_OBJ= ${PROG}.o -ALT_TARGET= ${PROG} +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/2019/ciura/README.md b/2019/ciura/README.md index 048993d47..73aac8e69 100644 --- a/2019/ciura/README.md +++ b/2019/ciura/README.md @@ -5,12 +5,16 @@ make ``` +There is an alternate version available. See [Alternate code](#alternate-code) +below. + + ### Bugs and (Mis)features: The current status of this entry is: ``` -STATUS: known bug - please help us fix +STATUS: INABIAF - please **DO NOT** fix ``` For more detailed information see [2019 ciura in bugs.md](/bugs.md#2019-ciura). @@ -26,34 +30,37 @@ For more detailed information see [2019 ciura in bugs.md](/bugs.md#2019-ciura). ### Try: ```sh -./getwords.sh en | grep .. | ./prog aeiouvwxyz +./try.sh -./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz - -./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx - -./en.sh - -./fr.sh - -./ru.sh ``` ## Alternate code: -There is an alternate version of this code that flushes stdout after writing a newline. -See the Author's remarks for more information. +There is an alternate version of this code that flushes `stdout` after writing a +newline. See the Author's remarks for more information. + + +### Alternate build: -To compile this alternate version: ```sh make alt ``` + +### Alternate use: + Use `prog.alt` as you would `prog` above. +### Alternate try: + +```sh +./try.alt.sh +``` + + ## Judges' remarks: A few letters, one at a time, with no repeats. How many different ways can this @@ -105,21 +112,24 @@ This entry implements Algorithm X (_Exact cover via dancing links_) from Section 7.2.2.1 in fascicle 5C of _The Art of Computer Programming_ by Donald E. Knuth. As of June 2019, you can download an incomplete draft of the fascicle from [Knuth's -website](https://www-cs-faculty.stanford.edu/~knuth/fasc5c.ps.gz). +website](https://www-cs-faculty.stanford.edu/~knuth/fasc5c.ps.gz), converted to +PDF as [fasc5c.pdf](fasc5c.pdf) for your convenience. + ### Usage: `./prog LETTERS [N]` reads allowed words from standard input and writes perfect pangrams -with at most _N_ words composed of _LETTERS_ to standard output, one -per line. If _N_ is not given, the number of words in the pangrams is -unlimited. The characters in _LETTERS_ must not repeat. The length of -_LETTERS_ must not exceed 97 characters. +with at most `N` words composed of `LETTERS` to standard output, one +per line. If `N` is not given, the number of words in the pangrams is +unlimited. The characters in `LETTERS` must not repeat. The length of +`LETTERS` must not exceed 97 characters. The exit status is 0 if no error occurred, 1 if the input word list is too long, and 2 if the command-line arguments are missing. + ### Helper scripts: - [getwords.sh](getwords.sh) @@ -143,6 +153,7 @@ is too long, and 2 if the command-line arguments are missing. English, French, Italian, Polish, and Russian perfect pangrams, respectively. They require a UTF-8 locale. + ### Miscellaneous remarks: I dare submit this entry to categories _algorithms_, @@ -151,7 +162,7 @@ among the programs that won IOCCC in the past), and _obscure bugs_ (see the questions about Linux core dumps below). To a casual eye, this entry may look similar to -[2005 klausler](https://www.ioccc.org/years.html#2005_klausler). +[2005/klausler](/2005/klausler/README.md). However, `prog` is internationalized and way faster. On my machine, `./klausler abcdefghijklmnopqrstuvwxyz` printed only 3,965 perfect pangrams until I killed it after 144 hours running, while the @@ -181,7 +192,7 @@ Why does `yes | ./prog y` hang on Linux? Change `static int` to `#define P 9<<23^1` to `#define P 9<<23` and recompile `prog`. Why does `yes | ./prog y` exit gracefully? -Answer: Nf bs Whar 2019, guhf znavsrfg ohtf va `tyvop` 2.22--2.29: +Answer: As of June 2019, thus manifest bugs in `glibc` 2.22--2.29: [1](https://sourceware.org/bugzilla/show_bug.cgi?id=20568) naq [2](https://sourceware.org/bugzilla/show_bug.cgi?id=20632). diff --git a/2019/ciura/de.alt.sh b/2019/ciura/de.alt.sh new file mode 100755 index 000000000..c294e850c --- /dev/null +++ b/2019/ciura/de.alt.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# Are the umlauts ä, ö, ü and Eszett (ß) letters in the German alphabet? There +# is more than one opinion on the subject but a lot of words do have an umlaut +# (or Umlaut in German). In some (probably all) systems this script outputs +# nothing probably because it's very hard to form a perfect pangram in German, +# if it's not impossible. Nevertheless, we do include the other characters +# whether or not they are in your view considered part of the alphabet for the +# reason that so many words have them. + +LC_ALL=C ./getwords.sh de | LC_ALL=C grep .. | LC_ALL=C ./prog.alt aäbcdefghijklmnoöpqrsßtuüvwxyz diff --git a/2019/ciura/de.sh b/2019/ciura/de.sh index f2e074d49..82bc59276 100755 --- a/2019/ciura/de.sh +++ b/2019/ciura/de.sh @@ -1,3 +1,11 @@ #!/usr/bin/env bash -set -x -LC_ALL=C ./getwords.sh de | LC_ALL=C tr '[:lower:]' '[:upper:]' | LC_ALL=C grep .. | LC_ALL=C ./prog aäbcdefghijklmnoöpqrsßtuüvwxyz +# +# Are the umlauts ä, ö, ü and Eszett (ß) letters in the German alphabet? There +# is more than one opinion on the subject but a lot of words do have an umlaut +# (or Umlaut in German). In some (probably all) systems this script outputs +# nothing probably because it's very hard to form a perfect pangram in German, +# if it's not impossible. Nevertheless, we do include the other characters +# whether or not they are in your view considered part of the alphabet for the +# reason that so many words have them. + +LC_ALL=C ./getwords.sh de | LC_ALL=C grep .. | LC_ALL=de_DE.UTF-8 ./prog aäbcdefghijklmnoöpqrsßtuüvwxyz diff --git a/2019/ciura/en.alt.sh b/2019/ciura/en.alt.sh new file mode 100755 index 000000000..dca8350ce --- /dev/null +++ b/2019/ciura/en.alt.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -x +./getwords.sh en | grep .. | ./prog.alt abcdefghijklmnopqrstuvwxyz diff --git a/2019/ciura/fasc5c.pdf b/2019/ciura/fasc5c.pdf new file mode 100644 index 000000000..362ca30ca Binary files /dev/null and b/2019/ciura/fasc5c.pdf differ diff --git a/2019/ciura/it.alt.sh b/2019/ciura/it.alt.sh new file mode 100755 index 000000000..c9ba4b0e0 --- /dev/null +++ b/2019/ciura/it.alt.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +(>&2 echo "Please be patient. Extracting Italian words") +(>&2 echo "from aspell takes a few minutes.") +set -x +LC_ALL=C ./getwords.sh it | LC_ALL=C grep .. | LC_ALL=C ./prog.alt aàbcdeèéfghiìlmnoòpqrstuùvz #jkwxy diff --git a/2019/ciura/pl.alt.sh b/2019/ciura/pl.alt.sh new file mode 100755 index 000000000..f481b99b3 --- /dev/null +++ b/2019/ciura/pl.alt.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -x +LC_ALL=C ./getwords.sh pl | LC_ALL=C grep -vE '^[^aiouwz]$' | LC_ALL= ./prog.alt aąbcćdeęfghijklłmnńoóprsśtuwyzźż diff --git a/2019/ciura/ru.alt.sh b/2019/ciura/ru.alt.sh new file mode 100755 index 000000000..7f58e0d5b --- /dev/null +++ b/2019/ciura/ru.alt.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -x +LC_ALL=C ./getwords.sh ru | LC_ALL=C ./prog.alt абвгдеёжзийклмнопрстуфхцчшщъыьэюя diff --git a/2019/ciura/try.alt.sh b/2019/ciura/try.alt.sh new file mode 100755 index 000000000..3d0d58bdc --- /dev/null +++ b/2019/ciura/try.alt.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2019/ciura alt code +# + +# 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" everything >/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: ./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz: " +./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz | less -EXF +echo 1>&2 + +echo "$ ./getwords.sh en | grep .. | ./prog.alt aeiouhjklmnvwxyz" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog.alt aeiouhjklmnvwxyz | less -EXF + +echo "$ ./getwords.sh en | grep .. | ./prog.alt mrjocktvquizphdbagsfewlynx | head -n 256" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog.alt mrjocktvquizphdbagsfewlynx | head -n 256 | less -EXF + + +echo "$ ./en.alt.sh" 1>&2 +echo "There will likely be a lot of output. Quit when bored. No logophiles will be hurt." 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +./en.alt.sh | less -EXF diff --git a/2019/ciura/try.sh b/2019/ciura/try.sh new file mode 100755 index 000000000..d714d19e9 --- /dev/null +++ b/2019/ciura/try.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2019/ciura +# + +# 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: ./getwords.sh en | grep .. | ./prog aeiouvwxyz: " +./getwords.sh en | grep .. | ./prog aeiouvwxyz | less -EXF +echo 1>&2 + +echo "$ ./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz | less -EXF + +echo "$ ./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx | head -n 256" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx | head -n 256 | less -EXF + + +echo "$ ./en.sh" 1>&2 +echo "There will likely be a lot of output. Quit when bored. No logophiles will be hurt." 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +./en.sh | less -EXF diff --git a/bugs.md b/bugs.md index 7198deada..46ae1b617 100644 --- a/bugs.md +++ b/bugs.md @@ -3277,6 +3277,43 @@ The author pointed out that some implementations of `wc(1)` show different values but his implementation matches that of macOS and FreeBSD. +## 2019 ciura + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2019/ciura/prog.c](2019/ciura/prog.c) +### Information: [2019/ciura/README.md](2019/ciura/README.md) + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the scripts so +that they can work but it might end up that the scripts don't show any output +anyway as they use the full alphabet. To test that it works one can have a +script like: + +```sh +LC_ALL=C aäbcdefghijklmnoöpqrsßtuüvwxyz | LC_ALL=C grep .. | LC_ALL=de_DE.UTF-8 ./prog aäbcdefghijklmnoöpqrsßtuüvwxyz +``` + +If you run this you should see: + +``` +aäbcdefghijklmnoöpqrsßtuüvwxyz +``` + +which shows it works. However as the de.sh script refers to all letters it can't +find a perfect pangram. BTW, as far as the question of whether the umlaut +letters or the Eszett are considered letters in the German alphabet, Cody noted +in the de.sh/de.alt.sh scripts: + +``` +# Are the umlauts ä, ö, ü and Eszett (ß) letters in the German alphabet? There +# is more than one opinion on the subject but a lot of words do have an umlaut +# (or Umlaut in German). In some (probably all) systems this script outputs +# nothing probably because it's very hard to form a perfect pangram in German, +# if it's not impossible. Nevertheless, we do include the other characters +# whether or not they are in your view considered part of the alphabet for the +# reason that so many words have them. +``` + + ## 2019 duble ### STATUS: INABIAF - please **DO NOT** fix @@ -3315,22 +3352,6 @@ find . -name '.[A-Z]*' -delete though one might want to check that the program is not currently running. :-) -## 2019 ciura - -### STATUS: known bug - please help us fix -### Source code: [2019/ciura/prog.c](2019/ciura/prog.c) -### Information: [2019/ciura/README.md](2019/ciura/README.md) - -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the scripts so -that the locale is correct (or at least correct for the commands to be run -without error, notwithstanding English which isn't a problem) but he notes that -under both macOS and fedora linux the alternative language scripts don't report -anything. This happened before and after the fix to the scripts. - -Maybe it's the locale or maybe it's the dictionary files but it appears that -they did work for some. If you can identify the problem we would appreciate the -help! - ## 2019 endoh diff --git a/thanks-for-help.md b/thanks-for-help.md index ffb9d1e88..f8e72a766 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4120,10 +4120,25 @@ wrong about) in [cow.sh](/2019/burton/cow.sh) (which was renamed from `cow`) ## [2019/ciura](/2019/ciura/prog.c) ([README.md](/2019/ciura/README.md])) -[Cody](#cody) fixed invalid bytes error in `tr` in the scripts. He notes that at least on -his systems (macOS and fedora Linux) the alternative languages do not work. -Perhaps that is the wrong locale or it's unable to come up with perfect pangrams -but one will not get errors now (it did not work before the fixes either). +[Cody](#cody) fixed an invalid bytes error in `tr` in the scripts. This does not +mean that they will produce any output, though, as they provide expect all +letters and that makes it harder to form perfect pangrams. On the subject of +German umlauts and Eszett (ß) see the [entry in bugs.md](/bugs.md#2019-ciura). + +Cody also fixed the Makefile so that the alt code would be built when running +`make alt`. + +Cody converted the PS file linked to by the author to a PDF +([fasc5c.pdf](/2019/ciura/fasc5c.pdf)) and added it to the +website. + +Cody also added the [try.sh](/2019/ciura/try.sh) and +[try.alt.sh](/2019/ciura/try.alt.sh) scripts. + +Finally he added the scripts for the different languages that use the alt +version but with the caveat that only English appears to work. See the [entry in +bugs.md](/bugs.md#2019-ciura) for more details. + ## [2019/diels-grabsch1](/2019/diels-grabsch1/prog.c) ([README.md](/2019/diels-grabsch1/README.md]))