Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Дан список чисел, нужно вывести элемент у которого нет дупбиката
- 1) Решение через count
- 2) Решение через словарь
- 3) Решение через доп список
- '''
- def count_posibility(arr):
- for el in arr:
- if arr.count(el) == 1:
- return el
- return None
- def dictionary_posibility(arr):
- dictionary = {}
- for element in arr:
- if element not in dictionary.keys():
- dictionary[element] = 0
- else:
- dictionary[element] += 1
- for element in dictionary.values():
- if element == 0:
- return element
- return None
- def tuple_posibility(arr: list):
- stack = []
- arr.sort()
- for element in arr:
- if element not in stack:
- stack += [element]
- elif (element not in stack) and (type(tuple) in stack):
- for el in stack:
- if type(el) == list:
- if el[0] == element:
- index = stack.index(el)
- i = 0
- while i < len(stack):
- if i == index:
- stack.pop(index)
- break
- i += 1
- else:
- result = stack.pop()
- print(type(tuple[element]))
- stack.append([element])
- x_stack = []
- for element in stack:
- if type(element) == list:
- x_stack += [element[0]]
- y_stack = []
- for el in stack:
- if type(el) == list:
- y_stack += [el[0]]
- else:
- y_stack += [el]
- for element in y_stack:
- if element not in x_stack:
- return element
- else:
- continue
- arr = list(map(int, input().split()))
- print(tuple_posibility(arr))
Advertisement
Add Comment
Please, Sign In to add comment