1. Puzzling Nuggets

A certain fast food restaurant prides itself on being
able to provide its customers with any number of nuggets
between 1 and 160. 
A customer may go to the counter and say "I want 43 nuggets"
and 43 nuggets will appear.

The restaurant wants to manufacture (what other
word could one use?) nuggets in packets of
four different sizes.
Your job is to figure out what those sizes should be in order to
minimize the number of packets needed to fill the average order.
For starters assume that any order between 1 and 160 is equally
likely.

For example, suppose the packet sizes are 1, 5, 10, and 20.
If someone orders 48 nuggets, then the number of packets required is six:
two packets of 20, one of 5, and three of 1.

Your goal is to find the optimal packet sizes.


2. Winning at the Slots


Consider a special slot machine with five wheels.
One has four different values.
The others have three each.

wheel 1: apples, cherries, grapes, pears

wheel 2: cherries, grapes, pears

wheel 3: apples, grapes, pears

wheel 4: apples, cherries, pears

wheel 5:  apples, cherries, grapes

In this machine, the player sets the
wheel values then pulls the lever.
If it's a winning combination, the payout is $500.
Each pull of the lever costs $10.
The winning combination depends on only three wheels. 
You don't know which three except that you know that the first
wheel is one of them.
If you are lucky enough to find the correct values of
the correct three wheels,
the values in the remaining
two wheels don't matter.
For example, suppose the winning combination were
apples on wheel 1, grapes on wheel 3, and pears on wheel 4. 
Then the values on wheels 2 and 5 can be anything at all
and you will receive the payout.

Warm-Up:
The house changes the winning combinations after either
15 attempts or a payout whiever comes first.
If each attempt costs $10 and the payout is $500,
is this a good game to the player?

Solution to Warm-Up:
In order to understand how to go about solving this problem,
realize first that there are 9 winning combinations since
there are 9 possible settings of the remaining wheels.
The total number of combinations of all wheels
is 4 * 3 * 3 * 3 * 3 = 324.
So the odds of winning are 9/324 = 1/36.
Because each pull of the lever costs $10 and the payout is $500,
this is a good bet.
That would be true even if the winning combination were changed
after every attempt.

End of Warm-Up

In fact, the odds are better than this, because each attempt
reduces the search space.
This increases the odds much as your chances of winning
increase as the deck empties in black jack.

1. Can you show how to guarantee to win in 36 lever pulls? 

Hint: Notice that you want to combine each value of wheel 1
with every pair of values of every pairs of other wheels.
For example, if the order of these fruits correspond to wheel numbers,
then the three lever pulls

 1,apples,pears,apples,pears,apples
 2,apples,cherries,apples,apples,grapes
 3,apples,grapes,apples,cherries,cherries

corresponds to setting apples for wheel 1 and then testing
all other wheels against apples for wheel 3.
At the same time, we have tested pears vs. pears, cherries vs. apples,
and grapes vs. cherries for wheels 2 and 4.
So we can test many wheel-to-wheel pairs with just a few lever pulls.

From rajas.gokhale@capgemini.com  Tue Sep 27 12:50:47 2011
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.49.99])
	by mail.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8RGol4l019299
	for <shasha@mail.cims.nyu.edu>; Tue, 27 Sep 2011 12:50:47 -0400 (EDT)
Received: from SPFSESTO03.capgemini.com (SPFSESTO03.capgemini.com [198.184.235.103])
	by mx.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8RGoYNg024657
	for <shasha@courant.nyu.edu>; Tue, 27 Sep 2011 12:50:34 -0400 (EDT)
DomainKey-Signature: s=ggt; d=capgemini.com; c=simple; q=dns;
  h=X-IronPort-AV:Received:Received:Received:Received:
   Received:From:To:CC:Date:Subject:Thread-Topic:
   Thread-Index:Message-ID:In-Reply-To:Accept-Language:
   Content-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator:
   acceptlanguage:Content-Type:MIME-Version:Return-Path:
   Content-Transfer-Encoding;
  b=P36bDC5pmIH5IglRM5h12C60lcdYAkbw15SxSg7TL3U5nubK6F2lbXSF
   JikKdpjEtkIoESVp5HXMR3LMU9k3gANu0Gs9o3siYlue6dhdeSbonyoga
   /62uOkhjcZTBWD6dMN3lv2dgz9+cJBo+p2T7q3PBs1idSdDSTEA+zEcQZ
   g=;
X-IronPort-AV: E=Sophos;i="4.68,450,1312149600"; 
   d="scan'208";a="39645201"
Received: from unknown (HELO IN-PNQ-HUBCAS1.corp.capgemini.com) ([10.102.17.88])
  by IRSESTO-C650-03-D2-incoming.capgemini.com with ESMTP/TLS/AES128-SHA; 27 Sep 2011 18:50:27 +0200
