This is trivial:
number of matches required to get a winner = number of players - 1
explanation:
one match eliminates one player
every player but one must be eliminated to have a winner
therefore.......
I didn't know someone has actually solved the problem when I
posted the last message.
The answer is elegant, not trivial. I gave this problem to people
in a first programming class over a period of 15 years. Maybe 10
people solved it correctly in the approximately 1,000 students who
took it. Almost everyone did something like.
N = N /2 rounded up.
M = N /2 rounded down.
If N = 1 display Matches
about half tried it with an example of N being a power of two and
never rounded.
This is an emulation of an actual tournament.
Another variation was:
N = decrement N
M = increment M
If N = 1 display Matches.
Your answer required a different philosophical approach.
You are asking, how is a looser determined? The above two
approaches ask how is a winner determined?
Urb
Urb
Dr. Urban A. LeJeune, President
E-Government.com
800-204-9545
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php