Escreva, no menor número de caracteres possível, um programa que aceite zero ou seis argumentos da linha de comando
menorah
menorah YEAR MONTH DAY HOUR MINUTE SECOND
(Ambos os formulários devem ser suportados. A versão com argumento zero deve ser equivalente a chamar a versão com seis argumentos com a data e hora atuais do sistema no fuso horário local.)
e se a data e hora especificadas (calendário gregoriano) caírem durante o Hanukkah , produza uma menorá de nove ramos da arte ASCII (ou arte Unicode) com o número apropriado de velas acesas. Se é não durante Hanukkah, de saída, em seguida, uma única nova linha. Por exemplo,
~$ ./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
~$
No nono dia do festival, N + 1 velas estão acesas: a vela shamash central e N das 8 velas Hanukkah, colocadas na ordem da direita para a esquerda.
As variações permitidas no formato de saída são:
- Velas não utilizadas podem ser apagadas em vez de omitidas.
- Você pode usar caracteres não ASCII para tornar o resultado mais agradável esteticamente. Como
🔥
(U + 1F525) em vez de*
. Ou caracteres de desenho de caixa em vez de+-|
.
Para o propósito deste desafio, pode-se presumir que um dia no calendário hebraico começa às 18:00.
Os resultados devem estar corretos para os anos gregorianos entre 1900 e 2239, inclusive.
Hanukkah começa ao pôr do sol nas datas gregorianas
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