Skip to content

Instantly share code, notes, and snippets.

@dastinnette
Last active March 26, 2016 23:42
Show Gist options
  • Save dastinnette/4a11e599e423a1e7833d to your computer and use it in GitHub Desktop.
Save dastinnette/4a11e599e423a1e7833d to your computer and use it in GitHub Desktop.
Comparing my exercism submissions to other solutions

Leap

My Code

Other Solutions

  • Solution 1 - This person used an approach similar to my own but included an explicit if else statement. This makes the code more readable, but refactoring is possible.
  • Solution 2 - This person used a more variable oriented approach. It's interesting to see them store the modulo result to a variable and run that through an if/else statement. Refactoring possible, but fairly concise solution.
  • Solution 3 - This is a very concise solution, similar to my own, yet they have omitted parenthesis making this code slightly less readable. A good example of when refactoring is taken to an unnecessary extreme.
  • Solution 4 - This solution is concise yet very readable. I like the explicit variable names, repeated yet intuitive calculations that go into each variable, and overall flow of this method. It's not completely DRY, but I think more than makes up for it with superior readability.
  • Solution 5 - This person used an approach similar to mine with the addition of variables storing function return values. I'm sensing more refactored solutions use the prototype method, a powerful function I should master how to use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment