コード例 #1
0
def main():
    global MAXDEPTH
    MAXHEIGHT = 6
    MAXWIDTH  = 6
    ifilename = 'cal.txt'
    ofilename = 'cal.txt'
    cal = eval(open(ifilename).read())
    limits,n,ps = Pazzle.readfromfile()
    
    if len(sys.argv) > 1:
        MAXDEPTH = int(sys.argv[1])
    if len(sys.argv) > 2:
        ofilename = sys.argv[2]
    
    nSuccess = 0
    for i,p in enumerate(ps):
        if cal[i] != '':
            print 'already solved',i+1
            continue
        if p.height <= MAXHEIGHT and p.width <= MAXWIDTH:
            oplst = trySolve(p)
            if oplst != '':
                nSuccess += 1
                print i+1,p.height,p.width,oplst
                cal[i] = oplst
            else:
                print 'miss',i+1
                pass
    
    ofs = open(ofilename, 'w')
    ofs.write(repr(cal))
    ofs.close()
コード例 #2
0
import Pazzle

limits,n,ps = Pazzle.readfromfile()

for i,seq in enumerate(eval(open('cal.txt').read())):
    if seq == '':
        continue
    for ch in seq:
        ps[i].operate(ch)
    if not ps[i].isComplete():
        print 'error: Problem No=%d' % (i+1)
        
コード例 #3
0
import pqueue
import Pazzle

l,n,ps = Pazzle.readfromfile()
q = pqueue.PriorityQueue()
for p in ps:
    item = ((p.height, p.width), p)
    q.put(item)

for i in range(10):
    (h,w),p = q.get()
    print i
    print p.width, p.height
    print p
    print