Решение на Генератори и итератори от Слави Кадиев

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

Към профила на Слави Кадиев

Резултати

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

Код

def fibonacci():
previous, next = 0, 1
while True:
previous, next = next, previous + next
yield previous
def primes():
number = 2
primes = set()
while True:
for item in primes:
if number % item == 0:
break
else:
primes.add(number)
yield number
number += 1
def get_letters(alphabet):
for item in alphabet:
yield item
def alphabet(*, code='', letters=''):
alphabets = {'lat': 'abcdefghiklmnopqrstvhyz',
'bg': 'абвгдежзийклмнопрстуфхцчшщъьюя'}
if not letters:
letters = alphabets[code]
return get_letters(letters)

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

...E..EEEEEE..
======================================================================
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

----------------------------------------------------------------------
Ran 14 tests in 14.482s

FAILED (errors=7)

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

Слави обнови решението на 03.04.2015 10:31 (преди над 9 години)

+def fibonacci():
+ previous, next = 0, 1
+ while True:
+ previous, next = next, previous + next
+ yield previous
+
+
+def primes():
+ number = 2
+ primes = set()
+ while True:
+ for item in primes:
+ if number % item == 0:
+ break
+ else:
+ primes.add(number)
+ yield number
+ number += 1
+
+
+def get_letters(alphabet):
+ for item in alphabet:
+ yield item
+
+
+def alphabet(*, code='', letters=''):
+ alphabets = {'lat': 'abcdefghiklmnopqrstvhyz',
+ 'bg': 'абвгдежзийклмнопрстуфхцчшщъьюя'}
+ if not letters:
+ letters = alphabets[code]
+ return get_letters(letters)