Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 CD Rom Limits
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MysticVegeta




PostPosted: Mon May 09, 2005 5:14 pm   Post subject: CD Rom Limits

Hi, This question deals with which is the most efficient way to burn stuff on CD's. Its a Dwite Contest Question and i have part of the solution. Now it goes something like this, The first Integer in every line of 5 inputs states the CD ROM Capacity limit "c", and the second integer consists of how many things i want to burn on it "n" . The next integers are the number of "n" things and their capacity so it looks something like this ->

700 4 500 300 300 100
700 5 200 750 75 240 420
650 3 400 100 400
700 3 100 200 300
600 5 100 50 90 200 300

Here is the solution i have so far,
code:

var one : int
var count : int := 2
var sum : int := 0
open : one, "Data4.txt", get
var storage, items : array 1 .. 5 of int
var cap : flexible array 1 .. 1 of int

%Getting the variables
for s : 1 .. 5
    get : one, storage (s), items (s)

    %Calculating the capacities
    for x : 1 .. items (s)
        get : one, cap (x)
        sum += cap (x)
        if x not= items (s) then
            new cap, x + 1
        end if
    end for

    %Processing for the greatest possible capacity in the loops
    if sum > storage (s) then
        sum := 0
        loop
            for ss : count .. items (s)
                sum += cap (ss)
            end for
            count += 1
            exit when count > items (s)
        end loop
    end if

    %Freeing the variables in the end and making the sum 0
    free cap
    put ""
    sum := 0
    count := 2
    new cap, 1
end for


I have matched up ->
500 + 300 + 300 + 100
300 + 300 + 100
300 + 100
100

But i have no clue how match the rest of combos ->
300 + 300 + 500
100 + 500
........
........

Can anyone help? thanks
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Wed May 11, 2005 5:52 pm   Post subject: (No subject)

Any ideas?? I am sure a lot of people here have aced dwite contests. Please help Crying or Very sad
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: