The following program places 10 to 20 houses "randomly" depending on the entered seed value (1-65535). Extend the program to find the best location for the fire station and mark it with a small circle (radius 2). Then draw the circumscribed circle, that includes all houses and print it's radius. The calculated locations shown in the video are not the optimal solutions.
The program area between 0 and 99 must not be changed. Start your program at line 100.
Code: Select all
10 INPUT "No.: ";n: IF n<1 OR n>65535 THEN GO TO 1e4 20 RANDOMIZE n: DIM x(20): DIM y(20): INK 2: CLS 30 LET n=INT (11*RND+10): LET m=30*RND+30: FOR i=1 TO n 40 LET a=2*PI*RND: LET r=m*RND: LET x(i)=r*COS a+128: LET y(i)=r*SIN a+88 50 PLOT x(i),y(i): DRAW 0,1: DRAW 1,-2: DRAW -2,0: DRAW 0,1 60 NEXT i: LET a=0: LET m=0: LET r=0: INK 0:
The solutions for the examples should be near these values:
54321: r = 35.6
3456: r = 48.6
77: r = 42,0
See also: https://www.facebook.com/groups/ZXBasic ... 957501142/