1. A Teaser Solving Program
Would it be possible to write a simple program to solve this?
Three students checked into a hotel and paid the clerk $30 for a room
($10 each). When the hotel manager returned, he noticed that the clerk
had incorrectly charged $30 instead of $25 for the room. The manager
told the clerk to return $5 to the students. The clerk, knowing that the
students would not be able to divide $5 evenly, decided to keep $2 and
to give them only $3.
The students were very happy because they paid only $27 for the room ($9
each). However, if they paid $27 and the clerk kept $2, that adds up to
$29. What happened to the other Dollar?
2. Re: A Teaser Solving Program
Tristen Wilson wrote:
>
> Would it be possible to write a simple program to solve this?
>
> Three students checked into a hotel and paid the clerk $30 for a room
> ($10 each). When the hotel manager returned, he noticed that the clerk
> had incorrectly charged $30 instead of $25 for the room. The manager
> told the clerk to return $5 to the students. The clerk, knowing that the
> students would not be able to divide $5 evenly, decided to keep $2 and
> to give them only $3.
>
> The students were very happy because they paid only $27 for the room ($9
> each). However, if they paid $27 and the clerk kept $2, that adds up to
> $29. What happened to the other Dollar?
>
What is it that you would want the program to do? Point out the flaw in
the text? This is an old "brain teaser" that uses a false statement to
confuse the listener.
Assuming that you're really asking what the answer is, then it's that they
didn't pay $27. They paid $25 for the room, and the clerk "split" the
change with them. The hotel got $25, the clerk got $2, and they kept the
other $3.
Matt
3. Re: A Teaser Solving Program
> What is it that you would want the program to do? Point out the flaw in
> the text? This is an old "brain teaser" that uses a false statement to
> confuse the listener.
>
> Assuming that you're really asking what the answer is, then it's that they
> didn't pay $27. They paid $25 for the room, and the clerk "split" the
> change with them. The hotel got $25, the clerk got $2, and they kept the
> other $3.
>
> Matt
I'm severely confused!
4. Re: A Teaser Solving Program
Tristen Wilson wrote:
>
> > What is it that you would want the program to do? Point out the flaw in
> > the text? This is an old "brain teaser" that uses a false statement to
> > confuse the listener.
> >
> > Assuming that you're really asking what the answer is, then it's that they
> > didn't pay $27. They paid $25 for the room, and the clerk "split" the
> > change with them. The hotel got $25, the clerk got $2, and they kept the
> > other $3.
> >
> > Matt
> I'm severely confused!
Matt is correct (of course). The text of the question is misleading.
Yes, in total the three student paid a net total of $27. The hotel got $25 and
the clerk got $2. The text implies that it proper logic to add the students' $27
and the clerk's $2 to get $29, but the $27 already includes the clerk's take.
--
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell
5. Re: A Teaser Solving Program
Tristen Wilson wrote:
>
> > What is it that you would want the program to do? Point out the flaw in
> > the text? This is an old "brain teaser" that uses a false statement to
> > confuse the listener.
> >
> > Assuming that you're really asking what the answer is, then it's that they
> > didn't pay $27. They paid $25 for the room, and the clerk "split" the
> > change with them. The hotel got $25, the clerk got $2, and they kept the
> > other $3.
> >
> > Matt
> I'm severely confused!
I've been trying to figure out how to explain this problem. The error is pretty
subtle and I had to look it up. I've seen the problem before but I had forgotten.
This is my third attempt to explain it (I canceled the others).
The room cost $25. The students paid $30. They were refunded $5. Of that $5, $2
went to the clerk.
So the students paid $27 for the room. Of that $27, $25 went to the hotel and $2
went to the clerk. The $3 is a red herring and the extra $1 is a phantom.
I don't know how to solve a basic mathematical error with a computer.
$25 + $5 = $30 -- room charge plus overpayment equals total.
$25 + $2 = $27 -- refund $3 to the students (subtract $3 from both sides)
$25 = $25 -- give the clerk his $2 cut (subtract $2 from both sides)
Less confused? Me neither. But that's why it's a puzzle. Basically the reverse
of the problem is wrong -- the $2 shouldn't be added, it should be subtracted.
$30 total - $3 to students - $2 to clerk = room cost ($25) whereas the problem
says $30 total - $3 to students + $2 to clerk = room cost ($25). See the problem?
--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
6. Re: A Teaser Solving Program
That kinda makes sense to me. Ok, I declare this topic closed.
7. Re: A Teaser Solving Program
Matt Lewis wrote:
> Tristen Wilson wrote:
> > Would it be possible to write a simple program to solve this?
> What is it that you would want the program to do? Point out the flaw in
> the text?
If somebody could write a program to find the logical flaw, that would be
very cool.
8. Re: A Teaser Solving Program
Derek Parnell wrote:
> Tristen Wilson wrote:
> >
> > > What is it that you would want the program to do? Point out the flaw in
> > > the text? This is an old "brain teaser" that uses a false statement to
> > > confuse the listener.
> > >
> > > Assuming that you're really asking what the answer is, then it's that they
> > > didn't pay $27. They paid $25 for the room, and the clerk "split" the
> > > change with them. The hotel got $25, the clerk got $2, and they kept the
> > > other $3.
> > >
> > > Matt
> > I'm severely confused!
>
> Matt is correct (of course). The text of the question is misleading.
>
> Yes, in total the three student paid a net total of $27. The hotel got $25 and
> the clerk got $2. The text implies that it proper logic to add the students'
> $27
> and the clerk's $2 to get $29, but the $27 already includes the clerk's
> take.
Exactly. Calculating $27 + $2 wouldn't make any sense here. Suggesting this
is what confuses the reader. The proper math operation here is $27 - $2:
The sudents had payed $27, minus the $2 which the clerk kept, gives $25
for the hotel.
Just for fun, I wrote a small Eu program. It can't actually "solve" the
problem, but it might help human beings not to get confused.
atom student_a, student_b, student_c, clerk, hotel
procedure show_money (sequence title)
puts(1, title & "\n")
puts(1, "----------\n")
printf(1, "student_a: %5.2f\n", {student_a})
printf(1, "student_b: %5.2f\n", {student_b})
printf(1, "student_c: %5.2f\n", {student_c})
printf(1, "clerk : %5.2f\n", {clerk})
printf(1, "hotel : %5.2f\n", {hotel})
printf(1, "There are %.2f $ total in the game.\n\n",
{student_a+student_b+student_c+clerk+hotel})
end procedure
-- Initialize: E.g. each student has 10 $, the clerk and the hotel have nothing.
student_a = 10
student_b = 10
student_c = 10
clerk = 0
hotel = 0
show_money("Initially")
-- Step 1: Each student gives 10 $ to the hotel.
student_a -= 10 hotel += 10
student_b -= 10 hotel += 10
student_c -= 10 hotel += 10
-- Step 2: The hotel gives 5 $ to the clerk.
hotel -= 5 clerk += 5
-- Step 3: The clerk gives 1 $ to each student.
clerk -= 1 student_a += 1
clerk -= 1 student_b += 1
clerk -= 1 student_c += 1
-- Let's see how many money everyone has in the end.
show_money("In the end")
puts(1, "\nPress [Enter] to continue ...")
if getc(0) then end if
Regards,
Juergen
9. Re: A Teaser Solving Program
Juergen Luethje wrote:
>
<snip>
Sorry Juergen, this topic is closed.
Matt
10. Re: A Teaser Solving Program
Matt Lewis wrote:
> Juergen Luethje wrote:
> >
>
> <snip>
>
> Sorry Juergen, this topic is closed.
>
> Matt
Can you please explain to me, as a friend of the fine art of lock picking,
what the word "closed" means?
Regards,
Juergen