Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_ord(lst): # ну, я пытался изобрести сортировку сравнением с линейной сложностью :)
- ords = []
- for i in lst:
- ords.append(ord(i))
- return ords
- def remove_common(lst):
- unique = []
- for i in lst:
- if i not in unique:
- unique.append(i)
- return unique
- def find_max(lst):
- max = 0
- for i in lst:
- if i > max:
- max = i
- return max
- def find_min(lst):
- min = 100000000
- for i in lst:
- if i < min:
- min = i
- return min
- def zero_push(lst):
- zeros = []
- for i in range(len(lst)):
- zeros.append(0)
- return zeros
- def remove_zero(lst):
- res = []
- for i in lst:
- if i != 0:
- res.append(i)
- return res
- def compare_elements(lst):
- big = []
- small = []
- for i in range(1, len(lst)):
- if lst[i] < lst[i-2] and lst[i] not in big:
- small.append(lst[i])
- if lst[i] > lst[i-2] and lst[i] not in small:
- big.append(lst[i])
- return small + big
- asc_str = "ghfjhvlmayhdsopleznshix"
- ords = convert_ord(asc_str)
- ords = remove_common(ords)
- max = find_max(ords)
- min = find_min(ords)
- zeros = zero_push(ords)
- zeros[0] = min
- zeros[-1] = max
- middle = int(len(ords)/2)
- first_half = zeros[:middle]
- second_half = zeros[middle:]
- for i in ords:
- if i not in zeros:
- if (max % i) > (i % min):
- first_half.append(i)
- else:
- second_half.append(i)
- first_half = remove_zero(first_half)
- second_half = remove_zero(second_half)
- first_half = compare_elements(first_half)
- second_half = compare_elements(second_half)
- all = first_half + second_half
- print(all) # получилось ровным счетом никак :)
- # ну яндекс, ну придумали задачу
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement