All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
Four Cards (Posted on 2014-04-10) Difficulty: 3 of 5
  1. Five friends Alice, Ben, Carla, Dan, Ellen and Frank guess at four aces.
  2. Although nobody gets all answers right, there is a clear winner.
  3. 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?

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution the computer method Comment 2 of 2 |

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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information