Решение на Генератори и итератори от Иван Вичев

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

Към профила на Иван Вичев

Резултати

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

Код

# This Python file uses the following encoding: utf-8
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = b, a + b
def primes():
prime = []
end = 1
while True:
end += 1
for p in prime:
if end % p == 0:
break
else:
prime.append(end)
yield end
def alphabet(*args, code=None, letters=None):
if letters:
for item in range(len(letters)):
yield letters[item]
elif code == 'lat':
lat_a = ord('a')
lat_end = ord('z')
for number in range(lat_a, lat_end + 1):
yield chr(number)
elif code == 'bg':
bg_a = ord('а')
bg_end = ord('я')
for number in range(bg_a, bg_end + 1):
yield chr(number)

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

EE....EEEEEE..
======================================================================
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_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 16.323s

FAILED (errors=8)

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

Иван обнови решението на 03.04.2015 15:14 (преди над 9 години)

+def fibonacci():
+ a, b = 1, 1
+ while True:
+ yield a
+ a, b = b, a + b
+
+
+def primes():
+ prime = []
+ end = 1
+ while True:
+ end += 1
+ for p in prime:
+ if end % p == 0:
+ break
+ else:
+ prime.append(end)
+ yield end
+
+
+def alphabet(*args, code=None, letters=None):
+ if letters:
+ for item in range(len(letters)):
+ yield letters[item]
+ elif code == 'lat':
+ lat_a = ord('a')
+ lat_end = ord('z')
+ for number in range(lat_a, lat_end + 1):
+ yield chr(number)
+ elif code == 'bg':
+ bg_a = ord('а')
+ bg_end = ord('я')
+ for number in range(bg_a, bg_end + 1):
+ yield chr(number)

Иван обнови решението на 03.04.2015 15:44 (преди над 9 години)

+# This Python file uses the following encoding: utf-8
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = b, a + b
def primes():
prime = []
end = 1
while True:
end += 1
for p in prime:
if end % p == 0:
break
else:
prime.append(end)
yield end
def alphabet(*args, code=None, letters=None):
if letters:
for item in range(len(letters)):
yield letters[item]
elif code == 'lat':
lat_a = ord('a')
lat_end = ord('z')
for number in range(lat_a, lat_end + 1):
yield chr(number)
elif code == 'bg':
bg_a = ord('а')
bg_end = ord('я')
for number in range(bg_a, bg_end + 1):
- yield chr(number)
+ yield chr(number)