






'''simple docstring'''





from multiprocessing import Lock, Pipe, Process

# lock used to ensure that two processes do not access a pipe at the same time
__lowerCamelCase	:		Tuple										=   Lock()







def 			A__							(      _a  :					List[Any]		,  _a  :					List[Any]		,  _a  :					Optional[int]		,  _a  :					Optional[Any]		,  _a  :					Optional[int]		,  _a  :					Any		,  _a  :					int	):





 '''simple docstring'''







 global process_lock

 # we perform n swaps since after n swaps we know we are sorted
 # we *could* stop early if we are sorted already, but it takes as long to
 # find out we are sorted as it does to sort the list with this algorithm
 for i in range(0		,  10	):
  if (i + position) % 2 == 0 and r_send is not None:
   # send your value to your right neighbor
   process_lock.acquire()
   r_send[1].send(_a	)
   process_lock.release()

   # receive your right neighbor's value
   process_lock.acquire()
   snake_case__  :    List[Any]							       =rr_cv[0].recv()
   process_lock.release()

   # take the lower value since you are on the left
   snake_case__  :    Tuple							       =min(_a		,  _a	)
  elif (i + position) % 2 != 0 and l_send is not None:
   # send your value to your left neighbor
   process_lock.acquire()
   l_send[1].send(_a	)
   process_lock.release()

   # receive your left neighbor's value
   process_lock.acquire()
   snake_case__  :    List[Any]							       =lr_cv[0].recv()
   process_lock.release()

   # take the higher value since you are on the right
   snake_case__  :    Dict							       =max(_a		,  _a	)
    # after all swaps are performed, send the values back to main
 result_pipe[1].send(_a	)







def 			A__							(      _a  :					Dict	):





 '''simple docstring'''







 snake_case__  :    int							       =[]
 snake_case__  :    Dict							       =[]
 # initialize the list of pipes where the values will be retrieved
 for _ in arr:
  result_pipe.append(Pipe()	)
 # creates the processes
 # the first and last process only have one neighbor so they are made outside
 # of the loop
 snake_case__  :    Optional[Any]							       =Pipe()
 snake_case__  :    Any							       =Pipe()
 process_array_.append(
     Process(
         target=_a		,  args=(0, arr[0], None, temp_rs, None, temp_rr, result_pipe[0])		,  )	)
 snake_case__  :    Any							       =temp_rs
 snake_case__  :    str							       =temp_rr

 for i in range(1		,  len(_a	) - 1	):
  snake_case__  :    Union[str, Any]							       =Pipe()
  snake_case__  :    Optional[Any]							       =Pipe()
  process_array_.append(
      Process(
          target=_a		,  args=(i, arr[i], temp_ls, temp_rs, temp_lr, temp_rr, result_pipe[i])		,  )	)
  snake_case__  :    str							       =temp_rs
  snake_case__  :    Optional[int]							       =temp_rr

 process_array_.append(
     Process(
         target=_a		,  args=(
             len(_a	) - 1,
             arr[len(_a	) - 1],
             temp_ls,
             None,
             temp_lr,
             None,
             result_pipe[len(_a	) - 1],
         )		,  )	)

 # start the processes
 for p in process_array_:
  p.start()

 # wait for the processes to end and write their values to the list
 for p in range(0		,  len(_a	)	):
  snake_case__  :    List[str]							       =result_pipe[p][0].recv()
  process_array_[p].join()
 return arr







def 			A__							(      ):





 '''simple docstring'''







 snake_case__  :    Any							       =list(range(10		,  0		,  -1	)	)
 print("""Initial List"""	)
 print(*_a	)
 snake_case__  :    Dict							       =odd_even_transposition(_a	)
 print("""Sorted List\n"""	)
 print(*_a	)


if __name__ == "__main__":
       main()













__lowerCamelCase	:		dict[str, float]										=   {
    "km/h": 1.0,
    "m/s": 3.6,
    "mph": 1.60_93_44,
    "knot": 1.8_52,
}

__lowerCamelCase	:		dict[str, float]										=   {
    "km/h": 1.0,
    "m/s": 0.2_77_77_77_78,
    "mph": 0.6_21_37_11_92,
    "knot": 0.5_39_95_68_03,
}







def 			A__							(      _a  :					float		,  _a  :					str		,  _a  :					str	):





 '''simple docstring'''







 if unit_to not in speed_chart or unit_from not in speed_chart_inverse:
  snake_case__  :    Tuple							       =(
      f"Incorrect 'from_type' or 'to_type' value: {unit_from!r}, {unit_to!r}\n"
      f"Valid values are: {', '.join(_a	)}"
  )
  raise ValueError(_a	)
 return round(speed * speed_chart[unit_from] * speed_chart_inverse[unit_to]		,  3	)


if __name__ == "__main__":
       import doctest

       doctest.testmod()





