示例#1
0
文件: hihi.py 项目: blitzhunterz/grow
def hi():
    m=0
    print 'Hi,jie.'
    time.sleep(2)
    print 'Boo.'
    time.sleep(2)
    n=raw_input('To continue, please enter your date of birth in the format DD/MM/YYYY and press enter. Don\'t ask me why.:')
    try:
        while n!='10/05/1990':
            n=raw_input('Please try again. Did you enter it in the correct format? For example, mine would be 23/06/1995 :')
        else:
            if m!=1:
                time.sleep(1)
                print 'Happy Birthday! Here are some pretty graphs.'
                time.sleep(3)
                print 'okay never mind. I wanted to make some fractal patterns but it\'s beyond me now. Here are some random programs I made for project euler instead.'
            primes.sumprimes()
            z=int(raw_input('Pick a number. This program finds the all primes that are smaller than the number you choose.'))
            print (primes.listprimes(z))
            z=int(raw_input('Pick a number. This program expresses the number you choose as a product of its prime factors.'))
            print (primefact.primefact(z))
            lcm.lcm()
            print 'That\'s all, bye.'
            time.sleep(2)
            print 'Okay not really. Here\'s the last thingy.'
            card.happy()
            card.birthday()
            print 'Self-destruct in 10...'
            time.sleep(10)
            quit()
    except:    
        m=1
 def test_lcm_2(self):
     self.assertEqual(lcm(), 8400)
示例#3
0
 def test_with_preceeding_lower_bound_of_a_as_zero(self):
     lcm(0, 1)
示例#4
0
 def test_with_226553150_and_1023473145(self):
     self.assertEqual(46374212988031350, lcm(226553150, 1023473145))
 def test_small(self):
     for (a, b) in product(range(1, 15), repeat=2):
         self.assertEqual(lcm(a, b), lcm_naive(a, b))
示例#6
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (184769846, 48647616, 154976077872192)]:
         self.assertEqual(lcm(a, b), m)
示例#7
0
def test_lcm(a, b, expected):
    assert lcm(a, b) == expected
from lcm import lcm
from lcm import gcd
import random

# We generate test cases, find the
# answer using a naive algorithm
# and then compare it with the more 
# 'intelligent' algorithm
# Note of course that naive algorithm
# has its limitations: its slower, 
# or works on smaller domain

while True:
	a = random.randint(4, 100)
	b = random.randint(4, 100)

	print("Input a = " + str(a) + ", b = " + str(b))

	gcd_a_b = gcd(a, b)

	expected = (a * b) / gcd_a_b
	actual = lcm(a, b)

	if expected == actual:
		print("OK")
	else:
		print("Expected " + str(expected) + ", but got " + str(actual) + " instead")
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (123213123, 232132, 28601708668236)]:
         self.assertEqual(lcm(a, b), m)
示例#10
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046), (1234324,56754,35026412148)]:
         self.assertEqual(lcm(a, b), m)
示例#11
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (4958723, 9943943, 49309258864789)]:
         self.assertEqual(lcm(a, b), m)
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (959595, 232323232, 222936211811040)]:
         self.assertEqual(lcm(a, b), m)
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (761457, 614573, 467970912861)]:
         self.assertEqual(lcm(a, b), m)
示例#14
0
from lcm import lcm
from lcm import gcd
import random

# We generate test cases, find the
# answer using a naive algorithm
# and then compare it with the more
# 'intelligent' algorithm
# Note of course that naive algorithm
# has its limitations: its slower,
# or works on smaller domain

while True:
    a = random.randint(4, 100)
    b = random.randint(4, 100)

    print("Input a = " + str(a) + ", b = " + str(b))

    gcd_a_b = gcd(a, b)

    expected = (a * b) / gcd_a_b
    actual = lcm(a, b)

    if expected == actual:
        print("OK")
    else:
        print("Expected " + str(expected) + ", but got " + str(actual) +
              " instead")
示例#15
0
 def test_calculates_lcm_with_many_numbers(self):
     self.assertIs(lcm([2, 3, 4, 5, 6]), 60)
示例#16
0
 def test_lcm_4(self):
     self.assertEqual(lcm(), 46374212988031350)
示例#17
0
 def test_calculates_lcm_with_three_numbers(self):
     self.assertIs(lcm([2, 3, 4]), 12)
示例#18
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (123123, 321321, 13174161)]:
         self.assertEqual(lcm(a, b), m)
示例#19
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046), type here]:
         self.assertEqual(lcm(a, b), m)
示例#20
0
import math
from random import randint
from test_helper import run_common_tests, failed, passed, check_tests_pass
from lcm import lcm

if __name__ == '__main__':
    run_common_tests()
    check_tests_pass("lcm_unit_tests.py")

    all_tests_passed = True
    for _ in range(10):
        a, b = randint(1, 10**18), randint(1, 10**18)
        if lcm(a, b) != a * b // math.gcd(a, b):
            all_tests_passed = False
            failed("Wrong answer for a={}, b={}".format(a, b))
            break

        c = randint(1, 10**9)
        a, b = randint(1, 10**9) * c, randint(1, 10**9) * c
        if lcm(a, b) != a * b // math.gcd(a, b):
            all_tests_passed = False
            failed("Wrong answer for a={}, b={}".format(a, b))
            break

    if all_tests_passed:
        passed()
示例#21
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (2000000000, 100000000, 2000000000)]:
         self.assertEqual(lcm(a, b), m)
示例#22
0
import lcm

num1 = input("第一個數?")
num2 = input("第二個數?")

#測試正整數
if (lcm.check(num1) and lcm.check(num2)):
    num1 = int(num1)
    num2 = int(num2)

    lcm.lcm(num1, num2)
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (6134195, 604150552, 3705977295325640)]:
         self.assertEqual(lcm(a, b), m)
示例#24
0
# coding:utf-8
from hcf import hcf
from lcm import lcm

num3 = int(input("最大公约数请按1,最小公倍数请按2 "))
if num3 ==1: 
 num1 = int(input("输入第一个数字: "))
 num2 = int(input("输入第二个数字: "))
 print(hcf(num1, num2))
if num3 ==2:
 num1 = int(input("输入第一个数字: "))
 num2 = int(input("输入第二个数字: "))
 print(lcm(num1, num2))
示例#25
0
 def test_with_preceeding_lower_bound_of_a_as_negative(self):
     lcm(-1, 1)
示例#26
0
import numpy as np
from lcm import lcm

print lcm(np.arange(20)[2:])
示例#27
0
 def test_with_2000000000_and_2000000000(self):
     self.assertEqual(
         2 * int(math.pow(10, 9)),
         lcm(2 * int(math.pow(10, 9)), 2 * int(math.pow(10, 9))))
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046),
                       (12340, 123450, 152337300)]:
         self.assertEqual(lcm(a, b), m)
示例#29
0
 def test_with_preceeding_lower_bound_of_b_as_negative(self):
     lcm(1, -1)
示例#30
0
 def test_large(self):
     for (a, b, m) in [(28851538, 1183019, 1933053046), (14, 21, 42)]:
         self.assertEqual(lcm(a, b), m)
示例#31
0
 def test_lcm_3(self):
     self.assertEqual(lcm(), 233400)
示例#32
0
def test_lcm(a, b, answer):
    assert lcm(a, b) == answer
示例#33
0
 def test_lcm_1(self):
     self.assertEqual(lcm(), 540)
示例#34
0
 def test_calculates_lcm_with_two_numbers(self):
     self.assertIs(lcm([2, 3]), 6)