>>++++[->++++[->+>++++++<<]<]>>->[-<[-<<<<++++[->++++++++<]]>>>[<<<<<++++++++[->>++<<<+>]>>-<<<++>>]<<[>>>>>>[>>>]>+<<<<<[<<<]<<-]>>>>>>[>>>]++++[-<++++++++>]>[-<+>]<<[<<<]>>]<[-]<<,[[->+>+<<],[-]++++[->>--------<<]>>[>>>>[>>>]+[<<<]<-]>>>>[>>>]<<[-]<[<<<]<<[>>>>>[>>>]<<+<[<<<]<<-]>>>>>[>>>]<<<[[-]<<<]>[.>.>>]++++++++++[->+>++<<]>>[-<.>]<[-]<<<<[<<<]<,]
BrainFuck의 옵션은 매우 제한적이므로 출력은 터미널에 있으며 화면은 20 줄 바꿈으로 "지워집니다". 입력은 개행 문자로 구분 된 ASCII 문자 여야합니다.
온라인으로 사용해보십시오!
형식화 및 문서화
이것들은 내가 프로그램을 작성하는 데 사용한 디버그 노트입니다. 나는 사용했다디버깅을 위해 모든 '~'문자로 테이프 상태를 선택적으로 인쇄 할 수있는 통역사 를 .
[
run.bf
codegolf.stackexchange.com/questions/124306/map-inputted-ascii-characters
]
[
Calculate 16 * 6
Resulting tape state:
[0 0 0 0 0 0 16 96 0 0 0 0 ...]
^
Note that, to obtain a 16-by-6 grid, the 16
immediately to the right is decreased to 15
(since we will decrease it by 1 each loop
until we reach 0 and immediately reset)
]
>>>>++++[->++++[->+>++++++<<]<]>~
[
Our next goal is to make 96 sets of 3 cells each in the pattern [C D 0]
The first cell will represent an entered character--when the corresponding
input on the keyboard is pressed, it will change to the entered key.
The first cell is initialized to 32 (' ').
The second cell will represent the delimiter after that character.
Every 16 cells, this should be 10 for '\n'. Otherwise, it should be 32 for ' '.
The third cell is a buffer cell, used for traversal of the grid. In general,
it should be only temporarily modified and then reset to 0.
]
>->[-<
[
-<<<<++++[->++++++++<]
[
The second cell of our 3-set should be 32, so the above line
writes 32 to the 3rd cell from the beginning of the tape (0-indexed)
]
]
>>>
[
<<<[ The second cell of our 3-set should be 10, and we must reset the line counter ]
<<++++++++[->>++<<<+>]>>-<<<++>>
]
[ At this point, the delimiting cell we need is two cells to the left. ]
<<[>>>>>>[>>>]>+<<<<<[<<<]<<-]
>>>>>>[>>>]++++[-<++++++++>]
[ Debug Mode: In the previous loop, add a + in the string of 8 +'s to get visible spaces in the grid ($-signs) ]
>[-<+>]<<[<<<]>>
]
[ Go back to the beginning of the tape and clear up the residual '15' ]
<[-]~
<<,
[
[->+>+<<],[-]++++[->>--------<<]
[
Take input such that the state of the tape now looks like this:
[0 0 0 0 0 c c-32 0 32 32 0 32 32 0 32 32 0 ...]
^
Where 'c' was the entered character.
We now set up 1's in the buffer zones of the first c-32
3-sets and clear the character that is currently there.
All that is left, then, is to copy c to that location.
]
[ Set up the row of 1's. ]
>>[>>>>[>>>]+[<<<]<-]
[ Clear the current character. ]
>>>>[>>>]<<[-]~<[<<<]
[ Copy the new character. ]
<<[>>>>>[>>>]<<+<[<<<]<<-]
[ Clean up the 1's. ]
>>>>>[>>>]~<<<[[-]<<<]
[ Print the grid. ]
>[.>.>>]~
[ Print a bunch of newlines ]
++++++++++[->+>++<<]>>[-<.>]<[-]
[ Take a new input. ]
<<<<[<<<]<,
]