Draft
Late delivery
4 of 5artiekra
Description:
Description
Suddenly the delivery center got n
new packages, and they need to be delivered by tommorow. There is only 2 delivery cars left ( let's name the drivers Jake
and Alan
accordingly ), and so the packages need to be distributed beetwen cars. Knowing the mass of each package, and how much each car can take, return one of the outputs:
They can not do it!
if it's impossible to deliver all of the packages in one ride.They both can do it!
if either of them can do it without any help of the other one.Jake can do it!
if the first car can deliver all the packages on it's own, but not the second.Alan can do it!
if the second car can deliver all the packages on it's own, but not the first.- If neither of them can do it on their own, but they can do it, if you distribute the packages beetwen both of them, return 3 strings ( you will need to use \n, like this
String1\nString2
). First string is alwaysThey need to work together!
, second string is something likeJake 1 2 3
, and the last string in a form ofAlan 4 5
, where the numbers is the package numbers ( the indexing of the packages starts at 1, not at 0 ). Note that there is can be several correct distributions, and any of them will pass the tests. You can also output packages numbers in any order.
You will get input in a form of calculate_delivery([m₁, m₂, ..., mₙ], [Mj, Ma])
, where m₁
, m₂
, etc. is how much each package weights, Mj
is how much Jake can take and Ma
is how much Alan can take.
Examples
calculate_delivery([10,10,10,10,10], [20,20]) => They can not do it!
# They can at max take 20+20=40, but there is 5 packages, that in total weight 10+10+10+10+10=50, so they can't take all of them.
calculate_delivery([7,10,8,9,12,20,1], [100,100]) => They both can do it!
# There is 7 packages with a total weight of 7+10+8+9+12+20+1=67, and that can be taken by either of them.
calculate_delivery([7,10,8,9,12,20,1], [100,50]) => Jake can do it!
# The same packages as in the previous example, but now only the first car can take them.
calculate_delivery([7,10,8,9,12,20,1], [50,100]) => Alan can do it!
# The same packages as in the previous example, but now only the second car can take them.
calculate_delivery([7,8,9,10,11], [30,30]) => They need to work together! Jake 1 2, Alan 3 4 5.
# The total weight is 7+8+9+10+11=45, but neither of them can take it. They can deliver the packages though, but only if they will work together!
# Any correct distribution will pass the tests, in this example Jake will take packages 1 and 2 ( 7+8=15<=30 ), and Alan the rest - 3, 4 and 5 ( 9+10+11=30<=30 )
calculate_delivery([14,1,4,3], [11,12]) => They can not do it!
# A little edge-case to consider for you. 2 cars can take 11+12=23, and packages weight 14+1+4+3=22. But even with that, that's impossible to deliver everything.
# It's really easy to see in this example ( no one can deliver a package that weights 14 ), but it's not always the case ( take for example packages 3 1 9 4 5 and cars 11 11 ).
Limitations
The tests will use the folowing numbers:
- Number of packages n from 1 to 200.
- Weight of every package from 0 to 10⁴.
- Each car can take from 0 to 10⁸.
The idea for this kata is taken from Ukrainian informatics olympiad 2023
Puzzles
Similar Kata:
Stats:
Created | Jan 29, 2023 |
Warriors Trained | 14 |
Total Skips | 0 |
Total Code Submissions | 121 |
Total Times Completed | 5 |
Python Completions | 4 |
Total Stars | 1 |
% of votes with a positive feedback rating | 88% of 4 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |