Ejemplo n.º 1
0
    def testMethod():
        result = lib.outputOf(_fileName, stdinArgs=[10])

        for line in clean_lines(result):
            years = lib.getPositiveIntegersFromString(line)
            if len(years) > 0:
                return True
Ejemplo n.º 2
0
 def testMethod():
     primes = set([
         2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
         67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
         139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
         211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277,
         281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
         367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439,
         443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
         523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
         613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683,
         691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773,
         787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
         877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967,
         971, 977, 983, 991, 997
     ])
     result = lib.outputOf(_fileName)
     for line in result.split("\n"):
         if line.strip() == "":
             continue
         numbers = lib.getPositiveIntegersFromString(line)
         if sum(1 for n in numbers if n in primes) != 2:
             return False, "\"{}\" does not contain precisely two primes".format(
                 line)
     return True
Ejemplo n.º 3
0
 def testMethod():
     result = lib.outputOf(_fileName, stdinArgs=[100])
     expected_numbers = set([
         2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
         67, 71, 73, 79, 83, 89, 97
     ])
     printed_numbers = set(lib.getPositiveIntegersFromString(result))
     return expected_numbers == printed_numbers
Ejemplo n.º 4
0
 def testMethod():
     result = lib.outputOf(_fileName)
     for line in result.split("\n"):
         if line.strip() == "":
             continue
         numbers = lib.getPositiveIntegersFromString(line)
         if not any(sum(numbers) / 2 == n for n in numbers):
             return False, "\"{}\" is an incorrect calculation".format(line)
     return True
Ejemplo n.º 5
0
 def testMethod():
     result = lib.outputOf(_fileName)
     evenNumbers = set(range(4, 1001, 2))
     for line in result.split("\n"):
         if line == "\n":
             continue
         evenNumbers -= set(lib.getPositiveIntegersFromString(line))
     testResult = len(evenNumbers) == 0
     return testResult
Ejemplo n.º 6
0
def testBirthday(vali, valo):
    result = lib.outputOf(_fileName, stdinArgs=[vali])
    lines = clean_lines(result)
    if len(lines) < 1:
        return False, "No output"
    line = lines[0]
    ints = set(lib.getPositiveIntegersFromString(line))
    if valo in ints:
        return True
    return False, f'Expected {valo}'
Ejemplo n.º 7
0
    def testMethod():
        result = lib.outputOf(_fileName, stdinArgs=[1])

        lines = clean_lines(result)
        if len(lines) > 1:
            return False, "Output consists of more than one line"
        if len(lines) < 1:
            return False, "No output"
        line = lines[0]
        ints = lib.getPositiveIntegersFromString(line)
        if len(ints) < 1:
            return False, "No year found in the output"
        return True
Ejemplo n.º 8
0
	def testMethod():
		def findline(outputOf):
			tsts = ['starting', 'money', 'equal', 'number', 'streets']
			for line in outputOf.split("\n"):
				if all([assertlib.contains(line, tst) for tst in tsts]):
					return line
			return ""

		line = findline(lib.outputOf(_fileName))

		info = ""
		if not line:
			info = "Check the assignment for the proper output format of the solution."
		elif not any([assertlib.numberOnLine(number, line) for number in [0, 50, 100, 150, 200]]):
			info = "The found value was not rounded to the nearest value of 50 euros."
		else:
			info = "Properly rounded to the nearest value, but the value returned was incorrect."
		integers_found = set(lib.getPositiveIntegersFromString(line))
		return len(integers_found & set([100, 150])) > 0, info
Ejemplo n.º 9
0
 def testMethod():
     result = lib.outputOf(_fileName, stdinArgs=[11])
     expected_numbers = set([2, 3, 5, 7])
     printed_numbers = set(lib.getPositiveIntegersFromString(result))
     return expected_numbers == printed_numbers
Ejemplo n.º 10
0
 def testMethod():
     result = lib.outputOf(_fileName, stdinArgs=[1990, 2020])
     expected_years = set([1992, 1996, 2000, 2004, 2008, 2012, 2016])
     printed_years = set(lib.getPositiveIntegersFromString(result))
     return expected_years == printed_years
Ejemplo n.º 11
0
 def testMethod():
     result = lib.outputOf(_fileName, stdinArgs=[1890, 1920])
     expected_years = set([1892, 1896, 1904, 1908, 1912, 1916])
     printed_years = set(lib.getPositiveIntegersFromString(result))
     return expected_years == printed_years