Решение на Генератори и итератори от Антонио Илиев

Обратно към всички решения

Към профила на Антонио Илиев

Резултати

  • 6 точки от тестове
  • 0 бонус точки
  • 6 точки общо
  • 8 успешни тест(а)
  • 6 неуспешни тест(а)

Код

def fibonacci():
counter = 0
num = 0
if num == 0:
yield 1
num = num + 1
while num:
yield num + counter
num = num + counter
counter = num - counter
raise StopIteration
def primes():
def is_Prime(num):
for i in range(2, num):
if(num % i == 0):
return False
return True
numm = 2
while numm:
if is_Prime(numm):
yield numm
numm = numm + 1
raise StopIteration
def alphabet(*, code='', letters=''):
bgr = 'абвгдежзийклмнопрстуфхцчшщъьюя'
eng = 'abcdefghijklmnopqrstuvwxyz'
if code == 'bg':
return (letter for letter in bgr)
if code == 'lat':
return (letter for letter in eng)
if letters != '':
return (letter for letter in letters)

Лог от изпълнението

......EEEEEE..
======================================================================
ERROR: test_generator_definitions (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_infinite_intertwined (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_intertwine (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_intertwine_repeating_builtin (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_kwargs_generator (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

======================================================================
ERROR: test_repeating_with_different_args (test.TestIntertwine)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 65, in thread
    raise TimeoutError
TimeoutError

----------------------------------------------------------------------
Ran 14 tests in 13.466s

FAILED (errors=6)

История (1 версия и 0 коментара)

Антонио обнови решението на 02.04.2015 10:57 (преди над 9 години)

+def fibonacci():
+ counter = 0
+ num = 0
+ if num == 0:
+ yield 1
+ num = num + 1
+ while num:
+ yield num + counter
+ num = num + counter
+ counter = num - counter
+ raise StopIteration
+
+
+def primes():
+ def is_Prime(num):
+ for i in range(2, num):
+ if(num % i == 0):
+ return False
+ return True
+ numm = 2
+ while numm:
+ if is_Prime(numm):
+ yield numm
+ numm = numm + 1
+ raise StopIteration
+
+
+def alphabet(*, code='', letters=''):
+ bgr = 'абвгдежзийклмнопрстуфхцчшщъьюя'
+ eng = 'abcdefghijklmnopqrstuvwxyz'
+ if code == 'bg':
+ return (letter for letter in bgr)
+ if code == 'lat':
+ return (letter for letter in eng)
+ if letters != '':
+ return (letter for letter in letters)