SHARE
TWEET

2018-01

Sorceress Dec 1st, 2018 (edited) 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFLNG A-Z: INTMAX = 1E6
  2. DIM n(10000) AS LONG, g(INTMAX) AS LONG, r AS STRING
  3.  
  4. 'pt 1
  5. OPEN "input01.txt" FOR INPUT AS #1
  6. WHILE NOT EOF(1)
  7.   INPUT #1, r: t = t + 1: n(t) = VAL(r): s = s + n(t)
  8. WEND
  9. CLOSE #1
  10. PRINT "part 1:"; s
  11.  
  12. 'pt 2
  13. s = 0
  14. DO
  15.   FOR i = 1 TO t: s = s + n(i)
  16.     h = s: IF h < 0 THEN h = h + INTMAX
  17.     IF g(h) = 0 THEN g(h) = s ELSE EXIT DO
  18.   NEXT
  19. LOOP
  20. PRINT "part 2:"; s
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top