I've created a version of 2048 which I believe is the smallest which is coded in Ti-Basic. Can you make it smaller? If not, enjoy the program as-is!
PROGRAM:G2048
Goto Ø
Lbl M
If not(sum(L1
End
For(A,2,dim(L1
If L1(A:Then
For(B,A,2,~1
If L1(B)=L1(B-1) or not(L1(B-1
Then
L1(B-1)+L1(B → L1(B-1
0 → L1(B
1 → Ø
Else
2 → B
End:End:End:End:End
Lbl Ø
Delvar Ø 0identity(4 → [A]
SetupEditor G2048
Menu("2048","LOAD",L,"NEW",N
Lbl L
~1 → Ø
For(A,1,4)
For(B,1,4)
lG2048(4A+B-4 → [A](A,B
End:End
Lbl N
AxesOff
FnOff
ZStandard
ZInteger
Ø+1 → Ø
Repeat Ans=45
If Ø:Then
Repeat not([A](X,Y
randInt(1,4 → X
randInt(1,4 → Y
End
2+2(rand>.9 → [A](X,Y
End
ClrDraw
For(A,~36,36,18
5A/6
Line(A,~30,A,30
Line(~36,Ans,36,Ans:End
For(A,1,4
For(B,1,4
Text(15A-10,18B-5," " \\15sp
[A](A,B
If Ans
Text(15A-10,18B+1-2int(log(Ans)),Ans
End:End
Repeat Ans
Text(~1,0,90," " \\1sp
getKey
End
Delvar Ø
If Ans=25:Then
For(X,1,4
seq([A](B,X),B,1,4 → L1
For(L,~1,0
If L:Goto M
End:For(B,1,4
L1(B → [A](B,X
End:End:End
If Ans=26:Then
For(X,1,4
seq([A](X,B),B,4,1,~1 → L1
For(L,~1,0
If L:Goto M
End:For(B,1,4
L1(B → [A](X,5-B
End:End:End
If Ans=34:Then
For(X,1,4
seq([A](B,X),B,4,1,~1 → L1
For(L,~1,0
If L:Goto M
End:For(B,1,4
L1(B → [A](5-B,X
End:End:End
If Ans=24:Then
For(X,1,4
seq([A](X,B),B,1,4 → L1
For(L,~1,0
If L:Goto M
End:For(B,1,4
L1(B → [A](X,B
End:End:End:End
seq([A](int((A+3)/4),1+4fpart((A-1)/4)),A,1,16) → lG2048