Calculate optimal anvil combining sequences to avoid the "Too Expensive!" limit in Minecraft, minimize prior work penalties, and check conflicts.
Conflicts are resolved automatically
Follow this binary tournament bracket to avoid "Too Expensive!" (Level 40 limit)
Place "Looting III" in the left anvil slot and "Sweeping Edge III" in the right anvil slot.
Place "Sharpness V" in the left anvil slot and "Fire Aspect II" in the right anvil slot.
Place "Mending" in the left anvil slot and "Unbreaking III" in the right anvil slot.
Place the Sword (Netherite / Diamond) in the left slot and the merged enchanted book in the right slot.
When an anvil operation costs 40 or more levels in Survival mode, Minecraft blocks the action with "Too Expensive!". Combining books in pairs (like a tournament bracket) instead of adding books one by one onto the tool avoids this penalty.
No, in vanilla Survival Minecraft, Mending and Infinity are mutually exclusive enchantments.