Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ways of Thinking About Problems

Similar presentations


Presentation on theme: "Ways of Thinking About Problems"— Presentation transcript:

1 Ways of Thinking About Problems
Leap Year – After and including 1582, Evenly divisible by 4, except evenly divisible by 100, except evenly divisible by 400. Not leap year – Before 1582, Not evenly divisible by 4 and evenly divisible by 100 and not 400. All years Pre 1582 Post 1582 NOT % 4 == 0 % 100 == 0 % 400 == 0 IS NOT

2 All years Pre 1582 = and post 1582 NOT % 4 == 0 % 100 == 0 % 400 == 0 IS NOT if (year < 1582) “is not a leap year” else if (year % 400 == 0) “ is a leap year” else if (year % 100 == 0) “ is not a leap year” else if (year % 4 == 0) “ is a leap year else

3 All years Pre 1582 = and post 1582 NOT % 4 == 0 % 100 == 0 % 400 == 0 IS NOT if (year < 1582) “is not a leap year” else if (year % 4 != 0) else if (year % 400 == 0) “ is a leap year” else if (year % 100 == 0) “ is not a leap year” else “ is a leap year “ This variant seeks to eliminate most of the cases before we get down to the more specific leap year candidate cases.

4 There are many other solutions


Download ppt "Ways of Thinking About Problems"

Similar presentations


Ads by Google