Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. class Data_Set:
  2.     def __init__(self, amplitude_, duration_):
  3.         self.amplitude = amplitude_
  4.         self.duration = duration_
  5.  
  6.  
  7. class Point:
  8.     def __init__(self, x_, y_):
  9.         self.x = x_
  10.         self.y = y_
  11.  
  12.  
  13. First_Channel = []
  14. Second_Channel = []
  15. for i in input().split():
  16.     First_Channel.append(int(i.split(',')[0]))
  17.     Second_Channel.append(int(i.split(',')[1]))
  18. #print(First_Channel)
  19. #print(Second_Channel)
  20. First_Channel_Data = []
  21. Second_Channel_Data = []
  22.  
  23. # First channel analysis
  24. Start_Point = Point(0, First_Channel[0])
  25. Vertex = -1  # undefined if -1
  26. Finish_Point = -1
  27. for i in range(1, len(First_Channel) - 1):
  28.     if Vertex == -1:
  29.         if First_Channel[i] < First_Channel[i - 1]:
  30.             Vertex = Point(i - 1, First_Channel[i - 1])
  31.     elif First_Channel[i] > First_Channel[i - 1]:
  32.         Finish_Point = Point(i - 1, First_Channel[i - 1])
  33.         if 20 >= Finish_Point.x - Start_Point.x >= 12:
  34.             First_Channel_Data.append(
  35.                 Data_Set(amplitude_=Vertex.y - min(Start_Point.y, Finish_Point.y),
  36.                          duration_=Finish_Point.x - Start_Point.x))
  37.         Start_Point = Point(i, First_Channel[i])
  38.         Vertex = -1
  39.         Finish_Point = -1
  40. # Second channel analysis
  41. Start_Point = Point(0, Second_Channel[0])
  42. Vertex = -1  # undefined if -1
  43. Finish_Point = -1
  44. for i in range(1, len(Second_Channel) - 1):
  45.     if Vertex == -1:
  46.         if Second_Channel[i] < Second_Channel[i - 1]:
  47.             Vertex = Point(i - 1, Second_Channel[i - 1])
  48.     elif Second_Channel[i] > Second_Channel[i - 1]:
  49.         Finish_Point = Point(i - 1, Second_Channel[i - 1])
  50.         if 20 >= Finish_Point.x - Start_Point.x >= 12:
  51.             Second_Channel_Data.append(
  52.                 Data_Set(amplitude_=Vertex.y - min(Start_Point.y, Finish_Point.y),
  53.                          duration_=Finish_Point.x - Start_Point.x))
  54.         Start_Point = Point(i, Second_Channel[i])
  55.         Vertex = -1
  56.         Finish_Point = -1
  57. #for i in First_Channel_Data: print(i.amplitude, i.duration)
  58. Answer1 = sum([i.amplitude for i in First_Channel_Data]) / len(First_Channel_Data) if len(
  59.     First_Channel_Data) != 0 else 0
  60. Answer2 = sum([i.amplitude for i in Second_Channel_Data]) / len(Second_Channel_Data) if len(
  61.     Second_Channel_Data) != 0 else 0
  62. #print(Answer1, Answer2)
  63. print(1 if Answer1 > Answer2 else 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement