TI-BASIC,165字节
Ans→L₁:{.12345678,.23417865,.34126587,.41238756,.58671342,.67583124,.75862413,.86754231→L₂:For(I,1,8:10fPart(.1int(L₂(I)₁₀^(seq(X,X,1,8:List▶matr(Ans,[B]:If I=1:[B]→[A]:If I-1:augment([A],[B]→[A]:End:[A](L₁(1),L₁(2
输入是长度为2的列表Ans。
输出是(row, column)表中索引处的数字。
可能有一种更好的压缩方法可以节省字节,但我必须对此进行研究。
例子:
{1,2
{1 2}
prgmCDGF1B
2
{7,4
{7 4}
prgmCDGF1B
5
说明:(
为便于阅读,添加了换行符。)
Ans→L₁ ;store the input list into L₁
{.123456 ... →L₂ ;store the compressed matrix into L₂
; (line shortened for brevity)
For(I,1,8 ;loop 8 times
10fPart(.1int(L₂(I)₁₀^(seq(X,X,1,8 ;decompress the "I"-th column of the matrix
List▶matr(Ans,[B] ;convert the resulting list into a matrix column and
; then store it into the "[B]" matrix variable
If I=1 ;if the loop has just started...
[B]→[A] ;then store this column into "[A]", another matrix
; variable
If I-1 ;otherwise...
augment([A],[B]→[A] ;append this column onto "[A]"
End
[A](L₁(1),L₁(2 ;get the index and keep it in "Ans"
;implicit print of "Ans"
这是一个155字节的解决方案,但是它只是对矩阵进行硬编码并获取索引。
我觉得它更无聊,所以我没有把它作为我的官方意见书:
Ans→L₁:[[1,2,3,4,5,6,7,8][2,3,4,1,8,7,5,6][3,4,1,2,6,5,8,7][4,1,2,3,7,8,6,5][5,7,6,8,1,3,2,4][6,8,5,7,3,1,4,2][7,6,8,5,4,2,1,3][8,5,7,6,2,4,3,1:Ans(L₁(1),L₁(2
注意: TI-BASIC是一种标记化语言。字符数不不等于字节数。
Your choice of labels doesn't count against your code length.介意吗?就目前而言,我可以将矩阵硬编码到我的代码中,并声称它不计入我的分数。