-2
Aman15
2y

C++ coding question

Comments
  • 2
    Wait a minute .....

    First the bus can transport 50 people, the number of seats are never defined and 126-50 doesn't make 24 wtf
  • 9
    Outsourcing homework to disgruntled programmers in a rant forum?

    24 is the result of 50 minus 126 mod 50, you figure out the rest.
  • 2
    @jackpearce I had the same thought and was confused.

    However @Aman15 devRant is not a homework service.
  • 3
    @jackpearce The bus can transport 50 people at once, that's the number of seats. The exercise is asking to calculate the number of _free seats_ in the _last_ bus.
  • 1
  • 8
    Usually the hardest part in assignments like this is reading the assignment correctly.
  • 1
    @ethernetzero well I use the bus everyday and trust me the number of seats does not define how many people are in the bus/train/tram/subway

    especially with the 9€ ticket in germany (that was horrible)

    But jokes aside thank you for the explanation ^^' now I notice the keyword LAST bus
  • 2
    @jackpearce Your real life experience is not relevant to the theoretical exercise presented to the OP. The problem says the bus can carry 50 people, you don't need any more details.
  • 5
    That will be $15: https://ko-fi.com/lbfalvy

    Also, if you send any existing code that you have, I can make sure it looks similar. It's very easy to get caught outsourcing homework if your code has a different style on every submission.
  • 4
    @lbfalvy now that‘s what I call customer oriented service business! 😆
  • 1
    @lbfalvy great service. 11/10
  • 0
    @Lensflare I'm not new to the homework business.
  • 0
    @electrineer true. Understanding the task is the hardest part.
  • 1
    Oh its you asshole again. Mr. "I'm too arrogant to even ask people to help me I just list my babys-first programming question here and just expect people to give me the answer"

    Go fuck yourself
  • 1
    @ethernetzero technically the question is unsolvable since it is not mentioned how many seats there are if any. It's also not mentioned if all seats can be used to carry passengers at the same time. Also, many people choose to travel standing even if there are free seats, so it is also a valid assumption to make.

    Imo any result should be accepted as correct, as long as it's calculated in the program with some logic and printed out in the end. That's the thing the student expected to learn on this beginner course anyway.
  • 1
    Classic binpacking with binsize of 50 and 126 elements to be packed, print back the amount of usage of the last bin.

    126 - 50 = 76
    76 - 50 = 26

    26 is NOT 24.
  • 1
    Well, if that was a realistic scenario, the difficult part would be to come up with a way to reliably detect the number of people in the bus or in a seat. 😛
  • 3
    @max19931 I actually think it's a scheduling problem with concurrency, since the buses all arrive at different times /s
  • 3
    Wuuuut

    Anyway, downvoted
  • 1
    I wish I could downvote without the rant disappearing from the feed 🙁
  • 1
    @max19931 It's asking for free space, not amount of usage.

    50 - 26 = 24
  • 1
    busCapacity - peopleTotal % busCapacity
  • 3
    @max19931 You miss the 'empty seats' part.

    Yes only 26 people will be on the last bus so 50-26 = 24 empty spots.

    Seems like reading the question will be a great start for many here.
  • 1
    @max19931 The problem is not asking for the amount of usage of the last bin, but the opposite.
  • 1
    @electrineer And what if the bus crashed on its second trip? Or if the driver was fired or called in sick before starting?

    Too many variables.
  • 4
    So, just to recap a solution for @Aman15:

    You need to input the following variables:

    - Location of the bus stop

    - Destination of the bus trip

    - How many people are waiting at the bus stop

    - How many people will have forgotten something at home and not catch the bus

    - How many buses there are

    - The medical history of each one of the bus drivers

    - What did they have for breakfast/lunch/dinner

    - How many broken or gross seats are there on each bus

    - Space for people standing

    - The starting date and time of the first trip, if applicable

    - The traffic and road condition data for that time range

    - The weather report for that date/time range

    - The condition of all of the parts from each bus

    - If buses keep going to the bus stop even after there aren't any more people waiting there, in which case you'll also have to ask for

    - The ending datetime

    Then you calculate the number of free seats in the bus that last departs from the bus stop by simulating each trip in parallel.
  • 1
    @ethernetzero if you can justify it in your model, it's fine
  • 4
    @ethernetzero
    ✅ Accepted answer
  • 0
    @lbfalvy ok my bad.
  • 0
    @ethernetzero reread the Text and yes it says empty seats not used seats.
  • 3
    @electrineer I'm just providing @Aman15 with the totally legit answer he wants us to provide to his homework. ;)
  • 2
    @ethernetzero But those variables do not matter on for the last trip.

    1) second bus crashed

    a) all people already got on the bus before the crash => no problem

    b) people are not on the bus, new bus comes as a replacement and all 50 get on that bus.

    2) driver fired or called sick

    a) goto condition 1.b
  • 0
    @Grumm That's why you need the number of buses, because there could be just one, and the medical history of the drivers and the condition of the buses' parts, the weather, the traffic data, so you calculate if there will be a crash or if any drivers will call in sick.

    Also, more than one bus could crash.
  • 1
    @ethernetzero sure, but based on the question who mention a 'bus service', I do hope that they have more than 1 bus.

    Maybe some neural networking can be a good solution too for the problem ? :D
  • 0
    @Grumm Oh, definitely.
Add Comment