fork(1) download
  1. L = [1, 1, 1, 12, 13, 14, 21, -12, -13, 12, 12, 100, -100]
  2. def decreasing(l):
  3. for i in range(0,len(l) - 1):
  4. if(l[i+1] > l[i]):
  5. return False
  6. return True
  7. def strictly_decreasing(l):
  8. for i in range(0, len(l) - 1):
  9. if(l[i+1] >= l[i]):
  10. return False
  11. return True
  12.  
  13. dseq = {"nierosnacy":[],"niemalejacy":[],"staly":[],"mono":[],"rosnacy":[],"malejacy":[]}
  14. for begin in range(0,len(L) + 1):
  15. for end in range(begin + 2,len(L) + 1):
  16. subsequence = L[begin:end]
  17. if decreasing(subsequence):
  18. dseq["nierosnacy"].append(subsequence)
  19. if strictly_decreasing(subsequence):
  20. dseq["malejacy"].append(subsequence)
  21. print(dseq)# your code goes here
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
{'nierosnacy': [[1, 1], [1, 1, 1], [1, 1], [21, -12], [21, -12, -13], [-12, -13], [12, 12], [100, -100]], 'niemalejacy': [], 'staly': [], 'mono': [], 'rosnacy': [], 'malejacy': [[21, -12], [21, -12, -13], [-12, -13], [100, -100]]}