Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Christmas_elves
- from collections import deque
- elves = deque([int(x) for x in input().split()])
- materials = deque([int(x) for x in input().split()])
- total_energy = 0
- total_toys = 0
- iterations = 0
- while elves and materials:
- elf = elves.popleft()
- material = materials[-1]
- if elf < 5:
- continue
- iterations += 1
- current_toys_count = 0
- if iterations % 3 ==0:
- material *= 2
- current_toys_count += 1
- if elf >= material:
- total_energy += material
- elf -= material
- if iterations % 5 != 0: # Ако не си на 5-тата итерация даи играчки на елф
- elf += 1
- current_toys_count += 1
- else:
- current_toys_count = 0
- materials.pop()
- else:
- elf *= 2
- current_toys_count = 0
- total_toys += current_toys_count
- elves.append(elf)
- print(f"Toys: {total_toys}")
- print(f"Energy: {total_energy}")
- if elves:
- print(f"Elves left: {', '.join(str(x) for x in elves)}")
- if materials:
- print(f"Boxes left: {', '.join(str(x) for x in materials)}")
- # Pawn_wars
- SIZE = 8
- # Ako Редовете между белите и черните са четен брой -> печелят винаги белите
- # Ako Редовете между белите и черните са neчетен брой -> печелят винаги `черните
- board = []
- positions = [[], []]
- def save_positions(search_for, index_to_save, r):
- if search_for in board[r]:
- positions[index_to_save].append(r)
- positions[index_to_save].append(board[r].index(search_for))
- for row in range(SIZE):
- board.append([input().split()])
- save_positions("w", 0, row)
- save_positions("b", 1, row)
- if abs(positions[0][1] - positions[1][1]) != 1 or positions[1][0] > positions[0][0]:
- if SIZE - positions[0][0] - 1 <= positions[1][0]: # -1 защото индекс 8 е невалиден индекс и белите винаги започват 1-ви
- print(f"Game over! Black pawn promoted to a queen at {chr(97 + positions[1][1])}1.")
- else:
- print(f"Game over! White pawn promoted to a queen at {chr(97 + positions[0][1])}8.")
- else:
- place = (positions[0][0] + positions[1][0]) // 2
- # Ако и двете са на нечетни или на четни -> винаги печелят четрните
- if positions[0][0] % 2 == 0 and positions[1][0] % 2:
- print(f"Game over! Black win, capture on {chr(97 + positions[0][1])}{SIZE - place}.") # черните печелят но на колоната на белите, защото взимат пешката
- else:
- print(f"Game over! White win, capture on {chr(97 + positions[1][1])}{SIZE - place}.")
- # Words_sorting
- def words_sorting(*words):
- words_dict = {word: sum(map(ord, word)) for word in words} # map -> ord(letter) for letter in word
- if sum(words_dict.values()) % 2 ==0:
- return "\n".join([f"{w} - {s}" for w, s in sorted(words_dict.items(), key=lambda x: x[0])])
- return "\n".join([f"{w} - {s}" for w, s in sorted(words_dict.items(), key=lambda x: -x[0])])
- # ___________________________ Няма Викане на функцията ??
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement