Merge pull request #2005 from xexyl/birken2006-try
Improve 2006/birken/try.sh
This commit is contained in:
15 files changed
+285
-99
No files matched your search
+15
-16
@@ -21,27 +21,26 @@ echo "When looking at the output, notice how some of the output is different" 1>
|
|||||||
echo "from the aidan.c." 1>&2
|
echo "from the aidan.c." 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: ./$AIDAN < blank.sudoku (space = next page, q = quit): "
|
||||||
echo "$ ./$AIDAN < blank.sudoku" 1>&2
|
echo 1>&2
|
||||||
./"$AIDAN" < blank.sudoku
|
./"$AIDAN" < blank.sudoku | less -rEXF
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN (space = next page, q = quit): "
|
||||||
|
echo IOCCC | ./"$AIDAN" | less -rEXF
|
||||||
|
|
||||||
echo "$ echo IOCCC | ./$AIDAN" 1>&2
|
|
||||||
echo IOCCC | ./"$AIDAN"
|
|
||||||
echo "What just happened?" 1>&2
|
echo "What just happened?" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ echo IOCCC | ./$AIDAN 42" 1>&2
|
read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN 42 (space = next page, q = quit): "
|
||||||
read -r -n 1 -p "Press any key to continue (q = exit pager space = go down a page): "
|
echo IOCCC | ./"$AIDAN" 42 1>&2 | less -rEXF
|
||||||
echo IOCCC | ./"$AIDAN" 42 1>&2
|
echo 1>&2
|
||||||
echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2
|
echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
echo 1>&2
|
||||||
echo "$ ./$AIDAN < insane1.sudoku" 1>&2
|
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: ./$AIDAN < insane1.sudoku (space = next page, q = quit): "
|
||||||
./"$AIDAN" < insane1.sudoku
|
echo 1>&2
|
||||||
echo "Did you notice how much slower this is than aidan? If not try try.sh!" 1>&2
|
./"$AIDAN" < insane1.sudoku
|
||||||
|
echo 1>&2
|
||||||
|
echo "Did you notice how much slower this is than aidan.c? If not try try.sh!" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
+22
-18
@@ -18,37 +18,41 @@ clear
|
|||||||
AIDAN="aidan"
|
AIDAN="aidan"
|
||||||
|
|
||||||
echo "$ ./$AIDAN < blank.sudoku" 1>&2
|
echo "$ ./$AIDAN < blank.sudoku" 1>&2
|
||||||
./"$AIDAN" < blank.sudoku
|
read -r -n 1 -p "Press any key to run: ./$AIDAN < blank.sudoku (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./"$AIDAN" < blank.sudoku | less -rEXF
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./$AIDAN U < blank.sudoku" 1>&2
|
read -r -n 1 -p "Press any key to run: ./$AIDAN U < blank.sudoku (space = next page, q = quit): "
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
echo 1>&2
|
||||||
./"$AIDAN" U < blank.sudoku
|
./"$AIDAN" U < blank.sudoku | less -rEXF
|
||||||
|
echo 1>&2
|
||||||
echo "What was the difference between the previous command?" 1>&2
|
echo "What was the difference between the previous command?" 1>&2
|
||||||
echo "More specifically, what did it do?" 1>&2
|
echo "More specifically, what did it do?" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN (space = next page, q = quit): "
|
||||||
echo "$ echo IOCCC | ./$AIDAN" 1>&2
|
echo 1>&2
|
||||||
echo IOCCC | ./"$AIDAN"
|
echo IOCCC | ./"$AIDAN" | less -rEXF
|
||||||
|
echo 1>&2
|
||||||
echo "What just happened?" 1>&2
|
echo "What just happened?" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "$ echo IOCCC | ./$AIDAN 42 | less -r" 1>&2
|
|
||||||
read -r -n 1 -p "Press any key to continue (q = exit pager space = go down a page): "
|
read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN 42 (space = next page, q = quit): "
|
||||||
echo IOCCC | ./"$AIDAN" 42 | less -r
|
echo 1>&2
|
||||||
|
echo IOCCC | ./"$AIDAN" 42 | less -rEXF
|
||||||
|
echo 1>&2
|
||||||
echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2
|
echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./$AIDAN < insane1.sudoku" 1>&2
|
read -r -n 1 -p "Press any key to run: ./$AIDAN < insane1.sudoku (space = next page, q = quit): "
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
./"$AIDAN" < insane1.sudoku | less -rEXF
|
||||||
./"$AIDAN" < insane1.sudoku
|
|
||||||
|
|
||||||
read -r -n 1 -p "Do you with to run the test suite (y/n)? "
|
read -r -n 1 -p "Do you with to run the test suite (y/n)? "
|
||||||
if [[ "$REPLY" = "y" ]]; then
|
if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "$ make test" 1>&2
|
read -r -n 1 -p "Press any key to run: make test (space = next page, q = quit): "
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
echo 1>&2
|
||||||
make test
|
make test | less -rEXF
|
||||||
fi
|
fi
|
||||||
+1
-7
@@ -37,6 +37,7 @@ For more detailed information see [2005 anon in bugs.md](/bugs.md#2005-anon).
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
./anon 4 4
|
./anon 4 4
|
||||||
|
|
||||||
./anon 3 3 3
|
./anon 3 3 3
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -45,13 +46,6 @@ to destroy its runtime stack. This is the author's way to prevent you from being
|
|||||||
frustrated (which might happen as it likes to create unsolvable puzzles just to
|
frustrated (which might happen as it likes to create unsolvable puzzles just to
|
||||||
hook you) and spending too much time playing. :-)
|
hook you) and spending too much time playing. :-)
|
||||||
|
|
||||||
This is supposed to happen. As is written in the
|
|
||||||
[The Jargon File](http://catb.org/jargon/html/F/feature.html):
|
|
||||||
|
|
||||||
```
|
|
||||||
That's not a bug, that's a feature.
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to see this in action you can easily do this:
|
If you want to see this in action you can easily do this:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
+13
-12
@@ -7,37 +7,38 @@ make
|
|||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer.
|
You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer or
|
||||||
|
a converter like [ImageMagick](https://imagemagick.org/index.php)'s `convert`.
|
||||||
|
|
||||||
Look here to find some [SVG Viewer
|
Look here to find some [SVG Viewer
|
||||||
Implementations](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations).
|
Implementations](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations).
|
||||||
|
|
||||||
The following will create an `SVG` file:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg
|
./boutines < input > output.svg
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./boutines < input.txt > result.svg
|
./try.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
After running the above commands, use [ImageMagick](https://imagemagick.org/index.php)'s
|
If `ruby` is installed [try.sh](try.sh) will generate an SVG file by:
|
||||||
`convert` tool to convert the images to a png file:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
convert test.svg test.png
|
ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg
|
||||||
|
|
||||||
convert result.svg result.png
|
|
||||||
```
|
```
|
||||||
|
|
||||||
and then open it with your preferred graphics viewer or editor.
|
It will also create an SVG file with the file [input.txt](input.txt).
|
||||||
|
|
||||||
|
The script will check if `convert` is available and if so it will try converting
|
||||||
|
the SVG file(s) to PNG file(s) which you should be able to view in most any
|
||||||
|
graphics viewer, editor or web browser.
|
||||||
|
|
||||||
If you have a program that opens
|
If you have a program that opens
|
||||||
[SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) files then you could open
|
[SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) files then you could open
|
||||||
the `test.svg` file directly. An example program is
|
the `test.svg` and `result.svg` files directly. An example program is
|
||||||
[Inkscape](https://inkscape.org). See the
|
[Inkscape](https://inkscape.org). See the
|
||||||
[list](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations) cited above for
|
[list](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations) cited above for
|
||||||
others.
|
others.
|
||||||
|
|||||||
Executable
+69
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2005/boutines
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# see if the user has ruby installed
|
||||||
|
#
|
||||||
|
RUBY="$(type -P ruby)"
|
||||||
|
|
||||||
|
# see if convert(1) is available (hopefully from ImageMagick :-) )
|
||||||
|
#
|
||||||
|
CONVERT="$(type -P convert)"
|
||||||
|
|
||||||
|
if [[ -n "$RUBY" ]]; then
|
||||||
|
echo "$ $RUBY -e '20.times{puts \"\#{rand} \#{rand}\"}' | ./boutines > test.svg" 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to continue: "
|
||||||
|
echo 1>&2
|
||||||
|
"$RUBY" -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg
|
||||||
|
else
|
||||||
|
echo "ruby not installed, skipping generation of an SVG file via ruby." 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./boutines < input.txt > result.svg: "
|
||||||
|
echo 1>&2
|
||||||
|
./boutines < input.txt > result.svg
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
if [[ ! -f result.svg && ! -f test.svg ]]; then
|
||||||
|
echo "failed to create any SVG file, exiting." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$CONVERT" ]]; then
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: convert test.svg test.png: "
|
||||||
|
echo 1>&2
|
||||||
|
if ! convert test.svg test.png; then
|
||||||
|
echo "Failed to convert test.svg to test.png, try a graphics viewer that" 1>&2
|
||||||
|
echo "can view SVG files." 1>&2
|
||||||
|
else
|
||||||
|
echo "Now try viewing test.png with your favourite graphics viewer." 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to run: convert result.svg result.png: "
|
||||||
|
echo 1>&2
|
||||||
|
if ! convert result.svg result.png; then
|
||||||
|
echo "Failed to convert result.svg to result.png, try a graphics viewer that" 1>&2
|
||||||
|
echo "can view SVG files." 1>&2
|
||||||
|
else
|
||||||
|
echo "Now try viewing result.png with your favourite graphics viewer." 1>&2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 1>&2
|
||||||
|
echo "convert not found (ImageMagick not installed?)" 1>&2
|
||||||
|
echo "Try viewing *.svg with a graphics viewer that can view SVG files." 1>&2
|
||||||
|
fi
|
||||||
@@ -24,6 +24,9 @@ EXIT_CODE=0
|
|||||||
# delete temporary files first to make sure that they're clean
|
# delete temporary files first to make sure that they're clean
|
||||||
rm -f out out.count
|
rm -f out out.count
|
||||||
|
|
||||||
|
echo "This may take a while: please be patient." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
# redirect stdout to 'out' so that we can run the test suite of giljade
|
# redirect stdout to 'out' so that we can run the test suite of giljade
|
||||||
./"$GILJADE" > out
|
./"$GILJADE" > out
|
||||||
# here we want to show only the lines matching the regexp '^Line' but write
|
# here we want to show only the lines matching the regexp '^Line' but write
|
||||||
|
|||||||
+16
-10
@@ -15,21 +15,27 @@ make CC="$CC" all >/dev/null || exit 1
|
|||||||
# clear screen after compilation so that only the entry is shown
|
# clear screen after compilation so that only the entry is shown
|
||||||
clear
|
clear
|
||||||
|
|
||||||
read -r -p "Do you wish to run the test suite (y/n) ? "
|
# We don't use tee(1) here so as to show better what we're doing and to prompt
|
||||||
if [[ "$REPLY" == "y" ]]; then
|
# them to view the file with less(1) rather than dump it on them all at once.
|
||||||
echo "$ make test" 1>&2
|
echo 1>&2
|
||||||
make test
|
read -r -n 1 -p "Press any key to run: ./giljade > out: "
|
||||||
fi
|
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "$ ./giljade > out" 1>&2
|
|
||||||
./giljade > out
|
./giljade > out
|
||||||
|
echo 1>&2
|
||||||
echo "For this next step, make sure to keep pressing space (or hold it down) (q = quit)." 1>&2
|
echo "For this next step, make sure to keep pressing space (or hold it down) (q = quit)." 1>&2
|
||||||
echo "$ less -X out" 1>&2
|
read -r -n 1 -p "Press any key to run: less -rEXF out: "
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
less -rEXF out
|
||||||
less -X out
|
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "We've left the file 'out' for you in case you wish to open it in vi(m). If" 1>&2
|
echo "We've left the file 'out' for you in case you wish to open it in vi(m). If" 1>&2
|
||||||
echo "you do we recommend you try holding ctrl-f down in a similar way to how you held" 1>&2
|
echo "you do we recommend you try holding ctrl-f down in a similar way to how you held" 1>&2
|
||||||
echo "down space above. Of course you can open it in another editor if you wish." 1>&2
|
echo "down space above. Of course you can open it in another editor if you wish." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -p "Do you wish to run the test suite (y/n) ? "
|
||||||
|
if [[ "$REPLY" == "y" || "$REPLY" = "Y" ]]; then
|
||||||
|
echo "$ make test" 1>&2
|
||||||
|
make test
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
+39
-12
@@ -15,35 +15,62 @@ make CC="$CC" all >/dev/null || exit 1
|
|||||||
# clear screen after compilation so that only the entry is shown
|
# clear screen after compilation so that only the entry is shown
|
||||||
clear
|
clear
|
||||||
|
|
||||||
echo "$ ./klausler peter klausler | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler peter klausler | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler peter klausler | head -n 10
|
./klausler peter klausler | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler abc def ghi jkl mno | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler abc def ghi jkl mno | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler abc def ghi jkl mno | head -n 10
|
./klausler abc def ghi jkl mno | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler foo bar baz | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler foo bar baz | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler foo bar baz | head -n 10
|
./klausler foo bar baz | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler zebra elephant bear fox | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler zebra elephant bear fox | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler zebra elephant bear fox | head -n 10
|
./klausler zebra elephant bear fox | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler the lion king | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler the lion king | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler the lion king | head -n 10
|
./klausler the lion king | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler fire breathing dragon | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler fire breathing dragon | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler fire breathing dragon | head -n 10
|
./klausler fire breathing dragon | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler lord of the rings | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler lord of the rings | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler lord of the rings | head -n 10
|
./klausler lord of the rings | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler fawlty towers | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler fawlty towers | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler fawlty towers | head -n 10
|
./klausler fawlty towers | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler carriown fowl | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler carrion fowl | head -n 10: "
|
||||||
./klausler carriown fowl | head -n 10
|
echo 1>&2
|
||||||
|
./klausler carrion fowl | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler werewolf vampire dragon | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire dragon | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler werewolf vampire dragon | head -n 10
|
./klausler werewolf vampire dragon | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "$ ./klausler werewolf vampire | head -n 10" 1>&2
|
read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire elf dragon | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
|
./klausler werewolf vampire elf dragon | head -n 10
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire | head -n 10: "
|
||||||
|
echo 1>&2
|
||||||
./klausler werewolf vampire | head -n 10
|
./klausler werewolf vampire | head -n 10
|
||||||
|
echo 1>&2
|
||||||
+26
-9
@@ -16,27 +16,44 @@ make CC="$CC" all >/dev/null || exit 1
|
|||||||
clear
|
clear
|
||||||
|
|
||||||
|
|
||||||
echo "$ ./mikeash < mikeash.c" 1>&2
|
read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
./mikeash < mikeash.c
|
./mikeash < mikeash.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "The next command should print nothing." 1>&2
|
echo "The next command should print nothing." 1>&2
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c | diff - mikeash.c: "
|
||||||
echo "$ ./mikeash < mikeash.c | diff - mikeash.c" 1>&2
|
|
||||||
./mikeash < mikeash.c | diff - mikeash.c
|
|
||||||
|
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
# ShellCheck is incorrect here:
|
||||||
|
#
|
||||||
|
# SC2094 (info): Make sure not to read and write the same file in the same pipeline.
|
||||||
|
#
|
||||||
|
# so we disable it.
|
||||||
|
#
|
||||||
|
# shellcheck disable=SC2094
|
||||||
|
./mikeash < mikeash.c | diff - mikeash.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
echo "For the next two commands we will add a newline after the command's output" 1>&2
|
echo "For the next two commands we will add a newline after the command's output" 1>&2
|
||||||
echo "for your convenience as they will not print a newline themselves." 1>&2
|
echo "for your convenience as they will not print a newline themselves." 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "The next command should show: \"4." 1>&2
|
echo "The next command should show: \"4." 1>&2
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
read -r -n 1 -p "Press any key to run: echo '(format t \"~s\" (+ 2 2 ))' | ./mikeash: "
|
||||||
echo "$ echo '(format t "~s" (+ 2 2 ))' | ./mikeash" 1>&2
|
echo 1>&2
|
||||||
echo '(format t "~s" (+ 2 2 ))' | ./mikeash
|
echo '(format t "~s" (+ 2 2 ))' | ./mikeash
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo "The next command will evaluate the expression: (2+2) * (5 - 9/3), giving 8\"." 1>&2
|
echo "The next command will evaluate the expression: (2+2) * (5 - 9/3), giving 8\"." 1>&2
|
||||||
read -r -n 1 -p "Press any key to continue: "
|
|
||||||
echo "$ echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash" 1>&2
|
# ShellCheck warns:
|
||||||
|
#
|
||||||
|
# SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?
|
||||||
|
#
|
||||||
|
# ShellCheck is wrong.
|
||||||
|
#
|
||||||
|
# shellcheck disable=SC2140
|
||||||
|
read -r -n 1 -p "Press any key to run: echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash: "
|
||||||
|
echo 1>&2
|
||||||
echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash
|
echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
@@ -8,3 +8,4 @@ indent.o
|
|||||||
persano
|
persano
|
||||||
persano.orig
|
persano.orig
|
||||||
prog.orig
|
prog.orig
|
||||||
|
seal.gif
|
||||||
@@ -18,10 +18,10 @@ setting binary mode on `stdout`. See [alternate code](#alternate-code) below.
|
|||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./persano 3 16 > knot3-16.gif
|
./try.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Open the [GIF](https://en.wikipedia.org/wiki/GIF) file with a viewer capable of
|
Open the [GIF](https://en.wikipedia.org/wiki/GIF) files with a viewer capable of
|
||||||
displaying animated GIFs and watch closely at the bottom of the picture (you may
|
displaying animated GIFs and watch closely at the bottom of the picture (you may
|
||||||
need to use [gifsicle](https://www.lcdf.org/gifsicle/) - a great tool to
|
need to use [gifsicle](https://www.lcdf.org/gifsicle/) - a great tool to
|
||||||
manipulate animated GIFs - to slow down the animation and to compress the GIFs
|
manipulate animated GIFs - to slow down the animation and to compress the GIFs
|
||||||
|
|||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2005/persano
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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: ./persano 3 16 > knot3-16.gif: "
|
||||||
|
echo 1>&2
|
||||||
|
./persano 3 16 > knot3-16.gif
|
||||||
|
echo 1>&2
|
||||||
|
if [[ -f knot3-16.gif ]]; then
|
||||||
|
echo "Now open the file knot3-16.gif in a GIF viewer capable of viewing animated" 1>&2
|
||||||
|
echo "GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./persano 3 2 1 > foo.gif: "
|
||||||
|
echo 1>&2
|
||||||
|
./persano 3 2 1 > foo.gif
|
||||||
|
echo 1>&2
|
||||||
|
if [[ -f foo.gif ]]; then
|
||||||
|
echo "Now open the file foo.gif in a GIF viewer capable of viewing animated" 1>&2
|
||||||
|
echo "GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./persano 5 2 > seal.gif: "
|
||||||
|
echo 1>&2
|
||||||
|
./persano 5 2 > seal.gif
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
if [[ -f seal.gif ]]; then
|
||||||
|
echo "Now open seal.gif (Solomon's Seal knot) in a GIF viewer capable of viewing" 1>&2
|
||||||
|
echo "animated GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2
|
||||||
|
fi
|
||||||
@@ -21,6 +21,8 @@ clear
|
|||||||
echo "$ (echo \"20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; \
|
echo "$ (echo \"20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; \
|
||||||
echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]\") | ./timwi" 1>&2
|
echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]\") | ./timwi" 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to continue: "
|
||||||
|
echo 1>&2
|
||||||
(echo "20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]") | ./timwi
|
(echo "20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]") | ./timwi
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
echo "Now please go take better care of your brain. You only get one." 1>&2
|
echo "Now please go take better care of your brain. You only get one." 1>&2
|
||||||
+16
-3
@@ -16,53 +16,66 @@ make CC="$CC" all >/dev/null || exit 1
|
|||||||
clear
|
clear
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < adder.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < adder.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < adder.tofu 2>/dev/null
|
./birken < adder.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < buffer.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < buffer.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < buffer.tofu 2>/dev/null
|
./birken < buffer.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
echo "NOTE: the next one has longer output." 1>&2
|
read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null (space = next page, q = quit): "
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null: "
|
echo 1>&2
|
||||||
./birken < computer.tofu 2>/dev/null
|
./birken < computer.tofu 2>/dev/null | less -rEXF
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < counter.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < counter.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < counter.tofu 2>/dev/null
|
./birken < counter.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < divider.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < divider.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < divider.tofu 2>/dev/null
|
./birken < divider.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < lfsr.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < lfsr.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < lfsr.tofu 2>/dev/null
|
./birken < lfsr.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < memory.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < memory.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < memory.tofu 2>/dev/null
|
./birken < memory.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < multiplier.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < multiplier.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < multiplier.tofu 2>/dev/null
|
./birken < multiplier.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < multiplier2.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < multiplier2.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < multiplier2.tofu 2>/dev/null
|
./birken < multiplier2.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < oneline.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < oneline.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < oneline.tofu 2>/dev/null
|
./birken < oneline.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < shift.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < shift.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < shift.tofu 2>/dev/null
|
./birken < shift.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < zuse.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < zuse.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < zuse.tofu 2>/dev/null
|
./birken < zuse.tofu 2>/dev/null
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|
||||||
read -r -n 1 -p "Press any key to run: ./birken < zuse2.tofu 2>/dev/null: "
|
read -r -n 1 -p "Press any key to run: ./birken < zuse2.tofu 2>/dev/null: "
|
||||||
|
echo 1>&2
|
||||||
./birken < zuse2.tofu 2>/dev/null
|
./birken < zuse2.tofu 2>/dev/null
|
||||||
|
echo 1>&2
|
||||||
+15
-10
@@ -3161,16 +3161,17 @@ just to make it a bit easier to compile.
|
|||||||
## <a name="2005_aidan"></a>[2005/aidan](/2005/aidan/aidan.c) ([README.md](/2005/aidan/README.md]))
|
## <a name="2005_aidan"></a>[2005/aidan](/2005/aidan/aidan.c) ([README.md](/2005/aidan/README.md]))
|
||||||
|
|
||||||
[Cody](#cody) fixed the test script, described by the author in their remarks, to refer
|
[Cody](#cody) fixed the test script, described by the author in their remarks, to refer
|
||||||
to the proper compiled program (it's hardcoded). This had never been done and it
|
to the proper compiled program (it's hardcoded). This had never been done and so
|
||||||
broke the script.
|
the script did not even work (at least modernly?).
|
||||||
|
|
||||||
He also added the [alt code](/2005/aidan/README.md#alternate-code) based on the
|
He also added the [alt code](/2005/aidan/README.md#alternate-code) based on the
|
||||||
author's remarks which is a different approach than the one used and which 'is
|
author's remarks which is a different approach than the one used and which
|
||||||
slower (particularly in worst-case or nearly so scenarios), inelegant, and not a
|
(according to the author) 'is slower (particularly in worst-case or nearly so
|
||||||
good starting place for sudoku generation.'
|
scenarios), inelegant, and not a good starting place for sudoku generation.'
|
||||||
|
|
||||||
The [try.sh](/2005/aidan/try.sh) and [try.alt.sh](/2005/aidan/try.alt.sh)
|
Cody added the [try.sh](/2005/aidan/try.sh) and
|
||||||
correspond to the entry and alt code respectively.
|
[try.alt.sh](/2005/aidan/try.alt.sh) scripts that correspond to the entry and
|
||||||
|
alt code respectively.
|
||||||
|
|
||||||
Cody added the `make test` and `make test-n0` rules for easier use of the test
|
Cody added the `make test` and `make test-n0` rules for easier use of the test
|
||||||
suite.
|
suite.
|
||||||
@@ -3195,12 +3196,14 @@ movements.
|
|||||||
[Cody](#cody) added the [input.txt](/2005/boutines/input.txt) data file based on suggested
|
[Cody](#cody) added the [input.txt](/2005/boutines/input.txt) data file based on suggested
|
||||||
input from the author, adapting it to a command to try out.
|
input from the author, adapting it to a command to try out.
|
||||||
|
|
||||||
|
Cody also added the [try.sh](/2005/boutines/try.sh) script.
|
||||||
|
|
||||||
|
|
||||||
## <a name="2005_giljade"></a>[2005/giljade](/2005/giljade/giljade.c) ([README.md](/2005/giljade/README.md]))
|
## <a name="2005_giljade"></a>[2005/giljade](/2005/giljade/giljade.c) ([README.md](/2005/giljade/README.md]))
|
||||||
|
|
||||||
After Landon fixed the entry to compile with clang Cody noticed this does not
|
After Landon fixed the entry to compile with clang [Cody](#cody) noticed this
|
||||||
work at all in modern systems (see below). He fixed this to work and then he
|
does not work at all in modern systems (see below). He fixed this to work and
|
||||||
later fixed the self-test feature.
|
then he later fixed the self-test feature.
|
||||||
|
|
||||||
The problem that was showing up is that with either optimising or if anything
|
The problem that was showing up is that with either optimising or if anything
|
||||||
but 32-bit (as in `-m32`) was used it would not work (at least in 64-bit
|
but 32-bit (as in `-m32`) was used it would not work (at least in 64-bit
|
||||||
@@ -3327,6 +3330,8 @@ code](/2005/persano/README.md#alternate-code) which should work for Windows as i
|
|||||||
sets binary mode on `stdout`. It is untested as Cody has no Windows system to
|
sets binary mode on `stdout`. It is untested as Cody has no Windows system to
|
||||||
test it on.
|
test it on.
|
||||||
|
|
||||||
|
Cody also added the [try.sh](/2005/persano/try.sh) script.
|
||||||
|
|
||||||
|
|
||||||
## <a name="2005_sykes"></a>[2005/sykes](/2005/sykes/sykes.c) ([README.md](/2005/sykes/README.md]))
|
## <a name="2005_sykes"></a>[2005/sykes](/2005/sykes/sykes.c) ([README.md](/2005/sykes/README.md]))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user