Seasons
Well, it's Hurricane Season here in the Gulf South. But that's not the kind of seasons I'm talking about now.
Your job is to take a month (keyword) day (number) and a hemisphere (:north
or :south
) and determine which season it is (return a keyword), according to this handy table.
Start End North South
March 1 May 31 Spring Autumn
June 1 August 31 Summer Winter
September 1 November 30 Autumn Spring
December 1 February 29 Winter Summer
Example:
(which-season :north :march 5) ;=> :spring
(which-season :south :december 25) ;=> :summer
Thanks to this site for the challenge idea where it is considered Hard level in JavaScript.
Please submit your solutions as comments to this gist. Discussion is welcome.
Nice! That's a cleaner way of getting all the month names. And since we're code golfing, how about:
For my use I'd just have to rotate the months to start with december, something like:
(p.s. I looked over the java.time.Month javadoc, wondering if the order of enum values returned is guaranteed. Yup, values() will always return them in the order they're declared. Good, that order is unlikely to change! It also says .toString is preferred over .name)