12
1
Write, in as few characters as possible, a program that takes zero or six command-line arguments
menorah
menorah YEAR MONTH DAY HOUR MINUTE SECOND
(Both forms must be supported. The zero-argument version shall be equivalent to calling the six-argument version with the current system date and time in the local timezone.)
and if the specified (Gregorian-calendar) date and time falls during Hanukkah, then output an ASCII art (or Unicode art) nine-branch menorah with the appropriate number of candles lit. If it is not during Hanukkah, then output a single newline. For example,
~$ ./menorah 2015 12 7 0 0 0
*
| *
| |
| |
+++++++++
|
-+-
~$ ./menorah 2015 12 9 0 0 0
*
| ***
| |||
| |||
+++++++++
|
-+-
~$ ./menorah 2015 12 14 0 0 0
*
****|****
|||||||||
|||||||||
+++++++++
|
-+-
~$ ./menorah 2015 12 15 0 0 0
~$
On the Nth day of the festival, N+1 candles are lit: The central shamash candle, and N of the 8 Hanukkah candles, placed in right-to-left order.
Allowed variations in the output format are:
- Unused candles may be drawn unlit instead of omitted.
- You may use non-ASCII characters to make the result more aesthetically pleasing. Like
(U+1F525) instead of
*
. Or box-drawing characters instead of+-|
.
For the purpose of this challenge, a day on the Hebrew calendar may be assumed to start at 18:00.
Results must be correct for Gregorian years between 1900 and 2239, inclusive.
Hanukkah begins at sunset on the Gregorian dates
1900-12-16 1901-12-05 1902-12-24 1903-12-13 1904-12-02 1905-12-22
1906-12-11 1907-11-30 1908-12-18 1909-12-07 1910-12-25 1911-12-15
1912-12-04 1913-12-23 1914-12-12 1915-12-01 1916-12-19 1917-12-09
1918-11-28 1919-12-16 1920-12-05 1921-12-25 1922-12-14 1923-12-02
1924-12-21 1925-12-11 1926-11-30 1927-12-18 1928-12-07 1929-12-26
1930-12-14 1931-12-04 1932-12-23 1933-12-12 1934-12-01 1935-12-20
1936-12-08 1937-11-28 1938-12-17 1939-12-06 1940-12-24 1941-12-14
1942-12-03 1943-12-21 1944-12-10 1945-11-29 1946-12-17 1947-12-07
1948-12-26 1949-12-15 1950-12-03 1951-12-23 1952-12-12 1953-12-01
1954-12-19 1955-12-09 1956-11-28 1957-12-17 1958-12-06 1959-12-25
1960-12-13 1961-12-02 1962-12-21 1963-12-10 1964-11-29 1965-12-18
1966-12-07 1967-12-26 1968-12-15 1969-12-04 1970-12-22 1971-12-12
1972-11-30 1973-12-19 1974-12-08 1975-11-28 1976-12-16 1977-12-04
1978-12-24 1979-12-14 1980-12-02 1981-12-20 1982-12-10 1983-11-30
1984-12-18 1985-12-07 1986-12-26 1987-12-15 1988-12-03 1989-12-22
1990-12-11 1991-12-01 1992-12-19 1993-12-08 1994-11-27 1995-12-17
1996-12-05 1997-12-23 1998-12-13 1999-12-03 2000-12-21 2001-12-09
2002-11-29 2003-12-19 2004-12-07 2005-12-25 2006-12-15 2007-12-04
2008-12-21 2009-12-11 2010-12-01 2011-12-20 2012-12-08 2013-11-27
2014-12-16 2015-12-06 2016-12-24 2017-12-12 2018-12-02 2019-12-22
2020-12-10 2021-11-28 2022-12-18 2023-12-07 2024-12-25 2025-12-14
2026-12-04 2027-12-24 2028-12-12 2029-12-01 2030-12-20 2031-12-09
2032-11-27 2033-12-16 2034-12-06 2035-12-25 2036-12-13 2037-12-02
2038-12-21 2039-12-11 2040-11-29 2041-12-17 2042-12-07 2043-12-26
2044-12-14 2045-12-03 2046-12-23 2047-12-12 2048-11-29 2049-12-19
2050-12-09 2051-11-28 2052-12-15 2053-12-05 2054-12-25 2055-12-14
2056-12-02 2057-12-21 2058-12-10 2059-11-29 2060-12-17 2061-12-07
2062-12-26 2063-12-15 2064-12-03 2065-12-22 2066-12-12 2067-12-01
2068-12-18 2069-12-08 2070-11-27 2071-12-16 2072-12-04 2073-12-24
2074-12-13 2075-12-01 2076-12-20 2077-12-10 2078-11-29 2079-12-17
2080-12-06 2081-12-26 2082-12-15 2083-12-04 2084-12-22 2085-12-11
2086-11-30 2087-12-19 2088-12-07 2089-11-27 2090-12-16 2091-12-05
2092-12-23 2093-12-13 2094-12-02 2095-12-20 2096-12-09 2097-11-29
2098-12-18 2099-12-06 2100-12-26 2101-12-16 2102-12-05 2103-12-23
2104-12-12 2105-12-02 2106-12-21 2107-12-10 2108-11-28 2109-12-17
2110-12-06 2111-12-25 2112-12-13 2113-12-03 2114-12-22 2115-12-10
2116-11-29 2117-12-19 2118-12-08 2119-12-26 2120-12-15 2121-12-04
2122-12-23 2123-12-12 2124-12-01 2125-12-21 2126-12-10 2127-11-29
2128-12-17 2129-12-06 2130-12-24 2131-12-14 2132-12-03 2133-12-22
2134-12-11 2135-11-30 2136-12-18 2137-12-07 2138-12-26 2139-12-15
2140-12-04 2141-12-23 2142-12-12 2143-12-01 2144-12-20 2145-12-09
2146-11-27 2147-12-17 2148-12-05 2149-12-24 2150-12-13 2151-12-03
2152-12-22 2153-12-11 2154-11-30 2155-12-19 2156-12-07 2157-12-25
2158-12-15 2159-12-05 2160-12-23 2161-12-12 2162-12-01 2163-12-20
2164-12-09 2165-11-28 2166-12-16 2167-12-06 2168-12-24 2169-12-13
2170-12-02 2171-12-22 2172-12-10 2173-11-28 2174-12-18 2175-12-08
2176-12-26 2177-12-14 2178-12-04 2179-12-24 2180-12-12 2181-12-01
2182-12-20 2183-12-09 2184-11-28 2185-12-17 2186-12-06 2187-12-25
2188-12-14 2189-12-03 2190-12-21 2191-12-11 2192-11-29 2193-12-17
2194-12-07 2195-12-27 2196-12-15 2197-12-03 2198-12-23 2199-12-13
2200-12-02 2201-12-20 2202-12-10 2203-11-30 2204-12-18 2205-12-07
2206-12-26 2207-12-15 2208-12-03 2209-12-22 2210-12-11 2211-12-01
2212-12-19 2213-12-08 2214-12-27 2215-12-17 2216-12-05 2217-12-23
2218-12-13 2219-12-02 2220-12-20 2221-12-09 2222-11-29 2223-12-18
2224-12-05 2225-12-25 2226-12-15 2227-12-04 2228-12-21 2229-12-11
2230-12-01 2231-12-20 2232-12-08 2233-12-27 2234-12-16 2235-12-05
2236-12-23 2237-12-12 2238-12-02 2239-12-21
9For those of us who are not Jewish (and for those who are but don't know how to calculate the Jewish calendar) please explain how the start of Hanukkah is calculated. You should also explain the sequence of lighting the candles (it seems to be one per day, but does it matter which candle you light? ) – Level River St – 2015-11-18T05:18:24.197
Are we required to support both zero and six command-line arguments, or can we choose? – lirtosiast – 2015-11-18T05:27:37.540
@ThomasKwa: Both. The difference is that the zero-argument version uses the current date and time. – dan04 – 2015-11-18T05:39:04.080
@steveverrill: I've added a list of the relevant Gregorian-calendar dates. The calendar itself is based on the 19-year Metonic cycle. – dan04 – 2015-11-18T06:05:46.193
Can STDIN be used for languages that don't have command line arguments? – xnor – 2015-11-18T09:06:15.317
@xnor: Yes. If your language doesn't support command-line arguments, you may have the user enter the values at runtime (whether through STDIN or through GUI objects). – dan04 – 2015-11-18T14:01:16.457
@GamrCorps I'm casting a reopen vote, as the concerns I had when I cast the first closevote have been addressed. If there is something outstanding, please indicate what it is. Otherwise please don't pile on close votes after the problem is solved. Dan04, Ok I see you have added the list. I had to look up Metonic. So it means the lunar and solar cycles coincide once every 19 years. But not exactly, it seems there is a random(ish) variation by a +/-day every 19 year period. – Level River St – 2015-11-18T19:22:19.017
Beware that drawing unused candles as unlit will be much easier (and I think less interesting) than drawing them as missing. – xnor – 2015-11-18T21:51:24.300
1the option to draw unused candles as unlit means the dynamic ascii art portion of this is just one row of toggled asterisks, which is not interesting at all. not that I find the larger ascii art drawing particularly interesting to begin with. – Sparr – 2015-11-19T02:07:06.767
1@Sparr the ascii art portion is far from the most challenging part of this challenge at end, the conversion from gregorian to hebrew Date and checking if we're within the Holidays or not is far more interesting IMO – Tensibai – 2015-11-19T13:32:08.700
There is little or no incentive to do the "Aesthetically pleasing" challenge, as it will merely increase bytes. – Conor O'Brien – 2015-11-19T15:40:14.500