# 2018-03

Dec 3rd, 2018
216
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. DEFLNG A-Z
2. DIM g(999, 999) AS INTEGER
3. DIM c(2000, 5) AS INTEGER
4. DIM w\$(fake)
5.
6. OPEN "input03.txt" FOR BINARY AS #1
7. WHILE NOT EOF(1)
8. b\$ = INPUT\$(1, # 1)
9. IF b\$ >= " " THEN a\$ = a\$ + b\$
10. IF b\$ < " " OR EOF(1) THEN GOSUB procline: a\$ = ""
11. WEND
12. CLOSE #1
13.
14. FOR i = 1 TO t
15. FOR x = c(i, 1) TO c(i, 1) + c(i, 3) - 1
16. FOR y = c(i, 2) TO c(i, 2) + c(i, 4) - 1
17. j = g(x, y)
18. IF j <> 0 THEN c(i, 5) = 1
19. IF j > 0 THEN c(j, 5) = 1: g(x, y) = -1: sum = sum + 1
20. IF j = 0 THEN g(x, y) = c(i, 0)
21. NEXT
22. NEXT
23. NEXT
24. PRINT "part 1:"; sum
25. FOR i = 1 TO t
26. IF c(i, 5) = 0 THEN EXIT FOR
27. NEXT
28. PRINT "part 2:"; i
29.
30. END
31. '-------------------------------------------
32.
33. procline:
34. IF a\$ = "" THEN RETURN
35. GOSUB strsplit
36. t = t + 1: '0=id / 1=x / 2=y / 3=w / 4=h / 5=spoiled
37. c(t, 0) = VAL(w\$(1)): c(t, 1) = VAL(w\$(3)): c(t, 2) = VAL(w\$(4))
38. c(t, 3) = VAL(w\$(5)): c(t, 4) = VAL(w\$(6))
39. RETURN
40.
41. strsplit:
42. REDIM w\$(16)
43. DL\$ = "#,: x": ii = 1: ok = 0
44. FOR jj = 1 TO LEN(a\$)
45. b\$ = MID\$(a\$, jj, 1)
46. splitme = 0
47. FOR kk = 1 TO LEN(DL\$)
48. IF b\$ = MID\$(DL\$, kk, 1) THEN splitme = 1
49. NEXT
50. IF splitme = 1 THEN
51. IF ok = 1 THEN ii = ii + 1: ok = 0
52. ELSE
53. IF b\$ > " " THEN w\$(ii) = w\$(ii) + b\$: ok = 1
54. END IF
55. NEXT
56. 'FOR i = 1 TO ii: PRINT i; ") "; w\$(i): NEXT: SLEEP 'test
57. RETURN
RAW Paste Data