挑战
编写一个程序,将1789年4月30日至2019年8月21日的一天作为输入,并返回当日为美国总统的输出。
笔记
April 30, 1789 - March 4, 1797 George Washington
March 4, 1797 - March 4, 1801 John Adams
March 4, 1801 - March 4, 1809 Thomas Jefferson
March 4, 1809 - March 4, 1817 James Madison
March 4, 1817 - March 4, 1825 James Monroe
March 4, 1825 - March 4, 1829 John Quincy Adams
March 4, 1829 - March 4, 1837 Andrew Jackson
March 4, 1837 - March 4, 1841 Martin Van Buren
March 4, 1841 - April 4, 1841 William Henry Harrison
April 4, 1841 - March 4, 1845 John Tyler
March 4, 1845 - March 4, 1849 James K. Polk
March 4, 1849 - July 9, 1850 Zachary Taylor
July 9, 1850 - March 4, 1853 Millard Fillmore
March 4, 1853 - March 4, 1857 Franklin Pierce
March 4, 1857 - March 4, 1861 James Buchanan
March 4, 1861 - April 15, 1865 Abraham Lincoln
April 15, 1865 - March 4, 1869 Andrew Johnson
March 4, 1869 - March 4, 1877 Ulysses S. Grant
March 4, 1877 - March 4, 1881 Rutherford B. Hayes
March 4, 1881 - September 19, 1881 James A. Garfield
September 19, 1881 - March 4, 1885 Chester A. Arthur
March 4, 1885 - March 4, 1889 Grover Cleveland
March 4, 1889 - March 4, 1893 Benjamin Harrison
March 4, 1893 - March 4, 1897 Grover Cleveland
March 4, 1897 - September 14, 1901 William McKinley
September 14, 1901 - March 4, 1909 Theodore Roosevelt
March 4, 1909 - March 4, 1913 William Howard Taft
March 4, 1913 - March 4, 1921 Woodrow Wilson
March 4, 1921 - August 2, 1923 Warren G. Harding
August 2, 1923 - March 4, 1929 Calvin Coolidge
March 4, 1929 - March 4, 1933 Herbert Hoover
March 4, 1933 - April 12, 1945 Franklin D. Roosevelt
April 12, 1945 - January 20, 1953 Harry S. Truman
January 20, 1953 - January 20, 1961 Dwight D. Eisenhower
January 20, 1961 - November 22, 1963 John F. Kennedy
November 22, 1963 - January 20, 1969 Lyndon B. Johnson
January 20, 1969 - August 9, 1974 Richard Nixon
August 9, 1974 - January 20, 1977 Gerald Ford
January 20, 1977 - January 20, 1981 Jimmy Carter
January 20, 1981 - January 20, 1989 Ronald Reagan
January 20, 1989 - January 20, 1993 George H. W. Bush
January 20, 1993 - January 20, 2001 Bill Clinton
January 20, 2001 - January 20, 2009 George W. Bush
January 20, 2009 - January 20, 2017 Barack Obama
January 20, 2017 - Incumbent Donald Trump
总统任期包括第一天和最后一天。例如,“ 1861年3月4日至1865年4月15日;亚伯拉罕·林肯”表示林肯从1861年3月4日至1865 年4月14日担任总统。
这是代码高尔夫球,每种语言中最短的程序胜出。
例
输入:“ 1865年2月7日”输出:“亚伯拉罕·林肯”
WolframAlpha["president on "<>#]&
我敢肯定,纯Mathematica在某处具有内置函数,但是直到找到所谓的东西,我才坚持使用W | A。
WolframAlpha["US president on "<>#]&
会使我的输出不正确