Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

9 of 10
replaced http://meta.codegolf.stackexchange.com/ with https://codegolf.meta.stackexchange.com/

Next public holiday

Australians love public holidays, and drinking. Yesterday, the 26th January, was Australia day, which is a public holiday. I was glad to not be at work yesterday, and eager to know the next time I get a public holiday! Unfortunately, I had a bit too much to drink, and I'm not able to work it out for myself.

Write a program that will take a date in Australian date/time notation (dd/mm) as input, and output the amount of days until the next public holiday. Because I'm a Queensland (QLD) resident, I'm only interested in public holidays that affect Queenslanders:

25/03 | Good Friday
26/03 | Easter Saturday
28/03 | Easter Monday
25/04 | Anzac Day
02/05 | Labour Day
03/10 | Queen's Birthday
25/12 | Christmas Day
26/12 | Boxing Day
27/12 | Christmas Day holiday

Note the following from the site:

###Christmas Day holiday An additional public holiday to be added when New Year's Day, Christmas Day or Boxing Day falls on a weekend.

Because Christmas day is on Sunday, there is an extra public holiday. Christmas day is still a public holiday.

Because I'm a morning person, you should include the current date as a day (as that's the most likely time I will check your program for the next public holiday). That is, if a public holiday's date is entered, your output should be 0; if the day before a public holiday is entered, your output will be 1.

I'm only interested in dates between now (the 27/01) until the end of the year. The final date you will need to account for is 31/12 where your output will be 1 (for New Year's day).

Standard loopholes are forbidden.

###Input

  • Input will always be 5 characters: 4 letters, separated with a hyphen - or slash /
  • Input will only be a date between 27/01 and 31/12

###Output

  • The number of days until the next public holiday in Queensland Australia, inclusive of the input date: should be a number between 0 and 153 (the longest gap)
  • No new lines or errors

###Examples 01-05 = 1
02-05 = 0
03-05 = 153
25/12 = 0 26-ひく12 = 0 27/12 = 0 30/12 = 2 31-12 = 1

Hopefully this is clear and nothing is missed; however, this is my second question so I will appreciate any feedback and do my best to fix problems ASAP.

Tas
  • 613
  • 6
  • 15

AltStyle によって変換されたページ (->オリジナル) /