Merge pull request #210 from xexyl/1992-westley

Add & fix author provided alt code for 1992/westley
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-03-29 13:50:52 -07:00
commit b5cca7ca12
4 files changed
+29 -13

No files matched your search

+1
View File
@@ -1,2 +1,3 @@
westley westley
whereami whereami
westley.alt
+2 -2
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
DATA= DATA=
TARGET= ${PROG} TARGET= ${PROG}
# #
ALT_OBJ= ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ALT_TARGET= ${PROG}.alt
################# #################
+22 -11
View File
@@ -16,9 +16,9 @@
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for clang by [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for clang by
changing the third and fourth arg of main() to be ints inside main(); clang changing the third and fourth arg of main() to be ints inside main(); clang
requires args 2 - 4 to be `char **`. He also fixed it so that the program would requires args 2 - 4 to be `char **`. He also fixed it so that the program would
not segfault if not enough args were specified. Thank you Cody for your not segfault if not enough args were specified. He did the same for the
assistance! alternative version (see below) provided by the author (the original can be seen
in the author's comments below). Thank you Cody for your assistance!
### To run ### To run
@@ -35,13 +35,23 @@ 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 NOTE: you **MUST** have a terminal that wraps at 80 columns (!) in order for this to
show correctly! show correctly!
## Try: ## Try:
./whereami 47 -122 (- means west of meridian) ./whereami 47 -122 (- means west of meridian)
./whereami 47 122 ./whereami 47 122
### Alternative code:
The author provided a version for the USA. To build:
make alt
Use `westley.alt` as you would `whereami` above.
NOTE: this alternative version also needs a terminal that wraps at 80 columns.
## Judges' comments: ## Judges' comments:
To find the approximate place where this entry was judged, type: To find the approximate place where this entry was judged, type:
@@ -49,7 +59,7 @@ To find the approximate place where this entry was judged, type:
./whereami 37 -122 (- means west of meridian) ./whereami 37 -122 (- means west of meridian)
## Author's comments ## Author's comments:
Run the program with your latitude & longitude as integer Run the program with your latitude & longitude as integer
arguments; it will produce a map made up of '!' with the given arguments; it will produce a map made up of '!' with the given
@@ -75,7 +85,7 @@ To find the approximate place where this entry was judged, type:
give you an exception, as it will access arguments that give you an exception, as it will access arguments that
don't exist and characters before a string constant. don't exist and characters before a string constant.
How it works: ### 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 autowrap used to stack up slices of 80. The map data is with the autowrap used to stack up slices of 80. The map data is
@@ -89,7 +99,7 @@ To find the approximate place where this entry was judged, type:
The position of latitude & longitude is changed into a single The position of latitude & longitude is changed into a single
character position within the one long string via the first character position within the one long string via the first
expression "d = latitude/10*80 - longitude/5 - offset" The expression `d = latitude/10*80 - longitude/5 - offset`. The
latitude is divided by ten because the vertical resolution is latitude is divided by ten because the vertical resolution is
ten degrees, then multiplied by 80 because of the 80 character ten degrees, then multiplied by 80 because of the 80 character
wrap (i.e. each ten degrees moves the position up or down one wrap (i.e. each ten degrees moves the position up or down one
@@ -106,11 +116,11 @@ To find the approximate place where this entry was judged, type:
prints the line of blanks past Tierra del Fuego and the last prints the line of blanks past Tierra del Fuego and the last
blank line. It's just for show, really. blank line. It's just for show, really.
Since the resolution is coarse, a few costal cities are shown to Since the resolution is coarse, a few coastal cities are shown to
be just off the map; this is an unavoidable artifact. The map be just off the map; this is an unavoidable artifact. The map
is reasonably accurate. is reasonably accurate.
Here are some cities you might like to try: ### Here are some cities you might like to try:
New York 41 -74 Los Angeles 34 -118 New York 41 -74 Los Angeles 34 -118
London 52 0 Paris 45 2 London 52 0 Paris 45 2
@@ -119,11 +129,12 @@ To find the approximate place where this entry was judged, type:
Sydney -34 151 Tokyo 36 140 Sydney -34 151 Tokyo 36 140
For a domestic (USA) version with higher resolution, try: For a domestic (USA) version with higher resolution, try:
---cut--- ```c
main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043; main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd" n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
[l++-3];)for(;n-->64;)putchar(!d+++33^l&1);} [l++-3];)for(;n-->64;)putchar(!d+++33^l&1);}
---cut--- ```
The code will test the 80-column wrap and document itself if it is The code will test the 80-column wrap and document itself if it is
joined together as one 160-character line and listed. You should see: joined together as one 160-character line and listed. You should see:
+4
View File
@@ -0,0 +1,4 @@
main(l,a,n,d)char**a,**n,**d;{int N=n,D=d;if(l>2){for(D=atoi(a[1])/2*80-atoi(a[2])-2043;
N="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
[l++-3];)for(;N-->64;)putchar(!D+++33^l&1);}}