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:

screen-shot-2016-09-08-at-11-45-42-am

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:

screen-shot-2016-11-01-at-5-41-58-pm

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:

screen-shot-2016-11-01-at-8-36-25-pm

Advertisements
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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s