This week’s code challenge comes from Coderbyte. Here are the basic instructions:
Have the function `StringReduction(str)` take the `str` parameter being passed and return the smallest number you can get through the following reduction method. The method is: Only the letters a, b, and c will be given in str and you must take two different adjacent characters and replace it with the third.
For example, if you were provided the string “abc,” you could simplify that to “cc” but no further. On the other hand, “aba” could be simplified to “ca” and then to “b.” For simplification, here are all of the transformations:
ac = b
ca = b
cb = a
bc = a
ab = c
ba = c
Here are some test cases:
StringReduction(“abcabc”) should equal 2.
StringReduction(“cccc”) should equal 4.
StringReduction(“baccabcbc”) should equal 1.
Here’s my solution collapsed:
Continue reading “Code Challenge: String Reduction”
This one was a bit of a doozy! I originally read this challenge three weeks ago and gave it a try. I couldn’t get it working so I moved on to another after an hour of frustration. Reflecting back on the “Second Greatest Length” challenge, I had a little epiphany of how it could work.
Challenge: Given a string, the function
highestRecurringLetter should return the word in that string that contains the highest recurring letter. For example, if given “Trees are great,” the function should return “Trees” because the letter ‘e’ occurs twice. If no letter occurs more than once in a word (“This is fun”), the function should return the last word in the string. Assume that the string has at least one word, and words are separated by spaces.
highestRecurringLetter("Soccer is fun") = ‘Soccer’;
highestRecurringLetter("Recurring challenges are fun") = ‘Challenges’;
highestRecurringLetter("I love them") = ‘Them’;
Here’s my solution minimized. I want to see yours though. If you give this a shot, let me know and post a link to your solution in the comments! Otherwise, just let me know what I could’ve done better!
Continue reading “Code Challenge: Recurring Letters”
This is the third post in a series of at least 10 code challenges. You can find the others here.
Compared to the previous two challenges, today’s challenge was short and straightforward.
Challenge: Given a string, the function reverseString should return the same string backwards. For example, reverseString(“This string”) would return “gnirts siht.” When writing your function, assume the message contains only letters and spaces, and all words are separated by one space.
Here’s my solution collapsed:
Continue reading “Code Challenge: Reverse, Reverse!”
Isaac Morehouse on Medium:
Not long ago a degree may have been the best signal most people could get. There weren’t many ways to demonstrate your value to the market, so a degree was one of the better bets. Things have changed dramatically. Technology has opened up the world. The tools available to you now have lowered search and information costs, and you can create signals of your own that are far more powerful than a degree.
I’ve tried to articulate this in the past with articles in self-learning, but Morehouse knocked it out of the park in his article on building a better signal.
There’s nothing wrong with getting a degree. I spent enough time in the classroom to get both a Bachelor’s and a Master’s. Degrees can be valuable, but they don’t set you apart as they did 10 years ago. There’s a clear path to getting a degree that’s relatively easy to navigate. The steps from start to finish are pretty clear.
Continue reading “Build a Better Signal”
This is the second post in a series of at least 10 code challenges. You can find the others here.
Challenge: Given an array of at least three strings, the function secondGreatest should return the second highest length value. For example, if you were given [“Three “, “Four “, “Fifteen”], the function should return “Five,” which is the length of the second longest item in the array (“Fifteen” would be the longest). Given an array of [“One”, “Two”, “Ten”, “Eleven”], the function should return “Three.” The array will always consist of at least three items.
Continue reading “Code Challenge: Find the second greatest length”