Three goblins traveling together chanced to encounter a giant, who was alone, and two ogres, who were walking together. A skirmish broke out among them and all combatants suffered bumps and bruises. . Their weapons included 3 clubs, 2 staves, and 1 sling, used for hurling stones.
- The names of the six contenders were: Opi, Rido, Som, Sumo, Tor and Zeb.
- No goblin used a staff, nor did Tor.
- The two ogres used different weapons.
- The sling was used by one of the goblins.
- Som, who was not an ogre, used a staff.
- Opi did not use a club, nor was he a goblin.
- Tor and Zeb used different weapons.
From the above statements, find out which ones were the goblins, which ones were the ogres, which one was the giant, and what weapon did each use?
DECLARE SUB permute (a$)
DIM typ AS STRING, weap AS STRING
typ = "gggoot": ht$ = typ 'goblin, ogre, giant
weap = "cccssl": hw$ = weap 'club, staff, sling
good = 1
o1$ = "": gslingct = 0
IF MID$(weap, 5, 1) = "s" THEN good = 0
FOR i = 1 TO 6
IF MID$(typ, i, 1) = "g" AND MID$(weap, i, 1) = "s" THEN good = 0
IF MID$(typ, i, 1) = "o" THEN
IF o1$ = "" THEN
o1$ = MID$(weap, i, 1)
IF o1$ = MID$(weap, i, 1) THEN good = 0
IF MID$(typ, i, 1) = "g" AND MID$(weap, i, 1) = "l" THEN gslingct = gslingct + 1
IF gslingct = 0 THEN good = 0
IF MID$(typ, 3, 1) = "o" THEN good = 0
IF MID$(weap, 3, 1) <> "s" THEN good = 0
IF MID$(typ, 1, 1) = "g" THEN good = 0
IF MID$(weap, 1, 1) = "c" THEN good = 0
IF MID$(weap, 5, 1) = MID$(weap, 6, 1) THEN good = 0
IF good THEN PRINT typ: PRINT weap: PRINT
LOOP UNTIL weap = hw$
LOOP UNTIL typ = ht$
where the order for each scenario is the original given name order: Opi, Rido, Som, Sumo, Tor and Zeb. The first line has g, t and o to represent goblin, giant and ogre respectively, and the second line has s, c and l to represent staff, club and sling.
Posted by Charlie
on 2014-02-05 12:33:12