#!/usr/bin/python # TYPE:sciencemath # DESC:Solver of the famous "twelve balls" problem, in which one must find a defect out of twelve seemingly identical metal balls. One is either heavier or lighter, and the only tools are a balance scale with three weighings. left = [1, 2, 3, 4] right = [5, 6, 7, 8] garbage = [9, 10, 11, 12] def showStuff(): print "[", for x in left: print x, print ":", for x in right: print x, print "] ", print "{", for x in garbage: print x, print "}" def getBalance(): redo = 1 while redo is 1: print """1: Left heavy 2: Balanced 3: Right heavy""" x = input("> ") if x < 4 and x > 0: redo = 0 return x showStuff() bal = getBalance()