Time Conversion

Write a method that will take in a number of minutes, and returns a string that formats the number into ‘hours:minutes’.

My answer:

Screen Shot 2016-08-11 at 2.13.19 PM

Provided solution:

Screen Shot 2016-08-11 at 2.22.02 PM

Second time solving this problem:


didn’t use a while loop but it seemed to work out fine..

Note to self: don’t forget to use “+” and .to_s to join integers together into strings.

3rd time:


I realized the provided solution didn’t account for the ‘6:00’ and ‘2:05’ cases, so I redid the problem entirely.

[Edit]: Ok, I was wrong.  The provided solution does account for those cases.  However, it doesn’t account for cases where you input negative minutes.  Here’s the revised version:


Time Conversion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s