Question:
How to find the possible number of combinations?
2009-01-31 21:02:57 UTC
ive always wanted to know how to calculate the number of combinations you can have? like say there was a four digit code **** numbers 0-9 of course. how could u find out how many combinations there could be?
Four answers:
2009-01-31 21:06:07 UTC
you do the number of possibilities so there are 10 digits raised to the power of the number of digits so 4 so it would be 10 to the 4 so 10000 combinations
Cirric
2009-01-31 21:07:24 UTC
Hi. I think that the factorial function on a calculator (9!) would give you the number. It would be 9*8*7*6*5*4*3*2*1, with the 1 being redundant. The answer is 362,880. You have to exclude zero, of course, or the answer would be 0.
William W
2009-01-31 21:16:35 UTC
If you actually want to write out all the possible combinations it gets a tad more laborious.



Here's some python code I wrote to do this. To use it you'll need to download IDLE from python.org and install it on your computer.



When that's done, open up IDLE and hit ctrl + n on your keyboard. Copy the code below:



##############################

def rotate(number, start_index = 0):

>>>>number = str(number)

>>>>rotations_list = []

>>>>number_rotations_required = len(number)

>>>>for index in range(start_index, number_rotations_required):

>>>>>>>>excluded = ""

>>>>>>>>if start_index != 0:

>>>>>>>>>>>>excluded = number[0 : start_index]

>>>>>>>>first_number = number[index]

>>>>>>>>other_numbers = number[index + 1 : ] + number[start_index : index]

>>>>>>>>rotation = excluded + first_number + other_numbers

>>>>>>>>rotations_list.append(rotation)

>>>>return rotations_list



def permute(number):

>>>>number = str(number)

>>>>start_index = len(number) - 2

>>>>list_to_permute = [number]

>>>>while start_index >= 0:

>>>>>>>>new_list = []

>>>>>>>>for list_element in list_to_permute:

>>>>>>>>>>>>new_list.extend(rotate(list_element, start_index))

>>>>>>>>start_index -= 1

>>>>>>>>list_to_permute = new_list

>>>>return list_to_permute

##############################



Unfortunately due to the formatting here you'll need to replace every ">" with an empty space " ". The first bracket followed by "..." should read: (rotation). The other brackets with "..." in them should read: (rotate(list_element, start_index)).



Now hit F5 on the keyboard and save the file to anywhere on your computer. Hit F5 again and a command line-like shell will appear. Type "permute(number)" where number is whatever you want to find combinations of. You can find combinations of words as well, just enter a word instead of a number.



Hope this helps!
2009-01-31 21:07:09 UTC
10x10x10x10x10x10x10x10x10x10=100


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...