Heap construction swap counts
Your task
A level loader stores enemy spawn priorities in an array and turns that array into a min-heap at load time. Two ways are on the table and the studio wants the swap counts side by side. The first is the bottom-up build: for i from n / 2 - 1 down to 0, sift index i down, where sifting down compares a node with its children, picks the smaller child (the left one when the two children are equal), swaps if that child is strictly smaller than the node, and repeats from the node's new position. The second inserts the values one at a time, left to right, into an initially empty heap, sifting each new value up while it is strictly smaller than its parent. Return two numbers: the swaps the bottom-up build performs, then the swaps the repeated insertion performs.
Examples
heapify_swap_counts(priorities: list[int]) -> list[int]heapify_swap_counts([5, 3, 8, 1, 9, 2])[4, 4]heapify_swap_counts([1, 2, 3, 4, 5])[0, 0]