Skip to content

Instantly share code, notes, and snippets.

@chadellison
Last active June 30, 2016 18:45
Show Gist options
  • Save chadellison/b2b43bfccf42701f6ebf2f895319e015 to your computer and use it in GitHub Desktop.
Save chadellison/b2b43bfccf42701f6ebf2f895319e015 to your computer and use it in GitHub Desktop.
##Leap
My code: http://exercism.io/submissions/714b4da37a15469fb6090b0a6eb206d5
* user #1 ([here](http://exercism.io/submissions/08fb2ad5e90d4bda802530565c868752)) - This user solved the problem pretty much the same way I did. He used if / else conditionals; whereas, I used a the && and || operator. I also broke mine out into a separate function.
* user #2 ([here](http://exercism.io/submissions/7e61b46cf54a473b82fb0a5d919fa0c0)) - This user broke the problem out into two functions as well. Our approaches were very similar except he is evaluating local variables inside the method instead of evaluatng the result of the method call.
* user #3 ([here](http://exercism.io/submissions/3134dcfb07df4977b7a62ad3d9daafd8)) - This user handled the entire if / else condition. The option seems very straight forward and is easy to follow.
* user #4 ([here](http://exercism.io/submissions/d2ff8f9e1aad445cb5641647379d0d7e)) - I have not seen this syntax before "isLeap: function()" for defining a function. This code seems very straightforward. It is easy to follow, but there is some repition with "this.year % (some number)". Perhaps this could be broken out into a separate function.
* user #5 ([here](http://exercism.io/submissions/a125b0e104cb42f9a66c9eb60e64b0f4)) - This user's approach is very similar to user # 4's. He did not break the function out into a separate function which would have been nice to eliminate the repition of "this.year % (some number)". Even though I personally find it easier to read without it being broken out, it seems like the convention is to break it out as much as possible for single responsibility and DRY.
##Hamming
My code: [here](http://exercism.io/submissions/c54c54ef556a49d788d1780050b44b02)
* user #1 ([here](http://exercism.io/submissions/86019762a6ae47b1bd978a64b7f07797)) - This person's code is much cleaner and clearer than mine. I have an if / else if loop nested in a conditional; whereas, she solved it by simply using an if. I could definitely refactor mine to look like this.
* user #2 ([here](http://exercism.io/submissions/385c9064e90e4295aacc29ed367a1416)) - Similar to the first user, this user solved the problem with just "if" instead of if / else if. The differences between this user and the first user are that this user throws an error if the strands are not equal length and the first user was more explicit in her variable naming. She used "dna"; whereas, this user just used "string".
* user #3 ([here](http://exercism.io/submissions/84427312947e4338b86a126985fcf7c0)) - This user used a "charAt" method instead of indexing with the "i" variable. I have no idea if there is a preferred way between these two in Javascript. The user's approach seems similar to the previous too other than that.
* user #4 ([here](http://exercism.io/submissions/b2f9d77b8db540d9a3d2e9cc3e9c4d74)) - This user's approach is very similar to the prior user's. It is very clear and easy to understand. This user has very explicit variable names ("firstStrand", "secondStrant"). The use of comments enhance the clarity as well. This one is the clearest for me thus far.
* user #5 ([here](http://exercism.io/submissions/ebffd37e170c4efbb4baad9cb10c1838)) - This approach is also very similar to the previous 4. It is very clear and concise. The simple if conditionals make it easier to apprehend than the if / else conditionals.
##Bob
My code: [here](http://exercism.io/submissions/513b68a994a34df4b221388092fb5043)
* user #1 ([here](http://exercism.io/submissions/e3c314e2e7a849479a69b1256455af3b)) - This user has an if / elsif conditional to solve this problem. I really like his use of regex to check the response. I ended up evaluating two other booleans in that "if" branch to check, which feels very clunky. The regex is both more efficient and clear.
* user #2 ([here](http://exercism.io/submissions/9753ac67bd3b451fa3e953db8c9331be)) - This user's approach is very similar to the first user's. This user, however, only used one regex expression instead of two. The user handled the second branch with "trim". This user also placed the "elses" below the "}" rather than on the same line. This makes things more understandable visually.
* user #3 ([here](http://exercism.io/submissions/bd267bd9c38845e58e2d5a9406ce7b99)) - This user pretty much only used regex to solve the problem. This really makes me want to get better at regex. In a matchers variable the user handles each case. It is very straightforward and clean. It is harder for me to understand simply because I'm not as familiar with regex.
* user #4 ([here](http://exercism.io/submissions/8c74f8fcf4b446ea8fa1e5efc514c267)) - This user's approach is similar users 1 and 2 in regards to the use of regex; however, this user used three "if" statements rather than using "else if". I think I prefer this way, atleast in this case. It is just as clear and perhaps more simple.
* user #5 ([here](http://exercism.io/submissions/5619a6e6556b4fb8937ddea68f0276c2)) - This user took a very similar approach to user 4. She just put her "return" statements on a new line. I like her use of regex and slice. This is probably the cleanest / most readable solution to Bob that I have seen. The "if / returns" are very explicit and readable on the new lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment