Add alt code to 1988/westley

The reason is it seems instructional and entertaining to see what
happens if the problem that the judges described in their remarks
occurs. Now one can do make clobber all alt; ./westley.alt; ./westley
and see if they are the same output.

The .gitignore file was updated - added westley.alt.

Updated README.md not only referring to the alt code but also format
fixes (the original fix of this commit).
This commit is contained in:
Cody Boone Ferguson committed 2023-04-13 14:24:34 -07:00
1 parent bb7c81e4f6
commit 7f5ee8ce42
4 files changed
+72 -20

No files matched your search

+1
View File
@@ -1 +1,2 @@
westley
westley.alt
+2 -2
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
+49 -18
View File
@@ -1,40 +1,71 @@
## Best layout
Merlyn LeRoy (Brian Westley)
Rosemount, Inc.
1121 Hamline Ave. N. #17
St. Paul, MN
55108
U.S.A.
Merlyn LeRoy (Brian Westley)
Rosemount, Inc.
1121 Hamline Ave. N. #17
St. Paul, MN
55108
U.S.A.
<http://www.westley.org>
http://www.westley.org
## To build:
```sh
make all
```
Misha Dynin provided a fix for [westley.c](westley.c) so that it may compile on
both K&R and more modern C compilers. Thank you Misha! The original code, used
for entertainment and educational value, is in [westley.alt.c](westley.alt.c),
described below.
## Try:
make all
./westley
```sh
./westley
```
## Judges' remarks
## Judges' remarks:
Your compiler must parse
#define _ -a
-_
```c
#define _ -a
-_
```
as "--a" and not "-(-a)" or some other tokenized form. Some strictly
as `--a` and not `-(-a)` or some other tokenized form. Some strictly
conforming ANSI C Preprocessors may object to this: for such
compilers, you can elide the non-standard token-pasting requirement
by changing the #define line to:
#define _ F-->00||F-OO--;
```c
#define _ F-->00||F-OO--;
```
You might enjoy looking at the output of:
cc -E westley.c
```sh
cc -E westley.c
```
### Alternate code:
To see if your compiler has the problem described above try:
```sh
make alt
./westley.alt
```
Does it show the same output as `westley`?
## Author's remarks:
No remarks were provided by the author.
Misha Dynin provided a fix for westley.c so that it may compile on
both K&R and more modern C compilers.
## Copyright and CC BY-SA 4.0 License:
+20
View File
@@ -0,0 +1,20 @@
#define _ -F<00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}