Skip to content

Instantly share code, notes, and snippets.

@amcrawford
Last active February 7, 2016 17:53
Show Gist options
  • Save amcrawford/e3e03be612fc27249d4a to your computer and use it in GitHub Desktop.
Save amcrawford/e3e03be612fc27249d4a to your computer and use it in GitHub Desktop.
Exercism Comparisons

##Bob My code: here

  • Responder #1 (here) - This person refactored by pulling the conditional input types out into variables which makes his code look a lot cleaner. He also uses 'switch' and 'case' instead of 'if' statements.
  • Responder #2 (here) - This person did pull some of the logic out into variables, but specifically for regular experessions. She also used regular expressions to seach for a question mark instead of comparing the last character like I did.
  • Responder #3 (here) - This person followed the similar pattern of pulling the logic out into variables but also saved the core 'if-statement' into a variable and then returned that variable, which was interesting.
  • Responder #4 (here) - This person pulled all of the logic out into separate methods which each stated to return true or false. It ended up being a bit wordy and has already gotten some feedback that he can use the result of his comparison statements instead of directly returning the booleans true or false.
  • Responder #5 (here) - This person's looks a lot like mine but I actually really like their use of the method 'trim' instead of the regular expressions to find the 'silent' phrases.

##RNA Transcription My code: here

  • Responder #1 (here) - This person used regex as well as a replace function instead of splitting, overwriting and then joining the characters again, which was pretty interesting.
  • Responder #2 (here) - This person created a long if-statement instead of using the hash dictionary of pairs and pushed into an empty array which definitely works but I think the hash dictionary is a bit cleanr here.
  • Responder #3 (here) - This person used a for-loop and also long if-statement similar to #2. He also only used 'ifs' instead of 'else ifs' which I haven't seen.
  • Responder #4 (here) - This person used 'this' instead of calling down to the method through the prototype chain, 'DnaTranscriber.prototype.toRna'. I'm not sure which is the preferred way with javascript but it's interesting to see.
  • Responder #5 (here) - This person also used the for-loop with long if statement in their function.

##Hamming My code: here

  • Responder #1 (here) - This person set a conditional at the beginning to break if the two strings equalled each other to avoid the comparison loop. Would this save computation time? Otherwise it seems redundant.
  • Responder #2 (here) - This looks a lot like my solution though this person used the (var++) to increment their count which is great!
  • Responder #3 (here) - This looks a lot like the last one though also sets an early conditional to set the different count to 0 right away if the strings are equal.
  • Responder #4 (here) - This person uses a while loop instead of the for loop in most of the others but otherwise creates a similar solution.
  • Responder #5 (here) - This solution looks a lot like mine.
@rrgayhart
Copy link

👍

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