SHARE
TWEET

2018-05-optimised

Sorceress Dec 5th, 2018 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFLNG A-Z
  2. DIM b(50000) AS _BYTE, s(50000&) AS _BYTE
  3. DIM m AS DOUBLE: m = TIMER(0.0001)
  4. OPEN "input05.txt" FOR BINARY AS #1
  5. GET #1, , b()
  6. CLOSE #1
  7.  
  8. FOR i = 0& TO 49999&
  9.   IF (s(p) XOR b(i) XOR 32&) THEN p = p + 1&: s(p) = b(i) ELSE p = p - 1&
  10. NEXT
  11. PRINT "Part 1:"; p
  12.  
  13. best = p: p1 = p
  14.  
  15. FOR c = 97& TO 122&: p = 0&
  16.   FOR i = 1& TO p1
  17.     IF (s(i) OR 32&) XOR c THEN
  18.       IF (b(p) XOR s(i) XOR 32&) THEN p = p + 1&: b(p) = s(i) ELSE p = p - 1&
  19.     END IF
  20.   NEXT
  21.   IF p < best THEN best = p
  22. NEXT
  23. PRINT "Part 2:"; best
  24. PRINT "time"; (TIMER(0.0001) - m) * 1000; "ms"
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