Sorceress

2018-06

Dec 6th, 2018
835
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFLNG A-Z
  2. TYPE tPoint
  3.   x AS INTEGER
  4.   y AS INTEGER
  5. END TYPE
  6. DIM p(50) AS tPoint
  7. DIM c(50) AS LONG
  8.  
  9. OPEN "input06.txt" FOR INPUT AS #1
  10. WHILE NOT EOF(1)
  11.   t = t + 1: INPUT #1, p(t).x, p(t).y
  12. WEND
  13. CLOSE #1
  14.  
  15. FOR x = 0 TO 400
  16.   FOR y = 0 TO 400
  17.     dsum = 0: dmin = 999: imin = 0: eq = 0
  18.     FOR i = 1 TO t
  19.       d = ABS(x - p(i).x) + ABS(y - p(i).y): dsum = dsum + d
  20.       IF d = dmin THEN eq = 1
  21.       IF d < dmin THEN dmin = d: imin = i: eq = 0
  22.     NEXT
  23.     IF dsum < 10000 THEN sum = sum + 1
  24.     IF eq = 0 THEN c(imin) = c(imin) + 1
  25.     IF x = 0 OR y = 0 OR x = 400 OR y = 400 THEN c(imin) = -99999
  26.   NEXT
  27. NEXT
  28.  
  29. FOR i = 1 TO t
  30.   IF c(i) > c(imin) THEN imin = i
  31. NEXT
  32. PRINT "part 1:"; c(imin)
  33. PRINT "part 2:"; sum
RAW Paste Data