add Ruby's solution (thanks @n0kada)