Implement some business logic in Python.
For this exercise, calculate a total from line items, quantity-based discount rules, and a tax percentage. Each item uses the highest applicable discount rule for its category, then tax is applied to that item's discounted subtotal.
Implement calculate_total(items, rules, tax_percent). Each item has category, quantity, and integer unit_price in cents. Each rule has category, min_quantity, and integer discount_percent. Return the total in cents, rounding down after each discount and tax calculation.
def calculate_total(items, rules, tax_percent):