Canoe or Dinghy?


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.

Canoe or Dinghy?

A sailing company is temporarily closing down to build more boats. It takes them 1 day to build a canoe, and 2 days to build a sailing dinghy. They can only build one boat at a time. They work everyday and are always building either a canoe or a dinghy. If they closed for 4 days, they would have 3 options available to them: to build 4 canoes, to build 2 canoes and a dinghy or to build 2 dinghies. If the sailing company closed for a year (that is not a leap year), how many options would be available to them?

Solution and answer (Canoe or Dinghy?.pas):

program Canoe_or_Dinghy( output );
Solution and answer for problem "Canoe or Dinghy?" (3rd May 2013) of

There are 183 manufacturing options in a (non-leap) year.

Solution programmed in Pascal using Metrowerks CodeWarrior IDE 2.1 (Discover Programming Edition); solution took ~1s to run on a 80MHz PowerPC 601.

  t_PositiveNonZeroInteger = 1..maxint;

function f( p : t_PositiveNonZeroInteger ) : t_PositiveNonZeroInteger;
  f := ( p - p mod 2 + 2 ) div 2

  writeln( 'There are ', f( 365 ), ' manufacturing options in a (non-leap) year.' )

No Responses Yet to “Canoe or Dinghy?”

  1. Leave a Comment

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: