Das perfekte Schwert

Optimal is 51 levels in total with the following pattern:
( (sword + loot) + (sharp + fire asp) ) + ( (sweep + unb) + (mend + kb) )
where you can exchange the places of looting and sweeping and/or mending and knockback.

Its kinda crazy to explain the full detail but ill try in short: you have fixed costs for the enchantments, but you get costs for anvil uses and placement of the enchantments in the pattern. in this (optimal 2-4-8) pattern you get multipliers for the enchantment costs of
( (0 + 1) + (1 + 2) ) + ( (1 + 2) + (2 + 3) )
So a 4 means you have to pay that enchantment cost 4 times, so you want the cheapest enchantment there. and obviously you want the most expensive ones in the slots with low multipliers. The costs for the vanilla sword enchantments are

  • 6 lvls: Looting 3
  • 5 lvls: Sharpness 5
  • 4 lvls: Fire Aspect 2
  • 6 lvls: Sweeping 3
  • 3 lvls: Unbreaking 3
  • 2 lvls: Mending
  • 2 lvls: Knockback 2

and you just put them into the pattern places from most expensive to least expensive, going from the lowest multiplier to the highest.

Take from a comment in this Youtube-Video

Perfect Armor

Helmet

Unbreaking III
Protection IV
Mending
Respiration III
Aqua Affinity

Chestplate

Unbreaking III
Protection IV
Mending

Leggings

Unbreaking III
Protection IV
Mending

Boots

Unbreaking III
Protection IV
Mending
Depth Strider III
Soul Speed III
Feather Falling IV

Take from this Youtube-Video