• Gentlemen, start your engines!

    From James Dow Allen@21:1/5 to All on Fri Dec 11 21:58:08 2020
    One day at Monte Carlo, there was a special Formula-Zero race. Seven famous race drivers entered, each with a special car designed by a famous manufacturer (one was Lamborghini). Since it was a Formula-Zero race, each engine used a different unusual
    power source.

    From the clues, determine the order (1st through 7th) in which each driver finished (there were no ties), the make of his car, and engine type.

    Clue 1: The first three cars to cross the finish line were the Ferrari, the car with hydrogen engine, and the car with a steam-powered engine, though not in that exact order.

    Clue 2: The last three cars to cross the finish line were the Bugatti, the car with electric engine, and Mr. Hakkinen's car, though not necessarily in that order.

    Clue 3: Mr. Villeneuve finished before Mr. Lauda, who finished before Mr. Prost.

    Clue 4: The car with a nuclear engine finished before the Maserati.

    Clue 5: Mr. Coulthard's car (which didn't have the solar-powered engine) finished before the Alfa Romeo.

    Clue 6: Four of the engines needed a major overhaul after the race: the diesel engine, the engine in the Mercedes-Benz, and the engines used by Mr. Schumacher and Mr. Villeneuve. The other three undamaged engines included the steam-powered engine (
    which wasn't used by Mr. Lauda).

    Clue 7: The first-place driver won ten cases of champagne, and the second-place driver won ten six-packs of beer. The other five drivers, in no particular order, were Mr. Coulthard, Mr. Senna, the Porsche driver, and the ones with the nuclear and
    propane engines.

    (Let me know what you think. The puzzle is difficult, but not ridiculously so. )
    Dearest regards, James Dow Allen (mail address: jamesdowallen at gmail)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Heathfield@21:1/5 to James Dow Allen on Sat Dec 12 10:47:59 2020
    SPOILER

    On 12/12/2020 05:58, James Dow Allen wrote:
    One day at Monte Carlo, there was a special Formula-Zero race. Seven famous race drivers entered, each with a special car designed by a famous manufacturer (one was Lamborghini). Since it was a Formula-Zero race, each engine used a different unusual
    power source.

    From the clues, determine the order (1st through 7th) in which each driver finished (there were no ties), the make of his car, and engine type.

    Clue 1: The first three cars to cross the finish line were the Ferrari, the car with hydrogen engine, and the car with a steam-powered engine, though not in that exact order.

    Clue 2: The last three cars to cross the finish line were the Bugatti, the car with electric engine, and Mr. Hakkinen's car, though not necessarily in that order.

    Clue 3: Mr. Villeneuve finished before Mr. Lauda, who finished before Mr. Prost.

    Clue 4: The car with a nuclear engine finished before the Maserati.

    Clue 5: Mr. Coulthard's car (which didn't have the solar-powered engine) finished before the Alfa Romeo.

    Clue 6: Four of the engines needed a major overhaul after the race: the diesel engine, the engine in the Mercedes-Benz, and the engines used by Mr. Schumacher and Mr. Villeneuve. The other three undamaged engines included the steam-powered engine (
    which wasn't used by Mr. Lauda).

    Clue 7: The first-place driver won ten cases of champagne, and the second-place driver won ten six-packs of beer. The other five drivers, in no particular order, were Mr. Coulthard, Mr. Senna, the Porsche driver, and the ones with the nuclear and
    propane engines.

    (Let me know what you think. The puzzle is difficult, but not ridiculously so. )

    If you don't want to know the solution, don't execute this program.

    #include <stdio.h>

    int main(void)
    {
    int dc, dh, dl, dp, ds, de, dv;
    int ma, mb, mf, ml, mm, me, mp;
    int ed, ee, eh, en, ep, es, et;
    /*************************************************/
    /* Drivers first. */
    /* de = Senna. */
    /*************************************************/

    for(dc = 3; dc <= 6; dc++) /* From C7, Coulthard not first or second.
    From C5, not last. */
    for(dh = 5; dh <= 7; dh++) /* From C2, Hakkinen not in top 4 */
    if(dh != dc)
    for(dl = 2; dl <= 6; dl++) /* C3: Lauda not first or last */
    if(dl != dc && dl != dh)
    for(dp = dl + 1; dp <= 7; dp++) /* C3: Prost finished after Lauda */
    if(dp != dc && dp != dh) /* no need to test for Pr != La */
    for(ds = 1; ds <= 7; ds++)
    if(ds != dc && ds != dh && ds != dl && ds != dp)
    for(de = 3; de <= 7; de++) /* From C7, Senna not first or second. */
    if(de != dc && de != dh && de != dl && de != dp && de != ds)
    for(dv = 1; dv <= 5; dv++) /* From C3, Villeneuve not 6th or 7th */
    if(dv != dc && dv != dh && dv < dl && dv != ds && dv != de) /* No
    need to test against Prost because Prost already known to be > Lauda */
    /*************************************************/
    /* Drivers done. 158 possible solutions to date. */
    /*************************************************/
    /* Now for manufacturers. me = Mercedes. */
    /*************************************************/
    for(ma = 2; ma <= 7; ma++) /* C5: Alfa not first. */
    if(ma > dc) /* C5: Coulthard beat the Alfa */
    for(mb = 5; mb <= 7; mb++) /* C2: Bugatti in last three. */
    if(mb != ma)
    if(mb != dh) /* C2: Hakkinen not in Bugatti */
    for(mf = 1; mf <= 3; mf++) /* C1: Ferrari on podium */
    if(mf != ma) /* Because of C1 and C2 above, no need to test Ferrari
    against Bugatti */
    for(ml = 1; ml <= 7; ml++)
    if(ml != ma && ml != mb && ml != mf)
    for(mm = 2; mm <= 7; mm++) /* C4: Maserati not first */
    if(mm != ma && mm != mb && mm != mf && mm != ml)
    for(me = 1; me <= 7; me++)
    if(me != ds && me != dv) /* C6: neither Schu nor Ville are in the Merc */
    if(me != ma && me != mb && me != mf && me != ml && me != mm)
    for(mp = 3; mp <= 7; mp++) /* C7: Porsche not in top two */
    if(mp != dc && mp != de) /* C7: Porsche not driven by Coulthard or
    Senna */
    if(mp != ma && mp != mb && mp != mf && mp != ml && mp != mm && mp != me)
    /*************************************************/
    /* Manufacturers done. Solutions whittled down */
    /* from 158 possible solutions to a mere 5820(!) */
    /*************************************************/
    /* Now for engines. et = steam. */
    /*************************************************/
    for(ed = 1; ed <= 7; ed++)
    if(ed != me) /* C6: Merc doesn't use diesel */
    for(ee = 5; ee <= 7; ee++) /* C2: electric in last three */
    if(ee != ed)
    if(ee != mb) /* C2: Bugatti not electric */
    if(ee != dh) /* C2: Hakkinen not electric */
    for(eh = 1; eh <= 3; eh++) /* C1: hydro on podium */
    if(eh != ed && eh != ee)
    if(eh != mf) /* C1: Ferrari not hydro */
    for(en = 3; en < mm; en++) /* C4: nuclear beat Maserati; C7: nuclear
    not in top two. */
    if(en != ed && en != ee && en != eh)
    if(en != dc && en != de && en != mp) /* C7: nuclear not Coulthard,
    Senna, or Porsche */
    for(ep = 3; ep <= 7; ep++)
    if(ep != ed && ep != ee && ep != eh && ep != en)
    if(ep != dc && ep != de && ep != mp) /* C7: propane not Coulthard,
    Senna, or Porsche */
    for(es = 3; es <= 7; es++)
    if(es != ed && es != ee && es != eh && es != en && es != ep)
    if(es != dc) /* C5: Coulthard not solar */
    for(et = 1; et <= 3; et++) /* C1: steam on podium */
    if(et != ed && et != ee && et != eh && et != en && et != ep && et != es)
    if(et != mf) /* C1: Ferrari not steam */
    if(et != dl && et != ds && et != dv && et != me) /* C6: steam not
    Lauda, Schu, Ville, Merc */
    if(!(mf == 1 && eh == 2 && et == 3)) /* C1: the specific order 1.
    Ferrari 2. Hydro 3. Steam is ruled out. */
    {
    int pos = 0;
    char *driver[8] = {0};
    char *manufacturer[8] = {0};
    char *engine[8] = {0};
    driver[dc] = "Coulthard";
    driver[dh] = "Hakkinen";
    driver[dl] = "Lauda";
    driver[dp] = "Prost";
    driver[ds] = "Schumacher";
    driver[de] = "Senna";
    driver[dv] = "Villeneuve";
    manufacturer[ma] = "Alfa Romeo";
    manufacturer[mb] = "Bugatti";
    manufacturer[mf] = "Ferrari";
    manufacturer[ml] = "Lamborghini";
    manufacturer[mm] = "Maserati";
    manufacturer[me] = "Mercedes-Benz";
    manufacturer[mp] = "Porsche";
    engine[ed] = "Diesel";
    engine[ee] = "Electric";
    engine[eh] = "Hydrogen";
    engine[en] = "Nuclear";
    engine[ep] = "Propane";
    engine[es] = "Solar";
    engine[et] = "Steam";

    printf("Pos Driver Manufacturer Engine\n");
    for(pos = 1; pos < 8; pos++)
    {
    printf(" %d %-10s %-13s %-8s\n", pos, driver[pos],
    manufacturer[pos], engine[pos]);
    }
    }
    return 0;
    }


    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)