在Emoji Math中,用户为视频游戏“不停说话”和“无人爆炸”创建了模块,数字被写成符号串,其中每个表情符号代表一个基数10位数。下面是数字和表情符号之间的转换表。
Digit | Emoticon
0 | :)
1 | =(
2 | (:
3 | )=
4 | :(
5 | ):
6 | =)
7 | (=
8 | :|
9 | |: 给定一个数字,以Emoji数学编码输出它。您可以假设没有非数字字符。
这是密码-高尔夫,所以以字节为单位的最短答案获胜。
发布于 2019-05-05 20:03:11
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数学编码的数字.
"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)-1134
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|是只能使用这个装配程序访问的两个字节令牌0xBBD 8。https://codegolf.stackexchange.com/questions/185208
复制相似问题