Einzelnen Beitrag anzeigen

PythonLover

Registriert seit: 29. Sep 2010
1 Beiträge
 
#9

AW: Knobelaufgaben der Zeitschrift Chip-Toms Compuzzle

  Alt 29. Sep 2010, 12:03
Ich habe gerade Puzzle #4 von C nach Python konvertiert, dann bin ich auf diesen Eintrag gestossen.
Der Thread ist ja schon über ein Jahr alt, aber vielleicht interessiert es noch jemanden.
Den Aufgabentext habe ich leider nicht mehr und außerdem ist das Programm nicht in Delphi...
Aber hier geht es doch in erster Linie um die Puzzles, oder?
Code:
# tom's compuzzle 4, chip 01/1987.228

nichts='nichts'
Schnaps='Schnaps'
trinkt=[nichts,Schnaps]
for mon in trinkt:
  for tue in trinkt:
    for wed in trinkt:
      for thu in trinkt:
        for fri in trinkt:
          for sat in trinkt:
            for sun in trinkt:
              if wed==Schnaps:
                if mon==sat:
                  pass
                else:
                  continue
              if mon==Schnaps:
                if thu==Schnaps and fri==nichts:
                  pass
                else:
                  continue
              if tue==Schnaps and wed==nichts:
                if mon==Schnaps:
                  pass
                else:
                  continue
              if mon==nichts:
                if sun==Schnaps:
                  pass
                else:
                  continue
              if mon==nichts and thu==nichts:
                if tue==Schnaps:
                  pass
                else:
                  continue
              if sun==Schnaps and wed==Schnaps:
                if sat==Schnaps:
                  pass
                else:
                  continue
              if thu==Schnaps:
                if fri==nichts:
                  if tue==Schnaps:
                    pass
                  else:
                    continue
              if tue==Schnaps:
                if sun==Schnaps and sat==nichts:
                  pass
                else:
                  continue
              if fri==Schnaps:
                if mon==nichts:
                  if wed==Schnaps:
                    pass
                  else:
                    continue
              print mon, tue, wed, thu, fri, sat, sun

# Schnaps Schnaps nichts Schnaps nichts nichts Schnaps
  Mit Zitat antworten Zitat