ruby solution works