Part 1 ez, part 2 was pain but theoretically works on a C64
Part 2 takes about 2 seconds per iteration and needs to do 46857582 iterations. From what ive tested everything else works and the C64 is capable of decrementing 46857582 so the loop should finish successfully... eventually...
This commit is contained in:
parent
cfd74a292a
commit
fce178d777
8 changed files with 101 additions and 0 deletions
1
day_6/answer1
Normal file
1
day_6/answer1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1108800
|
1
day_6/answer2
Normal file
1
day_6/answer2
Normal file
|
@ -0,0 +1 @@
|
||||||
|
36919753
|
2
day_6/hint1
Normal file
2
day_6/hint1
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Time: 7 15 30
|
||||||
|
Distance: 9 40 200
|
3
day_6/input1
Normal file
3
day_6/input1
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Time: 46 85 75 82
|
||||||
|
Distance: 208 1412 1257 1410
|
||||||
|
|
3
day_6/input2
Normal file
3
day_6/input2
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Time: 46857582
|
||||||
|
Distance: 208141212571410
|
||||||
|
|
4
day_6/notes
Normal file
4
day_6/notes
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
2000 - num_to_digit_stream(N) -> NS, D
|
||||||
|
2500 - modulo(A, B) -> M
|
||||||
|
3000 - bigmult(NA[], DA, NB[], DB) -> PR[], DP
|
||||||
|
3500 - biggt(NA[], DA, WD[], DW) -> G
|
14
day_6/part1.bas
Normal file
14
day_6/part1.bas
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
0 ACCUM = 1
|
||||||
|
100 INPUT "TIME"; TIME%
|
||||||
|
101 IF TIME% = -1 THEN GOTO 1000
|
||||||
|
110 INPUT "DIST"; DIST%
|
||||||
|
199 WINS% = 0
|
||||||
|
200 FOR I=0 TO TIME%
|
||||||
|
210 CALCDIST% = (TIME% - I) * I
|
||||||
|
211 REM PRINT CALCDIST%
|
||||||
|
220 IF CALCDIST% > DIST% THEN WINS% = WINS% + 1
|
||||||
|
300 NEXT I
|
||||||
|
301 REM PRINT WINS%
|
||||||
|
310 ACCUM = ACCUM * WINS%
|
||||||
|
900 GOTO 100
|
||||||
|
1000 PRINT ACCUM
|
73
day_6/part2.bas
Normal file
73
day_6/part2.bas
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
0 DIM WD(20)
|
||||||
|
1 DIM NA(20)
|
||||||
|
2 DIM NB(20)
|
||||||
|
3 DIM PR(20)
|
||||||
|
|
||||||
|
100 INPUT "TIME"; TM
|
||||||
|
110 INPUT "DIST"; DI$
|
||||||
|
111 DW = LEN(DI$)
|
||||||
|
112 FOR I=1 TO DW: WD(DW-I)=ASC(MID$(DI$,I,1))-48 :NEXT
|
||||||
|
199 WI = 0
|
||||||
|
200 FOR X = 0 TO TM
|
||||||
|
201 IF X MOD 100000 = 0 THEN PRINT X
|
||||||
|
210 N = TM - X
|
||||||
|
211 GOSUB 2000
|
||||||
|
212 FOR J=0 TO D: NA(J)=NS(J) :NEXT
|
||||||
|
213 DA = D
|
||||||
|
214 N = X
|
||||||
|
215 GOSUB 2000
|
||||||
|
216 FOR J=0 TO D: NB(J)=NS(J) :NEXT
|
||||||
|
217 DB = D
|
||||||
|
218 GOSUB 3000
|
||||||
|
219 GOSUB 3500
|
||||||
|
220 IF G > 0 THEN WINS = WINS + 1
|
||||||
|
300 NEXT X
|
||||||
|
310 PRINT WINS
|
||||||
|
320 END
|
||||||
|
|
||||||
|
2000 REM INT TO BASE10 STREAM
|
||||||
|
2010 D=0
|
||||||
|
2020 A = N
|
||||||
|
2021 B = 10
|
||||||
|
2022 GOSUB 2500
|
||||||
|
2023 NS(D) = M
|
||||||
|
2030 N = INT(N / 10)
|
||||||
|
2040 D = D + 1
|
||||||
|
2050 IF N > 0 THEN GOTO 2020
|
||||||
|
2060 RETURN
|
||||||
|
|
||||||
|
2499 REM
|
||||||
|
2500 REM MODULO
|
||||||
|
2501 REM
|
||||||
|
2510 M = A - INT(A / B) * B
|
||||||
|
2520 RETURN
|
||||||
|
|
||||||
|
3000 FOR I=0 TO DB
|
||||||
|
3010 FOR J=0 TO DA
|
||||||
|
3020 PR(I + J) = PR(I + J) + (NA(J) * NB(I))
|
||||||
|
3030 NEXT J
|
||||||
|
3040 NEXT I
|
||||||
|
3050 REM FIXING TIME
|
||||||
|
3060 FOR I=0 TO (DA+DB)
|
||||||
|
3070 TP = INT(PR(I) / 10)
|
||||||
|
3080 A = PR(I)
|
||||||
|
3081 B = 10
|
||||||
|
3082 GOSUB 2500
|
||||||
|
3083 PR(I) = M
|
||||||
|
3090 PR(I + 1) = PR(I + 1) + TP
|
||||||
|
3100 NEXT I
|
||||||
|
3110 IF PR(I) > 0 THEN GOTO 3140
|
||||||
|
3120 I = I - 1
|
||||||
|
3130 GOTO 3110
|
||||||
|
3140 DP = I
|
||||||
|
3150 RETURN
|
||||||
|
|
||||||
|
3500 IF DP > DW THEN GOTO 3540
|
||||||
|
3501 FOR I=DP TO 0 STEP -1
|
||||||
|
3510 IF PR(I) > WD(I) THEN GOTO 3540
|
||||||
|
3511 IF PR(I) < WD(I) THEN GOTO 3530
|
||||||
|
3520 NEXT I
|
||||||
|
3530 G = 0
|
||||||
|
3531 RETURN
|
||||||
|
3540 G = 1
|
||||||
|
3541 RETURN
|
Loading…
Reference in a new issue