14
1
Write a program that takes a birth date (month and day-of-month) as input and outputs the corresponding sign, element and quality of the western zodiac. For the purposes of this challenge, these are defined exactly as in the table in the linked wikipedia page:
Sign Date Range Element Quality
Aries March 21 to April 19 Fire Cardinal
Taurus April 20 to May 20 Earth Fixed
Gemini May 21 to June 21 Air Mutable
Cancer June 22 to July 22 Water Cardinal
Leo July 23 to August 22 Fire Fixed
Virgo August 23 to September 22 Earth Mutable
Libra September 23 to October 23 Air Cardinal
Scorpio October 24 to November 20 Water Fixed
Sagittarius November 21 to December 22 Fire Mutable
Capricorn December 23 to January 20 Earth Cardinal
Aquarius January 21 to February 21 Air Fixed
Pisces February 22 to March 20 Water Mutable
Rules
- The sign, element and quality will be calculated from the input date exactly according to the wikipedia table.
- I am giving some freedom over input date format (see Input section below). You must clearly state in your answer what format you are using.
- If an invalid date is provided (unparsable date, or month or day-of-month out of range), the program will exit with the message
Invalid date
. - The program must correctly handle leap years. i.e. if Feb 29th is the input, then output must correctly be
Pisces, Water, Mutable
. - Your language's Date libraries/APIs are allowed, but any APIs that specifically calculate signs of the zodiac are banned.
- Standard “loopholes” which are no longer funny
- This is code-golf, so the shortest answer in bytes wins.
Input
- The program may read the input date from STDIN, command-line, environment variables or whatever method is convenient for your language of choice.
- This is not primarily an exercise in datestring-parsing, so the input string may be provided in whatever format you choose, as long as it consists of only month and day-of-month components and not other values (such as year or time). E.g.
Jul 24
or24th of July
or7/24
or24/07
or whatever format is convenient. If input not matching your choice of input format is entered, then theInvalid date
error must be thrown.
Output
- The program will output to STDOUT, dialog box or whatever display method is convenient for your language of choice.
- The output format will be the sign, element and quality separated by a comma and a space:
Sign, Element, Quality
Examples
Input Output
1/1 Capricorn, Earth, Cardinal
2/29 Pisces, Water, Mutable
7/24 Leo, Fire, Fixed
13/1 Invalid date
2/31 Invalid date
-1/-1 Invalid date
1st of Golfember Invalid date
Is the day of the year (e.g.
Jan 21 -> 21
,Feb 5 -> 36
) a valid input format? – Mego – 2016-06-09T07:15:11.207@Mego no, sorry, that's invalid - "it consists of only month and day-of-month components" - IIRC, I think my intention was that the month and day-of-month components should be separate, and not combined – Digital Trauma – 2016-06-09T16:22:12.290
Is detection/warning of an invalid date required? If so, can we assume invalid numbers entered by the user will be greater than zero? (I'm guessing most people will use a numerical date format.) – Level River St – 2014-07-24T19:35:31.317
1@steveverrill I think I made that clear in the third item of the rules, but I've edited the Input section to clarify. TLDR valid input => valid output; invalid input => error message; no "undefined behaviour" allowed for any given input. – Digital Trauma – 2014-07-24T19:46:36.777
is a full date allowed? days, months and years? – Teun Pronk – 2014-07-25T12:10:09.277
@TeunPronk No, just month and day-of-month. I've clarified the input rule. – Digital Trauma – 2014-07-25T14:32:04.247