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

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

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

Резултати

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

Код

def fibonacci():
value1 = 1
value2 = 1
yield value1
yield value2
while True :
yield value1 + value2
c=value2
value2=value1 + value2
value1=c
def primes():
yield 2
n=3
while n :
bool=True
for i in range(2,n) :
if n%i == 0 :
bool=False
break
if bool == True :
yield n
n+=1
def alphabet(code='', letters='') :
if letters != "" :
for i in list(letters) :
yield i
else :
if code == "lat" :
for i in range(97, 123) :
yield chr(i)
elif code == "bg" :
yield 'а'
yield 'б'
yield 'в'
yield 'г'
yield 'д'
yield 'е'
yield 'ж'
yield 'з'
yield 'и'
yield 'й'
yield 'к'
yield 'л'
yield 'м'
yield 'н'
yield 'о'
yield 'п'
yield 'р'
yield 'с'
yield 'т'
yield 'у'
yield 'ф'
yield 'х'
yield 'ц'
yield 'ч'
yield 'ш'
yield 'щ'
yield 'ъ'
yield 'ь'
yield 'ю'
yield 'я'

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

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

----------------------------------------------------------------------
Ran 14 tests in 15.522s

FAILED (errors=7)

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

Йоана обнови решението на 03.04.2015 16:33 (преди над 9 години)

+def fibonacci():
+ value1 = 1
+ value2 = 1
+ yield value1
+ yield value2
+ while True :
+ yield value1 + value2
+ c=value2
+ value2=value1 + value2
+ value1=c
+def primes():
+ yield 2
+ n=3
+ while n :
+ bool=True
+ for i in range(2,n) :
+ if n%i == 0 :
+ bool=False
+ break
+ if bool == True :
+ yield n
+ n+=1
+
+def alphabet(code='', letters='') :
+ if letters != "" :
+ for i in list(letters) :
+ yield i
+ else :
+ if code == "lat" :
+ for i in range(97, 123) :
+ yield chr(i)
+ elif code == "bg" :
+ yield 'а'
+ yield 'б'
+ yield 'в'
+ yield 'г'
+ yield 'д'
+ yield 'е'
+ yield 'ж'
+ yield 'з'
+ yield 'и'
+ yield 'й'
+ yield 'к'
+ yield 'л'
+ yield 'м'
+ yield 'н'
+ yield 'о'
+ yield 'п'
+ yield 'р'
+ yield 'с'
+ yield 'т'
+ yield 'у'
+ yield 'ф'
+ yield 'х'
+ yield 'ц'
+ yield 'ч'
+ yield 'ш'
+ yield 'щ'
+ yield 'ъ'
+ yield 'ь'
+ yield 'ю'
+ yield 'я'
+
+
+
+
+
+
+