Skip to content

Instantly share code, notes, and snippets.

@Claudia108
Last active July 3, 2016 03:29
Show Gist options
  • Save Claudia108/04ee4ca280f3a5785dfd227b969261ef to your computer and use it in GitHub Desktop.
Save Claudia108/04ee4ca280f3a5785dfd227b969261ef to your computer and use it in GitHub Desktop.

Hamming

My colde here

  • Responder #1: (here) - The definition of a class in this case probably makes sense but I don't know enough about it yet. Interesting approach using map and reduce in one function. I don't like that the inputs are treated differently, one with split and one with atChar, makes it harder to read for me but makes it short and concise. Interesting use of =>. This synthax is new to me, might have to do with using functions within a class. Curious to find out more about it.

  • Responder #2: (here) - This approach is very similar to my first attempt to make the test pass. Can be refactored to break out parts in seperate functions. What I like about it is the use of charAt(index). I wasn't aware of this method and used split instead. This makes it shorter and easier to read.

  • Responder #3: (here) - Very similar approach to responder 2. Also some opportunity for refactoring. There is no use of atChar or split, just index. I was trying that before but it didn't work for me. Wondering why. Makes it even shorter.

  • Responder #4: (here) - A very short and concise approach but it doesn't account for the error message. Same approach as the former 2 and me. Seems like a very common way to solve this problem.

  • Responder #5: (here) - This one starts out similar but then uses filter to count number of different elements. Interesting approach.

Leap

My code (here)

  • Responder #1: (here) - Looks very similar to my approach. Interesting is Lovisa's comment that suggests using logical operators to simplify the statement to one line.

  • Responder #2: (here) - This approach is very different. It defines leap by using the conditions which is a very interesting way to do it. Short and concise but hard to understand at first sight for me.

  • Responder #3: (here) - Another very different approach. Uses && and || operators after defining the conditions. Uses function for defining conditions and passes year and modulo which is interesting. Also defines a class, which I am interested to learn more about.

  • Responder #4: (here) - Very similar approach to mine. Uses multiple if statements, could be combined with else if. And as with mine room for refactoring.

  • Responder #5: (here) - Similar approach again. Already refactored somewhat with && operator. Makes it a bit more concise.

Rna Transcription

My code (here)

  • Responder #1: (here) - This solution is similar to mine but uses a different syntax for for loop (with in) and uses case statement instead of if. Looks more elegant.

  • Responder #2: (here) - I really like this approach. Very consise and clean. It makes use of a class and defines a map function. This way no if or case statement is necessary. I used a similar approach when I did this example in Ruby but didn't quite know the syntax in javascript. Now I know! It also makes use of chaining functions (split, map and join) which is pretty slick and easy to understand.

  • Responder #3: (here) - Very similar approach to #2 but keeps functions split, map and join seperate and does not define a class. Also accounts for lower case letters which makes this safer. I like it.

  • Responder #4: (here) - Another similar solution. Very clean and easy to read. Makes use of => which I still don't fully understand.

  • Responder #5: (here) - And a last similar approach. This is somewhere between the last 3 and probably closest to how I would have written mine if I had used a mapping object.

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