Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- var words = input[0].split(/\W/).filter(Boolean);
- var foundwords = "";
- var found = false;
- for (var first = 0; first < words.length; first++) {
- for (var second = 0; second < words.length; second++) {
- for (var third = 0; third < words.length; third++) {
- if (first != second && first != third && second != first && second != third && third != first && third != second) {
- if (words[first] + words[second] == words[third]) {
- if (foundwords.indexOf(words[first] + "|" + words[second] + "=" + words[third]) == -1) {
- foundwords += words[first] + "|" + words[second] + "=" + words[third] + "\n";
- found = true;
- }
- }
- }
- }
- }
- }
- if (!found) {
- return "No";
- } else {
- return foundwords
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement