Merge pull request #1518 from xexyl/natori2k-try
Add 2000/natori/try.sh
This commit is contained in:
3 files changed
+156
-2
No files matched your search
@@ -18,8 +18,13 @@ version](#alternate-code) below.
|
|||||||
|
|
||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
Try modifying the code so that it will show another Moon phase based on input
|
|
||||||
or else just by the code itself. Bonus points if you can make it show all!
|
```sh
|
||||||
|
./try.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Also try modifying the code so that it will show another Moon phase based on
|
||||||
|
input or else just by the code itself. Bonus points if you can make it show all~
|
||||||
|
|
||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|||||||
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2000/natori
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
NATORI="natori"
|
||||||
|
moon()
|
||||||
|
{
|
||||||
|
read -r -n 1 -p "Press any key to randomly show the northern/southern hemisphere Moon: "
|
||||||
|
for ((i=0;i<=10;i++)); do
|
||||||
|
RAND=$((RANDOM % 1000))
|
||||||
|
if [[ "$RAND" -le 500 ]]; then
|
||||||
|
./"$NATORI"
|
||||||
|
else
|
||||||
|
./"$NATORI".alt
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
RAND=$((RANDOM % 1000))
|
||||||
|
if [[ "$RAND" -gt 500 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
echo "We will now reverse the order." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
if [[ "$RAND" -le 499 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
./"$NATORI".alt
|
||||||
|
./"$NATORI"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2
|
||||||
|
echo "We recommend that you try holding space down." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
RAND=$((RANDOM % 1000))
|
||||||
|
if [[ "$RAND" -gt 500 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \
|
||||||
|
./"$NATORI"; ./"$NATORI.alt" ) | less
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \
|
||||||
|
./"$NATORI.alt"; ./"$NATORI" ) | less
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2
|
||||||
|
echo "We now recommend that you try holding enter down." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
if [[ "$RAND" -gt 500 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \
|
||||||
|
./"$NATORI"; ./"$NATORI.alt" ) | less
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \
|
||||||
|
./"$NATORI.alt"; ./"$NATORI" ) | less
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "We will now reverse the order." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2
|
||||||
|
echo "We recommend that you try holding space down." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
if [[ "$RAND" -le 499 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \
|
||||||
|
./"$NATORI"; ./"$NATORI.alt" ) | less
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \
|
||||||
|
./"$NATORI.alt"; ./"$NATORI" ) | less
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2
|
||||||
|
echo "We now recommend that you try holding enter down." 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
if [[ "$RAND" -le 499 ]]; then
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: "
|
||||||
|
( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \
|
||||||
|
./"$NATORI"; ./"$NATORI.alt" ) | less
|
||||||
|
else
|
||||||
|
read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: "
|
||||||
|
( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \
|
||||||
|
./"$NATORI.alt"; ./"$NATORI" ) | less
|
||||||
|
fi
|
||||||
|
echo 1>&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# show the Moon phase in artistic ways!
|
||||||
|
moon
|
||||||
@@ -2333,6 +2333,9 @@ segfault when run or not compile at all (gcc and clang respectively).
|
|||||||
|
|
||||||
Cody also provided alternate code that supports the southern hemisphere.
|
Cody also provided alternate code that supports the southern hemisphere.
|
||||||
|
|
||||||
|
Cody also provided the [try.sh](2000/natori/try.sh) script that shows the Moon
|
||||||
|
phase in artistic ways.
|
||||||
|
|
||||||
Later on Cody restored the `#include`s in the source code which had been changed
|
Later on Cody restored the `#include`s in the source code which had been changed
|
||||||
by us to make it a one-liner again but this was an error as it was not a
|
by us to make it a one-liner again but this was an error as it was not a
|
||||||
one-liner but rather a small program. At the same point Cody made the code
|
one-liner but rather a small program. At the same point Cody made the code
|
||||||
@@ -3190,6 +3193,17 @@ Cody fixed it so that if the file cannot be opened it exits rather than trying
|
|||||||
to read from the file.
|
to read from the file.
|
||||||
|
|
||||||
|
|
||||||
|
## [2006/sykes1](2006/sykes1/sykes1.c) ([README.md](2006/sykes1/README.md]))
|
||||||
|
|
||||||
|
Cody provided the [alt code](2006/sykes1/README.md#alternate-code) based on the
|
||||||
|
author's remarks and the [try.sh](2006/sykes1/try.sh) script.
|
||||||
|
|
||||||
|
Cody also provided the [bedlam-cubes.pdf](2006/sykes1/bedlam-cubes.pdf) file,
|
||||||
|
obtained from the Internet Wayback Machine, as the file was no longer available.
|
||||||
|
The video was also no longer available but Cody found an alternative and added
|
||||||
|
it to the repo as well.
|
||||||
|
|
||||||
|
|
||||||
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md]))
|
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md]))
|
||||||
|
|
||||||
Cody fixed a segfault in this program which was making it fail to work under
|
Cody fixed a segfault in this program which was making it fail to work under
|
||||||
|
|||||||
Reference in new issue
Block a user