Created
January 7, 2011 23:24
-
-
Save dawnerd/770299 to your computer and use it in GitHub Desktop.
Meow
This file contains hidden or 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
var letters = "apples".split("").sort().join(""), words = ["pale", "ales", "ape", "grape", "pape", "pppp"]; | |
document.writeln("Matching words to: " + letters); | |
for(var i = 0, c = words.length; i < c; i++) { | |
var word = words[i].split("").sort().join(""), status = true, usedChars = []; | |
for(var ii = 0, cc = word.length-1; ii < cc; ii++) var lidx = letters.indexOf(word[ii], ii), idx = usedChars.indexOf(lidx), status = ((idx == -1 && lidx != -1) ? new Boolean(usedChars.push(lidx)) : false); | |
document.writeln(words[i] + " " + status); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var letters = "apples".split("").sort().join(""),
words = ["pale", "ales", "ape", "grape", "pape", "pp"];
document.writeln("Matching words to: " + letters);
for(var i = 0, c = words.length; i < c; i++) {
}