lvrz.org

Perl Weekly Challenge 226

After a long hiatus from the Perl Weekly Challenges, I found a bit of respite in week to pull one through. It is only for the first task, as I didn't have to invest too many neurons when I read it during my flight. Therefore, I chose Ruby to solve it this time, since I am currently on a Ruby project, and the language solves in near "english-sentence" time (lol). [See Task 1]:

def main(s, indices)
 raise "Error: Length of the arguments do not match!" unless s.length == indices.length

  hash = indices.zip(s.chars).to_h
  result = hash.sort_by { |k, v| k }.map { |v| v[1] }
  result.join
end

This solution is doggone near self-explanatory:

I miss doing these challenges. Perhaps, I'll get cracking on [Task 2] sometime this week. I may even catch up and do it all in Ruby and NodeJS (*since those are the tools I'm currently using for a client ;))

Happy hacking!

Subscribe to my blog via RSS.

#perl_weekly_challenge #ruby