I love CodeWars as a supplement to the FCC algorithm challenges. With CodeWars you can find easier / harder problems to solve so that you can reinforce your learning along with the FCC challenges. So I decided to do a monthly curation of my favourite code kata’s on my FCC portfolio website:
I had signup for CoderWars a while ago before joining FCC. Thanks for reminding me about the site as it does compliment many of the challenges on FCC as well as to expose me to new ones. It is a great way to broaden my approach to solving problems. I will update this post with my favourite code kata as I resume CodeWars and hone my coding skills.
Awesome, yeah it is the perfect tool to learn new approaches and work on easier problems, which really gives you a chance to tackle the FCC problems. I found the FCC challenges to be really hard, and so I just stuck with 8 KYU codewars challenges for a looooong time.
\5. And I still don’t know how to make classes in Js…
I’d say my favorite (read hardest one I’ve done) is creating a function that takes as input a number is seconds and returns a string of how many minutes, hours, days and years it is. in format “3 hours, 1 minute and 30 seconds” or “2 years and 5 days” Notice the output adjusting for a singular number. It’s a Kata 4
AWESOME!! Such good work, well done.
And for Number 5 you don’t need to know Classes, I’m not so crash hot at Object Oriented JS, but still managed… Do you want me to post my answers here??
Here’s my version of number 5 – it can surely be refactored!!!
I’m currently stuck on Snail. Seems like one of the coolest Kata I’ve attempted nonetheless. If anyone’s completed it and wants to drop a tip (but not a spoiler!) it would be much appreciated!
I solved it, testing everything from a 3x3 to a 6x6 (1 - 36). I traced a given input, doing a loop in my head and realized if the array was even, it would be for example (array is 8 x 8, you’d go through it 12 times. If it’s 4 you’d go through it 6 times). If it was odd, for example 9 you’d still go through it 13 times. If it’s 5 you’d go through it 7 times.
Within the entire loop I first pushed the entire first nested array into a variable result (which I created outside of the loop obviously). I then splice it from the array. Then I added two sepparate loops within entire, one called down and the other called up. In between I push the entire last nested array, reversed, into result. Then splice it out.
Down starts at 1 (array[0] has been pushed in its entirety and spliced away at this point) and goes up while it’s less than array.length - 1. For each index it pushes, then splices the last index of each nested array.
Then I push the final nested array, reversed into result and splice it away.
Then up starts at array.length - 1 and goes to 0. For each index, it pushes the first index of the nested array and splices it away.
I then concat result together with a reduce function.
In some cases (when the array was large and even), there ended up being an ‘undefined’ at the end, so I did an if statement testing whether ‘undefined’ was included in result. If so, I pop it away. Then return result.
Hmm, quite a lot of detail - thanks but I think I’d have to call that a spoiler! I solved it before reading your answer in though so I’m claiming my points. From what you write it seems we did something similar but not the same.
I (spoiler alert!) created 4 loops to cover the 4 sides of the matrix, first extracting the values to a new array and then cutting the extracted values out; this way the matrix gets smaller and smaller and I just keep repeating the same 4 steps (extracting from the sides) until array.length == 0, at which point return.
Yeah it sounds like a sweet problem, but I think 4kyu is a bit out of my league… I’m trying to get solid at 6kyu at the moment ! Have just finished my front end cert!!
I enjoyed solving katas from kyu2 and 3. Katas from kyu > 3 were quite boring. If I feel like solving a simple challenge, I’d rather go for a clash at codingame.