Received: from IN-PNQ-HUBCAS2.corp.capgemini.com (10.102.17.89) by
 IN-PNQ-HUBCAS1.corp.capgemini.com (10.102.17.88) with Microsoft SMTP Server
 (TLS) id 8.3.83.0; Tue, 27 Sep 2011 22:20:20 +0530
Received: from PUNEXCMS02.corp.capgemini.com ([10.102.17.126]) by
 IN-PNQ-HUBCAS2.corp.capgemini.com ([::1]) with mapi; Tue, 27 Sep 2011
 22:20:20 +0530
From: "Gokhale, Rajas" <rajas.gokhale@capgemini.com>
To: "'shasha@courant.nyu.edu'" <shasha@courant.nyu.edu>,
        "'dennisshasha@yahoo.com'" <dennisshasha@yahoo.com>,
        "Shivgopal, Sandeep"
	<sandeep.shivgopal@capgemini.com>
CC: "Moolay, Indranil" <indranil.moolay@capgemini.com>
Date: Tue, 27 Sep 2011 22:20:18 +0530
Subject: Re: Exam Paper
Thread-Topic: Exam Paper
Thread-Index: Acx9D2eexT+msIl0SNyqEC9dyEyX5AAJiIAF
Message-ID: <14CCA2BA95241348956B43C4DE7A8A5B01A02C58AE42@PUNEXCMS02.corp.capgemini.com>
In-Reply-To: <201109271216.p8RCGEbt006873@access1.cims.nyu.edu>
Accept-Language: en-US, en-IN
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: en-US, en-IN
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-Scanned-By: MIMEDefang 2.71 on 128.122.49.99
X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (mx.cims.nyu.edu [128.122.49.99]); Tue, 27 Sep 2011 12:50:47 -0400 (EDT)
Status: R
Content-Length: 2883

Hi Dennis,
It was great to discuss with you about potential approaches to including pr=
ogramming puzzles in the test.

As discussed, I will:
1. Exclude the questions that you listed in your prior mail from the test
2. Include the puzzle you sent as a 30 minute question and have the examine=
es answer it using pseudo code. We will focus on their line of thinking whi=
le evaluating
3. Once we begin training, we will include more puzzles with actual code to=
 evaluate and select our final set of trainees

Thanks,
Rajas


----- Original Message -----
From: Dennis Shasha [mailto:shasha@courant.nyu.edu]
Sent: Tuesday, September 27, 2011 05:46 PM
To: dennisshasha@yahoo.com <dennisshasha@yahoo.com>; Shivgopal, Sandeep; sh=
asha@courant.nyu.edu <shasha@courant.nyu.edu>
Cc: Moolay, Indranil; Gokhale, Rajas
Subject: Re: Exam Paper

Dear Colleagues,

Overall, the test is very nice, but feels a bit too much like
a school exam.=20
We want people who=20

1. know basic information (several of your questions
test that nicely)

2. can think through a problem at moderate leisure

3. can program

With that in mind, I would suggest deleting questions:
3, 7, 9, 10, 14, 15, 24, 25, 26, 28, 32, 34, 35, 36, 41, 46.
These are either redundant or really irrelevant to anything
I've ever seen in finance. (This is only my opinion of course
so you should feel free to overrule me).
Then I'd like you to give an hour to the following little
programming project. Students should send me both an answer
and their code.

Warm Regards,
Dennis


1. Puzzling Nuggets

A certain fast food restaurant prides itself on being
able to provide its customers with any number of vegetable nuggets
between 1 and 160.=20
A customer may go to the counter and say "I want 43 nuggets"
and 43 nuggets will appear.

The restaurant wants to manufacture (what other
word could one use?) nuggets in packets of
four different sizes.
Your job is to figure out what those sizes should be in order to
minimize the number of packets needed to fill the average order.

For example, suppose the packet sizes are 1, 5, 10, and 20.
If someone orders 48 nuggets, then the number of packets required is six:
two packets of 20, one of 5, and three of 1.

For starters assume that any order between 1 and 160 is equally
likely.
Your goal is to find the optimal packet sizes meaning the sizes
so the average purchase requires the fewest number of packets.








This message contains information that may be privileged or confidential an=
d is the property of the Capgemini Group. It is=20
intended only for the person to whom it is addressed. If you are not the in=
tended recipient, you are not authorized to=20
read, print, retain, copy, disseminate, distribute, or use this message or =
any part thereof. If you receive this message=20
in error, please notify the sender immediately and delete all copies of thi=
s message.

From shasha@access2.cims.nyu.edu  Tue Sep 27 14:44:32 2011
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.49.99])
	by mail.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8RIiVVd002909
	for <shasha@mail.cims.nyu.edu>; Tue, 27 Sep 2011 14:44:31 -0400 (EDT)
Received: from access2.cims.nyu.edu (access2.cims.nyu.edu [128.122.49.16])
	by mx.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8RIiLPa009698
	for <shasha@courant.nyu.edu>; Tue, 27 Sep 2011 14:44:22 -0400 (EDT)
