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

Home > Logic
Girls Just Wanna Have Fun (Posted on 2003-11-06) Difficulty: 3 of 5
5 Girls (named Alice, Betty, Carol, Diane, Emily) visit a mall to shop. They come upon a clothing shop and they decide to buy clothing.

But, for some strange reason, different colored shirts cost different amounts, which now came in increments of 10 dollars. (Every shirt of the same color costs the same amount.) This store doesn't carry very many shirts; the most expensive one is 50 dollars, and they only come in red, green, blue, yellow, and orange.

Each girl goes into the store and finds two different shirts. No two girls got the same pair of shirts, and no girl got a shirt for free. It ended up that each color shirt was bought exactly twice.

Using the following clues, can you figure out the two colors of shirts each girl bought, and how much each color bought, as well as how much each girl spent?

1) When the 5 girls were comparing their purchases, they found that Diane spent the most money, 2 girls tied for second most money spent, and the other 2 girls spent the same amount of money as well.

2) When Carol bought the blue shirt, she was mad that the it was more expensive than the 10-dollar price it was last week, and didn't buy the green shirt because of this.

3) Diane's and Emily's different styles resulted in them not buying any shirts the same color as each other's.

4) Alice and Emily both decided not to buy the orange shirt, but instead, Alice went with Carol to pick out the same color shirt to buy, noting that it didn't cost 20 dollars like last week.

5) As Betty was waiting to buy a red shirt (which she did end up buying), she saw Carol buy a shirt that cost 40 dollars.

See The Solution Submitted by Gamer    
Rating: 3.5714 (14 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: Each shirt purchased twice | Comment 20 of 37 |
(In reply to Each shirt purchased twice by Gamer)

With the added rule, the solution set is indeed reduced to one. The revised program is:

DECLARE SUB varyGirl (which!)
DECLARE SUB permute (a$)
CLS
DIM SHARED colr$, gs$(2, 5), total(5)
colr$ = "rgbyo"
OPEN "shirts.txt" FOR OUTPUT AS #2
FOR costs = 1 TO 120
  varyGirl 1
  permute colr$
NEXT

CLOSE

SUB permute (a$)
DEFINT A-Z
 x$ = ""
 FOR i = LEN(a$) TO 1 STEP -1
  l$ = x$
  x$ = MID$(a$, i, 1)
  IF x$ < l$ THEN EXIT FOR
 NEXT

 IF i = 0 THEN
  FOR j = 1 TO LEN(a$) \ 2
   x$ = MID$(a$, j, 1)
   MID$(a$, j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
   MID$(a$, LEN(a$) - j + 1, 1) = x$
  NEXT
 ELSE
  FOR j = LEN(a$) TO i + 1 STEP -1
   IF MID$(a$, j, 1) > x$ THEN EXIT FOR
  NEXT
  MID$(a$, i, 1) = MID$(a$, j, 1)
  MID$(a$, j, 1) = x$
  FOR j = 1 TO (LEN(a$) - i) \ 2
   x$ = MID$(a$, i + j, 1)
   MID$(a$, i + j, 1) = MID$(a$, LEN(a$) - j + 1, 1)
   MID$(a$, LEN(a$) - j + 1, 1) = x$
  NEXT
 END IF
END SUB

DEFSNG A-Z
SUB varyGirl (which)
  DIM t(5)
  DIM colrCt(5)
  FOR shirt1 = 1 TO 4
    gs$(1, which) = MID$(colr$, shirt1, 1)
    FOR shirt2 = shirt1 + 1 TO 5
      gs$(2, which) = MID$(colr$, shirt2, 1)
      total(which) = shirt1 + shirt2
      SELECT CASE which
        CASE 1
         IF gs$(1, which) = "o" OR gs$(2, which) = "o" THEN GOTO notThis
        CASE 2
         IF gs$(1, which) <> "r" AND gs$(2, which) <> "r" THEN GOTO notThis
        CASE 3
         IF gs$(1, which) <> "b" AND gs$(2, which) <> "b" THEN GOTO notThis
         IF gs$(1, which) = "b" AND shirt1 = 1 OR gs$(2, which) = "b" AND shirt2 = 1 THEN GOTO notThis
         IF gs$(1, which) = "g" OR gs$(2, which) = "g" THEN GOTO notThis
         IF gs$(1, which) <> gs$(1, 1) AND gs$(1, which) <> gs$(2, 1) AND gs$(2, which) <> gs$(1, 1) AND gs$(2, which) <> gs$(2, 1) THEN GOTO notThis
         IF gs$(1, which) = gs$(1, 1) OR gs$(1, which) = gs$(2, 1) THEN
          IF shirt1 = 2 THEN GOTO notThis
         ELSE
          IF shirt2 = 2 THEN GOTO notThis
         END IF
         IF shirt1 <> 4 AND shirt2 <> 4 THEN GOTO notThis
        CASE 5
         IF gs$(1, which) = "o" OR gs$(2, which) = "o" THEN GOTO notThis
      END SELECT
      FOR j = 1 TO which - 1
        IF gs$(1, j) = gs$(1, which) AND gs$(2, j) = gs$(2, which) THEN GOTO notThis
      NEXT
      IF which < 5 THEN
        varyGirl which + 1
      ELSE
        GOSUB evaluate
      END IF
notThis:
    NEXT
  NEXT
  EXIT SUB

evaluate:
  IF total(4) > total(1) AND total(4) > total(2) AND total(4) > total(3) AND total(4) > total(5) THEN
   t(1) = total(1): t(2) = total(2): t(3) = total(3): t(4) = total(5)
   DO
    fl = 0
    FOR i = 1 TO 3
      IF t(i) > t(i + 1) THEN SWAP t(i), t(i + 1): fl = 1
    NEXT
   LOOP UNTIL fl = 0
   gs1$ = gs$(1, 1) + gs$(1, 2) + gs$(1, 3) + gs$(1, 4) + gs$(1, 5)
   gs2$ = gs$(2, 1) + gs$(2, 2) + gs$(2, 3) + gs$(2, 4) + gs$(2, 5)
   IF t(3) = t(4) AND t(1) = t(2) THEN
    IF gs$(1, 4) <> gs$(1, 5) AND gs$(1, 4) <> gs$(2, 5) AND gs$(2, 4) <> gs$(1, 5) AND gs$(2, 4) <> gs$(2, 5) THEN
      bad = 0
      FOR i = 1 TO 2
       FOR j = 1 TO 5
        ix = INSTR(colr$, gs$(i, j))
        colrCt(ix) = colrCt(ix) + 1
        IF colrCt(ix) > 2 THEN bad = 1
       NEXT
      NEXT
      IF bad = 0 THEN
        PRINT
        PRINT colr$
        PRINT gs1$
        PRINT gs2$
        FOR g = 1 TO 5
          PRINT 10 * total(g);
        NEXT
        PRINT
      END IF
    END IF
   END IF
  END IF
 RETURN
END SUB

and it finds the one solution
yrobg (order of colors from $10 to $50 value)

yryor (girls' less expensive shirts: Alice to Emily)
gobgb (girls' more expensive shirts: Alice to Emily)
60 50 50 80 60 (amounts spent: Alice to Emily)


  Posted by Charlie on 2003-11-07 21:18:54

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