Решение на Генератори и итератори от Цветан Коев

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

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

Резултати

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

Код

def fibonacci():
a = 1
b = 1
while True:
yield a
a, b = b, a + b
def primes():
def is_prime(number):
for _ in range(2, number):
if number % _ == 0:
return False
return True
current = 2
while True:
if is_prime(current):
yield current
current = current + 1
def alphabet(code=None, letters=None):
if letters is None:
if code == 'lat':
letters = "abcdefghijklmnopqrstuvwxyz"
else:
letters = "абвгдежзийклмнопрстуфхцчшщъьюя"
for letter in letters:
yield letter

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

......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.535s

FAILED (errors=6)

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

Цветан обнови решението на 03.04.2015 12:56 (преди около 9 години)

+def fibonacci():
+ a = 1
+ b = 1
+ while True:
+ yield a
+ a, b = b, a + b
+
+
+def primes():
+ def is_prime(number):
+ for _ in range(2, number):
+ if number % _ == 0:
+ return False
+ return True
+
+ current = 2
+ while True:
+ if is_prime(current):
+ yield current
+ current = current + 1
+
+
+def alphabet(code=None, letters=None):
+ if letters is None:
+ if code == 'lat':
+ letters = "abcdefghijklmnopqrstuvwxyz"
+ else:
+ letters = "абвгдежзийклмнопрстуфхцчшщъьюя"
+ for letter in letters:
+ yield letter