Ad
  • Custom User Avatar

    Sorry for offtop, but what software you used to generate this image? I was looking for something like that for a while

  • Custom User Avatar

    My solution is just an optimized version of permutating active tasks and calculating minimum time needed, so it's supposed to work.

  • Custom User Avatar

    How does your algorithm fare on this test case?

    1. Wash: carrots for 10 minutes
    2. Wash: rice for 5 minutes
    3. Boil: rice (takes 10 minutes)
    4. Boil: carrots (takes 2 minutes)
    5. Add: carrots for 20 minutes
    
  • Custom User Avatar

    The current reference solution returns suboptimal answers in some cases, for example:

    1. Wash: meat (takes 2 minutes)
    2. Wash: eggs (takes 1 minutes)
    3. Peel: eggs (takes 6 minutes)
    4. Cut: cheese (takes 2 minutes)
    5. Fry: cheese for 13 minutes
    6. Grate: cheese (takes 2 minutes)
    7. Fry: cheese for 30 minutes
    8. Wash: eggs (takes 3 minutes)
    9. Wash: eggs (takes 2 minutes)
    

    As shown in the Gantt chart below, the optimal answer is no more than (4) + (5) + (6) + (7) = 47 minutes, while the reference solution returns 48.

  • Custom User Avatar

    I would add test cases as this too. Not sure ref sol deals with those correctly. Such cases skip scheduled active tasks to give priority to future active tasks on other ingredient first, after an ongoing passive one.

    1. Wash: carrots for 10 minutes
    2. Wash: rice for 5 minutes
    3. Boil: rice (takes 10 minutes)
    4. Boil: carrots (takes 2 minutes)
    5. Add: carrots for 20 minutes
    
    -> should take 32 minutes
    - start 1 and 2
    - when 2 completes, don't start 3 yet
    - when 1 completes, start 4
    - when 4 completes, start 3 and 5
    
  • Custom User Avatar

    I would keep repeated actions and other "meaningless" actions. A good algorithm should be able to deal with all of those.

  • Custom User Avatar

    I only saw your reply when I posted mine and the page refreshed. At least you got a second confirmation.

  • Custom User Avatar

    Excellent kata btw!

  • Custom User Avatar

    Yes, thanks for answering, 44 was my (incorrect) answer. I came to the same conclusion.

  • Custom User Avatar

    Is 44 your answer or the expected answer ? Because 39 seems correct to me.

    • First do step 1, 2 and 4 (takes 13 minutes)
    • Then do step 6 in the background (will last for 21 more minutes)
    • Do steps 3 and 5 while the carrots boil (doesn't take time as step 6 is longer)
    • Finish with steps 7 and 8 (takes 5 minutes)

    13 + 21 + 5 = 39

  • Custom User Avatar

    Needs more random tests in general, making sure also edge cases such as specified in the other issue below are generated. I was able to pass random tests with an inferior algorithm because of good dice roll.

  • Custom User Avatar

    Needs more random and fixed tests with edge cases such as below, where we need to skip certain steps of some ingredients, to eagerly take a bottleneck ingredient first:

    1. Add: carrots, meat, rice (takes 2 minutes)
    2. Peel: carrots (takes 9 minutes)
    3. Cut: meat (takes 5 minutes)
    4. Wash: carrots (takes 2 minutes)
    5. Cut: meat (takes 4 minutes)
    6. Boil: carrots for 21 minutes
    7. Grate: carrots (takes 1 minutes)
    8. Add: carrots, rice (takes 4 minutes)
    
  • Custom User Avatar

    Oh I think I get it, 1,2,4 first, and then in parallel 3,5 <-> 6, then 7 and then 8. This makes this kata even harder than I expected. I've logged an issue about making sure to include such tests in random tests.

  • Custom User Avatar

    surely, this can't be right?

    1. Add: carrots, meat, rice (takes 2 minutes)
    2. Peel: carrots (takes 9 minutes)
    3. Cut: meat (takes 5 minutes)
    4. Wash: carrots (takes 2 minutes)
    5. Cut: meat (takes 4 minutes)
    6. Boil: carrots for 21 minutes
    7. Grate: carrots (takes 1 minutes)
    8. Add: carrots, rice (takes 4 minutes)
    
    44 should equal 39
    
  • Custom User Avatar

    Great kata, I had a lot of fun solving it.

  • Loading more items...