Иван обнови решението на 03.04.2015 15:36 (преди над 9 години)
+def fibonacci():
+ first = 1
+ second = 1
+ while True:
+ yield second
+ x = second
+ second = first
+ first += x
+
+
+def primes():
+ prime_number = 2
+ flag = 0
+ while True:
+ for i in range(2, prime_number):
+ if prime_number % i == 0:
+ flag = 1
+ break
+ else:
+ pass
+ if flag == 0:
+ yield prime_number
+ else:
+ flag = 0
+ prime_number += 1
+
+
+def alphabet(code='', letters=''):
+ def alphabet_help(letters):
+ for i in range(0, len(letters)):
+ yield letters[i]
+
+ while True:
+ if letters != '':
+ return alphabet_help(letters)
+ if code == 'bg':
+ return alphabet_help("абвгдежзийклмнопрстуфхцчшщъьюя")
+ elif code == 'lat':
+ return alphabet_help("abcdefghijklmnopqrstuvwxyz")
+
+
+def intertwined_sequences(iter_object):
+ work_list = []
+ fibon = fibonacci()
+ prime = primes()
+ for i in range(0, len(iter_object)):
+ if iter_object.__getitem__(i)['sequence'] == 'fibonacci':
+ for j in range(0, iter_object.__getitem__(i)['length']):
+ work_list.append(next(fibon))
+ elif iter_object.__getitem__(i)['sequence'] == 'primes':
+ for j in range(0, iter_object.__getitem__(i)['length']):
+ work_list.append(next(prime))
+ elif iter_object.__getitem__(i)['sequence'] == 'alphabet':
+ if 'letters' in iter_object.__getitem__(i):
+ alpha = alphabet(letters=iter_object.__getitem__(i)['letters'])
+ for j in range(0, iter_object.__getitem__(i)['length']):
+ work_list.append(next(alpha))
+ else:
+ alpha_second = alphabet(code=iter_object.__getitem__(i)['code'])
+ for j in range(0, iter_object.__getitem__(i)['length']):
+ work_list.append(next(alpha_second))
+ return work_list # nai-groznoto parche kod , koeto sym pisal ...no raboti