Three teams A, B and C participated in a 3 sided hockey tournament. In three games, team A played team B, team B played against team C, and team A played against team C.
- The three final scores of the games consisted of the numbers 1, 2, 3, 4, 5, and 6.
- The difference between the team Aís higher score and the team B's higher score was one more than the difference between team Bís lower and team Cís lower score.
- The highest total of a teamís two scores was achieved by the team that lost the greatest number of games.
Which team achieved the highest total of its two scores?
DECLARE SUB permute (a$)
s$ = "123456": h$ = s$
a1 = VAL(MID$(s$, 1, 1))
a2 = VAL(MID$(s$, 5, 1))
b1 = VAL(MID$(s$, 2, 1))
b2 = VAL(MID$(s$, 3, 1))
c1 = VAL(MID$(s$, 4, 1))
c2 = VAL(MID$(s$, 6, 1))
IF a1 > a2 THEN ahi = a1: ELSE ahi = a2
IF b1 > b2 THEN bhi = b1: blo = b2: ELSE bhi = b2: blo = b1
IF c1 > c2 THEN clo = c2: ELSE clo = c1
IF ABS(ahi - bhi) = 1 + ABS(blo - clo) THEN
atot = a1 + a2
btot = b1 + b2
ctot = c1 + c2
hitot$ = ""
IF atot > btot AND atot > ctot THEN hitot$ = "a"
IF btot > atot AND btot > ctot THEN hitot$ = "b"
IF ctot > btot AND ctot > atot THEN hitot$ = "c"
awon = 0: bwon = 0: cwon = 0
IF a1 > b1 THEN awon = awon + 1: ELSE bwon = bwon + 1
IF a2 > c2 THEN awon = awon + 1: ELSE cwon = cwon + 1
IF b2 > c1 THEN bwon = bwon + 1: ELSE cwon = cwon + 1
lowon$ = ""
IF awon < bwon AND awon < cwon THEN lowon$ = "a"
IF bwon < awon AND bwon < cwon THEN lowon$ = "b"
IF cwon < bwon AND cwon < awon THEN lowon$ = "c"
IF hitot$ = lowon$ AND hitot$ > "" THEN
PRINT hitot$, MID$(s$, 1, 2); " "; MID$(s$, 3, 2); " "; MID$(s$, 5, 2),
PRINT atot; btot; ctot, awon; bwon; cwon
LOOP UNTIL s$ = h$
game tot games
scores points won
AB BC AC A B C A B C
c 12 43 65 7 6 8 1 2 0
meaning C achieved the highest total score. A lost to B 1-2; B won against C 4-3 and A won against C 6-5. A had a total of 7 points; B, 6 and C, 8, for respective numbers of wins of 1, 2 and 0.
Edited on February 3, 2014, 1:31 pm
Posted by Charlie
on 2014-02-03 13:22:32