Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 479 Bytes

quarter_of_the_year.md

File metadata and controls

18 lines (13 loc) · 479 Bytes

Description

Given a month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number.

For example: month 2 (February), is part of the first quarter; month 6 (June), is part of the second quarter; and month 11 (November), is part of the fourth quarter.

Constraint:

  • 1 <= month <= 12

My Solution

def quarter_of(month)
  (month/3.0).ceil
end