--- title: Execute a Markov algorithm id: 59e09e6d412c5939baa02d16 challengeType: 5 videoUrl: '' localeTitle: '' --- ## Description undefined ## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert(typeof markov === "function", "markov is a function.");' - text: '' testString: 'assert.deepEqual(markov(rules[0],tests[0]),outputs[0],"markov(["A -> apple","B -> bag","S -> shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.") should return "I bought a bag of apples from my brother.".");' - text: '' testString: 'assert.deepEqual(markov(rules[1],tests[1]),outputs[1],"markov(["A -> apple","B -> bag","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.") should return "I bought a bag of apples from T shop.".");' - text: '' testString: 'assert.deepEqual(markov(rules[2],tests[2]),outputs[2],"markov(["A -> apple","WWWW -> with","Bgage -> ->.*","B -> bag","->.* -> money","W -> WW","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As W my Bgage from T S.") should return "I bought a bag of apples with my money from T shop.".");' - text: '' testString: 'assert.deepEqual(markov(rules[3],tests[3]),outputs[3],"markov(["_+1 -> _1+","1+1 -> 11+","1! -> !1",",! -> !+","_! -> _","1*1 -> x,@y","1x -> xX","X, -> 1,1","X1 -> 1X","_x -> _X",",x -> ,X","y1 -> 1y","y_ -> _","1@1 -> x,@y","1@_ -> @_",",@_ -> !_","++ -> +","_1 -> 1","1+_ -> 1","_+_ -> "],"_1111*11111_") should return "11111111111111111111".");' - text: '' testString: 'assert.deepEqual(markov(rules[4],tests[4]),outputs[4],"markov(["A0 -> 1B","0A1 -> C01","1A1 -> C11","0B0 -> A01","1B0 -> A11","B1 -> 1B","0C0 -> B01","1C0 -> B11","0C1 -> H01","1C1 -> H11"],"") should return "00011H1111000".");' ```
## Challenge Seed
```js function markov (rules,test) { // Good luck! } ```
## Solution
```js // solution required ```