Added optimal ruby solution