Sorceress

aoc-2020-13

Dec 13th, 2020 (edited)
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'AoC-2020, day 13
  2. DIM r(20) AS LONG, u(20) AS LONG, i AS LONG
  3. 'OPEN "C:\test13" FOR INPUT AS #1
  4. OPEN "C:\day13" FOR INPUT AS #1
  5. INPUT #1, t0
  6. WHILE NOT EOF(1)
  7.   INPUT #1, a$: a = VAL(a$)
  8.   IF a > 1 THEN n = n + 1: r(n) = a: u(n) = m
  9.   m = m + 1
  10. WEND
  11. t1 = t0
  12. DO
  13.   FOR i = 1 TO n
  14.     IF t1 MOD r(i) = 0 THEN EXIT DO
  15.   NEXT
  16.   t1 = t1 + 1
  17. LOOP
  18. PRINT "pt1: "; (t1 - t0); "*"; r(i); " = "; (t1 - t0) * r(i)
  19.  
  20. DIM t AS _INTEGER64, tstep AS _INTEGER64
  21. t = 1: tstep = 1
  22. FOR i = 1 TO n
  23.   DO
  24.     IF (t + u(i)) MOD r(i) = 0 THEN EXIT DO ELSE t = t + tstep
  25.   LOOP
  26.   tstep = tstep * r(i)
  27. NEXT
  28. PRINT "pt2: "; t
RAW Paste Data