Elegance - codewars

Posted by r0tiart on February 9, 2018

Your first iteration over a code need not be elegant. A lesson I have learned, sometimes the best solutions are the most straight forward ones. Multiple for loops, nested foor loops… it doesn’t need to be efficient at first. Getting something more efficient is tricker but sometimes it’s just best to get the answer first. I’ve been practicing this via codewars, just solve the puzzle, worry about elegance later.

Compared to best practice or clever approaches mine seems messy in a sense - way more lines of code then “necessary”. But I got the job done.

Another thing i’ve been noticing a lot of on codewars is the tendency for questions to be math oriented. There is a lot of functions on the JS Math object that I have never seen before. It’s indeed a whole new experience. I personally try to balance a math question with an equal amount of others. As the math problems tend to require you to have some fundamental knowledge of the mathematical concept vs the other problems have no such requirement. If I don’t understand I find it helpful to just unlock the solution and read the solutions others have come across; I come to understand it, I follow through their code using examples provided in the question to understand what’s returning at every single point.

Breaking down someones solution has it’s own benefits, you learn new methodologies to do things that you have not seen, you are forever learning.