Advertisement
snowywhitee

Untitled

Dec 9th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. fin = open("1.txt", "r")
  2. fout = open("2.txt", "w")
  3.  
  4. text = fin.read()
  5. allpeaks = list()
  6. for item in text:
  7.     if item != ' ' and item != '\n':
  8.         allpeaks.append(int(item))
  9. #all peaks with no isolated
  10. #print(set(allpeaks))
  11.  
  12. #all peaks like pairs
  13. lines = text.split("\n")
  14. print("lines or how many ties: ", len(lines))
  15. peaks = list()
  16. for line in lines:
  17.     peaks = []
  18.     peaks = line.split()
  19.     #print(peaks)
  20.  
  21.  
  22. #find isolated
  23. isolated = []
  24. for i in range(1, 7):
  25.     if i not in allpeaks:
  26.         isolated.append(i)
  27. print("isolated peaks: ", isolated)
  28.  
  29.  
  30. #find stepen for all peaks separately
  31. a = list()
  32. a = (len(set(allpeaks))+1) * [0]
  33. print(a)
  34. for peak in allpeaks:
  35.     a[peak] = a[peak] + 1
  36. print(a)
  37.  
  38. print("Max peak: ", max(a))
  39. max = max(a);
  40. maxpeak = list()
  41. for i in range(1, len(a)):
  42.     if a[i] == max:
  43.         maxpeak.append(i)
  44. print(maxpeak)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement