Given a cargo shipment with various package weights, determine the number of ways to distribute these packages evenly into two spacecraft, Starblade and NovaSpur, such that the total weight of packages in both spacecraft is equal.
Explanation: Step-by-step: with input [1, 2, 3, 4, 5], we calculate the total weight of packages, which is 15. Since 15 is odd, we cannot evenly distribute the packages between two spacecraft. Therefore, the number of ways to distribute the packages is 0.
Explanation: Step-by-step: with input [10, 10, 10, 10], we calculate the total weight of packages, which is 40. We can evenly distribute the packages between two spacecraft by placing 20 packages in each spacecraft. Therefore, the number of ways to distribute the packages is 1.
Master coding challenges related to Recursion and solve the [Backup] Interstellar Cargo Distribution problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak