Skip to content

Instantly share code, notes, and snippets.

@NateAnderson1780
Last active November 27, 2016 23:20
Show Gist options
  • Save NateAnderson1780/878ac5bc5b1e27b6c5a45d5ecf06a50c to your computer and use it in GitHub Desktop.
Save NateAnderson1780/878ac5bc5b1e27b6c5a45d5ecf06a50c to your computer and use it in GitHub Desktop.

##Leap My code: here

  • Responder #1 (here) - This responder was able to only use one if/else statement with a full line of and/or to differentiate between the modulo difference. This definitely increases efficiency.

  • Responder #2 (here) - This responder uses a similar structure to my submission but uses a bang on the modulo comparison. I would assume the bang in this case means no remainder, because this will return true in these cases.

  • Responder #3 (here) - This responder omits the if/else statements entirely and goes right to the return statement for a very elegant solution. Not a fan of the underscore first letter variable though.

  • Responder #4 (here) - This responder has submitted a very similar solution to mine but ends the if/else on the last conditional which is probably more efficient than making that last check.

  • Responder #5 (here) - This last responder combines the conditionals for the 400 year and 100 year modulo comparison while leaving the 4 year modulo alone. It ends up saving a couple lines.

##Hamming My code: here

  • Responder #1 (here) - This responder's solution is very similar to mine but uses 'let' to set the difference variable at the beginning of the function. Otherwise, almost identical.

  • Responder #2 (here) - This responder splits their strings into arrays before comparing them but other than that, it is another solution very similar to mine.

  • Responder #3 (here) - This responder includes a nice check before iterating through the two strings to check if they are equal. Seems to be slightly more efficient if there are instances where they would be exactly the same.

  • Responder #4 (here) - This responder uses a class rather than a function the difference calculator only if the lengths are the same. I did not see many people attempt to do it this way so it was interesting.

  • Responder #5 (here) - This responder actually uses reduce after they split the original string to add the differences as they are compared. I thought it was pretty creative.

##RNA Transcription My code: here

  • Responder #1 (here) - This responder uses a very nice direct replace which uses very few lines and looks a lot cleaner than my implementation, but maybe not as readable.

  • Responder #2 (here) - This responder uses case statements and the switch method to also directly replace the specific letter. Extremely readable and pleasing to the eye.

  • Responder #3 (here) - This responder uses a for loop and if statements to catch the letters that need to be changed. Another pretty readable solution and becoming interesting how many different varieties of implementations can be used for one fairly simple problem.

  • Responder #4 (here) - This responder uses a hash which is very similar to my implementation and then uses a for loop to map through the original DNA. I like how similar it is to mine, but with subtle changes.

  • Responder #5 (here) - This responder immediately puts the RNA and DNA letters into their own separate arrays and then maps through to compare the string given with each array to replace them. Seems creative but a little roundabout to execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment