TI-BASIC, 311 288 바이트
TI-BASIC 답변이 없습니까? 내가 고칠 시간이야!
Ans→Str1:" →Str2:" →Str6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str4:For(S,1,length(Str1:sub(Str1,S,1:If inString(Str4+"abcdefghijklmnopqrstuvwxyz",Ans:Str2+Ans→Str2:End:sub(Str2,2,length(Str2)-1→Str2:For(B,1,.1+3⁻¹length(Str2:sub(Str2,3B-2,3→Str3:1+sum({4,2,1}seq(0≠inString(Str4,sub(Str3,X,1)),X,1,3→L₁(B:End:For(C,1,.1+dim(L₁:Str6+sub("><[]-+.,",L₁(C),1→Str6:End:sub(Str6,2,length(Str6)-1→Str6
입력은의 oOo 코드입니다 Ans
.
출력은 번역 된 BF 코드입니다.
예 :
"AbcDef
AbcDef
prgmCDGF18
--
"PROgRam reVERsES giVeN iNPut sEqUENcE
PROgRam reVERsES giVeN iNPut sEqUENcE
prgmCDGF18
.[>,]<[.<]+
"AbcDe
AbcDe
prgmCDGF18
-
언 골프 :
(개행 및 댓글 추가)
Ans→Str1 ;store the input in "Str1"
" →Str2 ;set "Str2" and "Str6" to a
" →Str6 ; space character
; (needed b/c TI-BASIC doesn't
; like concatenating empty
; strings)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str4 ;store the uppercase alphabet
; in "Str4"
For(S,1,length(Str1 ;loop over the input string
sub(Str1,S,1 ;get the current character
If inString(Str4+"abcdefghijklmnopqrstuvwxyz",Ans ;if the character is in either
; the uppercase or lowercase
; alphabet
Str2+Ans→Str2 ;add it to "Str2", the code
; string
End
sub(Str2,2,length(Str2)-1→Str2 ;remove the space added earlier
For(B,1,.1+3⁻¹length(Str2 ;loop over each 3-char substring
; and skip any extra chars
; (.1 is added to force one
; loop)
sub(Str2,3B-2,3→Str3 ;store said substring in "Ans"
1+sum({4,2,1}seq(0≠inString(Str4,sub(Str3,X,1)),X,1,3→L₁(B ;convert to the respective
; index in "><[]-+.,"
; (1-indexed)
End
For(C,1,.1+dim(L₁ ;loop over each index
; (.1 is added to force one
; loop)
Str6+sub("><[]-+.,",L₁(C),1→Str6 ;add the char to the translation
; string
End
sub(Str6,2,length(Str6)-1→Str6 ;remove the added space and
; store the result in "Str6"
; and "Ans"
;implicit print of "Ans"
노트:
- TI-BASIC은 토큰 화 된 언어입니다. 문자 수는 바이트 수와 같지 않습니다 .