The anagrams kata is a beginners kata.
It's purpose is to get acquinted how this works.
Make the solution as well readable as possible
Since the kata is not about showing how smart you are, but about learning to do the solution as well as possible, I give you a hint on how you can determine if two words are anagrams.
Two words are anagrams if they have the same "signature"
const generateSignature = (word) => {
// only working for non accentuated, non heavy metal umlauted languages, e.g. english
word = word.replace(/\W/g, '');
return word.toLowerCase().split('').sort().join('')
};
- Try this kata as a NodeJS commandline programm.
- Dont install any external modules, but use the default
- Create a terminal programm that reads in a list of words and prints out all anagrams.
Two words are considered anagrams if they contain the same letters in the same amount. Casing (lowercase/uppercase) should be ignored.
Skip/delete non letter characters like a ' - Output all anagrams line by line comma seperated like this:
stow, swot, tows, twos
if you got time, add these features to it
- add tests for your functions/classes/methods
I already set up the testing with jasemine
so you can run all tests wit
npm run test
- Make the programm take the wordfile as a commandline argument.
- Make the programm output only anagramms that have more than 5 annagrammatic words
- Make the programm take another commandline parameter, that is the number of annagrammatic words that are the minimum to get printed
- add a counter to the output (how many annagrammatic words per line)
- add a counter as last row, how many annagram lines were printed
- what was the most cumbersome in this kata? in nodejs?
- how much effort was it to put some additionals in?
- how much did you have to change existing functions/classes/methods/signatures to fit in more/other functionality?