Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools, random
- de = [1, 5, 7, 2, 8]
- def sum1(l): # for
- k = 0
- for i in l:
- k += i
- return k
- def sum2(l): #while
- final = 0
- incr = 0
- while incr < len(l):
- final += l[incr]
- incr += 1
- return final
- def sum3(l): #recursion
- if len(l) == 1:
- return l[0]
- else:
- return l[0] + sum3(l[1:])
- def altern(l1, l2):
- return list(itertools.chain.from_iterable(zip(l1, l2)))
- def fib():
- a = []
- for i_ in [0, 1, 1]: a.append(i_)
- for _ in range(3, 100):
- a.append(sum(a[-2:]))
- return a
- def arrLarg(l):
- iterations = len(l)**4
- b = []
- for i in range(iterations):
- k = l[:]
- random.shuffle(k)
- k = int(''.join([str(i) for i in k]))
- b.append(k)
- b = list(set(b))
- b.sort(reverse=True)
- return b[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement