Created
August 10, 2018 18:30
-
-
Save jaf7/22b3b40f8c86338d82fb095dbc4a7c61 to your computer and use it in GitHub Desktop.
Bluecore Coding Assessment
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
// Question 1 | |
function incorrectChars( input, output) { | |
const inputString = input.toLowerCase(); | |
const outputString = output.toLowerCase(); | |
const multiple = outputString.length / inputString.length; | |
let incorrect = 0; | |
for ( let i = 0; i < outputString.length - inputString.length; i + inputString.length ) { | |
const outputSubString = outputString.substring(i, i+inputString.length); | |
console.log('outputSubString: ' + outputSubString) | |
if ( outputSubString !== inputString ) { | |
incorrect ++; | |
} | |
} | |
return incorrect; | |
} | |
// Question 2 | |
function hasPalindrome( str ) { | |
const allPermutations = str + str | |
for ( let i = 0; i < allPermutations.length - str.length; i++) { | |
console.log(''); | |
} | |
function areAnagrams(stringA, stringB) { | |
return sorted(stringA) === sorted(stringB); | |
} | |
function sorted(str) { | |
let cleaned = str.replace(/ /g, '') | |
.toLowerCase() | |
.split('') | |
.sort() | |
.join(); | |
return cleaned; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment