Java past time puzzle !

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeffbroodwar
    New Member
    • Oct 2006
    • 118

    #1

    Java past time puzzle !

    Hi everyone,

    Take a look at this problem. try to answer this program using a single class... :

    Problem 1: CD Dubbing Optimization

    A feature now becoming available on some compact disc players allows the
    user to optimize the copying of a compact disc to cassette. The user
    specifies the size of the cassette; the player selects the tracks that will
    best fill the first side of the cassette and plays them, then plays the
    remaining tracks to be copied on the second side. You have been hired by a
    CD player manufacturer to implement this feature for their model line.

    The number of tracks and time of each track is supplied on every CD.
    Your program will be given this information, and is to determine which
    tracks will best fill the first side of a cassette, given the size of the
    cassette in minutes. Cassettes come in sizes of 45, 60, and 90 minutes; the
    size represents the total usable playing time of the cassette on both sides.

    The tracks which best fill the first side of the cassette are the ones
    with a total playing time closest to but not greater than half the cassette
    size (Take note - It is best fit NOT first fit).

    Input to your program will be the side of the cassette in minutes and the
    number of tracks on the CD to be played (up to 17), followed by the time of
    each track on the CD in order, starting with track 1. The size and number
    of tracks will appear on one line, separated from each other by spaces. The
    track times will appear in order, one per line starting in the first column,
    with the minutes and seconds separated from each other by a colon. This
    information will be repeated for each cassette/CD combination, and will be
    terminated by end-of-file.

    The output for each combination should consist of five lines. The first
    line is to contain the total number of tracks and the size of the cassette,
    appropriately labeled. The second line is to contain the label "Side 1: "
    followed by the numbers of the tracks to be placed on the first side of the
    cassette, in ascending order separated from each other by single spaces.
    The third line is to contain the total time for the side (labeled, in mm:ss
    format, with a leading zero if needed for the seconds field). The fourth
    and fifth lines are to contain the same information for side 2. One blank
    line should appear between the output for each combination.

    You may assume that the cassette will be large enough to hold all the
    tracks on the compact disc. If there is more than one set of tracks that
    will yield the best possible result, any such set will be acceptable.

    <Sample Input>

    45 6
    7:45
    11:30
    0:59
    3:45
    9:25
    2:10
    60 4
    15:00
    15:00
    15:00
    15:00


    <Sample Output>

    6 tracks on a C-45 cassette
    Side 1: 1 2 3 6
    Side 1 Elapsed Time 22:24
    Side 2: 4 5
    Side 2 Elapsed Time 13:10

    4 tracks on a C-60 cassette
    Side 1: 1 3
    Side 1 Elapsed Time 30:00
    Side 2: 2 4
    Side 2 Elapsed time 30:00


    Please post your class in code tags.... for evaluation.... Good luck !!!!

    Regards,
    Jeff
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    That's a binpacking problem; google is your friend.

    kind regards,

    Jos

    Comment

    • prometheuzz
      Recognized Expert New Member
      • Apr 2007
      • 197

      #3
      Originally posted by jeffbroodwar
      ...

      Please post your class in code tags.... for evaluation.... Good luck !!!!

      Regards,
      Jeff
      Jeff, you're not trying to let us do your work, right?
      You know how the saying goes: I'll show you mine, if you show me yours first!
      ; )

      Comment

      • jeffbroodwar
        New Member
        • Oct 2006
        • 118

        #4
        nope, i can't show my answer cause it will lead to futility... ^^

        Regards,
        Jeff

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by jeffbroodwar
          nope, i can't show my answer cause it will lead to futility... ^^

          Regards,
          Jeff
          Circular dependancy.

          Comment

          • prometheuzz
            Recognized Expert New Member
            • Apr 2007
            • 197

            #6
            Originally posted by jeffbroodwar
            nope, i can't show my answer cause it will lead to futility... ^^

            Regards,
            Jeff
            No problem, then I'll keep my solution to myself as well.

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Bunch of partypoopers here ...

              kind regards,

              Jos ;-)

              Comment

              • jeffbroodwar
                New Member
                • Oct 2006
                • 118

                #8
                ok... then better shut up Prometheuz... ehehehe. if your not gonna participate then just find another thread that you can answer.... also, guys i need to know the start and end time you did this puzzle so that i'll know how long you solved it... thanks and good luck ! ^^

                Comment

                • blazedaces
                  Contributor
                  • May 2007
                  • 284

                  #9
                  Originally posted by jeffbroodwar
                  ok... then better shut up Prometheuz... ehehehe. if your not gonna participate then just find another thread that you can answer.... also, guys i need to know the start and end time you did this puzzle so that i'll know how long you solved it... thanks and good luck ! ^^
                  Honestly, how is this a "puzzle"? It's a given input and a given output... I don't see anything puzzling about it. This sounds more like a homework assignment to me.

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Originally posted by jeffbroodwar
                    ok... then better shut up Prometheuz... ehehehe. if your not gonna participate then just find another thread that you can answer.... also, guys i need to know the start and end time you did this puzzle so that i'll know how long you solved it... thanks and good luck ! ^^
                    Prometheuz is probably the only one who has "solved" it here, and you just told him to shut up.
                    Therefore, we go back into our deadlock again.

                    P.S It's very bad to tell someone to shut up in a public forum. Don't do it again.

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      As I wrote before: this is a Binpacking problem which is equivalent to a Knapsack
                      problem where al the weights are equal. Just a bit of backtracking will solve it
                      for a moderate amount of 'bins' (read: songs).

                      kind regards,

                      Jos

                      Comment

                      • prometheuzz
                        Recognized Expert New Member
                        • Apr 2007
                        • 197

                        #12
                        Originally posted by jeffbroodwar
                        ok... then better shut up Prometheuz... ehehehe. if your not gonna participate then just find another thread that you can answer.... also, guys i need to know the start and end time you did this puzzle so that i'll know how long you solved it... thanks and good luck ! ^^
                        You are not the one that decides who should and shouldn't post in your thread. Also, I was never rude to you, so why are you rude to me? I don't think by doing so that other members are likely to participate in your, err, "puzzle".
                        Seriously, it is so obvious that you are trying to find someone to do this for you, it is embarrasing.
                        If you want to receive help, you had better post what you have so far and explain what it is you're stuck. Just Google on what Jos said.

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #13
                          Me, myself and I have democratically decided that this is not an interesting thread
                          anymore. I put the cause of this at the OP. There may be three possible reasons
                          for this:

                          1) The OP is very proud of the solution he found. Let me be a partypooper again:
                          for these type of problems (all NP complete) there is always a better solution.
                          We're interested in any efficient algorithm though because that makes scientific
                          progress go *boink*.

                          2) The OP is trying to suck the solution out of other posters. Let me be a party-
                          pooper again: nobody is going to supply it in code per forum guidelines.

                          3) The OP found a proof of NP == P in which case certainly I, and a lot of others
                          I'm sure are more than interested. If the OP wants to go for the Nobel Price, he
                          shouldn't post teasers here.

                          No matter the reason, this thread deserves to be closed but I encourage the OP
                          to try again and show some initiative first, because this thread went from nothing
                          to nowhere, almost no information was in it; above all the level of conversation
                          isn't friendly anymore either. I hate that.

                          kind regards,

                          Jos

                          Comment

                          • jeffbroodwar
                            New Member
                            • Oct 2006
                            • 118

                            #14
                            Hello everyone....

                            Ok i'm sorry to those people who doesn't deserve to be offended... but i didn't start the being rude role in this conversation... . as JosAh said.... there are lots of party poopers here. Don't you guys think that it's rude to say that i posted this thread because it's a homework that i can't solve? cmon guys.... i didn't start being rude here... i always wanna have friends.. and please before you accuse someone of being rude.... try to read what you've replied in this thread.... JosAh is right..... this thread is getting nowhere.. Thanks anyway.


                            Jeff

                            Comment

                            • blazedaces
                              Contributor
                              • May 2007
                              • 284

                              #15
                              I'm hijacking this thread... so this thread is titled java puzzles (or something like it) so how about we try throwing java challenges at each other. So here's mine:

                              First, read Jos' Soduku solver thread. Then, design your own. The best one wins. What do you win? A cookie! Well, the point is after you "win" you can go and get yourself a cookie from your own kitchen. The cool thing is, even if you lose, get this! You can still go and get yourself not just one, but two cookies! So if you win, you win, but if you lose... you win!

                              Go!

                              -blazed

                              Comment

                              Working...