Received: from access2.cims.nyu.edu (localhost [127.0.0.1])
	by access2.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8RIiJXj010611;
	Tue, 27 Sep 2011 14:44:19 -0400 (EDT)
Received: (from shasha@localhost)
	by access2.cims.nyu.edu (8.14.4+Sun/8.14.4/Submit) id p8RIiIOH010610;
	Tue, 27 Sep 2011 14:44:18 -0400 (EDT)
Date: Tue, 27 Sep 2011 14:44:18 -0400 (EDT)
From: Dennis Shasha <shasha@courant.nyu.edu>
Message-Id: <201109271844.p8RIiIOH010610@access2.cims.nyu.edu>
To: dennisshasha@yahoo.com, rajas.gokhale@capgemini.com,
        sandeep.shivgopal@capgemini.com, shasha@courant.nyu.edu
Subject: Re: Exam Paper
Cc: indranil.moolay@capgemini.com
X-Scanned-By: MIMEDefang 2.71 on 128.122.49.99
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (mx.cims.nyu.edu [128.122.49.99]); Tue, 27 Sep 2011 14:44:31 -0400 (EDT)
Status: R
Content-Length: 300

Dear Rajas,
Yes, I like this plan.
Just two small notes:

Tell them that they can use any language they like in
their pseudo-code description (including English), but
that the code should be clear enough so they can estimate
the order of magnitude time complexity of their algorithm.

Thanks,
Dennis

From rajas.gokhale@capgemini.com  Tue Sep 27 22:25:11 2011
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.49.99])
	by mail.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8S2PAZW015907
	for <shasha@mail.cims.nyu.edu>; Tue, 27 Sep 2011 22:25:11 -0400 (EDT)
Received: from SPFSESTO01.capgemini.com (SPFSESTO01.capgemini.com [198.184.235.101])
	by mx.cims.nyu.edu (8.14.4+Sun/8.14.4) with ESMTP id p8S2OxWp003338
	for <shasha@courant.nyu.edu>; Tue, 27 Sep 2011 22:24:59 -0400 (EDT)
X-IronPort-AV: E=Sophos;i="4.68,452,1312149600"; 
   d="scan'208";a="322072466"
Received: from unknown (HELO IN-PNQ-HUBCAS1.corp.capgemini.com) ([10.102.17.88])
  by IRSESTO-C650-01-D2-incoming.capgemini.com with ESMTP/TLS/AES128-SHA; 28 Sep 2011 03:54:31 +0200
Received: from PUNEXCMS02.corp.capgemini.com ([10.102.17.126]) by
 IN-PNQ-HUBCAS1.corp.capgemini.com ([::1]) with mapi; Wed, 28 Sep 2011
 07:24:30 +0530
From: "Gokhale, Rajas" <rajas.gokhale@capgemini.com>
To: "'shasha@courant.nyu.edu'" <shasha@courant.nyu.edu>,
        "'dennisshasha@yahoo.com'" <dennisshasha@yahoo.com>,
        "Shivgopal, Sandeep"
	<sandeep.shivgopal@capgemini.com>
CC: "Moolay, Indranil" <indranil.moolay@capgemini.com>
Date: Wed, 28 Sep 2011 07:24:29 +0530
Subject: Re: Exam Paper
Thread-Topic: Exam Paper
Thread-Index: Acx9RXl5tWsBvEtJRraF2LvRBDOPYQAPBWme
Message-ID: <14CCA2BA95241348956B43C4DE7A8A5B01A02C58AE48@PUNEXCMS02.corp.capgemini.com>
In-Reply-To: <201109271844.p8RIiIOH010610@access2.cims.nyu.edu>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: en-US
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-Scanned-By: MIMEDefang 2.71 on 128.122.49.99
X-Greylist: Delayed for 00:30:07 by milter-greylist-4.2.6 (mx.cims.nyu.edu [128.122.49.99]); Tue, 27 Sep 2011 22:25:10 -0400 (EDT)
Status: R
Content-Length: 675

Thanks Dennis. Will proceed per your mail.=20
Best,=20
Rajas


----- Original Message -----
From: Dennis Shasha [mailto:shasha@courant.nyu.edu]
Sent: Wednesday, September 28, 2011 12:14 AM
To: dennisshasha@yahoo.com <dennisshasha@yahoo.com>; Gokhale, Rajas; Shivgo=
pal, Sandeep; shasha@courant.nyu.edu <shasha@courant.nyu.edu>
Cc: Moolay, Indranil
Subject: Re: Exam Paper

Dear Rajas,
Yes, I like this plan.
Just two small notes:

Tell them that they can use any language they like in
their pseudo-code description (including English), but
that the code should be clear enough so they can estimate
the order of magnitude time complexity of their algorithm.

Thanks,
Dennis


