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

Home > Logic
Boxing Baffle (Posted on 2012-09-12) Difficulty: 3 of 5
A boxing tournament was scheduled in a distant island, and seven inhabitants registered for the competition. Each contestant was to box with each of the others, and each boxer's number of wins would be totaled to determine the winner, and the rankings of the 6 runner-up boxers.
  1. Ian finished ahead of Gary, but behind Vince.
  2. Each of the ranks of Abel and Vince was an odd number.
  3. Each of Brad and Abel finished behind Ian .
  4. Sam had precisely four wins.
  5. Hal finished two places behind Brad .
  6. Gary finished two places ahead of Abel.
In which order did the boxers finish, and how many wins did each have?

Note: There were no ties, either in any individual match or in the final standings.

No Solution Yet Submitted by K Sengupta    
Rating: 2.0000 (1 votes)

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

DECLARE SUB build (a!, b!)
CLEAR , , 25000
CLS
DIM SHARED box(7, 7), score(7), id(7), abel, brad, gary, hal, ian, sam, vince, name$
t = TIMER
name$ = "abghisv"
abel = 1
brad = 2
gary = 3
hal = 4
ian = 5
sam = 6
vince = 7

build 1, 2

PRINT TIMER - t

SUB build (a, b)
   FOR awin = 0 TO 1
     box(a, b) = awin
     IF a = 6 AND b = 7 THEN
       FOR bxr = 1 TO 7
         score(bxr) = 0
         id(bxr) = bxr
         FOR opp = 1 TO 7
           IF opp < bxr THEN
              score(bxr) = score(bxr) + 1 - box(opp, bxr)
           ELSEIF opp > bxr THEN
              score(bxr) = score(bxr) + box(bxr, opp)
           END IF
         NEXT
       NEXT
       good = 1
       IF score(ian) <= score(gary) OR score(ian) >= score(vince) THEN good = 0
       IF score(ian) <= score(brad) OR score(ian) <= score(abel) THEN good = 0
       IF score(sam) <> 4 THEN good = 0
       IF good THEN
          DO
            finished = 1
            FOR i = 1 TO 6
              IF score(i) < score(i + 1) THEN
                SWAP score(i), score(i + 1)
                SWAP id(i), id(i + 1)
                finished = 0
              END IF
            NEXT
          LOOP UNTIL finished
          FOR i = 1 TO 7
            SELECT CASE id(i)
              CASE abel
                abelr = i
              CASE vince
                vincer = i
              CASE hal
                halr = i
              CASE brad
                bradr = i
              CASE gary
                garyr = i
            END SELECT
          NEXT
          IF abelr MOD 2 = 0 OR vincer MOD 2 = 0 THEN good = 0
          IF halr <> bradr + 2 THEN good = 0
          IF garyr <> abelr - 2 THEN good = 0
          ' NO TIES ALLOWED:
          FOR i = 1 TO 6
             IF score(i) = score(i + 1) THEN good = 0
          NEXT
        
          IF good THEN
            FOR i = 1 TO 7
              PRINT MID$(name$, id(i), 1); score(i); "   ";
            NEXT
            PRINT
            PRINT " "; name$
            FOR row = 1 TO 6
             PRINT MID$(name$, row, 1);
             FOR col = 1 TO 7
               IF col <= row THEN
                 PRINT ".";
               ELSE
                 IF box(row, col) = 1 THEN
                  PRINT "<";
                 ELSE
                  PRINT "^";
                 END IF
               END IF
             NEXT
             PRINT
            NEXT
          END IF
       END IF
     ELSE
        newa = a: newb = b + 1
        IF newb > 7 THEN newa = a + 1: newb = newa + 1
        build newa, newb
     END IF
   NEXT
END SUB

 

Their scores, by initials of their names, were:

v 6    i 5    s 4    b 3    g 2    h 1    a 0

The box score below shows the winner of each game. The < or ^ are used as arrowheads to point to the winner's initial, at either the top or the left side:

 abghisv
a.^^^^^^
b..<<^^^
g...<^^^
h....^^^
i.....<^
s......^

The program took 120.7266 seconds using QB 4.5, but 6.535156 seconds using QB64, 18.5 times as fast.


  Posted by Charlie on 2012-09-12 15:58:11
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 (15)
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