Help with a complex Math problem

GoodSelf

Zhu Li! Do the thing!
Veteran
Joined
Jul 23, 2016
Messages
598
Reaction score
1,134
First Language
English
Primarily Uses
RMMV
So, I'm trying to figure out how many combinations I can make using the following restrictions, it's kind of hard to explain, but bear with me.

Let's say I have four actors in a party, each one of those actors has a small image associated with them, and when a battle starts, a large image is displayed showing all 4 of the small actor images. With this in mind, it doesn't matter if the order is 1234 or 3241, the image will stay the same, thus changing the number of combinations from 24 to 1 with 4 playable characters.

Now, let's say I have 20 playable actors - how many large images (not the small ones associated with each character) will I need to make sure one can be displayed for each possible party combination?

I guess a simpler way of explaining the math problem would be: I have 20 friends over my house, but only 4 chairs. In how many ways can all of my friends sit?

My brain is melting.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,003
Reaction score
5,644
First Language
English
Primarily Uses
RMVXA
The answer is 20!/4!: In other words, 20 times 19 times 18 times 17 times...times 3 times 2 times 1, divided by 24.

Since this number is way beyond the number of atoms in the world, you will definitely want to script the pictures to be shown individually rather than make a combination pic for each combination.


EDIT: I think Shaz is right. 20 * 19 * 18 * 17 / 24, since there are only 4 slots to fill. That still makes nearly 5000 combinations, so you'll still want to script the image display on a per-actor basis, I think.
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,154
Reaction score
14,652
First Language
English
Primarily Uses
RMMV
If you're only allowing 4 of those 20 actors into your party at any given time, then you would have 20 x 19 x 18 x 17 possible combinations. However, each group of 4 would have all 24 order possibilities in there. So divide the result by 24.
 

EliteZeon

Third-Rate Noob
Veteran
Joined
Mar 10, 2014
Messages
193
Reaction score
302
First Language
English
Primarily Uses
N/A
Ughh... Its been awhile since I last did a math problem like this. Alright, let's grab out google for formulas and a calculator.

This is going to require the combination formula I believe... lets see if I can paste this in:

813f7124a61dac205542db3f8491b36cb306453a


Incase the formula didn't paste in:

Combination Formula = (n!)/[(k!)(n-k)!]

n= the total amount of party members
k= the the amount of party members in the combination.

I'll explain what n! and k! are in case you don't know. The ! represents the calculation of a factorial. A facotial represents a number being multiplied by all integers below it. Such as 4! = 4x3x2x1 = 24

This number is going to get big, so I'll do a quick example to explain why.

One party member equates to being able to choose 19 different buddies to pair up with.

For party member 1... you got like 19 combos, then 18 for party member 2 since you don't include party member 1, then 17 combos for party member 3 since you ignore pairing party member 1 and 2...

Or when calculating the first two people pairing together in the party it is:
19+18+17+16+15+14+13+12+11+10+9+8+7+6+5+4+3+2+1 = 190

In the above formula, we would put:

(20!)/[(2!)(20-2)!] = 190

Now getting into the main question...

Combination Formula = (n!)/[(k!)(n-k)!]

n= 20 party members
k= 4 people that can be tossed into the party

Amount of possible party combinations = (20!)/[(4!)(20-4)!]

Simplified: (20!)/[(4!)(16)!]

So two people out of 20 can be chosen in an order of 190 different ways... or rather, for the first two party members, the combo can be 95 different pairings if we don't consider the order they are paired in.

So n! (n factorial) is going to be 2.432902e+18 (that is a really big number)
K factorial is going to be 24. (n-k)! equates to 2.092279e+13.

So... we go and plug in chug.
(2.432902e+18) / [(24)(2.092279e+13)] = 4845 different party combinations.

This means out of 20 party members, they can be arranged in 4845 different ways. Since you just want one image to represent a potential 4 combos, we will divide this by 4.

So about 1211 or 1212 or so different images will be needed for each party composition.


My math might be a little off. But you're looking at A LOT of images.

I highly advise against this method of having a unique party image per 4 person combo. Unless you really can get that many images made.

EDIT
Hmm... I think I used the wrong formula. But... well you now know the party can be arranged 4845 different times! :D

EDIT 2
There is a reason I had to retake Calculus 2 a couple of times at my University. The answer is 4845... a whole number makes more sense, the formula already did the division required.

EDIT 3
Wow freaken ninjas man!

So looking over at everyone's else' answer.

With the combination formula, we have:

20! / [(4!)(16!)]

Mathematically, the 20! and 16! begins to cancel out each other, such that:

20! = 20x19x18x16x15x14x13x12x11x10x9x8x7x6x5x4x3x2x1
16! = 16x15x14x13x12x11x10x9x8x7x6x5x4x3x2x1

When 20!/16! occurs, the entire formula becomes. Every number of 16 and below gets knocked out and the formula simplifies to:

(20x19x18x17) / (4!)

and 4! = 24

Which brings us back to getting 4845 as the answer.
 
Last edited:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,789
Reaction score
14,589
First Language
English
Primarily Uses
RMVXA
@EliteZeon got it. This is a combination 20 choose 4 problem (since the order doesn't matter), making it 4845 total combinations.
 

Latest Threads

Latest Profile Posts


No water this time, just trying for a majestic cliffside... The cave snuck in because I liked it. Now I guess I need a mini cave map or "secret" for it. :kaoswt:
Revamped the crew for my VN about thirty times. Only character that's stayed constant has been the fungus character. Guess it really grew on me...
I want to work on my reboot, but I don't have time to do it. ;_;
4y195n.png
big image so i posted it as a spoiler
Just a reminder to back your projects up. Do it now! :yamero:

Forum statistics

Threads
111,273
Messages
1,059,816
Members
144,571
Latest member
HangSapa
Top