ruby solution for 29