I am trying now to crunch this function in BASIC. I want something speedy and memory efficient. My first draft shows my youthful indesretion. I was so objective driven back then...
Code: Select all
1 INPUT A
2 TI$= "000000"
10 IF A=9 THEN Y=Y+15: D=D-1
11 IF A=10 THEN Y=Y+300: D=D-10
12 IF A=11 THEN Y=Y-15: D=D+1
13 IF A=12 THEN Y=Y-300: D=D+10
14 PRINT TI, FRE(0), Y, D
Code: Select all
1 INPUT A
2 TI$= "000000"
10 T=10-A: IF ABS(T)=1 THEN Y=Y+15*T: D=D-T: GOTO 14
11 T=T+1: Y=Y+300*T: D=D-10*T
14 PRINT TI, FRE(0), Y, D
This compression is slightly faster (TI=2 in the first draft, TI=1 in the second) and saves about 26 bytes.
I combined the four lines into two. Still, my current math skills suck. I know there should be a way to further crunch it (perhaps into one equation without losing speed or memory). Any suggestions? I am pulling a brain freeze at the moment.