Решение на Генератори и итератори от Мария Османлиева

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

Към профила на Мария Османлиева

Резултати

  • 4 точки от тестове
  • 0 бонус точки
  • 4 точки общо
  • 5 успешни тест(а)
  • 9 неуспешни тест(а)

Код

#!/usr/bin/env python
# -*- coding: utf-8 -*-
def primes():
number = 2
while True:
if all([number % divisor for divisor in range(2, number)]):
yield number
number += 1
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = b, a + b
def alphabet(code='', letters=''):
if code == 'lat':
while True:
for i in lat:
yield i
i += 1
elif code == 'bg':
while True:
for i in bg:
yield i
i += 1
else:
while True:
for i in letters:
yield i
i += 1

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

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

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

======================================================================
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

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

----------------------------------------------------------------------
Ran 14 tests in 18.145s

FAILED (errors=9)

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

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

+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+
+
+def primes():
+ number = 2
+ while True:
+ if all([number % divisor for divisor in range(2, number)]):
+ yield number
+ number += 1
+
+
+def fibonacci():
+ a, b = 1, 1
+ while True:
+ yield a
+ a, b = b, a + b
+
+
+def alphabet(code='', letters=''):
+ if code == 'lat':
+ while True:
+ for i in lat:
+ yield i
+ i += 1
+ elif code == 'bg':
+ while True:
+ for i in bg:
+ yield i
+ i += 1
+ else:
+ while True:
+ for i in letters:
+ yield i
+ i += 1