From 8b893ddfdecf14ce7b38f5e771bae743658b6d7e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 7 Nov 2023 08:09:34 -0800 Subject: [PATCH] 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. --- 1992/westley/README.md | 66 ++++++++++++++++++++++++------------------ 1992/westley/try.sh | 57 ++++++++++++++++++++++++++++++++++++ bugs.md | 19 ++++++++++++ thanks-for-fixes.md | 4 +++ 4 files changed, 118 insertions(+), 28 deletions(-) create mode 100755 1992/westley/try.sh diff --git a/1992/westley/README.md b/1992/westley/README.md index ff4e2967a..114346a52 100644 --- a/1992/westley/README.md +++ b/1992/westley/README.md @@ -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 diff --git a/1992/westley/try.sh b/1992/westley/try.sh new file mode 100755 index 000000000..2e09efeee --- /dev/null +++ b/1992/westley/try.sh @@ -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 diff --git a/bugs.md b/bugs.md index 8990dc0c1..ba0ce1be7 100644 --- a/bugs.md +++ b/bugs.md @@ -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 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 87b6e54dc..9b69fdd52 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -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