Skip to content

Instantly share code, notes, and snippets.

@jecrockett
Created March 20, 2016 20:20
Show Gist options
  • Save jecrockett/1bfe79d620011a0b31ef to your computer and use it in GitHub Desktop.
Save jecrockett/1bfe79d620011a0b31ef to your computer and use it in GitHub Desktop.

Exercism Review

Bob

My Solution

  • 1 - Looks cleaner than mine, though I like that I set up variables to make the code more readable. I also like my .match method better than his .search method for checking to see if the input has letters.
  • 2 - Again, I prefer my way of setting up the variables so that it's clear what everything tests. I prefer the .trim() method to testing for /\S, which I assume is whitespace.
  • 3 - I like how readable it is. It's super broken out into abstrations. It's too much though, I think the functions are unnecessary -- those can simply be saved in variables.
  • 4 - I don't think this one will work. It relies on the '!' input to return 'Whoa.' (which isn't right..) but there's a test with only numbers and an '!' that will fail this.
  • 5 - Second or third submission I've seen use the "check upper case matches the input AND check lower case doesn't match the input." as the way around the issue mentioned above (numbers only plus '!' being a "Whatever." response. I like this better than my check for letters in the input, I think.

Leap

[My Solution] (http://exercism.io/submissions/997391f3efe44932bc80d8cb5f4d5a85)

  • 1 - Not particularly readable, as it's all on one line. I do actually like this logic better than my own, however. Mine first checks for the quadricentennial and this first checks for the leap year before qualifying. Makes more sense.
  • 2 - Identical logic to the previous one, but in a more legible format.
  • 3 - Identical to above.
  • 4 - Less pretty than the other because, like me, they used else if for a big if statement rather than doing individual ones. Unclear the best way tot go about this. Makes more sense to me to have a single method as you only want one response, but it looks way cleaner with multiple.
  • 5 - A lot like the first one with logic on one line. Extracted to a function...not sure if it's necessary but it does look cleaner. Don't fully understand what's going on with the Year function. Seems like they created a function just to return the output of another function...why not just use the one?

RNA Transcription

My Solution

  • 1 - I like the extra function that uses a hash to pair the conversions. Ultimately it makes for a complicated looking line 12, though. Don't understand the benefit of saving input_length = input.length, they read exactly the same just call input.length in the for loop. They're doing the same thing I am it just looks a little more complicated to me.
  • 2 - Did the same thing as the previous one with the dictionary-like hash conversions. Ends up creating an array of characters and then mapping over that to genreate the new string.
  • 3 - Same thing I did, almost. I like the use of the concat method though I think += is easier. Needs else before the other if's...no?
  • 4 - Most similar to mine yet. I just had else's at the end and they separated the ifs. Makes the most sense to me.
  • 5 - Same method as the second one. Has an RNA dictionary type thing, splits the string in to an array and loops through it. Don't see the need to array it if they're not going to map like the other person id, but whatever.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment