js1 |
for (var i = 0; i < arr.length; i++) { if (answers[i] !== PatternChaser(arr[i])) { console.log('Sam P failed test ' + i); throw 'failed test ' + i; } }
function PatternChaser(str) { var i = 0; var strLength = str.length; var ptrMaxLength = Math.floor(strLength / 2);
while (ptrMaxLength > 1) { testLength = 1 + strLength - (ptrMaxLength * 2);
for (; i < testLength; i += 1) { if (str.indexOf(str.substr(i, ptrMaxLength), i + ptrMaxLength) > -1) { return "yes " + str.substr(i, ptrMaxLength); } } ptrMaxLength -= 1; i = 0; } return "no null"; }
|
pending… |
js2 |
for (var i = 0; i < arr.length; i++) { if (answers[i] !== PatternChaser(arr[i])) { console.log('Sam P failed test ' + i); throw 'failed test ' + i; } }
function PatternChaser(str) { var i = 0; var strLength = str.length; var ptrMaxLength = Math.floor(strLength / 2); var maxPosLength = (strLength + 1) - (ptrMaxLength + ptrMaxLength);
while (ptrMaxLength > 1) { var testStr, passIndex = null; for (i = 0; i < maxPosLength; i += 1) { testStr = str.substr(i, ptrMaxLength); passIndex = i + ptrMaxLength - 1; if (str.lastIndexOf(testStr) > passIndex) { return "yes " + testStr; } } ptrMaxLength -= 1; maxPosLength += 2; } return "no null"; }
|
pending… |
js3 |
for (var i = 0; i < arr.length; i++) { if (answers[i] !== PatternChaser(arr[i])) { console.log('Sam P failed test ' + i); throw 'failed test ' + i; } }
function PatternChaser(str) { var strLength = str.length; var ptrMaxLength = Math.floor(strLength / 2); var maxPosLength = (strLength + 1) - (ptrMaxLength + ptrMaxLength);
while (ptrMaxLength > 1) { var i, testStr, passIndex = null; for (i = 0; i < maxPosLength; i += 1) { testStr = str.substr(i, ptrMaxLength); passIndex = i + ptrMaxLength - 1; if (str.lastIndexOf(testStr) > passIndex) { return "yes " + testStr; } } ptrMaxLength -= 1; maxPosLength += 2; } return "no null"; }
|
pending… |
js4 |
for (var i = 0; i < arr.length; i++) { if (answers[i] !== PatternChaser(arr[i])) { console.log('Sam P failed test ' + i); throw 'failed test ' + i; } }
function PatternChaser(str) { var i = 0; var strLength = str.length; var ptrMaxLength = Math.floor(strLength / 2); var maxPosLength = (strLength + 1) - (ptrMaxLength + ptrMaxLength);
while (ptrMaxLength > 1) { for (i = 0; i < maxPosLength; i += 1) { testStr = str.substr(i, ptrMaxLength); passIndex = i + ptrMaxLength - 1; if (str.lastIndexOf(testStr) > passIndex) { return "yes " + testStr; } } ptrMaxLength -= 1; maxPosLength += 2; } return "no null"; }
|
pending… |
js5 |
for (var i = 0; i < arr.length; i++) { if (answers[i] !== PatternChaser(arr[i])) { console.log('Sam P failed test ' + i); throw 'failed test ' + i; } }
function PatternChaser(str) { var strLength = str.length; var ptrMaxLength = Math.floor(strLength / 2); var maxPosLength = (strLength + 1) - (ptrMaxLength + ptrMaxLength); var i, testStr, passIndex = null; while (ptrMaxLength > 1) { for (i = 0; i < maxPosLength; i += 1) { testStr = str.substr(i, ptrMaxLength); passIndex = i + ptrMaxLength - 1; if (str.lastIndexOf(testStr) > passIndex) { return "yes " + testStr; } } ptrMaxLength -= 1; maxPosLength += 2; } return "no null"; }
|
pending… |
0 comments