Add 1992/westley/try.sh + format fixes

The try.sh script runs the program for the world cities and the alt
version for the US cities, one at a time, that the author suggested, as
well as the approximate location that the entry was judged, noted from
the judges.

The README.md has been format fixed.

There is a possible bug in the alt version which is in the bugs.md file.
There is also a feature in the bugs.md which does introduce a strange
look in the README.md file:

    STATUS: INABIAF - please **DO NOT** fix
    STATUS: known bug - please help us fix

but they are for different things.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-07 08:12:10 -08:00
1 parent d52d57fee9
commit 8b893ddfde
4 files changed
+118 -28

No files matched your search

+38 -28
View File
@@ -4,25 +4,32 @@
make all
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: known bug - please help us fix
```
For more detailed information see [1992 westley in bugs.md](/bugs.md#1992-westley).
## To use:
If lost:
```sh
make whereami
```
Then run:
```sh
./whereami lat long
```
Where lat and long correspond to your latitude and longitude.
Where `lat` and `long` correspond to your latitude and longitude.
NOTE: you **MUST** have a terminal that wraps at 80 columns (!) in order for this to
show correctly!
NOTE: you **MUST** have a terminal that is at least 80 columns for this to show
properly.
### Try:
@@ -48,10 +55,10 @@ make alt
### Alternate use:
```sh
./westley.alt lat long
./whereami.alt lat long
```
NOTE: this alternative version also needs a terminal that wraps at 80 columns.
NOTE: this alternative version also needs a terminal with at least 80 columns.
## Judges' remarks:
@@ -66,24 +73,24 @@ To find the approximate place where this entry was judged, type:
## Author's remarks:
Run the program with your latitude & longitude as integer
arguments; it will produce a map made up of '!' with the given
position marked with either a '"' (if the position is over a '!')
or a '#' (if the position is over a space). Southern latitudes
arguments; it will produce a map made up of `'!'` with the given
position marked with either a `'"'` (if the position is over a `'!'`)
or a `#` (if the position is over a space). Southern latitudes
and western longitudes are entered as negative numbers. For
example, to find San Francisco, run with "prog 38 -122". The
example, to find San Francisco, run with `./whereami 38 -122`. The
resolution of the map is five degrees horizontally, ten degrees
vertically. The map is a Mercator projection with equal spacing
of the latitudes, so the areas near the poles are very distorted.
Latitudes near the poles and Antarctica are not shown.
The program requires the ASCII character set, putchar(), atoi(),
The program requires the ASCII character set, `putchar()`, `atoi()`,
and a display that auto-wraps at 80 characters(!). If your display
does not work this way, you will have to massage the output;
for example, you can pipe it to a file and edit it with vi,
for example, you can redirect it to a file and edit it with vi,
which will do auto-wrap for you.
Lint complains that main() returns a random value and I'm not
checking the value that putchar() returns. Scandalous!
Lint complains that `main()` returns a random value and I'm not
checking the value that `putchar()` returns. Scandalous!
If you run it with fewer than 2 arguments, it will likely
give you an exception, as it will access arguments that
@@ -91,15 +98,15 @@ don't exist and characters before a string constant.
### How it works:
The map is printed as one long string of ' ' and '!' characters,
The map is printed as one long string of `' '` and `'!'` characters,
with the auto-wrap used to stack up slices of 80. The map data is
a string; the first character is how many '!'s are printed
('A'=1, 'B'=2, etc), the second character is how many ' 's, the
third is how many '!'s, etc. ASCII characters less than 'A'
a string; the first character is how many `!`s are printed
(`'A'`=1, `'B'`=2, etc), the second character is how many `' '`s, the
third is how many `!`s, etc. ASCII characters less than `'A'`
print no characters but still change the polarity, so any map
of ' 's and '!'s is possible. This is done in the putchar()
of `' '`s and `'!'`s is possible. This is done in the `putchar()`
argument as `33^l&1`, where `l` is the character `position+4`; if
`l` is odd, ' ' is printed, if `l` is even, '!' is printed.
`l` is odd, `' '` is printed, if `l` is even, `'!'` is printed.
The position of latitude & longitude is changed into a single
character position within the one long string via the first
@@ -113,17 +120,19 @@ are opposite because latitude is decreasing and longitude is
increasing as you go from upper left to lower right. The offset
is where the origin (latitude=0, longitude=0) is found.
The position counting down to zero changes the putchar() from
printing ('!' or ' ') to printing ('"' or '#').
The position counting down to zero changes the `putchar()` from
printing (`'!'` or `' '`) to printing (`'"'` or `'#'`).
The "H E L L O, W O R L D!" string inside the data string
prints the line of blanks past Tierra del Fuego and the last
The `"H E L L O, W O R L D!"` string inside the data string
prints the line of blanks past [Tierra del
Fuego](https://en.wikipedia.org/wiki/Tierra_del_Fuego) and the last
blank line. It's just for show, really.
Since the resolution is coarse, a few coastal cities are shown to
be just off the map; this is an unavoidable artifact. The map
is reasonably accurate.
### Here are some cities you might like to try:
- New York 41 -74\
@@ -137,6 +146,7 @@ is reasonably accurate.
- Beijing 40 116
- Tokyo 36 140
For a domestic (US) version with higher resolution, try:
```c
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
make everything || exit 1
echo "New York:" 1>&2
echo 1>&2
./westley.alt 41 -74
echo 1>&2
echo "London:" 1>&2
echo 1>&2
./westley 52 0
echo 1>&2
echo "Moscow:" 1>&2
echo 1>&2
./westley 56 38
echo 1>&2
echo "New Delhi:" 1>&2
echo 1>&2
./westley 29 77
echo 1>&2
echo "Sydney:" 1>&2
echo 1>&2
./westley -34 151
echo 1>&2
echo "Los Angeles:" 1>&2
echo 1>&2
./westley.alt 34 -118
echo 1>&2
echo "Paris:" 1>&2
echo 1>&2
./westley 45 2
echo 1>&2
echo "Rio de Janeiro:" 1>&2
echo 1>&2
./westley -23 -43
echo 1>&2
echo "Beijing:" 1>&2
echo 1>&2
./westley 40 116
echo 1>&2
echo "Tokyo:" 1>&2
echo 1>&2
./westley 36 140
echo 1>&2
echo "Approximate judging location:" 1>&2
echo 1>&2
./westley.alt 37 -122
+19
View File
@@ -834,6 +834,25 @@ echo $COLUMNS
```
### STATUS: known bug - please help us fix
The author suggested that the alternate version, which Cody added (but fixed for
modern systems), should print
```c
main(l,a,n,d)...
[A M E R I C A]...
```
...going down the left edge if your terminal auto-wraps at 80 characters.
This however does not seem to work. It does not appear to be because of the fix
for modern systems as it doesn't work for gcc either, even before any changes.
This might be a misunderstanding or it might be that having 80 columns (resized)
does not count (though the output before the fix of the 80 column requirement
showed was correct when at 80-columns so it seems like this could be a bug if
not a misunderstanding).
# 1993
+4
View File
@@ -1430,6 +1430,10 @@ the final loop it prints another newline. This fix has another bonus in that
resizing the terminal after running it should not mess up the display either,
unless of course it becomes too small.
Cody added the [try.sh](1992/westley/try.sh) script that shows the different
cities that the author recommended one try, labelling each city and printing a
newline before the next city.
Cody also added an arg check because the program and the
[alternate version](1992/westley/westley.alt.c) might have crashed or
[nuked](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire