Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Batle_of_names
- odd_set = set()
- even_set = set()
- for row in range(1, int(input()) + 1):
- ascii_sum_of_name = sum(ord(l) for l in input()) // row
- if ascii_sum_of_name % 2 == 0:
- even_set.add(ascii_sum_of_name)
- else:
- odd_set.add(ascii_sum_of_name)
- if sum(odd_set) > sum(even_set):
- print(*odd_set.difference(even_set), sep=", ")
- else:
- print(*odd_set.symmetric_difference(even_set), sep=", ")
- # Count_symbols
- occurrences = {}
- for letter in input():
- occurrences[letter] = occurrences.get(letter, 0) + 1
- # Solution 2
- for letter in input():
- if letter not in occurrences:
- occurrences[letter] = 0
- occurrences[letter] += 1
- # Solution 3
- for letter, times in sorted(occurrences.items()):
- print(f"{letter}: {times} time/s")
- # Solution 4
- text = input()
- for letter in sorted(set(text)):
- print(f'{letter}: {text.count(letter)} time/s')
- # Crossroads
- from collections import deque
- green_window = int(input())
- free_window = int(input())
- total_cars = 0
- cars = deque()
- info = input()
- while info != "END":
- if info != "green":
- cars.append(info)
- else:
- current_green = green_window
- while current_green > 0 and cars:
- car = cars.popleft()
- time = current_green + free_window
- if len(car) > time:
- print(f"A crash happened!\n{car} was hit at {car[time]}.")
- raise SystemExit
- current_green -= len(car)
- total_cars += 1
- info = input()
- print(f"Everyone is safe.\n{total_cars} total cars passed the crossroads.")
- # Cups_and_bottles
- from collections import deque
- cups = deque(int(cup) for cup in input().split())
- bottles = deque(int(bottle) for bottle in input().split())
- wasted_liters = 0
- while cups and bottles:
- current_cup = cups.popleft()
- current_bottle = bottles.pop()
- if current_cup < current_bottle:
- wasted_liters += current_bottle - current_cup
- else:
- cups.appendleft(current_cup - current_bottle)
- if cups:
- print(f"Cups: {' '.join(str(c) for c in cups)}")
- else:
- print(f"Bottles:: {' '.join(str(b) for b in bottles)}")
- print(f"Wasted litters of water: {wasted_liters}")
- # Longest_intersection
- longest_intersection = set()
- for _ in range(int(input())):
- # first_data, second_data = [map(int, el.split(",")) for el in input().split("-")]
- first_data, second_data = [el.split(",") for el in input().split("-")]
- first_range = set(range(int(first_data[0]), int(first_data[1]) + 1))
- second_range = set(range(int(second_data[0]), int(second_data[1]) + 1))
- intersection = first_range.intersection(second_range)
- if len(intersection) > len(longest_intersection):
- longest_intersection = intersection
- print(f" Longest intersection is "
- f"[{', '.join(str(x) for x in longest_intersection)}]"
- f"with length {len(longest_intersection)}"
- )
- # Periodic_table
- table = set()
- for _ in range(int(input())):
- for el in input().split():
- table.add(el)
- print(*table, sep="\n")
- # Coment
- n = 0
- first_set = set()
- for _ in range(n):
- first_set.add(int(input()))
- first_set = {int(input()) for _ in range(n)}
- # Set_of_elements
- n, m = [int(num) for num in input().split()]
- first_set = {int(input()) for _ in range(n)}
- second_set = {int(input()) for _ in range(m)}
- print(first_set.intersection(second_set), sep="\n")
- # Solution 2
- n, m = [int(num) for num in input().split()]
- first_set = {int(input()) for _ in range(n)}
- second_set = {int(input()) for _ in range(m)}
- print(first_set & second_set, sep="\n")
- # Solution 3
- print(first_set | second_set, sep="\n")
- # Solution 4
- print(first_set - second_set, sep="\n")
- # Solution 5
- print(first_set ^ second_set, sep="\n")
- # Unique_username
- # SETs
- # intersection -> сечение
- # union -> обединение
- names_count = int(input())
- names = set()
- for _ in range(names_count):
- names.add(input())
- print(*names, sep="\n")
- # КОМЕНТАРИ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement