Перфектни числа

Краен срок
07.03.2014 23:59

Срокът за предаване на решения е отминал

Едно естествено число ще наричаме перфектно, ако е равно на сумата на положителните си делители, по-малки от него

Например, 6 е перфектно число, защото:

1 + 2 + 3 = 6

Но 8 не е:

1 + 2 + 4 = 7

Условието

Напишете функция is_perfect, която приема int и връща булева стойност - True, ако подаденото число е пефектно и False, ако не е.

Пример

>>> is_happy(6)
<<< True

>>> is_happy(10)
<<< False

Решения

Виктория Христова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Виктория Христова
from functools import reduce
from operator import add
def is_perfect(number):
divisors = [d for d in range(1, number) if number % d == 0]
return reduce(add, divisors, 0) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Ивайло Бъчваров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Ивайло Бъчваров
def is_perfect(number):
divisors = []
for i in range(1, number):
if number % i == 0:
divisors.append(i)
if sum(divisors) == number:
return True
else:
return False
if __name__ == '__main__':
print(is_perfect(6))
print(is_perfect(10))
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Васил Тодоров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Васил Тодоров
def is_perfect (number):
return sum([x for x in range (1, number // 2 + 1) if number % x == 0 and number > x]) == number and number > 0
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Даяна Маринова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Даяна Маринова
def is_perfect(n):
sum = 0
for i in range(1, n):
if n % i == 0:
sum += i
if sum == n:
return True
else:
return False
print(is_perfect(6))
print(is_perfect(8))
print(is_perfect(12))
print(is_perfect(496))
print(is_perfect(8128))
True
False
False
True
True
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Веселин Генадиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Веселин Генадиев
def is_perfect(number):
smaller = range(1, abs(number) - 1)
divisors = [divisor for divisor in smaller if number % divisor == 0]
return sum(divisors) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Снежана Спасова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Снежана Спасова
def is_perfect(number):
return sum(list(filter(lambda x: number % x == 0, range(1, number)))) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.011s

OK
Момчил Станчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Момчил Станчев
def is_perfect(number):
if number > 0:
divisors = [divisor for divisor in range(1, number) if number % divisor == 0]
return number == sum(divisors)
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Станислав Гатев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Станислав Гатев
def is_perfect(number):
is_divisor = lambda x: number % x == 0
return sum(filter(is_divisor, range(1, number))) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.009s

OK
Антония Чекръкчиева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Антония Чекръкчиева
def is_perfect(number):
suma = 0
for i in range(1, number):
if (number % i == 0):
suma += i
return suma == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Драгомир Тунчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Драгомир Тунчев
def is_perfect(n):
a, b = 1, 0
while a < n:
if n % a == 0:
a, b = a + 1, b + a
else:
a = a + 1
if b == n:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK
Иван Георгиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Георгиев
def is_perfect(number):
if not number:
return False
amount = 0
for unit in range(1, number):
if not number % unit:
amount += unit
return amount == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Стоян Цветков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стоян Цветков
import math
def is_perfect(num):
if num == 0:
return False
factors = []
start = math.floor(num / 2)
for i in range(start, 0, -1):
if num % i == 0:
factors.append(i)
return sum(factors) == num
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Цветелина Борисова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Цветелина Борисова
def is_perfect(number):
count = 0
for n in range(1, number):
if(number % n == 0):
count += n
return bool(count == number and number != 0)
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Антонио Николов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Антонио Николов
def is_perfect(number):
sum_of_positive_divisors = 1
for i in range(2, divmod(number, 2)[0] + 1):
if divmod(number, i)[1] == 0:
sum_of_positive_divisors += i
return sum_of_positive_divisors == number
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1uzcyfi/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Александър Златков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Александър Златков
def is_perfect(num):
sum_divisors = 0
for i in range(1, num - 1):
if num % i == 0:
sum_divisors += i;
return sum_divisors == num
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Любомир Коев
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Любомир Коев
def dev_comb(devisors, top, cur=1):
res = set()
for d in devisors:
if top % (d * cur) == 0 and d * cur != top:
res = res | dev_comb(devisors, top, d * cur) | {d * cur}
return res
def is_perf(num):
if num <= 1:
return False
snum = int(num)
devisors = []
counter = 2
while num > 1:
while num % counter == 0:
devisors.append(counter)
num = int(num / counter)
counter += 2 if counter > 2 else 1
dev_set = set(dev_comb(list(set(devisors)), snum) | {1} | set(devisors))
return sum(list(dev_set)) == snum
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-u26gtv/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
AttributeError: 'module' object has no attribute 'is_perfect'

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-u26gtv/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
AttributeError: 'module' object has no attribute 'is_perfect'

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (errors=2)
Иван Бобев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Бобев
def is_perfect(x):
return x == sum(i for i in range(1, x // 2 + 1) if x % i == 0) and x != 0
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Теодор Драганов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Теодор Драганов
def is_perfect(number):
sum_of_divisors = 0
for divisor in range(1 , int(number/2)+1):
if number % divisor == 0 :
sum_of_divisors += divisor
return sum_of_divisors==number
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Божидар Карааргиров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Божидар Карааргиров
def is_perfect(n):
sum = 0
i = 1
while i <= n / 2:
if n % i == 0:
sum += i
i += 1
return sum == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Йосиф Цветков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Йосиф Цветков
def is_perfect(number):
sum = 0
for i in range(1, number):
if (number % i) == 0:
sum += i
if sum == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Станислав Димитров
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Станислав Димитров
def is_perfect(n):
index = 1
value = 0
while index < n:
if n % index == 0:
value = value + index
index+=1
check = value.__ne__(n)
if check:
return check
FF
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1ub8s0t/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1ub8s0t/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: None is not true : 8128 is expected to be a perfect number

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=2)
Йордан Дикманов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Йордан Дикманов
import math
def is_perfect( chislo ):
if not isinstance(chislo,int):
return print(False)
sum=0
for x in range(1, math.floor(chislo / 2)+1):
if chislo % x == 0:
sum+=x
return print(sum == chislo)
.F
Stdout:
True

======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1cdqeo1/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: None is not true : 8128 is expected to be a perfect number

Stdout:
True

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Марио Димитров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Марио Димитров
def is_perfect(number):
sum = 0
for div in range(1, number-1):
if number % div == 0:
sum += div
return number == sum
# There are only a few perfect numbers up to 2^13
def are_few():
count = 0
for i in range(1, 2**13):
if is_perfect(i):
count += 1
return count == 4
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Димитър Желев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Димитър Желев
def is_perfect(number):
"""determines if 'number' is a perfect number"""
sum = 0
if number == 0:
return False
for num in range(1, number):
if number % num == 0:
sum += num
if sum == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Марта Илиева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Марта Илиева
def is_perfect(number):
res = []
for x in range(1, number):
if number % x == 0:
res.append(x)
return number == sum(res)
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Тихомир Янев
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Тихомир Янев
def is_perfect(number):
if number < 6:
return False
divisors = [divisor for divisor in range(1, number) if number % divisor == 0]
return reduce(lambda x, y: x + y, divisors) == number
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-vyd466/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
  File "/tmp/d20140308-8332-vyd466/solution.py", line 6, in is_perfect
    return reduce(lambda x, y: x + y, divisors) == number
NameError: global name 'reduce' is not defined

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-vyd466/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
  File "/tmp/d20140308-8332-vyd466/solution.py", line 6, in is_perfect
    return reduce(lambda x, y: x + y, divisors) == number
NameError: global name 'reduce' is not defined

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (errors=2)
Мартин Георгиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Мартин Георгиев
def is_perfect( num ):
i=1
s=0
while i < num:
if num % i == 0:
s += i
i += 1
if s == num:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.010s

OK
Филип Митов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Филип Митов
def is_perfect(number):
sbor = 0
maxi = int (number / 2) + 1
for x in range(1, maxi):
if number % x == 0:
sbor += x
return number == sbor
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Аделина Рудова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Аделина Рудова
import functools
def is_perfect(number):
return number == functools.reduce(lambda x, y: x + y, factors(number), 0)
def factors(number):
return [x for x in range(1, number) if number % x == 0]
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Стоянка Йовкова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стоянка Йовкова
def is_perfect(number):
devisors = []
a = 1
while a < number:
if number%a == 0:
devisors.append(a)
a += 1
suma = sum(devisors)
if number == suma:
result = True
else:
result = False
return result
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK
Димитър Златев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Димитър Златев
def is_perfect(n):
sum = 0
for i in range(1, n - 1):
if n % i is 0:
sum += i
return sum == n
print(is_perfect(28))
True
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Ирина Иванова
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Ирина Иванова
def less_than_number(number):
count = 1
while count < number:
yield count
count += 1
def is_perfect(number):
divide_six_list = list(filter(lambda x: 6 % x == 0, less_than_number(6)))
return sum(divide_six_list) == number
.F
======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1erevqp/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: False is not true : 8128 is expected to be a perfect number

----------------------------------------------------------------------
Ran 2 tests in 0.004s

FAILED (failures=1)
Ангел Цанев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Ангел Цанев
def is_perfect(number):
if number < 6: return False
divisors = []
for i in range(1, int(number/2) + 1):
if number % i == 0: divisors.append(i)
return number == sum(divisors)
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Никола Димитров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Никола Димитров
def is_divisor(number, possibleDivisor):
return number % possibleDivisor == 0
def is_perfect(number):
return sum([k for k in range(1, number - 1) if is_divisor(number, k)]) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.010s

OK
Людмила Савова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Людмила Савова
def is_perfect(number):
sum = 0
perfect=False
for num in range(1, int(number/2)+1):
if (number % num ==0):
sum += num
if(sum == number):
perfect = True
else:
pass
return perfect
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Светлозар Йовчев
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Светлозар Йовчев
def is_perfect(n):
sum=0
for x in range(1,n):
if n%x==0:
sum+=x
if sum==n:
print(True)
else:
print(False)
is_perfect(6)
is_perfect(12)
True
False
.F
Stdout:
True

======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-61u5jz/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: None is not true : 8128 is expected to be a perfect number

Stdout:
True

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=1)
Николай Масларски
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Николай Масларски
def is_perfect(number):
if number <= 0:
return False
sumOfDivisor = 0
for n in range(1,number):
if number%n == 0:
sumOfDivisor += n
return number == sumOfDivisorsumOfDivisor
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-m060b6/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
  File "/tmp/d20140308-8332-m060b6/solution.py", line 9, in is_perfect
    return number == sumOfDivisorsumOfDivisor
NameError: global name 'sumOfDivisorsumOfDivisor' is not defined

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-m060b6/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
  File "/tmp/d20140308-8332-m060b6/solution.py", line 9, in is_perfect
    return number == sumOfDivisorsumOfDivisor
NameError: global name 'sumOfDivisorsumOfDivisor' is not defined

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (errors=2)
Стефан Василев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стефан Василев
def is_perfect(number):
return sum([devisor for devisor in range(1, number) if number % devisor == 0]) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Стефани Цакова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стефани Цакова
def is_perfect(number):
if not type(number) == int or number <= 0:
return "Your input is incorrect!"
else:
divisors = []
upBound = round(number/2) + 1
for divider in range(1, upBound):
if number % divider == 0:
divisors.append(divider)
return sum(divisors) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Атанас Филчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Атанас Филчев
def is_perfect(number):
sum_dels = 0
for i in range(1, number):
if number % i == 0:
sum_dels += i
if sum_dels == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Гергана Петрова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Гергана Петрова
def is_perfect(number):
return number == sum([i for i in range(1, number//2 + 1) if number % i == 0])
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Моника Димитрова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Моника Димитрова
def is_perfect(number):
sum = 0
for n in range(1, int(number/2) + 1):
if number % n == 0:
sum += n
return sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Божидар Михайлов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Божидар Михайлов
def is_perfect(n):
return sum(filter(lambda x: n%x == 0, range(1, n))) == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.010s

OK
Димитър Димитров
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Димитър Димитров
def is_perfect (num):
sumdel = 0
for i in range(1,num):
if (num % i) == 0:
sumdel += i
if (sumdel>0) and (num%sumdel) != 0:
return False
else :
return True
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1j3hx2a/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Евгени Евлогиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Евгени Евлогиев
def is_perfect(number):
sum = 0
for x in range (1, (number // 2) + 1):
if number % x == 0:
sum = sum + x
if sum == number :
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Марио Даскалов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Марио Даскалов
def is_perfect(number):
return sum([n for n in range(1, number) if number % n == 0]) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK
Емануел Стоянов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Емануел Стоянов
def is_perfect(n):
sum_divisors = 1
for divisor in range(2,n):
if n % divisor == 0:
sum_divisors += divisor
return sum_divisors == n
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-3eadkh/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Димитър Мутафчиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Димитър Мутафчиев
def is_perfect(n):
divisors_list = divisors(n)
return ( sum(divisors_list) == n )
def divisors(n):
divisors_list = []
for i in range(1, n):
if n % i == 0:
divisors_list.append(i)
return divisors_list
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Лъчезар Николов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Лъчезар Николов
def is_perfect(number):
if number == 0:
return False
factors = get_factors(number)
sum_of_factors = sum(factors)
return number == sum_of_factors
def get_factors(number):
factors = []
upper_bound = (number // 2) + 1
for i in range(1, upper_bound):
if number % i == 0:
factors.append(i)
return factors
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Стефан Владков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стефан Владков
def is_perfect(number):
sum = 0
for i in range(1, number - 1):
if number % i == 0:
sum = sum + i
if sum == number:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Елена Желева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Елена Желева
def sum_of_divisors(n):
result = 0
for i in range(1,n):
if n%i == 0:
result=result+i
return result
def is_perfect(n):
return n == sum_of_divisors(n)
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Моника Илиева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Моника Илиева
def factors(n):
factors = []
for i in range(1, n):
if n % i == 0:
factors.append(i)
return factors
def is_perfect(n):
if sum(factors(n)) == n:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Денис Бялев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Денис Бялев
def is_perfect(number):
sum_of_divisors=0
for i in range(1,number):
if number%i == 0:
sum_of_divisors += i
if sum_of_divisors == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Теодора Добрева
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Теодора Добрева
def is_prefect(n):
return sum(i for i in range(1, n - 1) if i % 2 == 0) == n
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-11v03oj/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
AttributeError: 'module' object has no attribute 'is_perfect'

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-11v03oj/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
AttributeError: 'module' object has no attribute 'is_perfect'

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (errors=2)
Симеон Цветков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Симеон Цветков
def is_perfect(number):
sum_of_divisors = 0
k = 1
for divisor in range (1, (int)(number/k)):
if number % divisor == 0:
sum_of_divisors += divisor
if divisor > 1 and k == 1:
k = divisor
if sum_of_divisors == number:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Ангел Новоселски
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Ангел Новоселски
def is_perfect(a):
b = 0
for i in range(1, a):
if a % i == 0:
b += i
print(a == b)
.F
Stdout:
True

======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1ttc0qy/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: None is not true : 8128 is expected to be a perfect number

Stdout:
True

----------------------------------------------------------------------
Ran 2 tests in 0.008s

FAILED (failures=1)
Йончо Йончев
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Йончо Йончев
def is_perfect(n):
div = [1]
[div.append(i) for i in range(2,n/2+1) if n%i == 0]
return sum(div) == n
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-ks0hqi/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
  File "/tmp/d20140308-8332-ks0hqi/solution.py", line 3, in is_perfect
    [div.append(i) for i in range(2,n/2+1) if n%i == 0]
TypeError: 'float' object cannot be interpreted as an integer

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-ks0hqi/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
  File "/tmp/d20140308-8332-ks0hqi/solution.py", line 3, in is_perfect
    [div.append(i) for i in range(2,n/2+1) if n%i == 0]
TypeError: 'float' object cannot be interpreted as an integer

----------------------------------------------------------------------
Ran 2 tests in 0.003s

FAILED (errors=2)
Георги Димитров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Димитров
def is_perfect(number):
sum_divisors = 0
for i in range(1, number // 2 + 1):
if number % i == 0:
sum_divisors += i
if sum_divisors == number:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Константин Тодоров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Константин Тодоров
def is_perfect(number):
sum = 0
for i in range(1,number):
if number % i == 0:
sum += i
return sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Георги Стайков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Стайков
def is_perfect(number):
result = 0
if isinstance(number, int) and number > 0:
for x in range(1, number):
if number % x == 0:
result += x
return result == number
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Димитър Чаушев
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Димитър Чаушев
def is_perfect(n):
a = set()
for num in range(1, n):
if n % num is 0:
a.add(num)
sum = 0
for num in a:
sum += num
if sum is n:
return True
else: return False
.F
======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1usy798/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: False is not true : 8128 is expected to be a perfect number

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=1)
Емилиан Станков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Емилиан Станков
def is_perfect(number):
divisors = []
sum_of_divisors = 0
for i in range(1, int(number / 2) + 1):
if number % i == 0:
divisors.append(i)
for divisor in divisors:
sum_of_divisors += divisor
print(sum_of_divisors)
if sum_of_divisors == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Данаил Койчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Данаил Койчев
def is_perfect(num):
sum = 0
for i in range (1, num):
if num % i == 0:
sum += i
if sum == num:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Венцислав Велков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Венцислав Велков
def is_perfect(number):
if number < 1:
return False
return sum(filter(lambda i: number % i == 0, range(1, number))) == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.010s

OK
Димитър Трендафилов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Димитър Трендафилов
def is_perfect(a):
i = 1
sum = 0
while i < a:
if a % i == 0:
sum += i
i += 1
if a == sum and a != 0:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK
Евгени Кунев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Евгени Кунев
from math import sqrt
def is_perfect(n):
if n <= 1: return False
return sum(i + n/i for i in range(1, int(sqrt(n)) + 1) if not n%i) == 2*n
..
----------------------------------------------------------------------
Ran 2 tests in 0.003s

OK
Никола Ненков
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Никола Ненков
def is_perfect(number):
sum_of_divisors = 0
for possible_divisor in range(1, number):
if number % possible_divisor == 0:
sum_of_divisors += possible_divisor
return sum_of_divisors == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Елена Димитрова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Елена Димитрова
def sum_of_div(number):
sum = 0
for i in range(1, number):
if number % i == 0:
sum += i
return sum
def is_perfect(number):
if number == sum_of_div(number):
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Спасимир Тупаров
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Спасимир Тупаров
def is_perfect( Number ):
if Number == 1:
return True
temp = 1
SumDev = 0
while temp < Number:
if Number % temp == 0:
SumDev += temp
temp += 1
if SumDev == Number:
return True
else:
return False
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-p85erd/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=1)
Любослав Павлов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Любослав Павлов
def is_perfect(Number):
divisorSum=0
for i in range (1,int(Number/2) + 1):
if Number%i == 0:
divisorSum += i
return divisorSum == Number
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Владимир Начев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Владимир Начев
def is_perfect (n):
a=1
for i in range( 2, n):
if( n % i == 0):
a += i
if n == 1:
return False
elif a == n:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Кирил Киров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Кирил Киров
def is_perfect(Value):
Result, CopyVal = 0, Value - 1
while CopyVal > 0:
if Value % CopyVal == 0:
Result = Result + CopyVal
CopyVal = CopyVal - 1
if Result == Value:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK
Пламен Димитров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Пламен Димитров
def is_perfect(a):
cnt = 1
sum = 0
while cnt < a:
if a%cnt == 0:
sum += cnt
cnt +=1
if sum == a:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Теодор Халваджиев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Теодор Халваджиев
def is_perfect(number):
dividerSum = 0
divider = number - 1
while divider > 0 :
if number % divider == 0 :
dividerSum += divider
divider -= 1
if dividerSum == number :
return True
else :
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Михаил Панайотов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Михаил Панайотов
def is_perfect(number):
deviders = [devider for devider in range(1, number) if not number % devider]
if sum(deviders) == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Мария Кърчева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Мария Кърчева
def is_perfect(num):
divisor_sum = 0
for divisor in range(1, num // 2 + 1):
if num % divisor == 0:
divisor_sum += divisor
return divisor_sum == num
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Славка Цанкова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Славка Цанкова
def is_perfect (number):
sum_divisors = 0
for index in range (1, number):
if number % index == 0:
sum_divisors += index
return number == sum_divisors
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Иван Латунов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Латунов
def denominators(n):
return_list = []
for x in range(1, n):
if (n % x == 0):
return_list.append(x)
return return_list
def is_perfect(n):
sum_of_denominators = 0
for i in denominators(n):
sum_of_denominators += i
return sum_of_denominators == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Милица Борисова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Милица Борисова
def is_perfect(a):
sum=0
for i in range (1,a):
if a%i==0:
sum+=i
if sum==a:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Ралица Цанова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Ралица Цанова
def is_perfect(num):
if isinstance(num, int) and num > 0:
my_sum = sum(filter(lambda x: num % x == 0, range(1, num // 2 + 1)))
return (my_sum == num)
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Петър Камбуров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Петър Камбуров
def is_perfect(n):
delims = 0
for i in range(1, int(n/2) + 1):
if n % i == 0:
delims += i
return n != 0 and n == delims
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Деян Камбуров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Деян Камбуров
def is_perfect(number):
sum = 0
for i in range(1, number):
if number % i == 0:
sum += i
return number != 0 and sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Атанас Димитров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Атанас Димитров
def is_perfect(number):
sum = 0
for i in range (1, number):
if number % i == 0:
sum = sum + i
if sum == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Веляна Димова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Веляна Димова
def is_perfect(n):
sum = 0
for i in range(1, n):
if n%i == 0:
sum += i
if n == sum:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Петър Парушев
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Петър Парушев
import math
def is_perfect(a):
divisorsList = []
for i in range(1,math.ceil(a/2) + 1):
if a%i == 0:
divisorsList.append(i)
sum = 0
for i in divisorsList:
sum+=i
return sum==a
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-3csgkn/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.003s

FAILED (failures=1)
Валентин Петров
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Валентин Петров
def is_perfect(n):
sum = 0
for i in range(1, n):
if ( n % i == 0 ):
sum += i
return True if sum == n else False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Милен Христов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Милен Христов
def is_perfect(n):
my_sum = 0
for x in range(1, int(n/2 + 1)):
if n % x == 0:
my_sum += x
if my_sum == n:
return True
return False
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1opx9k3/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 24 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Гено Чипилски
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Гено Чипилски
def is_perfect(i_input_number):
i_sum_of_delitels = 0
# We don't to spend time checking parameter if it isn't an integer or it is <= 0
if i_input_number <= 0:
return False
if not isinstance(i_input_number, int):
return False
# We don't need to spend time for all numbers. Max delitel of number is number/2 (with no rest)
i_max_deliter = i_input_number // 2
# Calculate the sum of all delitels of the given number
for i_possible_delitel in range(1, i_max_deliter + 1):
if not (i_input_number % i_possible_delitel):
i_sum_of_delitels += i_possible_delitel
if i_sum_of_delitels == i_input_number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Михаил Станин
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Михаил Станин
# Returns whether a number is perfect or not.
# (Perfect number - it's equal to the sum of the
# positive divisors that are less than it.)
def is_perfect(number):
if number <= 0:
return False
else:
perfect = False
divisors = []
candidate_divisor = 1
# Find the divisors.
while(candidate_divisor < number):
if (number % candidate_divisor == 0):
divisors.append(candidate_divisor)
candidate_divisor += 1
second_number = 0
for i in range(0, len(divisors)):
second_number += divisors[i]
if (number != second_number):
return False
return True
..
----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
Янислав Василев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Янислав Василев
def is_perfect(n):
sum = 0
for number in range(1, n):
if n % number == 0:
sum += number
return sum == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Джована Аспарухова
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Джована Аспарухова
def is_perfect(x):
if x>1:
n=x
if sum([i for i in range(1,n+1) if n%i==0])==2*n:
return True
return False
else:
return True
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1mxfua0/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Дамян Манев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Дамян Манев
def is_perfect(number):
sum_of_devisors = 0
for i in range(1, number//2 + 1):
if number%i == 0:
sum_of_devisors += i
return sum_of_devisors == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Иван Иванов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Иван Иванов
def is_perfect (x):
if x <= 0:
return False
sum = 0
i = 1
while i < x/2 + 1:
if x % i == 0:
sum += i
i += 1
if x == sum:
return True
return False
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-j158oq/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=1)
Атанас Пройчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Атанас Пройчев
def is_perfect(number):
dividers = []
for i in range(1, number):
if number % i == 0:
dividers.append(i)
if sum(dividers) == number:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Мария Кръстева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Мария Кръстева
def sum_of_divisors(n):
result=0
for i in range(1,n):
if n%i==0:
result=result + i
return result
def is_perfect(n):
return sum_of_divisors(n)==n
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Стоян Ефтимов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Стоян Ефтимов
def is_perfect(number):
sum = 1
divisor = 2
while divisor <= number**0.5 and sum <= number:
if number % divisor == 0:
sum += divisor + number / divisor
divisor += 1
return number == sum
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-93au76/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (failures=1)
Стоян Христов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стоян Христов
def is_perfect(n):
sum = 0
for x in range(1, n // 2 + 1):
if n % x == 0:
sum += x
return sum == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
Елица Илиева
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Елица Илиева
def sumOfDivisorsOfN(n):
if type(n) is not int or n <= 0:
raise Exception( "{} is not an integer or is not positive.".format(n))
if n == 1:
return 1
upperBound = n // 2 + 1
sum = 0
for i in range(1,upperBound):
if n % i == 0:
sum += i
return sum
def is_perfect(n):
if type(n) is not int:
raise Exception( "{} is not an integer.".format(n))
if sumOfDivisorsOfN(n) == n:
return True
else:
return False
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-i5g9ox/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.003s

FAILED (failures=1)
Мария Донева
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Мария Донева
import math
def is_perfect(n):
m = math.sqrt(n)
m = int(math.floor(m))
sum = 1
for i in range(2, m + 1):
if n % i == 0:
p = n/i
sum += i
sum += p
else:
continue
if sum == n:
return True
else:
return False
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-1bx0b4h/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (failures=1)
Стефан Колчев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стефан Колчев
def is_perfect(number):
sum = 0
for i in range(1, number - 1):
if number % i == 0:
sum += i
if sum == number:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Иван Котов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Котов
def is_perfect(n):
p = 0
for x in range(1,n + 1):
if n%x == 0:
p = p + x
if x == n:
if p == 2*n:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Иван Върбанов
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Иван Върбанов
def is_perfect(number):
divisors=[]
for i in range(1,10):
if number%i==0 and i<number:
divisors.insert(i-1,i)
sum=0
for i in range(len(divisors)):
sum+=divisors[i]
if number==sum:
return True
elif not number==sum:
return False
FF
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-10g7b8b/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 24 is expected to be an imperfect number

======================================================================
FAIL: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-10g7b8b/test.py", line 15, in test_perfect_numbers
    perfect_number))
AssertionError: False is not true : 8128 is expected to be a perfect number

----------------------------------------------------------------------
Ran 2 tests in 0.003s

FAILED (failures=2)
Виктор Иванов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Виктор Иванов
def is_perfect(n):
s = 0
for i in range(1, n):
if n % i == 0:
s += i
if s == n:
return True
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Стефан Маринов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Стефан Маринов
import random
import itertools
def is_perfect_dummy(number):
divisors = []
for i in range(1, number):
if not(number % i):
divisors.append(i)
return sum(divisors) == number
def gcd(a, b):
if a == b:
return a
while b > 0:
a, b = b, a%b
return a
def lcm(a, b):
return abs(a * b) // gcd(a, b)
def pollard_rho_brent(number):
if not(number % 2):
return 2
if not(number % 3):
return 3
y = random.randint(1, number-1)
c = random.randint(1, number-1)
m = random.randint(1, number-1)
g, r, q = 1, 1, 1
while g == 1:
x = y
for i in range(r):
y = ((y * y) % number + c) % number
k = 0
while (k < r) and (g == 1):
ys = y
for i in range(min(m, r-k)):
y = ((y * y) % number + c) % number
q = q * abs(x-y) % number
g = gcd(q, number)
k += m
r <<= 1
if g == number:
while True:
ys = ((ys * ys) % number + c) % number
g = gcd(abs(x-ys), number)
if g > 1:
break
return g
# Sieve of Eratosthenes
def primes_until(number):
sieve = list(range(3, number, 2))
for x in range(3, int(number ** .5) + 1, 2):
if sieve[(x-3)//2]:
for tmp in range((x*x-3)>>1, (number>>1)-1, x):
sieve[tmp] = 0
return [2] + [p for p in sieve if p>0]
# Assumes that number >= 1
def is_prime(number, precision=7):
limit = 100000
if number == 1 or not(number % 2):
return False
elif number < limit:
return number in set(primes_until(limit))
# Miller-Rabin Primality Test
d = number - 1
s = 0
while not(d % 2):
d >>= 1
s += 1
for repeat in range(precision):
a = random.randrange(2, number - 2)
x = pow(a, d, number)
if x == 1 or x == number-1:
continue
for r in range(s - 1):
x = pow(x, 2, number)
if x == 1:
return False
if x == number - 1:
break
else:
return False
return True
small_primes = primes_until(1024)
def get_prime_factors(number):
prime_factors = []
lim = int(number ** .5) + 1
for p in small_primes:
while (p <= lim) and not(number % p):
prime_factors.append(p)
number //= p
lim = int(number ** .5) + 1
if number < 2:
return prime_factors
while number > 1:
if is_prime(number):
prime_factors.append(number)
break
some_factor = pollard_rho_brent(number)
prime_factors.extend(primefactors(some_factor))
number //= factor
prime_factors.sort()
return prime_factors
def get_powers(number):
powers = {}
for prime_factor in get_prime_factors(number):
try:
powers[prime_factor] += 1
except KeyError:
powers[prime_factor] = 1
return powers
def product(numbers):
result = 1
for x in numbers:
result *= x
return result
def is_perfect(number):
#return is_perfect_dummy(number)
prime_factors = get_prime_factors(number)
powers = list(get_powers(number).items())
values = [[(factor**e) for e in range(exp+1)] for (factor, exp) in powers]
divisors = sorted(product(xs) for xs in itertools.product(*values))
return sum(divisors) == number<<1
..
----------------------------------------------------------------------
Ran 2 tests in 4.815s

OK
Весела Бандова
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Весела Бандова
def is_perfect(number):
divisior_sum = 0
for i in range(1, number):
if number % i == 0:
divisior_sum += i
return divisior_sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Дарина Кръстева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Дарина Кръстева
def is_perfect (number):
sum = 0
for n in range(1, number):
if number%n == 0:
sum += n
return sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Илиян Влахов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Илиян Влахов
import math
def summary(some_list):
return sum(some_list)
def is_perfect(number):
my_list = [1]
for magic in range(2,number):
if number % magic ==0:
my_list.append(magic)
if summary(my_list) == number:
return True
else:
return False
is_perfect(8)
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-16l7x1r/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=1)
Георги Йорданов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Йорданов
def is_perfect(n):
sum = 0
for i in range(1, n):
if n%i == 0:
sum += i
if sum == n:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Теодор Костадинов
  • Некоректно
  • 1 успешни тест(а)
  • 1 неуспешни тест(а)
Теодор Костадинов
def is_perfect(n):
sum = 1
div = 2
while div<n:
if n%div==0:
sum = sum+div
div+=1
return sum==n
F.
======================================================================
FAIL: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-vrn9ha/test.py", line 21, in test_imperfect_numbers
    imperfect_number))
AssertionError: True is not false : 1 is expected to be an imperfect number

----------------------------------------------------------------------
Ran 2 tests in 0.006s

FAILED (failures=1)
Беатрис Бонева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Беатрис Бонева
import math
def is_perfect(number):
divisor = 1
result = 0
while divisor <= number / 2:
if number % divisor == 0:
result += divisor
divisor += 1
return result == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
Велина Дойчева
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Велина Дойчева
from functools import reduce
def divisors(n):
return filter (lambda x: n % x == 0, range(1, n))
def is_perfect(n):
return reduce(lambda x, y: x + y, divisors(n), 0) == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.010s

OK
Георги Янев
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Янев
def is_perfect(digit):
"""
Get a positive digit and calculate if it's a perfect number
or not. Return True if yes and False if not
"""
half_digit = int((digit / 2) + 1)
possible_delimiters = list(range(1,half_digit))
real_delimiters = []
for i in possible_delimiters:
if digit % i == 0:
real_delimiters.append(i)
if sum(real_delimiters) == digit:
return True
else:
return False
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Тошко Тодоров
  • Некоректно
  • 0 успешни тест(а)
  • 2 неуспешни тест(а)
Тошко Тодоров
def is_perfect(n):
sum = 0
for i in xrange(1, n):
if n % i == 0:
sum += i
return sum == n
EE
======================================================================
ERROR: test_imperfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-16v3hmt/test.py", line 19, in test_imperfect_numbers
    self.assertFalse(solution.is_perfect(imperfect_number),
  File "/tmp/d20140308-8332-16v3hmt/solution.py", line 3, in is_perfect
    for i in xrange(1, n):
NameError: global name 'xrange' is not defined

======================================================================
ERROR: test_perfect_numbers (test.TestPerfectNumbers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20140308-8332-16v3hmt/test.py", line 13, in test_perfect_numbers
    self.assertTrue(solution.is_perfect(perfect_number),
  File "/tmp/d20140308-8332-16v3hmt/solution.py", line 3, in is_perfect
    for i in xrange(1, n):
NameError: global name 'xrange' is not defined

----------------------------------------------------------------------
Ran 2 tests in 0.002s

FAILED (errors=2)
Георги Антонов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Антонов
def is_perfect(number):
divisors_sum = 0
for i in range(1, number):
if number%i == 0:
divisors_sum += i
return divisors_sum == number
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK
Цветомир Цанов
  • Коректно
  • 2 успешни тест(а)
  • 0 неуспешни тест(а)
Цветомир Цанов
def is_perfect(n):
sum = 0
for i in range(1, n):
if n % i == 0:
sum += i
return sum == n
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s

OK