Skip to content

Instantly share code, notes, and snippets.

@sydlawrence
Last active December 24, 2015 14:19

Revisions

  1. sydlawrence revised this gist Oct 3, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions under-pressure-cheats.js
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,11 @@ runCode();
    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function longestString(i) { var l = ''; for (var j = 0; j < i.length; j++) if (i[j].length > l.length && typeof i[j] === 'string') l = i[j]; return l; }");
    editor.setValue("function longestString(i) { var l = ''; for (var j in i) if (i[j].length > l.length && typeof i[j] === 'string') l = i[j]; return l; }");
    runCode();

    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function arraySum(i) { var s = 0; for (var j = 0; j < i.length; j++) { if (typeof i[j] === 'number') s += i[j]; if (typeof i[j] === 'object') s += arraySum(i[j]); } return s; }");
    editor.setValue("function arraySum(i) { var s = 0; for (var j in i) { if (typeof i[j] === 'number') s += i[j]; if (typeof i[j] === 'object') s += arraySum(i[j]); } return s; }");
    runCode();
  2. sydlawrence created this gist Oct 3, 2013.
    29 changes: 29 additions & 0 deletions under-pressure-cheats.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // Paste these in chunks into the developer console. BEFORE you press "Start game"

    startGame();
    editor.setValue("function doubleInteger(i) { return i*2; }");
    runCode();

    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function isNumberEven(i) { return !(i%2); }");
    runCode();

    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function getFileExtension(i) { var s = i.split('.'); return (s.length > 1) ? s[1] : false; }");
    runCode();

    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function longestString(i) { var l = ''; for (var j = 0; j < i.length; j++) if (i[j].length > l.length && typeof i[j] === 'string') l = i[j]; return l; }");
    runCode();

    // wait for the previous tests to run and succeed, then paste the next

    runCode();
    editor.setValue("function arraySum(i) { var s = 0; for (var j = 0; j < i.length; j++) { if (typeof i[j] === 'number') s += i[j]; if (typeof i[j] === 'object') s += arraySum(i[j]); } return s; }");
    runCode();