Skip to content

Instantly share code, notes, and snippets.

@joladev
Last active December 25, 2015 06:49
Show Gist options
  • Save joladev/6934594 to your computer and use it in GitHub Desktop.
Save joladev/6934594 to your computer and use it in GitHub Desktop.
/*
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 = [];
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("");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment