Categories
Code challenges Programming

30 Days of Code #6

It felt exceptionally easy because I had seen that kind of problem before.

Is it just me, or is Codewars’ kyu level system spotty? The last problem I did was definitely more involved than a 6 kyu problem, whereas this one felt more like a level 7 or 8.

However, after looking at some of the other answers, I realized that it was only easy to me because I had done similar problems before. This one is the “Iterate over something else” problem. It isn’t necessary to always iterate over the elements of the given object. In this case, I iterated over a range of the alphabet letters from 'a' to 'z' and transformed them into the number of times they appeared in the given string. It felt easy, and it felt good to remember this problem-solving pattern.

It reminds me of middle school factoring in math class, where they gave us (what felt like) hundreds of problems just to get the sense of how to identify a pattern.

It only really feels easy because I’ve done it before. That’s a lesson to remember for life in general.

Problem: Simple decrypt algo

Solution:

def decrypt(key)
  ('a'..'z').map { |l| key.count(l) }.join
end