Skip to content

Instantly share code, notes, and snippets.

@JaredRoth
Last active July 5, 2016 09:07
Show Gist options
  • Save JaredRoth/7c7f8c01062c0c21a9aba3a91cb7270b to your computer and use it in GitHub Desktop.
Save JaredRoth/7c7f8c01062c0c21a9aba3a91cb7270b to your computer and use it in GitHub Desktop.

Rna Transcription

  • Code
  • Similar: Use of temp string to collect result
  • Different: Their use of if tree vs my hash; their toUppercase safety net.
  • Code
  • Similar: Hash for nucleotide pairs
  • Different: Split/map/join vs for/index
  • Code Same as previous.
  • Code Same as previous two (seems to be popular)
  • Code Pretty much the same as the first example In two ways, there seems to generally be two schools of thought:
  • split/map/join vs for/index (I prefer the latter)
  • if tree vs hash (also prefer the latter)

Leap

  • Code
  • Similar: Not much except for the conditions themselves that are manditory for the spec to pass.
  • Different: Initialized result to false; multiple / nested if statements (same logic as my boolean expressions, just more verbose); strict comparisons vs my abstract (=== vs ==)
  • Code Without running the code against the spec, I'm not even sure this solution works. It is a series of individual if statements that don't seem to handle all the cases correctly. If so, it looks very clean, but was harder for me to interpret.
  • Code Abstracts all the conditions into separate variables and then sets up the same boolean expression using those. Much cleaner and easier to understand. Still uses an if tree to return true/false rather than just the result of the expression.
  • Code I don't actually understand the syntax used to create his method, but it makes for an wonderfully clean and easy to interpret solution, although it does appear that his boolean expression needs to be grouped to calculate properly.
  • Code Very similar to the second solution.

Hamming

  • Code Practically identical solution. Marginally different syntax for throwing an error (Ihave no idea if I'm really doing it right or not) and declares the count before the error whereas I do it after.
  • Code On repeat here. See the above comment. (Except the throw syntax is slightly different in a different way...)
  • Code Again, the basic loop logic is identical, it's the setup that seems to have the variation. I like to initiate after the error for the insignificant 'performance' gain of not creating an unused variable (or two, in this case: He inexplicable creates a length variable for one string, but not the other. ).
  • Code Again, practically identical. Not a lot of variation in these solutions.
  • Code Primary difference here is that the loop is wrapped in the trailing else statement of the error rather than just sitting outside. Functionally the same, just a little more cluttered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment