My Ruby solution