Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- 'anagram',
- '6',
- 'gramana',
- 'aaagrnm',
- 'anagra',
- 'margana',
- 'abc',
- 'xy'
- ]3
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let W = gets().split('')
- let NumberOfWords = gets()
- let matchedArr = []
- console.log(W)
- console.log(NumberOfWords)
- let checkAnagram = function(W, WORDS){
- if(WORDS.length !== W.length){
- console.log('No')
- }
- for(let i = 0; i < W.length; i++){
- for(let j = 0; j < WORDS.length; j++){
- if(W[i] === WORDS[j]){
- matchedArr.push(WORDS[j])
- }else if (W[i] !== WORDS[j]){
- matchedArr.length = 0
- }
- }
- }
- }
- for(let i = 0; i < NumberOfWords; i++){
- let WORDS = gets().split('')
- let result = checkAnagram(W, WORDS)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement