combinations - Total possible solutions for 8 Queen.

Was reading about the 8-Queen problem here - says 'For eight queens, this solution considers 64^8 or 281474976710656 different solutions'. Since every consecutive queen will have one less position to consider during its placement on the board, shouldn't that total number of solutions be - (64-1)*(64-2)...(64-8)?...Read more

combinations - Adding one digit (0-9) to the sequence/string creates new 4 digits number

I'm trying to find an algorithm which "breaks the safe" by typing the keys 0-9. The code is 4 digits long. The safe will be open where it identifies the code as substring of the typing. meaning, if the code is "3456" so the next typing will open the safe: "123456". (It just means that the safe is not restarting every 4 keys input).Is there an algorithm which every time it add one digit to the sequence, it creates new 4 digits number (new combinations of the last 4 digits of the sequence\string)?thanks, km.Editing (I post it years ago):The quest...Read more

permutation - Combinations and probability

So I'm having trouble with these two problems, and have kind of started them but not sure if I'm on the correct track. (I'm using the combination and permutation formulas)Problem 1: "A group of students contains five men and six women.""I go to the store to buy hats for the eleven students. Hats come in four colors: red, blue,green, and yellow. How many different ways can I buy the hats, if I have to buy at least one hateach color?" This is how I'm going about the problem:Total ways buy hats with 1 of each color = Total ways of buying hats - To...Read more

combinations - How to get all possible permutations of string and all their substrings?

I am trying to find all possible permutations of a character string and all their substrings.For example given the input 'abc' the function should return:['a', 'b', 'c', 'ab', 'ac', 'ba', 'bc', 'ca', 'cb', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba']I've been trying for hours on end and couldn't find any solution. Didn't find any related question either. A C# or Java solution would be prefered but it doesn't matter much. Pseudocode would be fine too....Read more

combinations - Possible numbers with each digit value range given

We are given 3 variables, d, a and b.d specifies the maximum number of places.a and b specify the minimum digit and maximum digit respectively.We have to find how many numbers can be made each of which has its digits in non-decreasing order, with maximum d places, and each digit between a and b, both inclusive.Ex-d = 1a = 8b = 9Answer = 2 (Possible numbers are 8 and 9)Ex-d = 2a = 8b = 9Answer = 5 (Possible numbers are 8, 9, 88, 89, and 99)I have tried applying, permutation and combinations, but could not come across a generic answer for all val...Read more

combinations - Algorithm to schedule courses

I currently have a problem that for my senior year, I need to choose 5 elective courses out of 20+ possible courses. All these courses are distributed to weekdays. I need to develop a robust algorithm to show me all possible combinations without overlapping any of the course hours. I am a little bit short of time, so I figured I'd ask here, and it would be of help to other people in the future.My original idea was to try all combinations of 5 out of 20+, and remove the schedules that had overlapping courses. The brute force solution seems easy ...Read more

genetic algorithm - Iterative Combinations with Repetitons disregarding Order

I have the following problem. Given a set S of n elements, I need to generate all the possible combinations with repetitions disregarding order of sizes k=1,2,...,m.Example:n =3S = {1,2,3}All the possible combinations are:k=1: 1,2,3k=2: 11, 12, 13, 22, 23, 33k=3: 111, 112, 113, 122, 123, 133, 222, 223, 233, 333.k=4: 1111, 1112, 1113, ......k=m: ...Clearly, combinations at step k can be computed using the combinations obtained at k-1.What is the best algorithm (pseudocode) and its complexity to get all combinations for all k....Read more

generating combinations of combinations

I'm trying to generate code which will take the components (i.e, a-f) of various combination permutations (combo) one, two, three, or four units long using these six components and provide various non duplicating combinations of combinations (combo.combo) which contain all of the components (i.e., [ab + cdef and ac + bde + f] but not [ae + bc + df and aef + bc + d]). It would be nice if this code could allow me to 1) input the number of components, 2) input the min and max unit length per combo, 3) input the min and max number of combos per com...Read more

combinations - Permutations of NxN matrix with equal summation of any row elements or column elements (N being odd number)

The matrix NxN has N rows and columns. It has all unique elements starting from 1 to (N^2). The condition is the summation of any row elements should be equal to summation of any other row or column elements.Example: For 3x3 matrix, one of the possible combination looks like following.4 8 32 6 79 1 5 Now the question is how many possible combinations can occur to satisfy the given condition of given NxN matrix where N is any odd number?Thanks for the help in advance.Patrick...Read more