zd : n  , : X$"Subway Scavenger" : x  , : X$"(c) by David H. Ahl, 1986" :  , : | : r7 , : X$"(Initializing data -- please be patient)" :  PN(),PKGDES$(),PKSTNU(),PKGSTA(,),PKSTDS(,),LGPKG() DORP(),STATION$(,),STANU(,),STATR(,,) TRAIN$( ),TRSTOP( ),TRSTA( ,2),TRDES$( ,),DUM()DPS : STNS : TRNS  : :For reading data: packages, stations, trains{  : LGMAX : TKMAX : :Packages to start  :  :  : :Read data into variables RN : RNRN1 : : RN  : STA : :Starting station' , : <) " " : | : j "Do you want to be able to deliver after 5:00pm (easier)";A$  : A$"Y" TM : TM$"6:00" : TM : TM$"5:00" I  : :Information about deliveriesDORP(I) : I(" I  : :Information about pick-ups<,DORP(I) : I6 : "You may want to print or copy this screen for later reference."@ :  : :Print package logJ:T:Arrive at station routine^  : :Print time&h "You have arrived at " STATION$(STA) " station."Pr "Trains that stop at this station:"g| I STANU(STA) " " TRAIN$(STATR(STA,I)) : I PERS L :  : :If on foot, buy token STATRSTA(TR,) STATRSTA(TR,TRSTOP(TR)) ; "End of the line. You'll have to get off." : e "Do you want to get off";A$ :  A$"N"  : :If want to stay on train, branch to train travelPERS : "Do you want to:" : " Make a pickup (P)"/ " Make a delivery (D)" : " Check your logbook (C)"R " Get another train (T)" "Your choice please (P, D, C, or T)";A$  : A$"P" A$"D"  : A$"T"  A$"C"  :  "Not a valid choice. Enter P, D, C, or T please.";A$ : :<:Trains coming routineV  : :Print time&RN(STANU(STA)()) : :Which train is coming?0TRSTATR(STA,RN): STATRSTA(TR,) DES : X : :At one end of line?&D STATRSTA(TR,TRSTOP(TR)) DES : X : :or the other?NNDES(()) : :Destination?X "Here comes the " TRAIN$(TR) " train to " TRDES$(TR,DES)bMINMINl "Do you want to get on";A$ : v A$"N" & : :If don't get on train, wait for next one9 I TRSTOP(TR) : :Find out where train isn TRSTA(TR,I)STA I : "ERROR at Line 465"TRSTXI : :Train station identification index DES TRX : TRX::Train travel routine,PERS : "You are on the " TRAIN$(TR) " train to " TRDES$(TR,DES)Q  : :Possible trip hazardsTRSTXTRSTXTRX : STATRSTA(TR,TRSTX) : MINMIN(ff&()) T : :Go to next station routine::Pickup and delivery routine A$"P" X$"pickup" : X$"delivery"\ "Which " X$; : " do you want to make (by Logbook number)";As  DORP(A) 4 "That number seems to be in error. Want to check your logbook";A$   : A$"Y" *  4 "That " X$ " is at " PKGDES$(A)> I PKSTNU(A);H PKGSTA(A,I)STA fuR I : "which is too far to walk from this station."\ "Perhaps you should try something else." : f PKSTDS(A,I) X$"s" : X$"" p " which is" PKSTDS(A,I) "block" X$ " from here. Off you go." z:E :Successful pickup or delivery MINMINPKSTDS(A,I) : :Add to time (2 min per block, 6 at destination) DELTOTDELTOT : DORP(A)  : :Is this a pick-up? ! : "You find someone to sign for the package."?!DORP(A) :  : :Mark delivery completed!LGMAXLGMAX : "You pick up a package and log it in as no." LGMAX! "The address on it is " PKGDES$(LGMAX)!DORP(A) : DORP(LGMAX) : !:":Check if all pickups and deliveries madeM" DELTOT , : :Have all deliveries been made?q" PKSTNU(A) X$"" : X$"s"": "From here you can walk to the following subway station" X$":"" PKSTNU(A) " " STATION$(PKGSTA(A,)) : T1# I PKSTNU(A) : :Iterate through possible stationsa# " " I "-- " STATION$(PKGSTA(A,I)) : I#$ "Which station do you want to go to (by number)";B#. B BPKSTNU(A) "Not a valid response." : $ $8STAPKGSTA(A,B) : MINMINPKSTDS(A,B) : T$B:.$L:Buy token subroutineW$VTOKENTOKEN : TOKENTKMAX $` : "You have spent the entire $20 your boss gave you on tokens."$j TK ~ : :Used own money yet? %t "Moreover, you have used up your own money as well." : S%~TK : "Do you want to buy tokens with your own money";A$ : % A$"N" "Okay, that's it then." : %RN(,X())d : "You have exactly $" RN;% "so you can buy" (RN) "more tokens." : TKMAXTKMAX(RN)& &:,&:Trip hazards subroutineI&:Door refuses to close& ()L|   : :5% chance of a sticky door& "One of the car doors refuses to close and the train can't move." 'RN( ()) : MINMINRN : RN X$"s" : X$"";' "You're stuck here for" RN "minute" X$ "."C':[':Possible mugging'  ()333  : :35-65 chance of mugging or fire on the tracks' ()L| : :5% chance of tough characters*( "Some real unsavory types are whooping it up in the car across from"m(( "your seat. Do you want to move to another car"; A$ : (2 A$"Y" ()L| F : Z(< ()L| P : d)F "They jeer at you but let you pass. All is okay...for now." : G)P "They look at you and try to bait you, but you avoid them." : ~)Z "Uh oh. Two of them get up and block your way.")d "Oh my, oh my. They're all moving to surround you.")n "They pull knives and demand your money." : ^9*x "You, deciding that discretion is the better part of valor, give"|* "them all your money and call it quits for the day." : *:*:Fire on the track* ()oz : :0.8% chance of fire on the tracks+ "Uh oh. The train is slowing down and seems to be stopping."W+ ^ : "You're stuck here in the tunnel." : ^+ "A trainman finally comes through and announces, 'It's just a"+RN( #()) : MINMINRN, "fire on the tracks folks. We'll be underway in a few minutes.'"B, "In fact, the delay is more like" RN "minutes!" : J,:e,:End of game routine, DELTOT , : :Were all deliveries made?, : "You made it to" DELTOT "locations, but"- "your log still shows the following items:" : E-  : "Perhaps you'll be able to do better tomorrow."O-" J}-,  : : ) "CONGRATULATIONS !" : -6 "You made all your deliveries and pick-ups successfully in the"-@ "largest city in the world. Very good!".J "You used $" TOKEN " for tokens."M.T : "Would you like to try again";A$ : k.^ A$"Y" : "M" : s.h:.r : X$"Subway Scavenger" :  : : .| " You have a job with a messenger/courier service located in"3/ "mid-town Manhattan. Today, you have five packages to deliver and"{/ "five packages to pick up for delivery to other locations in the"/ "city. So, in total you must visit 15 different locations." : 0 " You can use 264 stations of the New York Subway System which"V0 "are serviced by the following 11 trains: A, B, CG, D, E, F, N, 1,"o0 "2, 4, and 7." : 0 " You must complete all your deliveries and pickups by 5:00 pm."1 "Your boss has given you $20 for tokens (which will allow for a few"Q1 "wrong trains). Any money which you don't use on tokens is yours to"1 "keep. Good luck! (You'll need it.)" : 1:1:Subroutine to read data about package deliveries1 I PS1 PN(I),PKGDES$(I),PKSTNU(I)2 J PKSTNU(I)&2 PKGSTA(I,J),PKSTDS(I,J)82& J : I : l20 1,"Curator, Museum of Natural History",1,17,12: 2,"George Washington Bridge Bus Terminal",1,5,12D 3,"West Side Tennis Club, Forest Hills",1,75,43N 4,"Nathan's at Coney Island Amusement Park",1,95,2\3X 5,"Big Al's Discount Mart, Rockaway Blvd, Woodhaven",3,50,1,49,9,51,93b 6,"Apollo Theater, 125th St, Harlem",2,11,1,12,93l 7,"Met's Dugout, Shea Stadium",1,260,33v 8,"Press Room, Yankee Stadium",1,246,34 9,"Lion Keeper, Bronx Zoo",2,204,5,205,8K4 10,"Borough Hall, Brooklyn",2,32,1,221,2w4 11,"Brooklyn Academy of Music",1,67,24 12,"Registrar, Brooklyn College, Flatbush",1,234,14 13,"Computer Science Dept, NYU, Washington Sq",1,25,35 14,"NY Botanical Gardens",1,55,4Y5 15,"Windows on the World, World Trade Center",3,29,1,28,5,191,15 16,"Metropolitan Museum of Art",1,249,15 17,"Computer Education Dept, Columbia Univ.",2,174,2,175,85 18,"Alice Tully Hall, Lincoln Center",1,181,2-6 19,"New York Stock Exchange",2,219,2,252,2c6 20,"Lin Chows, Mott St, Chinatown",2,65,4,146,4k6:6:Subroutine to read data about subway stations6  I STNS : :STNS = number of subway stations6 STA, STATION$(I), STANU(I) 7  J STANU(I)K7* STATR(I,J) : :Read train numbers that stop at station]74 J : I : 7> 1,"207 St/Bdwy/Wash Hts (Manhattan)",1,17H 2,"Dyckman St/Bdwy",1,17R 3,"190 St/Ft Wash Av",1,17\ 4,"181 St/Ft Wash Av",1,1 8f 5,"175 St/GW Bridge",1,138p 6,"168 St/Bdwy (Manhattan)",3,1,3,6U8z 7,"163 St/Amsterdam Av",1,3y8 8,"155 St/St Nicholas Av",1,38 9,"145 St/St Nicholas Av",3,1,3,48 10,"135 St/St Nicholas Av",1,38 11,"125 St/St Nicholas Av",3,1,3,4 9 12,"116 St/8 Av",1,3/9 13,"110 St/Cathedral Pkwy",1,3R9 14,"103 St/Central Pk W",1,3t9 15,"96 St/Central Pk W",1,39 16,"86 St/Central Pk W",1,39 17,"81 St/Museum Natl History",1,39 18,"72 St/Central Pk W",1,3 : 19,"59 St/Columbus Circle",4,1,3,4,6&: 20,"50 St/8 Av",1,2B: 21,"42 St/8 Av",2,1,2f: 22,"34 St/Penn Station",2,1,2: 23,"23 St/8 Av",1,2:$ 24,"14 St/8 Av",2,1,2:. 25,"W 4 St/Washington Sq",5,1,2,3,4,5:8 26,"Spring St/6 Av",1,2;B 27,"Canal St/6 Av",2,1,2.;L 28,"Chambers St/Church St",3,1,2,7P;V 29,"World Trade Center",1,2;` 30,"Bdwy/Nassau St/Fulton St (Manhattan)",3,1,7,8;j 31,"High St/Brooklyn Br (Bklyn)",1,1;t 32,"Jay St/Borough Hall",2,1,5;~ 33,"Hoyt St",2,1,11< 34,"Lafayette Av",1,11*< 35,"Clinton Av",1,11F< 36,"Franklin Av",1,11a< 37,"Nostrand Av",1,1}< 38,"Kingston Av",1,11< 39,"Utica Av",1,1< 40,"Ralph Av",1,11< 41,"Rockaway Av",1,11< 42,"Bdwy, E NY",1,11= 43,"Liberty Av",1,11= 44,"Van Sicien Av",1,11:= 45,"Shepherd Av",1,11S= 46,"Euclid Av",1,1v= 47,"Grant Av (Brooklyn)",1,1= 48,"80 St/Liberty Av (Queens)",1,1= 49,"88 St/Liberty Av",1,1=( 50,"Rockaway Blvd",1,1=2 51,"104 St/Liberty Av",1,1>< 52,"111 St/Liberty Av",1,1D>F 53,"Lefferts Blvd (Queens)",1,1p>P 54,"205 St/Bainbridge Av (Bronx)",1,4>Z 55,"Bedford Pk Blvd (NY Botanical Garden)",1,4>d 56,"Kingsbridge Rd",1,4>n 57,"Fordham Rd",1,4>x 58,"Tremont Av",1,4&? 59,"47-50 St/Rockefeller Center",3,3,4,5M? 60,"42 St/Av Americas",4,3,4,5,9s? 61,"34 St/Herald Sq",4,3,4,5,10? 62,"23 St/Av Americas",1,5? 63,"14 St/Av Americas",3,5,6,7? 64,"Bdwy/Lafayette St",4,3,4,5,8@ 65,"Grand St (Manhattan)",2,3,46@ 66,"DeKalb Av/Flatbush Av (Bklyn)",2,4,10i@ 67,"Atlantic Av/Pacific St/BAM",5,3,4,7,8,10@ 68,"179 St/Hillside Av (Queens)",2,2,5@ 69,"169 St",1,2@ 70,"Parsons Blvd",2,2,5@ 71,"Sutphin Av",1,2A 72,"Van Wyck Blvd",1,2A 73,"Union Tpk",2,2,51A 74,"75 Av",1,2jA" 75,"71 Av/Continental Av/Forest Hills",4,2,5,10,11A, 76,"Roosevelt Av",5,2,5,9,10,11A6 77,"Queens Plaza",4,2,5,10,11A@ 78,"23 St/Ely Av (Queens)",2,2,5BJ 79,"Lexington Av (Manhattan)",2,2,5#BT 80,"5th Av/53 St",2,2,5CB^ 81,"7th Av/53 St",3,2,3,4`Bh 82,"36 St/4 Av",2,3,10zBr 83,"9 Av/39 St",1,3B| 84,"Ft Hamilton Pky",1,3B 85,"50 St/New Utrecht Av",1,3B 86,"55 St/New Utrecht Av",1,3C 87,"62 St/New Utrecht Av",2,3,10,C 88,"71 St/New Utrecht Av",1,3PC 89,"79 St/New Utrecht Av",1,3tC 90,"18 Av/New Utrecht Av",1,3C 91,"20 Av/86 St",1,3C 92,"Bay Pky/86 St",1,3C 93,"25 Av/86 St",1,3C 94,"Bay 50 St",1,3D 95,"Coney Island/Surf Av (Bklyn)",4,3,4,5,108D 96,"67 Av/Queens Blvd",2,10,11]D 97,"63 Dr/Queens Blvd",2,10,11D 98,"Woodhaven Blvd",2,10,11D 99,"Grand Av/Queens Blvd",2,10,11D 100,"Elmhurst Av",2,10,11D& 101,"65 St/Bdwy",2,10,11E0 102,"Northern Blvd",2,10,11'E: 103,"46 St/Bdwy",2,10,11GED 104,"Steinway St",2,10,11gEN 105,"2 Av/Houston St",1,5EX 106,"Delancey St",1,5Eb 107,"East Bdwy (Manhattan)",1,5El 108,"York St/Jay St (Brooklyn)",1,5Ev 109,"Bergen St",2,5,11F 110,"Carroll St",2,5,11*F 111,"Smith St",2,5,11GF 112,"4 Av/9 St",2,5,10aF 113,"7 Av/9 St",1,5F 114,"15 St/Prospect Park",1,5F 115,"Ft Hamilton Pwy",1,5F 116,"Church Av",1,5F 117,"Ditmas Av",1,5F 118,"18 Av/McDonald Av",1,5G 119,"Kings Hwy",1,5.G 120,"Avenue U",1,5GG 121,"Avenue X",1,5bG 122,"Neptune Av",1,5G 123,"W 8th/NY Aquarium",1,5G 124,"7 Av/Flatbush Av",1,4G 125,"Prospect Park",1,4G 126,"Church Av/E 18 St",1,4H* 127,"Newkirk Av",1,4"H4 128,"Kings Hwy/E 16 St",1,4AH> 129,"Sheepshead Bay",1,4`HH 130,"Brighton Beach",1,4~HR 131,"Court Square",1,11H\ 132,"21 St/Jackson Av (Queens)",1,11Hf 133,"Greenpoint Av (Bklyn)",1,11Hp 134,"Nassau Av",1,11 Iz 135,"Metropolitan Av",1,11/I 136,"Broadway/Union Av",1,11SI 137,"Flushing-Marcy Avs",1,11zI 138,"Myrtle-Willoughby Avs",1,11I 139,"Bedford-Nostrand Avs",1,11I 140,"36 St/Northern Blvd",2,10,11I 141,"Lexington Av/59-60 Sts (Manhattan)",2,8,10 J 142,"5th Av/59-60 Sts",1,10 257,"Queensboro Plaza (Queens)",1,9 ZH 258,"61 St/Roosevelt Av",1,9(ZR 259,"Junction Blvd",1,9SZ\ 260,"Willets Point/Shea Stadium",1,9}Zf 261,"Main St/Flushing (Queens)",1,9Zp 262,"Classon Av",1,11Zz 263,"Clinton-Washington Avs",1,11Z 264,"Fulton St/Lafayette Av",1,11Z:$[:Subroutine to read data about subway trainsY[ I TRNS : :TRNS = number of subway trainsx[ TR, TRAIN$(I), TRSTOP(I)[ J TRSTOP(I)[ TRSTA(I,J) : :Read station numbers for a train[ J\TRDES$(TR,)STATION$(TRSTA(TR,)) : :Station name at north or west endm\TRDES$(TR,)STATION$(TRSTA(TR,TRSTOP(TR))) : :Station at south or east endy\ I : \ 1,"A - 8 Av Express",29,1,2,3,4,5,6,9,11,19,21,22,24,25,27,28\ 30,31,32,33,37,39,46,47,48,49,50,51,52,539] 2,"E - 8 Av Local",24,68,69,70,71,72,73,74,75,76,77,78,79,80,81,20,21W] 22,23,24,25,26,27,28,29] 3,"B - Av Americas Express",36,6,7,8,9,10,11,12,13,14,15,16,17,18]$ 19,81,59,60,61,25,64,65,67,82,83,84,85,86,87,88,89,90,91,92,93,94,953^. 4,"D - Av Americas Express",26,54,55,56,57,58,246,9,11,19,81,59,60j^8 61,25,64,65,66,67,124,125,126,127,128,129,130,95^B 5,"F - Av Americas Local",37,68,70,73,75,76,77,78,79,80^L 59,60,61,62,63,25,64,105,106,107,108,32,109,110_V 111,112,113,114,115,116,117,118,119,120,121,122,123,95d_` 6,"1 - Bdwy-7th Av Local",38,161,162,163,164,165,166,167,168,169,6_j 170,171,172,173,174,175,176,177,178,179,180,181,19,182,144,183,184_t 185,186,63,187,188,189,190,191,192,193,194&`~ 7,"2 - 7th Av Express",49,195,196,197,198,199,200,201,202,203,204p` 205,206,207,208,209,210,211,212,213,214,215,216,217,218,177,180,144` 183,63,191,28,30,219,220,221,222,223,67,224,225,226,227,228,229,230` 231,232,233,234a 8,"4 - Lexington Av Express",29,235,236,237,238,239,240,241,242,243ea 244,245,246,214,248,249,141,250,145,64,251,30,252,253,221,223,67,254sa 255,256a 9,"7 - Flushing Express",9,144,60,250,257,258,76,259,260,261a 10,"N - Broadway Express",40,75,96,97,98,99,100,76,101,102,103,104Hb 140,77,141,142,143,144,61,145,146,66,67,147,112,148,149,82,150,151xb 152,153,154,87,155,156,157,158,159,160,95b 11,"CG - Bklyn/Queens Crosstown",29,75,96,97,98,99,100,76,101,102c 103,104,140,77,131,132,133,134,135,136,137,138,139,262,263,264,33c 109,110,111"c :Zc:Subroutine to check for lunch and end of workday~c MINTM d : :After 5 pm?c( c2 LUN : :Had lunch already?c< MIN : :Before 12 noon?cF PERS : :On a train?8dP : "Time for a lunch break. Chili dog and cola. Burp!"ddZ : MINMIN(()) : LUN : dd : "So sorry, it is after " TM$ "pm and the places to which"dn "you want to go to will be closed." : dx:e:Subroutine to print the timeEeHR(MIN<) : MNMIN