Problem 1187. Knave in the middle attack
Solution Stats
Problem Comments
-
5 Comments
Broken test suite? The handle wont work in some cases
Yes, it seems that test suit is wrong. cases 13 e 14 won't work.
For instance from case 13:
A=false; X=@(x)rem(x,2); str='F(''F(''''X(3)'''')'')';
f0=inline('logical(interp1([0,1],[0,x],1))','x','A','X');
F=@(str)xor(~A,f0(eval(str),A,X));
if I execute F(str) inside my function AnswerGenerator it complains...
Error using eval
Unrecognized function or variable 'F'.
It seems the syntax is wrong. So we cannot know what the answer would be from the knight or the knave (I'm trying to fix the string input).
So I was able to fix the strings (str) manually using replace. Previous solutions won't work, so I guess the test cases were changed and broken. Please ignore my solution if this is fixed later on (it's only right for now, fixing it and evaluating it manually is a pain). I will resubmit a proper solution when it is fixed and I see it fixed.
Problematic test cases have been commented out. Hopefully, @Alfonso will get around to fixing this.
thanks for the heads up and temporal fix. I am still looking into this, it seems that the issue was probably a change in memory-management affecting function handles in some of the more recent Matlab releases, and I should probably just change the way I implement the Knight/Knave answer function to explicitly allow self-references...
Problem Recent Solvers14
Suggested Problems
-
Calculate the Levenshtein distance between two strings
944 Solvers
-
Back to basics 8 - Matrix Diagonals
881 Solvers
-
Find best placement for ordered dominoes (harder)
266 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
751 Solvers
-
The Answer to Life, the Universe, and Everything
477 Solvers
More from this Author38
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!