Here's a simple logic puzzle (much simpler than the one Paul posted last week!)...
You have one input in your policy model: the assessment date
Your goal attribute is: the number of days in the month in which the assessment date falls
In addition to regular months in regular years, your policy model must cater for leap years, including the century leap year rules. For example:
- if the input is 12 Dec 2017, the output is 31
- if the input is 20 Feb 2016, the output is 29
- if the input is 20 Feb 2015, the output is 28
- if the input is 20 Feb 2000, the output is 29
- if the input is 20 Feb 1900, the output is 28 (although 1900 is divisible by 4, it’s not a leap year, see Century Leap Year rules)
This logic was part of a demo I'm working on, and it occurred to me it might be a nice little puzzle. It can be solved in one (fairly undecipherable!) rule, but I broke it out into four rules so the logic was easier to follow.
You don’t need to solve this puzzle in any particular number of rules. Anything that’s logically correct (and ideally efficient) is fine.
Cheers,
Jasmine