Skip to Main Content

Intelligent Advisor

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

OPA Logic Puzzle: Days in Month

Jasmine Lee-OracleDec 22 2017 — edited Jan 2 2018

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 30 2018
Added on Dec 22 2017
4 comments
532 views