Merge pull request #1883 from xexyl/buzzard192-try

Slightly improve 1992/buzzard.1/try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-13 18:55:08 -08:00
commit c50f7c58e7
17 files changed
+316 -88

No files matched your search

+12
View File
@@ -8,6 +8,18 @@ There is an alternate version for those using Turbo-C or MSC. See [alternate
code](#alternate-code) below for details.
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1990 baruch in bugs.md](/bugs.md#1990-baruch).
## To use:
```sh
+5
View File
@@ -20,6 +20,11 @@ echo 1>&2
echo 5 | ./baruch | less -rEXF
echo 1>&2
read -r -n 1 -p "Press any key to run: echo 8 | ./baruch (space = next page, q = quit): "
echo 1>&2
echo 8 | ./baruch | less -rEXF
echo 1>&2
read -r -n 1 -p "Press any key to run: echo 2 | ./baruch: "
echo 1>&2
echo 2 | ./baruch
+3 -4
View File
@@ -8,11 +8,10 @@ make all
### Try:
```sh
./brnstnd < sorta.i2+2
./brnstnd < sorta.iwhosort
```
./try.sh
See also the other `sorta.*` files.
./sorta < sorta.itailrec
```
## Judges' remarks:
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1991/brnstnd
#
# 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
sorta_with_arg()
{
if [[ "$#" != 2 ]]; then
echo "$0: sorta_with_arg() expects a file and arg, only got file name" 1>&2
return
fi
read -r -n 1 -p "Press any key to run: ./sorta < $1 $2: "
echo 1>&2
./sorta < "$1" "$2"
echo 1>&2
}
sorta()
{
if [[ "$#" != 1 ]]; then
echo "$0: sorta() expects 1 arg, got: $#" 1>&2
return
fi
read -r -n 1 -p "Press any key to run: ./sorta < $1: "
echo 1>&2
./sorta < "$1"
echo 1>&2
}
sorta sorta.i2+2
sorta sorta.icalc
sorta_with_arg sorta.iecho "IOCCC 1991/brnstnd"
sorta sorta.ifact2
sorta sorta.iio
sorta sorta.isleep
sorta sorta.iwhosort
sorta sorta.iarg0
sorta sorta.idup
sorta sorta.ifact1
sorta sorta.ifact3
read -r -n 1 -p "Press any key to show try.txt: "
echo 1>&2
cat try.txt
echo 1>&2
sorta_with_arg sorta.irot13 try.txt
+1
View File
@@ -0,0 +1 @@
The quick brown fox jumps over the lazy dog.
+30 -52
View File
@@ -14,57 +14,35 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen to remove any compiler message to make the entry stand out more
clear
echo -n "Green terra <-> "
echo "Green terra" | ./fine
fine()
{
if [[ "$#" != 1 ]]; then
echo "$0: expected 1 arg, got $#" 1>&2
return
fi
echo -n "Vex <-> "
echo "Vex" | ./fine
read -r -n 1 -p "Press any key to run: echo $1 | ./fine: "
echo 1>&2
echo -n "$1 <-> "
echo "$1" | ./fine
echo 1>&2
}
echo -n "Tang <-> "
echo "Tang" | ./fine
echo -n "Vend onyx <-> "
echo "Vend onyx" | ./fine
echo -n "Cheryl be flashy <-> "
echo "Cheryl be flashy" | ./fine
echo -n "Rail <-> "
echo "Rail" | ./fine
echo -n "Clerk <-> "
echo "Clerk" | ./fine
echo -n "Ones <-> "
echo "Ones" | ./fine
echo -n "Fur <-> "
echo "Fur" | ./fine
echo -n "Er <-> "
echo "Er" | ./fine
echo -n "IV <-> "
echo "IV" | ./fine
echo -n "NYC <-> "
echo "NYC" | ./fine
echo -n "Fubar <-> "
echo "Fubar" | ./fine
echo -n "DQ <-> "
echo "DQ" | ./fine
echo -n "Off <-> "
echo "Off" | ./fine
echo -n "Ire <-> "
echo "Ire" | ./fine
echo -n "PEP <-> "
echo "PEP" | ./fine
echo -n "The rug gary lenT <-> "
echo "The rug gary lenT" | ./fine
fine "Green terra"
fine "Vex"
fine "Tang"
fine "Vend onyx"
fine "Cheryl be flashy"
fine "Rail"
fine "Clerk"
fine "Ones"
fine "Fur"
fine "Er"
fine "IV"
fine "NYC"
fine "Fubar"
fine "DQ"
fine "Off"
fine "Ire"
fine "PEP"
fine "The rug gary lenT"
+22 -8
View File
@@ -14,16 +14,30 @@ make CC="$CC" all >/dev/null || exit 1
#
clear
echo "$ ./buzzard.1 0 10" 1>&2
read -r -n 1 -p "Press any key to run: ./buzzard.1 0 10: "
echo 1>&2
./buzzard.1 0 10
echo "$ ./buzzard.1 56 720" 1>&2
./buzzard.1 56 720
echo "$ ./buzzard.1 1 521" 1>&2
./buzzard.1 1 521
echo 1>&2
echo "$ ./buzzard.1 '1+1' 111" 1>&2
read -r -n 1 -p "Press any key to run: ./buzzard.1 56 720: "
echo 1>&2
./buzzard.1 56 720
read -r -n 1 -p "Press any key to run: ./buzzard.1 1 521: "
echo 1>&2
./buzzard.1 1 521
echo 1>&2
read -r -n 1 -p "Press any key to run: ./buzzard.1 '1+1' 111: "
echo 1>&2
./buzzard.1 '1+1' 111
echo "$ ./buzzard.1 '1+1' 11" 1>&2
echo 1>&2
read -r -n 1 -p "Press any key to run: ./buzzard.1 '1+1' 11: "
echo 1>&2
./buzzard.1 '1+1' 11
echo "$ ./buzzard.1 '1+1' 1" 1>&2
echo 1>&2
read -r -n 1 -p "Press any key to run: ./buzzard.1 '1+1' 1: "
echo 1>&2
./buzzard.1 '1+1' 1
+9
View File
@@ -15,6 +15,15 @@ make all
```
## Try:
To see a number of options and configurations:
```sh
./try.sh
```
## Judges' remarks:
The program is more interesting to run on workstations that can make use of a
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1992/imc
#
# 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: ./imc -text: "
echo 1>&2
./imc -text
echo 1>&2
echo "$ ./imc -text -size 40 40 -limit 256 -julia 0.5 -0.5"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./imc -text -size 40 40 -limit 256 -julia 0.5 -0.5 | less -rEXF
echo "$ ./imc -text -size 40 40 -limit 1024 -julia 2 -2.5"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./imc -text -size 40 40 -limit 1024 -julia 2 -2.5 | less -rEXF
echo "$ ./imc -text -size 40 40 -limit 1024 -centre 1 2 -julia 2 -2.5"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./imc -text -size 40 40 -limit 1024 -centre 1 2 -julia 2 -2.5 | less -rEXF
echo "$ ./imc -text -size 40 40 -limit 256"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./imc -text -size 40 40 -limit 256 | less -rEXF
echo "$ ./imc -text -size 40 40 -limit 1024"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./imc -text -size 40 40 -limit 1024 | less -rEXF
+2 -2
View File
@@ -78,8 +78,8 @@ NOTE: Some systems do not need (or have) `-lsocket -lresolv -lnsl`.
Such systems should compile using `-lX11`.
NOTE: The original winning source [kivinen.orig.c](kivinen.orig.c) assumed that
exit returned a value which cause problems for some systems where exit returns
void. The file [kivinen.c](kivinen.c) avoids this problem.
`exit(3)` returned a value which cause problems for some systems where `exit(3)` returns
`void`. The file [kivinen.c](kivinen.c) avoids this problem.
## Author's remarks:
+1 -1
View File
@@ -19,7 +19,7 @@ For more detailed information see [1992 lush in bugs.md](/bugs.md#1992-lush).
## To use:
```sh
./runme.sh
./lush.sh
```
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#
# lush.sh - run IOCCC winner 1992/lush
#
# 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 clobber all
"$CC" -include stdio.h -o lush lush.c|& ./lush
-4
View File
@@ -1,4 +0,0 @@
#!/usr/bin/env bash
make clobber all
cc -include stdio.h -o lush lush.c|& ./lush
+1 -1
View File
@@ -24,7 +24,7 @@ NOTE: Some systems need to compile with `-ltermcap` as well as `-lcurses`.
NOTE: The original winning source [marangon.orig.c](marangon.orig.c), found in
the archive directory, assumed that `exit(3)` returns a value which cause
problems for some systems where `exit(3)` returns a void. The file
problems for some systems where `exit(3)` returns a `void`. The file
[marangon.c](marangon.c) avoids this problem.
+21 -4
View File
@@ -13,14 +13,31 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ ./nathan obfuscate < nathan.c > foobarf.c" 1>&2
read -r -n 1 -p "Press any key to run: ./nathan obfuscate < nathan.c > foobarf.c: "
echo 1>&2
./nathan obfuscate < nathan.c > foobarf.c
echo 1>&2
echo "$ ./nathan - obfuscate < foobarf.c > barfoof.c" 1>&2
read -r -n 1 -p "Press any key to show foobarf.c (space = next page, q = quit): "
echo 1>&2
less -rEXF foobarf.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./nathan - obfuscate < foobarf.c > barfoof.c: "
echo 1>&2
./nathan - obfuscate < foobarf.c > barfoof.c
echo 1>&2
echo "$ diff nathan.c barfoof.c" 1>&2
read -r -n 1 -p "Press any key to show barfoof.c (space = next page, q = quit): "
echo 1>&2
less -rEXF barfoof.c
echo 1>&2
read -r -n 1 -p "Press any key to run: diff -s nathan.c barfoof.c: "
echo 1>&2
diff -s nathan.c barfoof.c
echo 1>&2
echo "$ echo 'IOCCC 1992 winner nathan' | ./nathan" 1>&2
read -r -n 1 -p "Press any key to run: echo 'IOCCC 1992 winner nathan' | ./nathan: "
echo 1>&2
echo 'IOCCC 1992 winner nathan' | ./nathan
+72 -1
View File
@@ -673,6 +673,75 @@ Enjoy! :-)
# 1990
## 1990 baruch
### STATUS: known bug - please help us fix
### Source code: [1990/baruch/baruch.c](1990/baruch/baruch.c)
### Information: [1990/baruch/README.md](1990/baruch/README.md)
A point worth considering is that as the number passed into the program gets
bigger the number of lines of output gets substantially larger and it takes much
more time and resources to run as well. For instance:
```sh
$ for n in $(seq 1 18); do echo "$n"; echo "$n" | time "./baruch" | wc -l | sed -E -e 's/[[:space:]]//g'; done
1
3
./baruch 0.00s user 0.00s system 5% cpu 0.115 total
2
1
./baruch 0.00s user 0.00s system 64% cpu 0.004 total
3
1
./baruch 0.00s user 0.00s system 60% cpu 0.003 total
4
11
./baruch 0.00s user 0.00s system 64% cpu 0.003 total
5
61
./baruch 0.00s user 0.00s system 66% cpu 0.003 total
6
29
./baruch 0.00s user 0.00s system 61% cpu 0.003 total
7
321
./baruch 0.00s user 0.00s system 69% cpu 0.002 total
8
829
./baruch 0.00s user 0.00s system 76% cpu 0.003 total
9
3521
./baruch 0.00s user 0.00s system 87% cpu 0.005 total
10
7965
./baruch 0.01s user 0.00s system 95% cpu 0.014 total
11
32161
./baruch 0.05s user 0.00s system 98% cpu 0.053 total
12
184601
./baruch 0.29s user 0.00s system 99% cpu 0.294 total
13
1031969
./baruch 1.78s user 0.00s system 99% cpu 1.794 total
14
5483941
./baruch 11.26s user 0.02s system 99% cpu 11.311 total
15
36466945
./baruch 79.20s user 0.15s system 99% cpu 1:19.72 total
16
251132705
./baruch 592.89s user 0.77s system 99% cpu 9:55.34 total
17
1724671873
./baruch 4535.71s user 5.25s system 99% cpu 1:15:49.76 total
18
12655721857
./baruch 37496.97s user 58.50s system 99% cpu 10:27:48.29 total
```
## 1990 jaw
### STATUS: known bug - please help us fix
@@ -926,7 +995,8 @@ If you want to try and fix this (mis)feature, you are welcome to try.
### Information: [1992/lush/README.md](1992/lush/README.md)
We used a patch from [Yusuke Endoh](/winners.html#Yusuke_Endoh) to get this to
work but it only works with gcc. Cody removed the warnings of `gets()`.
work but it only works with gcc. Cody removed the warnings of `gets()` and
provided a script to run the entry properly.
Unfortunately due to the way the entry works and the fact that other compilers
like clang have different warnings and errors this simply does not work with
@@ -1000,6 +1070,7 @@ Hello World.
Can you help us?
## 1992 vern
### STATUS: INABIAF - please **DO NOT** fix
+18 -11
View File
@@ -1177,12 +1177,15 @@ invalid operands to binary expressions were resolved with the comma operator.
Later on, Cody added back the macro `#define D define` to make it look ever so
slightly more like the original, even though it's unused.
Cody also added the [try.sh](/1991/brnstnd/try.sh) script and
[try.txt](/1991/brnstnd/try.txt) which the script uses.
## <a name="1991_buzzard"></a>[1991/buzzard](/1991/buzzard/buzzard.c) ([README.md](/1991/buzzard/README.md]))
[Cody](#cody) fixed this so that the coordinates being specified would not crash the
program. This happened because the function that calls `atoi(3)` took an arg
without any type specified and as an implicit int it was not a `char *` which
without any type specified and as an implicit `int` it was not a `char *` which
crashed the program in modern systems.
Cody also made the file name in the code (which is the default maze file) not
@@ -1192,7 +1195,8 @@ Finally Cody added the [alternate
version](/1991/buzzard/README.md#alternate-code) which will possibly feel more at
home with those familiar with vi(m) (it certainly does feel more at home with
him): `k` for forward, `h` for left and `l` for right. This version also has a
more useful way to exit, just entering `q` followed by enter.
more useful way to exit, just entering `q` followed by enter, rather than
completing or killing the program.
## <a name="1991_davidguy"></a>[1991/davidguy](/1991/davidguy/davidguy.c) ([README.md](/1991/davidguy/README.md]))
@@ -1496,7 +1500,7 @@ necessary to include `time.h` so Cody did this as well.
## <a name="1992_buzzard.1"></a>[1992/buzzard.1](/1992/buzzard.1/buzzard.1.c) ([README.md](/1992/buzzard.1/README.md))
[Cody](#cody) added a check for the right number of args, exiting 1 if not enough (/2)
[Cody](#cody) added a check for the right number of args, exiting 1 if not enough (2)
used. This was not originally done but at a time it was changed to be considered
a bug so it was fixed at that point as it only took a few seconds and had to be
verified that it was consistent with the [bugs.md](/bugs.md) file.
@@ -1527,9 +1531,11 @@ details if you're interested in trying to understand it (or fix?).
## <a name="1992_imc"></a>[1992/imc](/1992/imc/imc.c) ([README.md](/1992/imc/README.md]))
[Cody](#cody) provided the [try.sh](/1992/imc/try.sh) script.
The original code, [imc.orig.c](/1992/imc/imc.orig.c), assumed that `exit(3)`
returned a value but this will cause problems where `exit(3)` returns void. The
source code was modified to avoid this problem but like [Cody](#cody) did with other fixes
source code was modified to avoid this problem but like Cody did with other fixes
he made this more like the original by redefining `exit` to use the comma
operator so that it could be used in binary expressions.
@@ -1538,7 +1544,8 @@ operator so that it could be used in binary expressions.
It was observed that on modern systems this goes much too quick. [Yusuke](#yusuke) created
a patch that calls `usleep(3)` but [Cody](#cody) thought the value was too slow so he
made it a macro in the Makefile `Z`, defaulting at 15000. This was made an [alt
made it a macro in the Makefile `Z` (which can be redefined with `make
SLEEP=...`), defaulting at 15000. This was made an [alt
version](/1992/kivinen/kivinen.alt.c) and it is recommended one use the alt
version first. See the README.md file to see how to reconfigure it.
@@ -1564,13 +1571,13 @@ it moves towards the right but if you click the mouse it goes back.
[Yusuke](#yusuke) supplied a patch which makes this work with gcc. Due to how it works (see
Judges' remarks in the README.md file) this will not work with clang.
[Cody](#cody) also provided the `runme.sh` script to demonstrate it as using make was
problematic.
[Cody](#cody) also provided the [lush.sh](/1992/lush/lush.sh) script to
demonstrate it as using make was problematic.
Cody made it use `fgets()` instead of `gets()`.
NOTE: this entry cannot work with clang due to different compiler messages. See
[bugs.md](/bugs.md) for details.
NOTE: this entry cannot work with clang due to different compiler messages (it
will compile fine but it won't work). See [bugs.md](/bugs.md) for details.
## <a name="1992_marangon"></a>[1992/marangon](/1992/marangon/marangon.c) ([README.md](/1992/marangon/README.md))
@@ -1600,7 +1607,7 @@ loop, reading again if `scanf(3)` did not return 2 (that was not a problem in
that `scanf(/2)` will not return until the number of specifiers have been
processed or some error occurs) or a function it called returned non-zero.
Instead the fix involves the `scanf(3)` specifiers being `"%4s %4s" on two
Instead the fix involves the `scanf(3)` specifiers being `"%4s %4s"` on two
new char arrays (always cleared in the beginning of the loop) and then using
`strtol(3)` with a base of `8` (as it's octal), checking for `< 0 || > 077` on
both numbers (using `"%o %o"` does not solve the problem).
@@ -1646,7 +1653,7 @@ Cody also added an arg check because the program and the
[nuked](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire
world](https://en.wikipedia.org/wiki/Earth) or just the
[USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough
args (/2). And not that we need the help or anything for this :-) but we
args (2). And not that we need the help or anything for this :-) but we
encourage you to try the original without two args :-)