Algorithms 2

Solve these problems in either Java or Python and email your solution to ben@suits.org.au

Problem 1

As part of a clock SUITS is building we need to write code for an alarm clock. The SUITS alarm clock is special in that it works from an offset. It takes the current time and an amount of sleep time then sets the alarm clock to current time + sleep time. However the SUITS clock is not very smart. If you give it a time greater than 24 hours it will simply wrap around to the beginning. Write a program that performs the task of taking current time and offset time input, then outputting what time the alarm should be.
Input will be as a 12-hour time string ie "hh:mm (a|p)m" and an offset "h:m" in hours and minutes (minutes not required to be 0-59).
Output will be a 12-hour time string similar to input representing the alarm time.

Sample Input 1
02:45 am
5:0

Sample Output 1
7:45 am

Sample Input 2
11:59 pm
0:1

Sample Output 2
12:00 am

Problem 1 Extension

The original SUITS clock turned out to be a market failure. Management decided that it was due to the unfortunate flaw of not being able to handle sleep times over 24-hours. So now the SUITS alarm clock stores date. Due to this new storage possibility management have decided that they want to be able to set alarms any time in the future. Your job is to implement an alarm that takes the current day and time with an offset in years, months, days, hours, minutes and outputs what day and time the alarm should go off.
Input will be as a date string ie "dd/mm/yyyy hh:mm (a|p)m" and an offset "y:m:d:h:min" (years, months, days hours and minutes are not restricted to any range other than int maximum).
Output will be a date string similar to input.

Sample Input
14/02/1989 12:37 am
19:2:0:16:8

Sample Output
14/04/2008 4:45 pm

Problem 2

It turns out that the SUITS alarm clock has an alarm sound so annoying that people have been throwing it through walls. Some people have even made multiple holes after throwing it through a wall again and again. The SUITS repair crew have been sent out to fix these holes. Your job is to determine before hand how much putty they have to make to fill the hole. Given a grid showing where holes in the wall are determine how many holes there are and how large the longest is so they may make the right amount of putty.
Input will be in the form, "w h" (width height) on the first line with h following lines each w wide indicating '.' for a wall and ' ' for a hole.
Output will be in the form "n l" (number length)

Sample Input
6 4
......
. .. .
. . ..
.. ...

Sample Output
4 2