--- title: Execute Brain**** id: 59e0a8df964e4540d5abe599 challengeType: 5 videoUrl: '' localeTitle: 执行大脑**** --- ## Description

编写一个函数来实现Brain ****解释器。该函数将字符串作为参数,并应返回一个字符串作为输出。更多细节如下:

RCBF是一套为各种语言的Rosetta Code编写的Brainf ***编译器和解释器。

以下是RCBF每个版本的链接。

实现只需要正确实现以下指令:

{|

!命令

!描述

| -

|风格=“文本对齐:中心” | > ||将指针向右移动

| -

|风格=“文本对齐:中心” | < ||将指针移到左侧

| -

|风格=“文本对齐:中心” | + ||增加指针下的内存单元格

| -

|风格=“文本对齐:中心” | - ||减少指针下的内存单元格

| -

|风格=“文本对齐:中心” | . ||输出指针处单元格表示的字符

| -

|风格=“文本对齐:中心” | , ||输入一个字符并将其存储在指针的单元格中

| -

|风格=“文本对齐:中心” | [ ||如果指针下的单元格为0,则跳过匹配]

| -

|风格=“文本对齐:中心” | ] ||跳回匹配[如果指针下的单元格非零

|}

允许任何单元格大小,EOF( E nd- O - F ile)支持是可选的,无论您是否有有界或无界内存。

## Instructions
## Tests
```yml tests: - text: brain(bye)应该重新调整一个字符串 testString: assert(typeof brain(bye) === 'string'); - text: brain("++++++[>++++++++++<-]>+++++.")++++++++++<-]>+++++."),"A"); - text: brain(bye)应该回归Goodbye, World!\\r\\n testString: assert.equal(brain(bye), 'Goodbye, World!\r\n'); - text: brain(hello)应该回归Hello World!\\n testString: assert.equal(brain(hello), "Hello World!\n"); - text: brain(fib)应该返回1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 testString: assert.equal(brain(fib), "1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89"); ```
## Challenge Seed
```js function brain (prog) { // Good luck! } ```
### Before Test
```js let fib=`+ ++ +++ ++++ +>+>> >>++++ +++++++ ++++++++ +++++++++ ++++++++++ ++++++>++++ ++++++++++++ +++++++++++++ +++<<<<<<[>[>> >>>>+>+<<<<<<<- ]>>>>>>>[<<<<<<< +>>>>>>>-]<[>++++ ++++++[-<-[>>+>+<< <-]>>>[<<<+>>>-]+<[ >[-]<[-]]>[<<[>>>+<< <-]>>[-]]<<]>>>[>>+>+ <<<-]>>>[<<<+>>>-]+<[> [-]<[-]]>[<<+>>[-]]<<<< <<<]>>>>>[++++++++++++++ +++++++++++++++++++++++++ +++++++++.[-]]++++++++++<[ ->-<]>+++++++++++++++++++++ +++++++++++++++++++++++++++. [-]<<<<<<<<<<<<[>>>+>+<<<<-]> >>>[<<<<+>>>>-]<-[>>.>.<<<[-]] <<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+ >-]>[<+>-]<<<-]`; let hello='++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.' let bye='++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>>>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++.<+++++++.--------.<<<<<+.<+++.---.'; ```
## Solution
```js // solution required ```