Esempio n. 1
0
 def do_GET(self):
     if self.path != '/':
         self.send_error(404)
         return
     s = SuDoKu()
     t0 = time.time()
     generated = s.generate()
     t1 = time.time()
     resolved = s.resolve()[0]
     t2 = time.time()
     difficulty = s.estimate()[0]
     substitutions = {
         'gen': s.to_string('html', generated),
         'gen_t': (t1 - t0) * 1000,
         'res': s.to_string('html', resolved),
         'res_t': (t2 - t1) * 1000,
         'dif': difficulty,
         'year': datetime.date.today().year,
     }
     html = (TEMPLATE % substitutions).encode('utf-8')
     self.send_response(200)
     self.send_header('Content-Type', 'application/xhtml+xml')
     self.send_header('Content-Length', len(html))
     self.end_headers()
     self.wfile.write(html)
Esempio n. 2
0
def run_tests():
    hpy().heapu() # pre-heating
    print('\n========   begin    ========\n')
    print(hpy().heapu())
    print('\n========    init    ========\n')
    s = SuDoKu()
    print(hpy().heapu())
    print('\n========    read    ========\n')
    s.from_string(problem)
    print(hpy().heapu())
    print('\n========  resolve   ========\n')
    s.resolve()
    print(hpy().heapu())
    print('\n========  generate  ========\n')
    s.generate()
    print(hpy().heapu())
    print('\n========    end     ========\n')
Esempio n. 3
0
def run_tests():
    hpy().heapu()  # pre-heating
    print('\n========   begin    ========\n')
    print(hpy().heapu())
    print('\n========    init    ========\n')
    s = SuDoKu()
    print(hpy().heapu())
    print('\n========    read    ========\n')
    s.from_string(problem)
    print(hpy().heapu())
    print('\n========  resolve   ========\n')
    s.resolve()
    print(hpy().heapu())
    print('\n========  generate  ========\n')
    s.generate()
    print(hpy().heapu())
    print('\n========    end     ========\n')