def test_magnitude(): assert(a.magnitude("[9,1]") == 29), "magnitude test 1 failed" assert(a.magnitude("[[1,2],[[3,4],5]]") == 143), "magnitude test 2 failed" assert(a.magnitude("[[[[0,7],4],[[7,8],[6,0]]],[8,1]]") == 1384), "magnitude test 3 failed" assert(a.magnitude("[[[[1,1],[2,2]],[3,3]],[4,4]]") == 445), "magnitude test 4 failed" assert(a.magnitude("[[[[3,0],[5,3]],[4,4]],[5,5]]") == 791), "magnitude test 5 failed" assert(a.magnitude("[[[[5,0],[7,4]],[5,5]],[6,6]]") == 1137), "magnitude test 6 failed" assert(a.magnitude("[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]") == 3488), "magnitude test 7 failed" sfn = a.main("test-magnitude") assert(a.SnailfishNumber.create(sfn).magnitude() == 4140), "test-magnitude failed"
def nexta(str, root): if str == "": messagebox.askokcancel('提示框', '不能输入空字符串') if str != "": print(str) root.destroy() a_isTrue = a.main() if a_isTrue == 1: print() b.main() c.main()
def clickb(self): self.sifre = self.lineEdit.text() if len(self.sifre) >=4 and len(self.sifre) <= 13: self.sifreleyici = hasher.sha256() self.sifreleyici.update(self.sifre.encode("utf-8")) hash = self.sifreleyici.hexdigest() if self.pushButton.text() == "Resim Başarıyla Seçildi": a.main(self.image, hash) self.pushButton_2.setText("Başarılı. (\"Sifreli\" Adlı Klasörü Kontrol Ediniz)") else: self.pushButton_2.setText("Hata!!, Tekrar Deneyiniz") else: self.pushButton_2.setText("Şifre uzunluğu 3 ila 14 arasında olamlı")
return rv def find_max_n(r, liters, left=0, right=10**20): # print "fmn", r, liters, left, right if right - left < 10: for n in range(left, right + 1): if paint_needed(r, n) > liters: break else: raise RuntimeError("something's wrong") return n - 1 mid = (left + right) / 2 if paint_needed(r, mid) > liters: return find_max_n(r, liters, left, mid) else: return find_max_n(r, liters, mid + 1, right) def main(): T = int(raw_input()) for case_num in range(1, T + 1): r, t = map(int, raw_input().split()) print "Case #{}: {}".format(case_num, find_max_n(r, t)) if __name__ == "__main__": import a a.main()
from a import main, C if __name__ == '__main__': main() c = C() c.f('foo') c.g('bar')
#-*coding:utf-8*- import a #0001.py import sqlite3 result = list(a.main()) def mysave(dbName, lis): cx = sqlite3.connect(dbName) cur = cx.cursor() sql = 'create table test (id integer primary key,val varchar(20) UNIQUE)' cur.execute(sql) tmp = [] for i in range(200): tmp.append((i,str(lis[i]))) for item in tmp: cx.execute("insert into test values (?,?)", item) cx.commit() #cur.execute('select * from test') #print cur.fetchall() if __name__ == '__main__': mysave('test.db',result)
(u'A+(((B+C))*D)', u'ABC+D*+'), (u'A*B*C*D', u'AB*C*D*'), (u'(A+(B/C))*D/E+F-G+(((H+I))*J)', u'ABC/+D*E/F+G-HI+J*+'), ]: s = AheuiStorage() in_file = io.StringIO(in_data + '\n') def input_char(): c = in_file.read(1) if not c: return -1 return ord(c) try: main(s, input_char=input_char) except AheuiHalt: pass else: raise Exception out_file = io.StringIO() for t, v in s.output_buffer: out_file.write({ 'char': unichr_(v), 'num': u'{}'.format(v), }[t]) out_file.seek(0) out_res = out_file.read() success = out_data.rstrip(u'\n') == out_res.rstrip(u'\n') print(u'-' * 50)
def test_a(): a.main() assert 1 == 1
from a import main from b import C if __name__ == '__main__': main() c = C() c.f('foo') c.g('bar')
def test_main(): assert(a.main("test1") == "[[[[1,1],[2,2]],[3,3]],[4,4]]"), "test 1 failed" assert(a.main("test2") == "[[[[3,0],[5,3]],[4,4]],[5,5]]"), "test 2 failed" assert(a.main("test3") == "[[[[5,0],[7,4]],[5,5]],[6,6]]"), "test 3 failed" assert(a.main("test4") == "[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]"), "test 4 failed"