Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ========== 01. Which Are In?
- first_sequence = input().split(", ")
- second_sequence = input().split(", ")
- substrings = []
- for substring in first_sequence:
- for string in second_sequence:
- if substring in string:
- if substring not in substrings:
- substrings.append(substring)
- print(substrings)
- # ========== 02. Next Version
- version = list(map(int, input().split(".")))
- first_digit = version[0]
- second_digit = version[1]
- third_digit = version[2]
- third_digit += 1
- if third_digit == 10:
- second_digit += 1
- third_digit = 0
- if second_digit == 10:
- first_digit += 1
- second_digit = 0
- print(f"{first_digit}.{second_digit}.{third_digit}")
- # ========== 03. Word Filter
- texts = input().split()
- even_length = [x for x in texts if len(x) % 2 == 0]
- for word in even_length:
- print(word)
- # ========== 04. Number Classification
- def filtering_numbers(nums):
- positive_filter = ", ".join(f"{x}" for x in nums if x >= 0)
- negative_filter = ", ".join(f"{x}" for x in nums if x < 0)
- even_filter = ", ".join(f"{x}" for x in nums if x % 2 == 0)
- odd_filter = ", ".join(f"{x}" for x in nums if x % 2 != 0)
- print(f"""Positive: {positive_filter}
- Negative: {negative_filter}
- Even: {even_filter}
- Odd: {odd_filter}""")
- numbers_for_filter = list(map(int, input().split(", ")))
- filtering_numbers(numbers_for_filter)
- # ========== 05. Office Chairs
- number_of_rooms = int(input())
- game_on = True
- free_chairs = 0
- for room in range(1, number_of_rooms +1):
- chairs_and_visitors = input().split()
- chairs = len(chairs_and_visitors[0])
- visitors = int(chairs_and_visitors[1])
- if chairs < visitors:
- print(f"{visitors-chairs} more chairs needed in room {room}")
- game_on = False
- else:
- free_chairs += chairs-visitors
- if game_on:
- print(f"Game On, {free_chairs} free chairs left")
- # ========== 06. Electron Distribution
- number_of_electrons = int(input())
- shells = []
- counter = 1
- while number_of_electrons != 0:
- formula = 2 * (counter ** 2)
- if number_of_electrons >= formula:
- shells.append(formula)
- else:
- shells.append(number_of_electrons)
- break
- number_of_electrons -= formula
- counter += 1
- print(shells)
- # ========== 07. Group of 10's
- number_of_sequence = list(map(int, input().split(", ")))
- counter = 0
- tens = []
- num_for_loop = (max(number_of_sequence) // 10) + 1
- if max(number_of_sequence) % 10 == 0:
- num_for_loop -= 1
- for index in range(num_for_loop):
- counter += 10
- print(f"Group of {counter}'s:", [x for x in number_of_sequence if x <= counter])
- number_of_sequence = [x for x in number_of_sequence if x > counter]
- # ========== 08. Decipher This!
- secret_message = input().split()
- decoded_word = []
- decoded_digits = ""
- for decode in secret_message:
- for letters in decode:
- if letters.isdigit():
- decoded_digits += letters
- else:
- decoded_word.append(letters)
- decoded_word[0], decoded_word[-1] = decoded_word[-1], decoded_word[0]
- decoded_word.insert(0, chr(int(decoded_digits)))
- print("".join(decoded_word), end=" ")
- decoded_word = []
- decoded_digits = ""
- # ========== 09. Anonymous Threat
- array_data = input().split()
- command = input().split()
- while command[0] != "3:1":
- current_command = command[0]
- if current_command == "merge":
- start_index = int(command[1])
- end_index = int(command[2])
- if start_index < 0:
- start_index = 0
- if end_index >= len(array_data):
- end_index = len(array_data)-1
- for merging in range(start_index+1, end_index+1):
- array_data[start_index] += array_data[merging]
- array_data[merging] = ""
- elif current_command == "divide":
- divided_words = []
- element_for_divide = int(command[1])
- amount_partitions = int(command[2])
- one_partition = len(array_data[element_for_divide]) // amount_partitions
- for parts in range(1, amount_partitions+1):
- if parts == amount_partitions and len(array_data[element_for_divide]) % amount_partitions != 0:
- divided_words.append(array_data[element_for_divide][::])
- else:
- divided_words.append(array_data[element_for_divide][:one_partition])
- array_data[element_for_divide] = array_data[element_for_divide][one_partition:]
- array_data.pop(element_for_divide)
- for elements in reversed(divided_words):
- array_data.insert(element_for_divide, elements)
- array_data = [x for x in array_data if x != ""]
- command = input().split()
- print(" ".join(array_data))
- # ========== 10. Pokemon Don't Go
- sequence_of_pokemons = list(map(int, input().split()))
- summed_elements = 0
- while True:
- indexes = int(input())
- if indexes >= len(sequence_of_pokemons):
- element_for_work = sequence_of_pokemons[-1]
- sequence_of_pokemons[-1] = sequence_of_pokemons[0]
- elif indexes < 0:
- element_for_work = sequence_of_pokemons[0]
- sequence_of_pokemons[0] = sequence_of_pokemons[-1]
- else:
- element_for_work = sequence_of_pokemons[indexes]
- sequence_of_pokemons.pop(indexes)
- for index, pokemon in enumerate(sequence_of_pokemons):
- if element_for_work >= pokemon:
- sequence_of_pokemons[index] += element_for_work
- else:
- sequence_of_pokemons[index] -= element_for_work
- summed_elements += element_for_work
- if len(sequence_of_pokemons) == 0:
- break
- print(summed_elements)
- # ========== 10. SoftUni Course Planning
- initial_schedule = input().split(", ")
- course_start = False
- while not course_start:
- list_commands = input()
- if list_commands == "course start":
- course_start = True
- break
- list_commands = list_commands.split(":")
- current_command = list_commands[0]
- if current_command == "Add":
- lesson = list_commands[1]
- if lesson not in initial_schedule:
- initial_schedule.append(lesson)
- elif current_command == "Insert":
- lesson = list_commands[1]
- index_for_insert = int(list_commands[2])
- if lesson not in initial_schedule:
- initial_schedule.insert(index_for_insert, lesson)
- elif current_command == "Remove":
- lesson = list_commands[1]
- if lesson in initial_schedule:
- initial_schedule.remove(lesson)
- if lesson+"-Exercise" in initial_schedule:
- initial_schedule.remove(lesson+"-Exercise")
- elif current_command == "Swap":
- lesson = list_commands[1]
- second_lesson = list_commands[2]
- if lesson in initial_schedule and second_lesson in initial_schedule:
- first_index_for_swap = initial_schedule.index(lesson)
- second_index_for_swap = initial_schedule.index(second_lesson)
- initial_schedule[first_index_for_swap], initial_schedule[second_index_for_swap] = \
- initial_schedule[second_index_for_swap], initial_schedule[first_index_for_swap]
- if lesson+"-Exercise" in initial_schedule:
- initial_schedule.remove(lesson+"-Exercise")
- initial_schedule.insert(second_index_for_swap+1, lesson+"-Exercise")
- if second_lesson+"-Exercise" in initial_schedule:
- initial_schedule.remove(second_lesson+"-Exercise")
- initial_schedule.insert(first_index_for_swap+1, second_lesson+"-Exercise")
- elif current_command == "Exercise":
- lesson = list_commands[1]
- if lesson not in initial_schedule:
- initial_schedule.append(lesson)
- initial_schedule.append(lesson+"-Exercise")
- elif lesson+"-Exercise" not in initial_schedule:
- index_for_exercise = initial_schedule.index(lesson)
- initial_schedule.insert(index_for_exercise+1, lesson+"-Exercise")
- number_of_lesson = 1
- for schedule in initial_schedule:
- print(f"{number_of_lesson}.{schedule}")
- number_of_lesson += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement