Skip to content

Instantly share code, notes, and snippets.

@bheim6
Last active November 22, 2016 03:07
Show Gist options
  • Save bheim6/eb909b521d3e63edf95af5d3fa1099ae to your computer and use it in GitHub Desktop.
Save bheim6/eb909b521d3e63edf95af5d3fa1099ae to your computer and use it in GitHub Desktop.

Brian Heim Exercism

##Leap My code: here

  • Responder #1 (here) - This solution is similar to mine butmore elegant, using only two lines of conditionals.
  • Responder #2 (here) - Another elegant solution, but even fewer lines than the first, and handles the definition of a leap year very nicely in my opinion. The statement first checks the obvious year % 4 == 0, then checks whether or not it is divisible by 100 and 400 to make the final determination.
  • Responder #3 (here) - This solution is similar to responder #2, but I like the way that they separated the logic to check 400 % == 0 first, then check whether or not it qualifies as a leap year by checking 4 and 100 next.
  • Responder #4 (here) - This solution is similar the the previous two, however the responder introduces (this.year / 4) % 2 === 0, adding the extra % 2 for what reason I do not know.
  • Responder #5 (here) - This solution is very difficult to read for such a simple problem. The code is written in a way that it is not obvious at first glance what each if statement will return, the use of nested if statements is not very clean in my opinion.

##Hamming My code: here

  • Responder #1 (here) - This solution is similar to mine, except the responder used one if statement and a nested for loop inside the else.
  • Responder #2 (here) - This solution is similar to mine as well, however this responder did not include the error statement.
  • Responder #3 (here) - Jesse's solution differs form mine quite a bit, he had his function return whether or not the strings were the same size, then return the hamming count, and an error if the strands were not of equal length. He accomplished this with multiple functions instead of just one long one.
  • Responder #4 (here) - The responder's solution uses a similar for loop to mine, but handles throwing the error and the for loop as part of the same if statement.
  • Responder #5 (here) - This solution is very similar to mine, but the respinder's for loop handles incrementing the count with different syntax.

##RNA Transcription My code: here

  • Responder #1 (here) - This approach was really neat to me. The responder used a case statement inside of a for loop to achieve the solution.
  • Responder #2 (here) - I liked Jesse's use of a hash to store the RNA - DNA values, he elimitated the need for an if statement, which I think is a very creative solution.
  • Responder #3 (here) - This responder did not need an if statement either, but instead used two arrays and their index to match up the RNA nucleotides to their DNA counterpart.
  • Responder #4 (here) - The responder here used ternary statements to push values into his RNA array depending on the DNA strand that was input into the function. This is similar to my solution except the responder used an array instead of a string.
  • Responder #5 (here) - This solution was very similar to mine, except I did not end my loop with else, I sloppily used else if.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment