Иванна обнови решението на 03.04.2015 09:44 (преди над 9 години)
+def primes():
+ n = 2
+ primes = set()
+ while True:
+ for p in primes:
+ if n % p == 0:
+ break
+ else:
+ primes.add(n)
+ yield n
+ n += 1
+
+
+a,b = 0,1
+def fibonacci():
+ global a,b
+ while True:
+ a,b = b, a+b
+ yield a
+
+
+
+import string
+lat = iter(list(string.ascii_lowercase))
+bg = iter(list('абвгдежзийклмнопрстуфхцчшщъьюя'))
+
+def alphabet(code="" , letters=""):
+ if code == 'lat':
+ for i in lat:
+ yield i
+ elif code == 'bg':
+ for i in bg:
+ yield i
+ else:
+ for i in letters:
+ yield i
+def intertwined_sequences(sequence):
+ i = 1
+ j = 0
+ for tup in sequence:
+ tup_iter = next (iter (tup.values()))
+ tup_iter_next = next (tup_iter)
+ if tup_iter is not 'alphabet':
+ for method_name, how_many_times in zip(tup_iter,tup_iter_next):
+ possibles = globals().copy()
+ possibles.update(locals())
+ method = possibles.get(method_name)()
+ while (i <= int(how_many_times)):
+ i += 1
+ print (method)
+
+ else: #is alphabet
+ for code, how_many in zip(tup_iter,tup_iter_next):
+ while (j <= int(how_many)):
+ j += 1
+ print (alphabet(code))