Solutions 1-4 in Ruby
Problem 1 solution in JS