VBA, 512 489 479 byte
Sub f(A,B):Debug.?">>>>>->>>>->--<<<"&Replace(Replace(Replace(A,"<","<<<[+]-<<"),">",">>>>>>>[+]-<<"),".",">>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]-<<")&">>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>"&Replace(Replace(Replace(B,"<","<<<<<"),">",">>>>>"),",","[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<"):End Sub
Giải trình
Mã VBA thay đổi mã brainfuck theo cách, rằng đầu ra của đoạn A sẽ được lưu trong danh sách và đầu vào của đoạn B sẽ được đọc từ danh sách đó.
Đầu tiên nó khởi tạo một số biến
>>>>>->>>>->--<<<
Sau đó nó đọc đoạn A và thay thế tất cả <
bằng cách <<<[+]-<<
, mỗi >
bằng >>>>>>>[+]-<<
và mọi .
bởi thói quen lưu trữ
>>>>>>>[+]-<<"),".",">>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<
sau đó nó xóa bộ nhớ của đoạn A và thay đổi danh sách được lưu trữ, vì vậy nó có thể được đọc làm đầu vào cho đoạn B:
>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<
Sau đó, đoạn B sẽ được đọc, mọi thứ <
sẽ được thay thế <<<<<
, mọi thứ >
sẽ được thay thế >>>>>
và mọi thứ ,
sẽ được thay thế bởi thói quen đọc danh sách:
[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<
Mã nguồn Brainfuck
Đây là nguồn của tôi cho các phần brainfuck của mã. Tôi sẽ giải thích chi tiết sau.
[
Tape: tempMem data out/in dataAnchors outAnchors (all repeating)
dataAnchors of Snippet A: -1 = memory has been used, -2 = active memory cell for copying to out/in
dataAnchors of Snippet B: -1 = active memory cell for copying from out/in
outAnchors of Snippet A: -1 = start of list, -2 = next output position
outAnchors of Snippet B: -1 = character has been read (or start of input)
]
### Init
>> two blank data cells (for non wrapping pointer)
>>>- set start of input
>> >>- set first "used" flag
>-- set end of input
<<< return to first usable data cell
### A move right routine
>>>>> move to the next data cell
>>[+]- clear and set "used" flag
<< return to data cell
### A move left routine
<<<[+]- clear and set "used" flag of previous data cell
<< go to data cell
### A print routine
>>- set flag
<<[ while value greater 0
- decrement value
<+ increment tempMem
>>>>+[-<<<<<+] find start of input
+[-->>>>>++]-- find end of input
<<+ increment input
>>+[-<<<<<+]- find start of input
<++[-->>>>>++]--find flag
<< go to active data cell
]
<[->+<] move stored value back to data
>>>>+[-<<<<<+] find start of input
+[-->>>>>++] find end of input
>>>>>- set new end of input
[-<<<<<+]- return to start of input
<++[-->>>>>++]- return to and delete data flag
<< go to data cell
### After snippet A: Delete memory of A and configure out/in list
>>[>>>>>]<<<<< go to last used data
[+<<[-]<<<] delete each data
>++[-->>>>>++] find and delete end of input flag
+[-<<<<<+]- go to start of input
>> go to first data cell
### B move right routine
>>>>> go to next data cell
### B move left routine
<<<<< go to previous data cell
### B reading routine
[-] set cell = 0
>>- set flag
>[>>>>>]+[-<<<<<+]- find start of input
>>>[ if value greater 0
- decrement value
<<<[<<<<<]>>>> go to initial start of input (combined with next)
+[->>>>>+]- find mem cell flag
<<+ increment mem cell
>>>[>>>>>]+[-<<<<<+]->>> return to input cell
]
>>- set new start of input
[<<<<<]>>>> go to initial start of input (combined with next)
+[->>>>>+] find and delete mem cell flag
<< go to mem cell
Đầu ra cho trường hợp thử nghiệm 1: f ",[..,]",",[...,]"
>>>>>->>>>->--<<<,[>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<,]>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<[...[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<]
Hãy thử trực tuyến!
Đầu ra cho trường hợp thử nghiệm 2: f ">,[>,]<[.<]",",[...,]"
>>>>>->>>>->--<<<>>>>>>>[+]-<<,[>>>>>>>[+]-<<,]<<<[+]-<<[>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<<<<[+]-<<]>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<[...[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<]
Hãy thử trực tuyến!
Đầu ra cho trường hợp thử nghiệm 3: f ",.",",."
>>>>>->>>>->--<<<,>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<.
Hãy thử trực tuyến!
Trường hợp thử nghiệm phức tạp:
Đoạn A: Xây dựng tam giác bảng chữ cái >+++++[<+++++>-]<+[>>[>[.>]]>++++++++++.--[<++++++++>-]<[+.<]<-]>>,>[.>]++++++++++.[<[.<]>,>[.>]<]
Hãy thử trực tuyến!
Đoạn B: Sắp xếp đầu vào theo thứ tự tăng dần >>,[>>,]<<[[-<+<]>[>[>>]<[.[-]<[[>>+<<-]<]>>]>]<<]
Hãy thử trực tuyến!
Kết quả:
>>>>>->>>>->--<<<>>>>>>>[+]-<<+++++[<<<[+]-<<+++++>>>>>>>[+]-<<-]<<<[+]-<<+[>>>>>>>[+]-<<>>>>>>>[+]-<<[>>>>>>>[+]-<<[>>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]-<<>>>>>>>[+]-<<]]>>>>>>>[+]-<<++++++++++>>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<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+]<<[>>>>>>>>>>[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<]<<<<<<<<<<[[-<<<<<+<<<<<]>>>>>[>>>>>[>>>>>>>>>>]<<<<<[.[-]<<<<<[[>>>>>>>>>>+<<<<<<<<<<-]<<<<<]>>>>>>>>>>]>>>>>]<<<<<<<<<<]
Hãy thử trực tuyến!
Shortest code in each language win
vàShortest Brainfuck solution will be accepted
là hai tiêu chí chiến thắng khác nhau.