HW08: Due Thursday 8am on HW server.

__Submit a text file with header.__

This is a challenging problem set, it does not give many easy examples to build up. The exam won't be this tricky. You have multiple days to think about the problems and work on them.

(1 Test case reminder, then 2 problem solving parts each with a and b)

0. For both questions and both parts of each question

You must discuss a set of test cases with your neighbors. Test your code with it.

The tests should be enough to convince everyone that your program works!

Include your test cases (commented out, along with your results commented out)

1. Leap Year

Write a function (LeapYear year) that returns true when the year given is a leap year, false otherwise.

"There is a leap year every year whose number is perfectly divisible by four

- except for years which are both divisible by 100 and not divisible by 400."

***The second part of the rule affects century years.

For example: the century years 1600 and 2000 are leap years,

but the century years 1700, 1800, and 1900 are not.

a. Try with if/cond *easier*

b. (LeapYearShort year) Same problem just use boolean logic, no if cond (but you need and/or/not) *trickier*

http://www.infoplease.com/spot/leapyear2.html

This is why we have this complex system for the century years.

2. Military time.

24 hour time is useful. It prevents you from getting ready for school at 6pm thinking it is 6am.

Also, there is no such thing as 12am or 12pm, only 12noon, 12midnight.

midnight -> 0:00

1 am to 12 noon -> 1:00-12:00

1 pm to 11 pm -> 13:00-23:00

Minutes are not changed at all in military time.

a) Write a function (to24hourtime hour ampm)

It takes an integer **hour **that is from 1 to 12 inclusive, and an integer **ampm **that is either 0 or 1, Where 0 represents am, and 1 represents pm. It returns the correct hour as an integer.

Even though 12am and 12pm don't really exist, we will designate 12am as midnight for this problem.

(to24hourtime 12 0) -> 0 ; this is midnight for our purposes.
(to24hourtime 12 1) -> 12 ; this is noon for our purposes.
(to24hourtime 1 0) -> 1
(to24hourtime 1 1) -> 13

(also you can google military time to learn the conversion rules)

After you write this using cond at first. Try to write it using a mathematical expression!

b) *Challenge! Do your best! If you get stuck think about it later*

(to24hourtimeShort hour ampm) -> same problem using no logic operators or decisions. Use math operations!

Do not use:

if cond and or not