SHARE
TWEET

2018-02

Sorceress Dec 2nd, 2018 (edited) 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFLNG A-Z
  2. DIM n(250) AS STRING
  3. DIM c(26) AS INTEGER
  4. DIM r AS STRING
  5.  
  6. 'pt 1
  7. OPEN "input02.txt" FOR INPUT AS #1
  8. WHILE NOT EOF(1)
  9.   INPUT #1, r: t = t + 1: n(t) = r: L = LEN(r)
  10.   FOR a = 0 TO 25: c(a) = 0: NEXT: pair = 0: triad = 0
  11.   FOR i = 1 TO L: a = ASC(MID$(r, i, 1)) - ASC("a"): c(a) = c(a) + 1: NEXT
  12.   FOR a = 0 TO 25
  13.     IF c(a) = 2 THEN pair = 1
  14.     IF c(a) = 3 THEN triad = 1
  15.   NEXT
  16.   sum2 = sum2 + pair: sum3 = sum3 + triad
  17. WEND
  18. CLOSE #1
  19. PRINT "part 1:"; sum2 * sum3
  20.  
  21. 'pt 2
  22. r = ""
  23. FOR i = 1 TO t - 1: FOR j = i + 1 TO t
  24.     d = 0
  25.     FOR k = 1 TO L
  26.       IF MID$(n(i), k, 1) <> MID$(n(j), k, 1) THEN d = d + 1: char = k
  27.     NEXT
  28.     IF d = 1 THEN
  29.       FOR k = 1 TO L
  30.         IF k <> char THEN r = r + MID$(n(i), k, 1)
  31.       NEXT
  32.       PRINT "part 2: "; r
  33.     END IF
  34. NEXT: NEXT
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top