Cody

Solution 195923

Submitted on 24 Jan 2013 by Alfonso Nieto-Castanon
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
x = 'ABCD'; y_correct = 'ABDC'; assert(isequal(nextP(x),y_correct)) x = 'ABDC'; y_correct = 'ACBD'; assert(isequal(nextP(x),y_correct)) x = 'ACBD'; y_correct = 'ACDB'; assert(isequal(nextP(x),y_correct)) x = 'ACDB'; y_correct = 'ADBC'; assert(isequal(nextP(x),y_correct)) x = 'LOVE'; y_correct = 'LVEO'; assert(isequal(nextP(x),y_correct)) x = 'CAST'; y_correct = 'CATS'; assert(isequal(nextP(x),y_correct)) x = 'THEQUICKBROWNFOXJUMPEDOVERTHELAZYDOG'; y_correct = 'THEQUICKBROWNFOXJUMPEDOVERTHELAZYGOD'; assert(isequal(nextP(nextP(x)),y_correct)); s = 1; x = 'ABCDE'; y_correct = 120; y = x; while(1) y = nextP(y); if ( strcmp(x,y) ) break; end s = s+1; end assert(s == y_correct)