Advertisement
renix1

Slicing a list, so bad...

Aug 7th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. __author__ = 'Reni A. Dantas'
  2. __version__ = '0.0.1'
  3. """
  4.    Big O Notation:
  5.        O(n): average performance
  6.        O(n+n): fast performance but complex algorithm
  7.        O(n*n) average performance too, consider as O(n)
  8.        O(n**2) poor performance
  9.        n log n
  10. """
  11. n = [x for x in range(0, 12)]
  12.  
  13.  
  14. def slicing(lista, partes):
  15.     """
  16.        Slice a list in many parts, consider that as O(n)
  17.    """
  18.     const_conj = conj = len(lista) // partes
  19.     conj_l = []
  20.     i = 0
  21.     while i < len(lista):
  22.         conj_l.append(lista[i:conj])
  23.         i += const_conj
  24.         conj += const_conj
  25.     return conj_l
  26.  
  27. print(slicing(n, 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement