TI-BASIC, 79 bayt
Ans→Str1:" :For(I,1,length(Str1:Ans+sub(":)=((:)=:():=)(=:||:",1+2expr(sub(Str1,I,1)),2:End:sub(Ans,2,length(Ans)-1
Girdi, içindeki bir basamak dizesidir Ans
.
Çıktı, Emoji Math kodlu sayıdır.
Örnekler:
"134
134
prgmCDGF1C
:)(:)=
"2213894
2213894
prgmCDGF1C
(:(:=()=:||::(
Açıklama:
Ans→Str1 ;store the input in Ans
" ;leave " " in Ans
For(I,1,length(Str1 ;loop over each character in the
; input string
Ans+sub(":)=((:)=:():=)(=:||:",1+2expr(sub(Str1,I,1)),2 ;convert the current character
; to a number and use it as the
; index into the encoding string
; then append the encoded digit
End
sub(Ans,2,length(Ans)-1 ;remove the prepended space and
; store the result in Ans
;implicit print of Ans
Alternatif olarak, sayı yerine dize yerine 94 baytlık bir çözüm var:
int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans→L₁:" :For(I,dim(L₁),1,-1:Ans+sub(":)=((:)=:():=)(=:||:",1+2L₁(I),2:End:sub(Ans,2,length(Ans)-1
Örnekler:
134
134
prgmCDGF1C
:)(:)=
2213894
2213894
prgmCDGF1C
(:(:=()=:||::(
Açıklama:
int(10fPart(Ans₁₀^(seq(⁻X-1,X,0,log(Ans→L₁ ;generate a list of the input's digits
; reversed and store it in L₁
" ;leave " " in Ans
For(I,dim(L₁),1,-1 ;loop over L₁ backwards
Ans+sub(":)=((:)=:():=)(=:||:",1+2L₁(I),2 ;use the value of the I-th element in L₁ as
; the index into the encoding string then
; append the encoded digit
End
sub(Ans,2,length(Ans)-1 ;remove the prepended space and store the
; result in Ans
;implicit print of Ans
Notlar: