Re: A Teaser Solving Program

new topic     » goto parent     » topic index » view thread      » older message » newer message

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. smile
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu