473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Java past time puzzle !

jeffbroodwar
118 100+
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
Jul 20 '07 #1
15 1907
JosAH
11,448 Expert 8TB
That's a binpacking problem; google is your friend.

kind regards,

Jos
Jul 20 '07 #2
prometheuzz
197 Expert 100+
...

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!
; )
Jul 20 '07 #3
jeffbroodwar
118 100+
nope, i can't show my answer cause it will lead to futility... ^^

Regards,
Jeff
Jul 25 '07 #4
r035198x
13,262 8TB
nope, i can't show my answer cause it will lead to futility... ^^

Regards,
Jeff
Circular dependancy.
Jul 25 '07 #5
prometheuzz
197 Expert 100+
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.
Jul 25 '07 #6
JosAH
11,448 Expert 8TB
Bunch of partypoopers here ...

kind regards,

Jos ;-)
Jul 25 '07 #7
jeffbroodwar
118 100+
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 ! ^^
Jul 26 '07 #8
blazedaces
284 100+
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.
Jul 26 '07 #9
r035198x
13,262 8TB
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.
Jul 26 '07 #10
JosAH
11,448 Expert 8TB
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
Jul 26 '07 #11
prometheuzz
197 Expert 100+
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.
Jul 26 '07 #12
JosAH
11,448 Expert 8TB
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
Jul 26 '07 #13
jeffbroodwar
118 100+
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
Jul 30 '07 #14
blazedaces
284 100+
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
Jul 30 '07 #15
JosAH
11,448 Expert 8TB
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
I'm interested what the results will be; my solution is just a brute force solution
without any additional cleverness (aka 'domain intelligence'); I haven't found a
Sudoku puzzle yet though that could not be solved within a short period of time.

kind regards,

Jos (<-- cookie monster ;-)
Jul 30 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
25
by: Digital Puer | last post by:
I'm looking at some software development jobs whose listings require C++ experience. My history is that I have a strong C background, and a few years of C++ from undergrad classes. I've been...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
0
by: autogoor | last post by:
I want to put a java Applet in a jsp page. Here is what I used: <jsp:plugin type="applet" code="mypackage.myApplet" width="450" height="350" > <jsp:params>...</jsp:params>
2
by: Andrea | last post by:
Hi evrybody ! Does anybody know how to call a java class from a COM component ? Any suggestion ? Thanks Andrea
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
148
by: BillJosephson | last post by:
Want to do OOP. Does c++ have all the abilities of java, or is it some subset? Thanks...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.