The Doomsday Clock is a universally-recognized symbolic clock face, representing a countdown to possible political related global catastrophe (nuclear war or climate change). It has been maintained since 1947 by the members of the Science and Security Board of the Bulletin of the Atomic Scientists1, who are in turn advised by the Governing Board and the Board of Sponsors, including 18 Nobel Laureates. The closer they set the Clock to midnight, the closer the scientists believe the world is to global disaster. The Clock — which hangs on a wall in a Bulletin's office in the University of Chicago — originally represented an analogy for the threat of global nuclear war. However, since 2007 it has also reflected climate change and new developments in the life sciences and technology that could inflict irrevocable harm to humanity.
In 1947, during the Cold War, the Clock was started at seven minutes to midnight and was subsequently advanced or rewound per the state of the world and nuclear war prospects. The Clock is not set and reset in real time as events occur. Rather than respond to each and every crisis as it happens, the Science and Security Board meets twice annually to discuss global events in a deliberative manner. The closest nuclear war threat, the Cuban Missile Crisis in 1962, reached crisis, climax, and resolution before the Clock could be set to reflect that possible doomsday. In 1991 the Clock was set seventeen minutes before midnight as the United States and the Soviet Union signed the Strategic Arms Reduction Treaty, after which the Soviet Union dissolved. This is the Clock's earliest setting since its inception.
The Doomsday Clock also works as a barometer that indicates how positive people saw the future at certain times in recent history, as evidenced by the 1969 hit song In the Year 2525 (Exordium et Terminus)2 by the American pop-rock duo Zager & Evans.
We represent progress of the Doomsday Clock as a string having the following format.
1947 7,1949 3,1953 2,1960 7,1963 12,1968 7,1969 10,1972 12,1974 9,1980 7,1981 4,1983 3,1984 3
This string representation contains a comma-separated sequence of Clock adjustments. Each adjustment is described as the year in which the Clock was reset, followed by a space and the minutes before midnight to which the Clock was set. The Clock adjustments are listed in chronological order, and you may assume that the Clock is never reset twice a year.
The figure below shows a graphical representation of the string representation shown above. If we represent time on a 24-hour clock, it's easy to see from the figure that the Doomsday Clock for example was set to 23:57 in 1950, to 23:48 in 1965 and to 23:51 in 1974. We will always consider the adjusted time in years where the clock was reset.
Your task is to determine the threat in a given year, given the progress of the Doomsday Clock. This threat is expressed as a timestamp on a 24-hour clock.
Write a function clock that takes a positive integer. This integer expresses a given number of minutes before midnight. The function must return a string containing the representation of that time stamp on a 24-hour clock, using the format hh:mm. This implies that $$0 \leq \text{hh} < 24$$ and $$0 \leq \text{mm} < 60$$.
Write a function progress that takes the string representation of the progress of the Doomsday Clock, formatted as described in the introduction of this assignment. The function must return the progress of the Clock as a tuple of tuples, where each adjustment to the Clock is represented as a tuple whose first element is the year (int) the clock was reset and whose second element is the time to which the Clock was set (string representation on a 24-hour clock, as generated by the function clock).
Write a function threat that takes two arguments: an integer representing a given year and a tuple of tuples representing the progress of the Doomsday Clock in the format returned by the function progress. The function must return the time indicated by the Clock in the given year, represented on a 24-hour clock. You may assume that the given year is always included in the interval in which the given progress of the Doomsday Clock is described, including the limits.
>>> clock(0)
'00:00'
>>> clock(7)
'23:53'
>>> clock(123)
'21:57'
>>> adjustments = '1947 7,1949 3,1953 2,1960 7,1963 12,1968 7,1969 10,1972 12,1974 9,1980 7,1981 4,1983 3,1984 3'
>>> doomsdayclock = progress(adjustments)
>>> doomsdayclock
((1947, '23:53'), (1949, '23:57'), (1953, '23:58'), (1960, '23:53'), (1963, '23:48'), (1968, '23:53'), (1969, '23:50'), (1972, '23:48'), (1974, '23:51'), (1980, '23:53'), (1981, '23:56'), (1983, '23:57'), (1984, '23:57'))
>>> threat(1974, doomsdayclock)
'23:51'
>>> threat(1950, doomsdayclock)
'23:57'
>>> threat(1965, doomsdayclock)
'23:48'