Merge pull request #1787 from xexyl/august1985-try
This commit is contained in:
4 files changed
+51
-3
No files matched your search
@@ -15,7 +15,7 @@ make all
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./august | head -n 10
|
./try.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have the `primes(6)` tool (sometimes part of [BSD
|
If you have the `primes(6)` tool (sometimes part of [BSD
|
||||||
@@ -27,6 +27,10 @@ what of the output in the first `N` (say `15` or `25`) lines are primes:
|
|||||||
./primes.sh 25
|
./primes.sh 25
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that `try.sh` will run this script anyway, telling you where to get
|
||||||
|
`primes(6)` if you don't have it installed, but it will only run with the
|
||||||
|
default value of 15, rather than trying several different values.
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ if [[ -n "$PRIMES" ]]; then
|
|||||||
while read -r n; do primes "$n" $((n + 1)); done < <((./august | head -n "$COUNT" ))
|
while read -r n; do primes "$n" $((n + 1)); done < <((./august | head -n "$COUNT" ))
|
||||||
else
|
else
|
||||||
echo "primes not installed" 1>&2
|
echo "primes not installed" 1>&2
|
||||||
|
echo 1>&2
|
||||||
echo "See the following GitHub repo:" 1>&2
|
echo "See the following GitHub repo:" 1>&2
|
||||||
echo "" 1>&2
|
echo 1>&2
|
||||||
echo " https://github.com/vattam/BSDGames"
|
echo " https://github.com/vattam/BSDGames" 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
echo "and after installing try again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 1985/august
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
REV="$(type -P rev)"
|
||||||
|
PRIMES=$(type -P primes)
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./august | head -n 11: "
|
||||||
|
echo 1>&2
|
||||||
|
./august | head -n 11
|
||||||
|
|
||||||
|
if [[ -n "$REV" ]]; then
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to reverse bits: "
|
||||||
|
echo 1>&2
|
||||||
|
./august | head -n 11 | "$REV"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run primes.sh too
|
||||||
|
echo 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to run: ./primes.sh: "
|
||||||
|
echo 1>&2
|
||||||
|
./primes.sh
|
||||||
|
exit 0
|
||||||
@@ -191,6 +191,10 @@ either the default or user specified. The inspiration was the previous 'try'
|
|||||||
command he gave to have fun with finding primes that might seem unusual in a
|
command he gave to have fun with finding primes that might seem unusual in a
|
||||||
way.
|
way.
|
||||||
|
|
||||||
|
Cody also added the [try.sh](/1985/august/try.sh) script (which calls
|
||||||
|
`primes.sh` whether `primes(6)` is installed or not but it only does it once
|
||||||
|
with the default value).
|
||||||
|
|
||||||
|
|
||||||
## <a name="1985_lycklama"></a>[1985/lycklama](/1985/lycklama/lycklama.c) ([README.md](/1985/lycklama/README.md]))
|
## <a name="1985_lycklama"></a>[1985/lycklama](/1985/lycklama/lycklama.c) ([README.md](/1985/lycklama/README.md]))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user