< previous page page_559 next page >

Page 559
Problem-Solving Case Study Rock, Paper, Scissors
0559-01.gif
Problem: Play the children's game rock, paper, scissors. In this game, two people simultaneously choose one of the following: rock, paper, or scissors. Whether a player wins or loses depends not only on that player's choice but also on the opponent's choice. The rules are:
Rock breaks scissors; rock wins.
Paper covers rock; paper wins.
Scissors cut paper; scissors win.
All matching combinations are ties.
The overall winner is the player who wins the most individual games.
Input: A series of letters representing player A's plays (fileA, one letter per line) and a series of letters representing player B's plays (fileB, one letter per line), with each play indicated by R (Rock), P (Paper), or S (Scissors).
Output: For each game, the game number and the player who won that game; at the end, the total number of games won by each player, and the overall winner.
0559-02.gif
The Far Side ©1986 FarWorks, Inc./Dist.
by Universal Press Syndicate. Reprinted
with permission. All rights reserved.

 
< previous page page_559 next page >