Solving algorithmic problems using Ruby language