7 kyu

Barista problem

1,419 of 3,014Stefan30
Description
Loading description...
Fundamentals
Sorting
  • Please sign in or sign up to leave a comment.
  • adbiLenLa Avatar

    excellent kata

  • vpopolitov Avatar

    Thanks for this nice kata! Enjoyed solving it.

  • PR3SS F Avatar

    Stop whining, all good here. Understanding complex text comes along side with programming. Business people don't talk programming :) Besides logic for the solution is implementable in excel...

  • xianjin Avatar

    Rust prototype is Vec<u8> whereas tests use &[u8].

  • Konstantin Modin Avatar

    Not quite a clear description. I would write task like: You as a barista have a list of coffee orders. You need to find a way to serve coffee for all people in the list in such a way that all people all together are waiting as little time as possible. And you need to calculate this time.

  • Discordanian Avatar

    Rust error in tests with function declaration. "error[E0308]: mismatched types" It looks like slices are being passed in and not Vec.

  • LooshProtocol Avatar

    The description should be concise, not written like a small novel.

  • marjan Avatar

    Solved in C++. I enjoy it. Description is clear, no comments.

  • MrCookies78 Avatar

    1kyu katas' descriptions are easier to understand than this one, I'm not a native english speaker but still.

  • post_lupy Avatar

    Problem description issue.

    Sorry mate, but in real-world logic, the sum doesn't make any sense since (i.e.) the third customer only waits for previous orders only once.

  • post_lupy Avatar

    I'm having enough of this english-language-related trick question. I'm here to learn coding after all...

    I'll just skip.

    (such a shame for an interesting problem tho)

  • marjan Avatar

    Please, can you check my code, because I test it in two different compilers, and I get expected result. But here in your compiler it print wrong result for random tests. For no order, small order and large order it prints correct.

  • shinyclovers Avatar

    C++ translation, random tests follow python generation

    https://www.codewars.com/kumite/6310c8d0e5da9e0016a2ef67

  • user204650 Avatar

    The description is bad and needs to be re-written by a native English speaker. It's very ambiguous and almost every comment is complaining about this exact problem. Here is a suggestion to put at the top:

    tl;dr Return the total value of the waiting times for all customers, so that the waiting time is the least it could be. (ie. Customer 1's wait + Customer 2's wait + Customer 3's wait...)

    Simple

  • Sayandziro Avatar

    Why every next coffee takes less time to make? What is going on?

  • Buccaneer12 Avatar

    Logic of counting time is false. Total waiting time has to be the last customers waiting time, but not the sum of all. Because waiting time of previous customers is already counted in the last customers waiting time/ So, [4, 3, 2] has to be 13 (4+2 + 3+2 + 2), but not ((4) + (4+2 +3) + (4+2 + 3+2 + 2))

  • akar-0 Avatar
  • clivepato Avatar

    thanks for the challenge got my brain to work :D

  • Royals88 Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • miquel_. Avatar

    I don't understand why in the notes says that the list [4, 3, 2] should return 26, but in the example says that the same list [4, 3, 2] should return 22. If anyone could help me I would apreciate becouse it doesn't make any sense for me.

  • el-f Avatar

    Change the barista manager link to the main kata url (https://www.codewars.com/kata/624f3171c0da4c000f4b801d) instead of the JS solutions page.

  • glebec Avatar

    Probably applies to many translations, though I specifically encountered it in the Lambda Calculus translation:

    • Zero-time drinks are sometimes generated by the random tests, which is neither directly implied by the description nor checked in the example or fixed tests. This can make a difference to some solutions which might assume zero is a starting base case (which it isn't, necessarily).
    • IMHO failing random test cases should print the failing input array/list in the message, to help users debug their implementation. I didn't understand why my first attempt failed until I guessed that perhaps some drink lists might contain zero-time drinks. Seeing the input array for random tests would have made that immediately clear.

    Zero-time drinks should be explicitly (dis)allowed and/or included in the example tests and/or shown in the failing test message.

    Otherwise, a fun kata, thanks.

  • romanjhyltsou Avatar

    where in the conditions it is written about a random test?

  • gotfede Avatar

    sorry but it doesen't make any sense the description

  • rowcased Avatar

    C Translation kumited, thanks.

  • leonaAtkins Avatar

    I really don't understand the description.

    coffees = [20,5] -> 32

    Cust 1 20 = 20

    Cust 2 20+2+5 = 27 not 32

    or

    Cust 1 5 = 5

    Cust 2 5+2+20 = 27 still not 32

    Must be miss understanding something, or it's not clear, I'm missing a calculation or magic number?

  • BinklerStrauss Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • Arkadiusz Kłeczek Avatar

    The description is misleading... Ive spend way much time to try to understand what do You mean in this kata.

  • Stefan30 Avatar

    I have taken this kata to the next level, so if you want to see what other challange you have to face as a barista, check this out: https://www.codewars.com/kata/624f3171c0da4c000f4b801d/solutions/javascript

  • JohanWiltink Avatar

    Lambda Calculus translation

    I did some minor cleaning up of the description. Hope you don't mind.

    ( Don't worry that the solution is a lot longer than in other languages. This is expected in LC. )

  • Stefan30 Avatar

    Translated to PHP. Happy coding!

  • NikCSharp Avatar
    test.assert_equals(barista([]),0,'Sorry, but the smallest waiting time possible is: 85')
    

    Test description should be changed to 'Sorry, but the smallest waiting time possible is: 0'

  • trashy_incel Avatar

    print the minimum total waiting time

    it should be 'return' rather than 'print' ;-)

  • Stefan30 Avatar

    Sorry coders. Apparently I broke something in the back, I will fix it ASAP.

  • JohanWiltink Avatar
  • JohanWiltink Avatar

    ( JS, possibly others )

    Random tests may generate an empty list of coffees. That means there should be a fixed test for this edge case.

  • Stefan30 Avatar

    Hello everyone. I have just added a JavaScript version of this Kata so it is now available for JS coders. Happy coding guys!

  • Osteg Avatar

    Can you help me with understanding this kata? Why in total time we are doubling time for coffee we already made? If I need 5 min for 1'st, 3 min for 2'nd and 2 min break between, I can do this with 10 min in total whatever order i choose...

  • FArekkusu Avatar

    There's no point in custom error messages which poorly duplicate the test.assert_equals behavior. Also, random tests should use test.assert_equals.

  • FArekkusu Avatar

    All fixed tests show the same wrong custom error message "Sorry, but the smallest waiting time possible is: 0".

  • FArekkusu Avatar

    I think it'd be better if the kata was only about finding the minimum total waiting time rather than additionaly comparing it to some value and returning a formatted string - this step has nothing to do with the actual task, it adds zero value/complexity to the kata overall, and it takes more code to return the correct string than to calculate the waiting time which is really dumb. Also, assuming this kata gets approved, it'll be very annoying to translate it to (and solve it in) lower-level languages like C.

  • natan Avatar

    typos:

    • caffeteria
    • .So
    • posible

    --

    Random test cases are under describe('Fixed Tests')

    --

    Test output doesn't show what input was used. (both random and fixed tests) The test framework doesn't really facilitate displaying what input was used (other than perhaps the it header) but what you can do is to do the comparison yourself and provide a custom error message to test.fail and otherwise test.expect(True) if the comparison succeeded, something like:

    if expected == user_reply:
        test.pass_()
    else:
        test.fail(f"Input:\ncoffees={coffees}, wait_time={wait_time}\nExpected: {expected!r}\nBut Got: {user_reply!r}")
    

    --

    that sol global var is an abomination, and, the test isn't entirely fixed if it's calling a reference solution

  • Stefan30 Avatar

    I believe I fixed every issue that was found. If you find anything else please do not hesitate to write about it here. Thank you for the help, now I just need to wait for the kata to get approved. All the best.

  • FArekkusu Avatar

    Sample tests should import the solution explicitly.

  • emgordon154 Avatar

    If you have the times: [5,3] you will need 5 minutes for the first coffee, and another 3 for the second, but in total, the waiting time for the first customer is 5 minutes, but for the second one is 2 minutes ( cleaning the machine ), 5 minutes ( the time you need to brew the first coffee ), and the 3 minutes you need for his coffee. So the total waiting time is: 5+2+5+3. This time depends on the order you choose to brew the cups of coffee.

    I'm confused. You said we can brew the cups in any order we want, so why can't we brew the 3-cup first and the 5-cup second for a total waiting time of 3+2+3+5?

  • FArekkusu Avatar

    The random input array grows more and more huge with each test - is this intended?

  • FArekkusu Avatar

    "Wrong output" is not a useful custom error message.

  • FArekkusu Avatar

    The user can modify the input.

  • LearningFTW Avatar

    What to do when answer is 0 ?

  • FArekkusu Avatar

    Solution should be imported explicitly.

  • FArekkusu Avatar

    No random tests.

  • Stefan30 Avatar

    If you have any feedback for this kata, please feel free to tell me about it. Thanks to everyone for their help. Have a great day/evening. :)