- Five friends Alice, Ben, Carla, Dan, Ellen and Frank guess at four aces.
- Although nobody gets all answers right, there is a clear winner.
- Two people are tied for second-best score, and two others are tied for third-best score.
The guesses are as follows:
1st Card 2nd Card 3rd Card 4th Card
Alice Spade Spade Club Diamond
Ben Heart Diamond Diamond Club
Carla Diamond Club Heart Spade
Dan Diamond Heart Spade Club
Ellen Heart Spade Club Diamond
Frank Club Spade Diamond Heart
What are the four cards?
DECLARE SUB permute (a$)
CLS
DATA sscd,hddc,dchs,dhsc,hscd,csdh
a$ = "schd": h$ = a$
DO
REDIM score(6), sc(4)
RESTORE
FOR i = 1 TO 6
READ g$
ct = 0
FOR j = 1 TO 4
IF MID$(a$, j, 1) = MID$(g$, j, 1) THEN ct = ct + 1
NEXT
score(i) = ct
sc(ct) = sc(ct) + 1
NEXT
s$ = ""
FOR i = 0 TO 4
IF sc(i) > 0 THEN
s$ = s$ + LTRIM$(STR$(sc(i)))
END IF
NEXT
IF s$ = "1221" THEN
PRINT a$,
FOR i = 1 TO 6
PRINT score(i);
NEXT: PRINT
END IF
permute a$
LOOP UNTIL a$ = h$
finds
hsdc 1 3 0 1 2 2
indicating the correct sequence of Hearts, Spades, Diamonds, Clubs.
The guess sets of Alice, Ben, Carla, Dan, Ellen and Frank, in order, had:
1, 3, 0, 1, 2, and 2 correct guesses.
|
Posted by Charlie
on 2014-04-10 14:58:10 |