Skip to content

Instantly share code, notes, and snippets.

@bethsecor
Created March 19, 2016 22:22
Show Gist options
  • Select an option

  • Save bethsecor/fa5283c3b8d48a843afc to your computer and use it in GitHub Desktop.

Select an option

Save bethsecor/fa5283c3b8d48a843afc to your computer and use it in GitHub Desktop.

Leap

my code

  • (code) This submission did not use the modulus operator, but instead checked if the result of dividing by a number was an integer.
  • (code) I liked this one because he created a method for checking if the year was divisible by a given number, it cleans the code up a lot.
  • (code) This solution doesn't take advantage of the fact that the bunch of logic will already return a boolean, no need to explicitly return true or false.
  • (code) Extremely similar to my solution, except that they are using == instead of the ===, which makes the code more readable, but might not be a good idea. I ran across this resource and it states: "If either value in a comparison could be of these specific values (0, "", or [] -- empty array), avoid == and use ===."
  • (code) This guy made three separate functions for if a given number was divisible by 4, 100, and 400. I like the earlier solution mentioned above of just having one function for this. He imported a package called ramda and used .modulo instead of the % operator, which does make it more readable.

Hamming

my code

  • (code) I liked this submission, it's easier to read than mine. I like that he just uses a for loop and goes through each index of the string, whereas I split the string into an array (which took more steps).
  • (code) Comparing this one to the previous one, I don't like it, her for loop is starting from the end of the strand and working backward, it just adds complexity.
  • (code) This one also uses a for loop, but starts at the beginning of the strand and works it's way forward. The first submission is still the simplest and best in my opinion. I've also noticed every single submission so far does not use descriptive variable names, which they should.
  • (code) Lo and behold! This one does use descriptive variable names. He also documents his code with comments very well. In Ruby we were told not to have any comments, but I remember Lovisa saying that lots of people put comments in their javascript code.
  • (code) Oooh! This one is very different from the others. They use let to define variables within the compute function, which I have learned will scope it to the enclosing block. They make use of a while loop, which will stop when i gets to zero (they are working backwards from the end of the strand).

RNA Transcription

my code

  • (code) I like that they defined the DNA to RNA dictionary within the class, I didn't do that. They use a for loop and add on to it the RNA transcription. They also considered the edge case where there is no DNA key, and put a space in it's place.
  • (code) This one was interesting. They pulled pieces apart by making functions to do those pieces, which was good. They also made a function to transcribe RNA back to DNA, which is why their mapping object has to be more complex ('A' to 'U' for RNA and 'A' to 'T' for DNA).
  • (code) This guy also defined the mapping inside the class (why did I not think to do this?). He also makes use of a for loop and appends the mapped value to a new variable.
  • (code) Oooh this was super cool. They used .replace and some regex. This was very clean and definitely my favorite.
  • (code) This guy didn't define a map, but had four if statements to transcribe the strand, not very DRY. I know this guy though so it's cool because he's a cool guy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment