Skip to content

Instantly share code, notes, and snippets.

@joladev
Last active December 25, 2015 06:49

Revisions

  1. Erik Kronberg revised this gist Oct 11, 2013. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions notquine.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,17 @@
    /*
    Description:
    Write a function 'notQuine' which returns a string containing every ASCII character that is NOT part of the source code of the function.
    The outer 'function () { }' wrapper is included.
    A function containing all of the characters is not a valid solution.
    You may not modify Function.prototype.toString, notQuine.toString, String.indexOf, or String.fromCharCode.
    Only return characters from ASCII code 32 to 254. Order does not matter.
    */

    var notQuine = function(){
    var ascii = function () {
    var result = [];
  2. Erik Kronberg created this gist Oct 11, 2013.
    21 changes: 21 additions & 0 deletions notquine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var notQuine = function(){
    var ascii = function () {
    var result = [];
    for (var i = 32; i < 255; i++) {
    result.push(i);
    }
    return result;
    };

    var code = notQuine
    .toString()
    .split("")
    .map(function (c) {
    return c.charCodeAt(0);
    });

    return ascii()
    .filter(function (c) { return code.indexOf(c) === -1; })
    .map(function (c) { return String.fromCharCode(c); })
    .join("");
    };