Add 2018/anderson/try.sh + format/typo checks
This commit is contained in:
1 parent
0cbd1db764
commit
7f4204bed8
3 files changed
+59
-14
No files matched your search
+19
-14
@@ -4,6 +4,9 @@
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
There is an alternate version of this entry. See [Alternate
|
||||||
|
code](#alternate-code) below for more details.
|
||||||
|
|
||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
@@ -15,32 +18,33 @@ make
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./prog < prog.c
|
./try.sh
|
||||||
./prog < prog.alt.c
|
|
||||||
./prog < README.md
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|
||||||
An alternate version of this entry, [prog.alt.c](prog.alt.c), is provided.
|
|
||||||
|
|
||||||
Compare [prog.c](prog.c) and [prog.alt.c](prog.alt.c) and find out why we had to
|
Compare [prog.c](prog.c) and [prog.alt.c](prog.alt.c) and find out why we had to
|
||||||
modify the entry, and what confused the author (see the author's remarks). No,
|
modify the entry, and what confused the author (see the author's remarks). No,
|
||||||
it was not the shape of the Roman V that we, or the compiler, didn't like.
|
it was not the shape of the Roman V that we, or the compiler, didn't like.
|
||||||
|
|
||||||
To compile this alternate version:
|
|
||||||
|
### Alternate build:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Alternate use:
|
||||||
|
|
||||||
Use `prog.alt` as you would `prog` above.
|
Use `prog.alt` as you would `prog` above.
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
With this entry, you won't need to turn your monitor [upside down](http://en.wikipedia.org/wiki/River_%28typography%29)!
|
With this entry, you won't need to turn your monitor [upside
|
||||||
|
down](http://en.wikipedia.org/wiki/River_%28typography%29)!
|
||||||
|
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
@@ -52,12 +56,13 @@ cc -Wall -Wextra -Wpedantic -O3 -std=c11 prog.c -o prog
|
|||||||
```
|
```
|
||||||
|
|
||||||
Also works with a standard of C99, but C90/C89 will not compile due to
|
Also works with a standard of C99, but C90/C89 will not compile due to
|
||||||
for loop initial declarations, along with additional warnings about
|
`for` loop initial declarations, along with additional warnings about
|
||||||
variable length arrays and lack of a return statement.
|
variable length arrays and lack of a `return` statement.
|
||||||
|
|
||||||
|
|
||||||
### Additional info:
|
### Additional info:
|
||||||
|
|
||||||
This small program, when given text on stdin, will produce a pattern of
|
This small program, when given text on `stdin`, will produce a pattern of
|
||||||
squiggly lines. This pattern is deterministic, and it shouldn't be too
|
squiggly lines. This pattern is deterministic, and it shouldn't be too
|
||||||
difficult to determine from whence they come. There is even a comment
|
difficult to determine from whence they come. There is even a comment
|
||||||
that describes the highlighted phenomena in the source, for those that
|
that describes the highlighted phenomena in the source, for those that
|
||||||
@@ -74,14 +79,14 @@ such as proper handling of tabs are left as an exercise to the reader.
|
|||||||
In developing this program, the author found a potentially interesting
|
In developing this program, the author found a potentially interesting
|
||||||
bug. If the expression `(j=k,j)` (near the middle of the source) is
|
bug. If the expression `(j=k,j)` (near the middle of the source) is
|
||||||
changed to `(j=k,k)`, the program produces different output. The author
|
changed to `(j=k,k)`, the program produces different output. The author
|
||||||
used compiler gcc 5.4.0, compiled for x86_64-linux-gnu. Enabling or
|
used gcc 5.4.0, compiled for `x86_64-linux-gnu`. Enabling or
|
||||||
disabling optimization produces the same results. The author is not
|
disabling optimization produces the same results. The author is not
|
||||||
sure who is the culprit, but instead shrugged and moved on with life.
|
sure who is the culprit, but instead shrugged and moved on with life.
|
||||||
Of course, YMMV with your own environment.
|
Of course, YMMV with your own environment.
|
||||||
|
|
||||||
The structure of this program, as you may have deduced, is two for
|
The structure of this program, as you may have deduced, is two `for`
|
||||||
loops, one nested in the other. There is also a bunch of direct
|
loops, one nested in the other. There are also a bunch of direct
|
||||||
variable assignment, such as `j=k`. There is some filler fluff, such as
|
variable assignments, such as `j=k`. There is some filler fluff, such as
|
||||||
`0-0+0`, but all that sort should be rather easy to spot. It was mostly
|
`0-0+0`, but all that sort should be rather easy to spot. It was mostly
|
||||||
added for the purpose of making certain things line up right, and only
|
added for the purpose of making certain things line up right, and only
|
||||||
secondarily to obfuscate.
|
secondarily to obfuscate.
|
||||||
|
|||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2018/anderson
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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: ./prog < prog.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./prog < prog.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./prog < prog.alt.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./prog < prog.alt.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./prog < README.md (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./prog < README.md | less -EXF
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./prog < Makefile (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./prog < Makefile | less -EXF
|
||||||
@@ -3952,6 +3952,11 @@ He also added the [try.sh](/2015/yang/try.sh) script.
|
|||||||
# <a name="2018"></a>2018
|
# <a name="2018"></a>2018
|
||||||
|
|
||||||
|
|
||||||
|
## <a name="2018_anderson"></a>[2018/anderson](/2018/anderson/prog.c) ([README.md](/2018/anderson/README.md))
|
||||||
|
|
||||||
|
[Cody](#cody) added the [try.sh](/2018/anderson/try.sh) script.
|
||||||
|
|
||||||
|
|
||||||
## <a name="2018_algmyr"></a>[2018/algmyr](/2018/algmyr/prog.c) ([README.md](/2018/algmyr/README.md))
|
## <a name="2018_algmyr"></a>[2018/algmyr](/2018/algmyr/prog.c) ([README.md](/2018/algmyr/README.md))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user