Cody

# Problem 1189. Knights and Knaves (part 3)

Solution 1761162

Submitted on 25 Mar 2019 by Sean Kavanagh
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
KNIGHT=true; PASSWORD='PASSWORD'; g=inline('logical(interp1([0,1],[0,x],1))','x','KNIGHT','PASSWORD'); F=@(str)xor(~KNIGHT,g(eval(str),KNIGHT,PASSWORD)); clear g KNIGHT PASSWORD; assert(isequal(solver(F),'PASSWORD'))

2   Pass
KNIGHT=false; PASSWORD='PASSWORD'; g=inline('logical(interp1([0,1],[0,x],1))','x','KNIGHT','PASSWORD'); F=@(str)xor(~KNIGHT,g(eval(str),KNIGHT,PASSWORD)); clear g KNIGHT PASSWORD; assert(isequal(solver(F),'PASSWORD'))

3   Pass
KNIGHT=false; PASSWORD='DONOTPANIC'; g=inline('logical(interp1([0,1],[0,x],1))','x','KNIGHT','PASSWORD'); F=@(str)xor(~KNIGHT,g(eval(str),KNIGHT,PASSWORD)); clear g KNIGHT PASSWORD; assert(isequal(solver(F),'DONOTPANIC'))

4   Pass
KNIGHT=true; PASSWORD='FORTYTWO'; g=inline('logical(interp1([0,1],[0,x],1))','x','KNIGHT','PASSWORD'); F=@(str)xor(~KNIGHT,g(eval(str),KNIGHT,PASSWORD)); clear g KNIGHT PASSWORD; assert(isequal(solver(F),'FORTYTWO'))

5   Pass
KNIGHT=false; PASSWORD='PLEASELETMEIN'; g=inline('logical(interp1([0,1],[0,x],1))','x','KNIGHT','PASSWORD'); F=@(str)xor(~KNIGHT,g(eval(str),KNIGHT,PASSWORD)); clear g KNIGHT PASSWORD; assert(isequal(solver(F),'PLEASELETMEIN'))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!