Cody

# Problem 1189. Knights and Knaves (part 3)

Solution 1938732

Submitted on 17 Sep 2019
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'))

password = 80 password = 80 65 password = 80 65 83 password = 80 65 83 83 password = 80 65 83 83 87 password = 80 65 83 83 87 79 password = 80 65 83 83 87 79 82 password = 80 65 83 83 87 79 82 68

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'))

password = 80 password = 80 65 password = 80 65 83 password = 80 65 83 83 password = 80 65 83 83 87 password = 80 65 83 83 87 79 password = 80 65 83 83 87 79 82 password = 80 65 83 83 87 79 82 68

3   Fail
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'))

password = 68 password = 68 79 password = 68 79 78 password = 68 79 78 79 password = 68 79 78 79 84 password = 68 79 78 79 84 80 password = 68 79 78 79 84 80 65 password = 68 79 78 79 84 80 65 78 password = 68 79 78 79 84 80 65 78 73

Assertion failed.

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'))

password = 70 password = 70 79 password = 70 79 82 password = 70 79 82 84 password = 70 79 82 84 89 password = 70 79 82 84 89 84 password = 70 79 82 84 89 84 87 password = 70 79 82 84 89 84 87 79

5   Fail
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'))

password = 80 password = 80 76 password = 80 76 69 password = 80 76 69 65 password = 80 76 69 65 83 password = 80 76 69 65 83 69 password = 80 76 69 65 83 69 76 password = 80 76 69 65 83 69 76 69 password = 80 76 69 65 83 69 76 69 84

Assertion failed.