Last active
December 25, 2015 06:49
-
-
Save joladev/6934594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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