Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Yes, my solution sorts the customers by arrival time. Hence, it returns,

    [1, 1, 1, 2, 3, 1, 1, 1, 1, 2], for the following sorted customer list:

    [(3, 3), (5, 5), (6, 6), (6, 6), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (10, 10)] (note that this is similar to the test case in your previous reply, but sorted.

    So when your question talks about allowing various permutations, I thought it should allow for sorting, too.

    Edit: but its ok, i'll fit the return value to the input.

  • Default User Avatar

    I found your solution.

    Here is a test case that shows that there's an issue with your solution. For customers = [(6,6),(5,5),(6,6),(10,10),(7,7),(10,10),(6,6),(8,8),(3,3),(9,9)], your solution returns [1, 1, 1, 2, 3, 1, 1, 1, 1, 2]. It allocates customers 1 and 3 to the same room, but this is not correct because they arrive and leave on the same day.

  • Custom User Avatar

    both cases' error msg says the same thing. "In room x, customer n1 departs at day y2 but customer n2 arrives at y1."

    I think its because i sorted the customer input? Anyway, do consider validating test results by using the minimum total number of rooms needed, i.e.: max(allocate_rooms(c)), if its not the case. I think this will be sufficient and more robust as validation.

    i'm using python. Have a safe and good trip!

  • Default User Avatar

    It looks like the message for the first case is referring to the customers (39, 81) and (71, 109). If you allocated them to the same room, then something is wrong with your solution, because they overlap.

    For the second case, your solution is fine. Did you get a message that you failed that test?

    There might be an issue with the customer numbers being printed by the debugging messages. For example, customer 2 in the first test case above is not the right number. Unfortunately, I'm going on a trip later today so I can't investigate more deeply now.

  • Custom User Avatar

    Here's what appeared on my log.

    Testing: Number of Customers = 22; Rooms needed = 15
    Log
    [(6, 106), (12, 51), (13, 38), (19, 30), (19, 113), (20, 95), (21, 109), (23, 102), (25, 99), (28, 102), (39, 81), (48, 108), (55, 58), (66, 90), (66, 81), (71, 109), (71, 75), (73, 80), (76, 110), (80, 159), (86, 136), (94, 179)]
    In room 2, customer 22 departs at day 109 but customer 2 arrives at day 39

    anyway, another test case is as such:

    customers input = [(18, 89), (27, 71), (33, 60), (34, 88), (43, 111), (46, 77), (48, 80), (54, 106), (60, 123), (65, 146), (68, 164), (76, 99), (80, 146), (87, 164), (88, 127), (99, 109), (100, 187)]

    my return = [1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 10, 2, 6, 7, 11, 1, 2]

  • Default User Avatar

    Any allocation of rooms that satisfies the conditions and minimizes the number of rooms is valid. This does not mean every possible permutation of the list is valid.

    What feedback message do you get from the random tests?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution