Решение на Генератори и итератори от Деница Петрова

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

Към профила на Деница Петрова

Резултати

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

Код

def fibonacci(a=1, b=1):
while True:
yield a
a, b = b, a + b
def primes():
n = 0
while True:
if len(list(filter(lambda x: n % x == 0, range(1, n)))) == 1:
yield n
n += 1
ALPHABET = {'bg': 'абвгдежзийклмнопрстуфхцчшщъьюя',
'lat': 'abcdefghijklmnopqrstuvwxyz'}
def alphabet(code='', letters=''):
if letters != '':
return iter(list(letters))
else:
return iter(list(ALPHABET[code]))

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

.E....EEEEEEE.
======================================================================
ERROR: test_endless_letters_generator (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 16.216s

FAILED (errors=8)

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

Деница обнови решението на 02.04.2015 18:19 (преди над 9 години)

+def fibonacci(a=1, b=1):
+ while True:
+ yield a
+ a, b = b, a + b
+
+def primes():
+ n = 0
+ while True:
+ if len(list(filter(lambda x: n % x == 0, range(1, n)))) == 1:
+ yield n
+ n += 1
+
+ALPHABET = {'bg': 'абвгдежзийклмнопрстуфхцчшщъьюя',
+ 'lat': 'abcdefghijklmnopqrstuvwxyz'}
+
+def alphabet(code='', letters=''):
+ if letters != '':
+ return iter(list(letters))
+ else:
+ return iter(list(ALPHABET[code]))
+
+