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

Home > Logic
A Hand of Cards (Posted on 2009-03-08) Difficulty: 3 of 5
What poker hand of 5 cards can meet these criteria:

  • There are no picture cards, and an ace counts as 1.
  • No two cards had the same denomination.
  • All four suits were present.
  • The total of the odd cards equalled the total of the even cards.
  • No three cards were in sequence in the sense of a straight.
  • The black cards' values totaled 10.
  • The values of the hearts totaled 14.
  • The lowest card was a spade.
  •   Submitted by Charlie    
    Rating: 1.5000 (4 votes)
    Solution: (Hide)
    2  4  5  8  9                                   
    S  D  H  C  H
    
    based on program output
    
    2  4  5  8  9               2  8  5  9    14  14
    

    with the 2 and 8 indicating those as the black cards, and 5 and 9 as being hearts. The odd and even cards each add up to 14.

    DECLARE SUB choose (p!)
    DIM SHARED card(5), tot, oddTot, evenTot
    CLS
    choose 1
    
    SUB choose (p)
      IF p = 1 THEN st = 1 ELSE st = card(p - 1) + 1
      IF p >= 3 THEN IF card(p - 1) - card(p - 2) = 1 THEN st = st + 1
      FOR fv = st TO p + 5
       card(p) = fv
       tot = tot + fv
       IF fv MOD 2 = 1 THEN oddTot = oddTot + fv: ELSE evenTot = evenTot + fv
    
       IF p = 5 THEN
        IF tot > 24 THEN
          FOR c1 = 1 TO 4
           FOR c2 = c1 + 1 TO 5
             IF c1 > 1 THEN cv1 = card(c1):  ELSE cv1 = 0
             tot10 = card(1) + cv1 + card(c2)
             IF tot10 = 10 THEN
             
              FOR h1 = 0 TO 4
               IF h1 <> 1 AND h1 <> c1 AND h1 <> c2 THEN
                 FOR h2 = h1 + 1 TO 5
                  IF h2 <> 1 AND h2 <> c1 AND h2 <> c2 THEN
                   hearts = card(h1) + card(h2)
                   IF hearts = 14 AND oddTot = evenTot THEN
              FOR i = 1 TO 5
                PRINT card(i);
              NEXT
              PRINT , card(c1); card(c2); card(h1); card(h2), oddTot; evenTot
              didIt = 1
                   END IF
                  END IF
                 NEXT
               END IF
              NEXT
             
             END IF
           NEXT c2
          NEXT c1
    
        END IF
       ELSE
         choose p + 1
       END IF
    
       tot = tot - fv
       IF fv MOD 2 = 1 THEN oddTot = oddTot - fv: ELSE evenTot = evenTot - fv
      NEXT fv
    END SUB
    

    The program contains a fudge, using 1 to represent the first of possibly two additional black cards, besides the (lowest) spade, and also as later, in printing, to represent that first card, when it was discovered in building the program that there could be only one additional black card.

    Puzzle from Giant Book of Mensa Mind Challenges, by Todd Johnson, "Nearly Impossible Brain Bafflers" chapter, page 191.

    Comments: ( You must be logged in to post comments.)
      Subject Author Date
    solution explanationDaniel2009-03-08 21:55:30
    SolutionSpreadsheetbrianjn2009-03-08 20:00:53
    SolutionSolutionDej Mar2009-03-08 17:24:51
    Please log in:
    Login:
    Password:
    Remember me:
    Sign up! | Forgot password


    Search:
    Search body:
    Forums (0)
    Newest Problems
    Random Problem
    FAQ | About This Site
    Site Statistics
    New Comments (14)
    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