Re: The RUN CHASE: A Challenge for the Programmer in U...

news.telesweet.net wrote:
On 4/5/2010 5:49 AM, Richard Heathfield wrote:
CVS wrote:
In a game of cricket,

1. Assume you can score exactly as you want on each ball.

2. Single/Double/Triple/Four/Six are the options available to you on
each ball.(no extras)

3. RISK is defined as the square of the score on each ball.

* * * *
Write a program that accepts:-
a. Target runs to score (N)
b. No. of balls to score it in (x)

and prints the runs to score on each ball.

Remember U have to ACHIEVE the target with MINIMUM RISK possible.

Hypothesis: for scoring N, the minimum risk is achieved when you hit N
singles.

To score N + 1, we can do one of these things:

* reduce N to N-5, then add a six. The effect on the risk is that R[N+1]
is (R[N] - 5) + 36 = R[N] + 31, which is greater than R[N];
* reduce N to N-3, then add a four. This gives a risk greater than R[N]
by 4*4-3 = 13;
* reduce N to N-2, then add a three. This gives a risk greater than R[N]
by 3*3-2 = 7;
* reduce N to N-1, then add a two. This gives a risk greater than R[N]
by 2*2-1 = 3;
* simply add a single. This increases the risk by 1, the minimum.

Now the base cases. To score 0, the least risky score is 0. To score 1,
the least risky score is a single. To score 2, the least risky score is
two singles. To score 3, the least risky score is three singles. To
score 4, the least risky score is four singles. To score 5, the least
risky score is five singles. And just to be sure, to score 6 the least
risky score is six singles.

Induction has shown us that singles are always the safest way. Since the
overriding requirement is minimum risk, x is irrelevant and can be ignored.

You have implicitly assumed that x >= N in this argument. If x < N then it is simply impossible to score N on x balls by only scoring singles.

If x < N, you haven't minimised the risk, which is a requirement - in fact, it's the only requirement, and it's spelled out in CAPITAL LETTERS, so it's obviously vital. Therefore, x must be >= N.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
.

Relevant Pages

• Re: The RUN CHASE: A Challenge for the Programmer in U...
... RISK is defined as the square of the score on each ball. ... Remember U have to ACHIEVE the target with MINIMUM RISK possible. ... the least risky score is 0. ... two singles. ...
(comp.programming)
• Re: The RUN CHASE: A Challenge for the Programmer in U...
... RISK is defined as the square of the score on each ball. ... Remember U have to ACHIEVE the target with MINIMUM RISK possible. ... the least risky score is 0. ... two singles. ...
(comp.programming)
• Re: The RUN CHASE: A Challenge for the Programmer in U...
... RISK is defined as the square of the score on each ball. ... Remember U have to ACHIEVE the target with MINIMUM RISK possible. ... the least risky score is a single. ... the least risky score is two singles. ...
(comp.programming)
• Re: Curious teaser
... up the ball and throw it, while not being close to where the ball is. ... A few supporting cries of "No singles to you!" ... Ball" for this unless the MCC or whoever offers suitable guidance *for ... appears to have been deemed as unfair. ...
(uk.sport.cricket)
• Re: Curious teaser
... up the ball and throw it, while not being close to where the ball is. ... But there are any number of ways of deterring the batsmen from taking singles to you. ... I must confess I have not noticed the ploy described by "max.it" in any televised match I have seen. ... Yokel posts via a spam-trap account which is not read. ...
(uk.sport.cricket)