All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Name this city (Posted on 2007-02-15) Difficulty: 2 of 5
Which city is twice as far from one of the following cities, New York and San Diego, than from the other and has something to do with shine and a circular type of chart?

No Solution Yet Submitted by Art M    
Rating: 3.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
and the program Comment 3 of 3 |
(In reply to re: some cities that meet the distance criteria by Charlie)

DEFDBL A-Z
DIM SHARED pi
DECLARE FUNCTION dist (lat1, lon1, lat2, lon2)
pi = ATN(1) * 4


OPEN "\mworld\uscity.txt" FOR INPUT AS #1
OPEN "namecity.txt" FOR OUTPUT AS #2

DO
 LINE INPUT #1, l$
 lat = VAL(MID$(l$, 2, 5)): lon = VAL(MID$(l$, 8, 7))
 d1 = dist(lat, lon, 40.75, -74)
 d2 = dist(lat, lon, 32.75, -117.2)
 IF d1 > 0 AND d2 > 0 THEN
   IF d1 / d2 > 1.9 AND d1 / d2 < 2.1 OR d2 / d1 > 1.9 AND d2 / d1 < 2.1 THEN
     PRINT l$: ct = ct + 1
     PRINT #2, USING "& #### #### #.##"; l$; d1 * 4000; d2 * 4000; d1 / d2
   END IF
 END IF
LOOP UNTIL EOF(1)

CLOSE 1
OPEN "\mworld\wrldcity.txt" FOR INPUT AS #1

DO
 LINE INPUT #1, l$
 lat = VAL(MID$(l$, 1, 5)): lon = VAL(MID$(l$, 8, 7))
 d1 = dist(lat, lon, 40.75, -74)
 d2 = dist(lat, lon, 32.75, -117.2)
 IF d1 > 0 AND d2 > 0 THEN
   IF d1 / d2 > 1.9 AND d1 / d2 < 2.1 OR d2 / d1 > 1.9 AND d2 / d1 < 2.1 THEN
     PRINT l$: ct = ct + 1
     PRINT #2, USING "& #### #### #.##"; l$; d1 * 4000; d2 * 4000; d1 / d2
   END IF
 END IF
LOOP UNTIL EOF(1)


PRINT ct
END

FUNCTION dist (lat1, lon1, lat2, lon2)
 lDiff = ABS(lon2 - lon1) * pi / 180
 s1 = (90 - lat1) * pi / 180
 s2 = (90 - lat2) * pi / 180
 cd = COS(s1) * COS(s2) + SIN(s1) * SIN(s2) * COS(lDiff)
 d = ATN(SQR(1 - cd * cd) / cd)
 IF d < 0 THEN d = d + pi
 dist = d
END FUNCTION

 


  Posted by Charlie on 2007-02-15 11:59:34
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information