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

Username:   Password: 
 RegisterRegister   
 Partition Problem
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Clayton




PostPosted: Fri Mar 03, 2006 4:59 pm   Post subject: Partition Problem

hi guys, im taking part in a competition soon and ive looked up some previous problems to practice, but i dont quite understand them heres the first one:
you have to make a program to find the partition of a number. the partition of a number is the number of ways you can add numbers together (1 to the number) to make that number for example:

5=1+1+1+1+1
5=1+1+1+2
5=1+2+2
5=1+1+3
5=2+3
5=1+4
5=5

so therefore partition(5)=7 because there are seven ways to make 5,
what you have to do is code it so that a user can input a number from 1-50 and the program must find the partition of that number heres a sample

INPUT
50
OUTPUT
Partition(50)=204226

my question is does anybody here know how you might go about doing that if so plz help
Sponsor
Sponsor
Sponsor
sponsor
batman




PostPosted: Fri Mar 03, 2006 5:06 pm   Post subject: Code

Well, there are many ways of doing this type of code. You could use an array if you wanted too. That might work and maybe a for loop. It be best if you showed me what you've done so far and then I could help you out from there. Very Happy
chrispminis




PostPosted: Fri Mar 03, 2006 6:30 pm   Post subject: (No subject)

No, batman, I think he's asking a math question. As in how you would reliably find the partition of a number. You should try googling it, or figure it out yourself. Get say the first 10 partitions and try to find a pattern.
batman




PostPosted: Fri Mar 03, 2006 7:09 pm   Post subject: program

Yes chris is right! Find a pattern first. The pattern is 1,2,3,5,7,9 for 1,2,3,4,5,6! Thats what ive gotten so far. The only way this prgram will work is you have to use a "counter."
McKenzie




PostPosted: Fri Mar 03, 2006 9:23 pm   Post subject: (No subject)

You've posted in the wrong area. Post under contests. ... Seems trivial, I know, but if you are doing contest training post under contests because there are some killer contest writers who visit this site (e.g. Bugz (I know of no better))
md




PostPosted: Fri Mar 03, 2006 9:30 pm   Post subject: Re: program

batman wrote:
Yes chris is right! Find a pattern first. The pattern is 1,2,3,5,7,9 for 1,2,3,4,5,6! Thats what ive gotten so far. The only way this prgram will work is you have to use a "counter."


*sigh* there are many ways this program will work; though in order to return a total you either need a math formula or yes a counter. I can see a recursive method in this; thought it might be a bit challenging.

Oh, and there are 10 ways to get 6.
MysticVegeta




PostPosted: Fri Mar 03, 2006 9:33 pm   Post subject: (No subject)

Wow bugz must feel proud after that reply no?
Anyways, what you are doing calls for DP (Dynamic Programming) For a better understanding of what I am saying go here and read posts by Bugz and Martin.
http://www.compsci.ca/v2/viewtopic.php?t=11393
md




PostPosted: Fri Mar 03, 2006 9:38 pm   Post subject: (No subject)

MysticVegeta wrote:
Wow bugz must feel proud after that reply no?
Anyways, what you are doing calls for DP (Dynamic Programming) For a better understanding of what I am saying go here and read posts by Bugz and Martin.
http://www.compsci.ca/v2/viewtopic.php?t=11393

Wrong topic?
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Fri Mar 03, 2006 10:38 pm   Post subject: (No subject)

huh? what?
batman




PostPosted: Sat Mar 04, 2006 9:22 am   Post subject: Code

There are many ways to do this type of code but the best way is too use a counter.
[Gandalf]




PostPosted: Sat Mar 04, 2006 9:49 am   Post subject: (No subject)

"Best" is relative, and I doubt that your point is true in this case.
Cervantes




PostPosted: Sat Mar 04, 2006 11:36 am   Post subject: (No subject)

I think batman should take a challenge.
MysticVegeta




PostPosted: Sat Mar 04, 2006 12:27 pm   Post subject: Re: Code

batman wrote:
There are many ways to do this type of code but the best way is too use a counter.


I will take it you mean counting the # of possible combinations. I would sort of because I think the best way to accomplish this is to use a boolean array..? look at martins explanation for a better explanation
batman




PostPosted: Sat Mar 04, 2006 1:20 pm   Post subject: Code

What is the challenge?
MysticVegeta




PostPosted: Sat Mar 04, 2006 1:36 pm   Post subject: (No subject)

Hint: Click the link "challenge" to find out. Rolling Eyes
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 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: