Данаил обнови решението на 01.04.2015 23:48 (преди над 9 години)
+from string import ascii_lowercase
+
+
+def fibonacci():
+ first = 1
+ second = 1
+ while True:
+ yield first
+ second += first
+ first = second-first
+
+
+def primes():
+ prime_numbers = []
+ current = 2
+ while True:
+ prime_numbers.append(current)
+ yield current
+
+ primeness = lambda prime: current % prime == 0
+ while list(filter(primeness, prime_numbers)):
+ current += 1
+
+
+CODE = {
+ 'lat': list(ascii_lowercase),
+ 'bg': list('абвгдежзийклмнопрстуфхцчшщъьюя')
+}
+
+
+def alphabet(code='', letters=''):
+ alpha = ''
+ if code != '':
+ alpha = CODE[code]
+ if letters != '':
+ alpha = letters
+ for letter in alpha:
+ yield letter
+
+
+def intertwined_sequences(sequences, generator_definitions={}):
+ for seq in sequences:
+ if seq['sequence'] in generator_definitions:
+ sequence = generator_definitions[seq['sequence']]
+ else:
+ sequence = seq['sequence']
+ del seq['sequence']
+ length = seq['length']
+ del seq['length']
+ if seq != {}:
+ gen = globals()[sequence](**seq)
+ else:
+ gen = globals()[sequence]()
+ while length > 0:
+ yield next(gen)
+ length -= 1