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.
The most natural way (to me) to structure the data is to index the seasons and
reshape
prior to use. Also, since I spent time worrying about day accuracy (which was buggy anyway), why not spice it up a little? Addingupdate-seasons
and a signature towhich-season
.(New bugfix: both 'start and 'end can be the same month, switched from condp to cond->, my first use thereof :)