TI-BASIC, 79 바이트
Ans→Str1:" :For(I,1,length(Str1:Ans+sub(":)=((:)=:():=)(=:||:",1+2expr(sub(Str1,I,1)),2:End:sub(Ans,2,length(Ans)-1
입력은의 숫자 문자열입니다 Ans.
출력은 Emoji Math 인코딩 숫자입니다.
예 :
"134
134
prgmCDGF1C
:)(:)=
"2213894
2213894
prgmCDGF1C
(:(:=()=:||::(
설명:
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
또는 문자열 대신 숫자를 입력으로 사용 하는 94 바이트 솔루션이 있습니다.
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
예 :
134
134
prgmCDGF1C
:)(:)=
2213894
2213894
prgmCDGF1C
(:(:=()=:||::(
설명:
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
노트: