Christmas Day 3000

24May13

In the twelve months from March 2013 to March 2014, I programmed solutions to the problems posted on the Contest Coding blog run by Lewis Cornwall, solving 33 problems (out of 47) and achieving a position of 4th on the leaderboard (out of 23).

As that blog has now been discontinued, I’m posting here the solutions I programmed to those problems.

Christmas Day 3000

Find the day of the week that 25th December 3000 A.D. will fall on.

Solution and answer (Christmas Day 3000.pas):

Uses: lib_seal_calendar.

{$R+}
program Christmas_Day_3000( output );
{
Solution and answer for problem "Christmas Day 3000" (24th May 2013) of http://ContestCoding.WordPress.com/

25th December 3000 is a Thursday.

Solution programmed in Pascal using Metrowerks CodeWarrior IDE 2.1 (Discover Programming Edition); solution took ~4s to run on a 80MHz PowerPC 601.
}
uses
  lib_seal_calendar;
var
  day : t_Day;
  month : t_Month;
  year : 2013..3000;
  day_of_week : 1..7;
begin
  day := 24;
  month := 5;
  year := 2013;
  day_of_week := 5;
  repeat
    if day < f_NumberOfDaysInMonth( month, year ) then
      day := day + 1
    else begin
      day := 1;
      if month < 12 then
        month := month + 1
      else begin
        month := 1;
        year := year + 1
      end
    end;
    if day_of_week < 7 then
      day_of_week := day_of_week + 1
    else
      day_of_week := 1
  until ( year = 3000 ) and ( month = 12 ) and ( day = 25 );
  write( '25th December 3000 is a ' );
  case day_of_week of
    1:write( 'Mon' );
    2:write( 'Tues' );
    3:write( 'Wednes' );
    4:write( 'Thurs' );
    5:write( 'Fri' );
    6:write( 'Satur' );
    7:write( 'Sun' )
  end;
  writeln( 'day.' )
end.
Advertisements


No Responses Yet to “Christmas Day 3000”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: