Consider the set {1, 1/2, 1/3, 1/4, 1/5, ..., 1/n}Choose any two numbers x and y and replace them with x + y + xyFor example, if we choose the numbers 1 and 1/2 , we will replace them by 1 + 1/2 + 1/2 = 2.If we keep repeating this process until only number remains, what is the final number?So far I understand that this will result in all possible combinations of the terms for example:{a, b, c, d} = a+b+c+d+ab+ac+ad+bc+bd+cd+abc+abd+acd+bcd+abcdHow do we compute this sum effectively though?...Read more

How do I distribute 48 items each with its own dollar value to each of 3 inheritors so that the value given to each is equal or nearly equal?This is a form of partitioning problem with is NP-complete (or some such) and therefore impossible to perfectly answer with 48 items. I'm looking for a practical and generally acknowledged approximate algorithm to do this. It's a problem faced by many in resolving wills and estates. Answer must be out there somewhere! The answer could be a computer script or just a manual method.A heuristic that is "Genera...Read more

I am looking for information about "Product Partitions" (I don't know the official name)In the "classic" partition we search the decompositions of a positive integer as sums: Partition(5) 5 1 4 2 3 1 1 3 1 2 2 1 1 1 2 1 1 1 1 1 I want to find all the decompositions as products: ProductPartition(36) 36 2 18 3 12 4 9 6 6 2 2 9 2 3 6 3 3 4 2 2 3 3 I have a recursive solution, but it is not efficient enough.Thank you very much in advance for any information.P...Read more

I need to find the rank/index of a lottery combination and be able to reverse the process (Find the lottery combination given its rank).Consider a lottery game with 5 balls from 1 to 45 and 1 powerball from 1 to 20. Duplication is not allowed and the order does not matter. The number of combinations is:(45 * 44 * 43 * 42 * 41 / 5!) * 20 = 24,435,180The first combination (index 0) is:1, 2, 3, 4, 5, 1The last combination (index 24,435,179) is:41, 42, 43, 44, 45, 20How can I convert a combination into its index and vice versa without exhaustivel...Read more

I want to iterate over all distinct permutations of a vector. I have tried doing this by using vecextract() in combination with numtoperm() to create a vector of permutations, and vecsort(,,,8) to remove equivalent permutations. Unfortunately, this doesn't scale well: the maximum size of a vector within my current stack size of 4GB is less than 12!, and my machine only has 16GB. Is there a way to do this without running out of memory, maybe by generating the k-th distinct permutation directly?...Read more

let's say my traveling salesman is allowed to ignore some nodes, as long as he finishes visiting the nodes he chose , within a time range. his goal is to maximize the gain from the nodes visited (such as the total sales amount from these nodes). I guess we don't need a total time window constraint, since we already have the availability window for each ndoe. so basically the question boils down to TSPTW with possibility to ignore nodes. it's referred to as Generic TSP (GTSP ) in literature, does OptaPlanner have some knobs to model this?thanksY...Read more

I have some bins with different capacities and some objects with specified size. The goal is to pack these objects in the bins. Until now it is similar to the bin-packing problem. But the twist is that each object has a partial overlap with another. So while object 1 and 2 has sizes s1 and s2, when I put them in the same bin the filled space is less than s1+s2. Supposing that I know this overlapping value for each pair of objects, is there any approximation algorithm like the ones for original bin-packing for this problem too?...Read more

Given a set of S elements, how many unique combination of k elements can I find without any ripetition of the same pairs of elements?...Read more

I am trying to solve question 2 on the following link: Check out Q.2.That is I am interested in the number N(k) of binary strings of length k accepted by the following deterministic finite automaton (source: the URL).For example N(2)=2, as only such strings are 01 and 10. In particular I am interested in a recurrence relation for N(k)....Read more

Suppose a list is {1,2,2,3,2,4}.For one query, suppose the given range is [2,5]. So cnt[2] = 3, cnt[3] = 1 and PRODUCT = 3! * 1! = 6Then I want (num/PRODUCT) mod p, where 'num' is (R-L+1)! and p is 1e9+7, where [L, R] is the given range.Query contains different ranges each time.How do I solve it?I was thinking somewhat on the lines of Fermat's Little Theorem, but couldnt actually workout a proper method. How do I code it?I was trying like preprocessing all ranges possible, but that goes upto 10^10, i need an algo inside 10^8. It is given in my ...Read more

Calculate the number of ways of distributing k distinct items among r distinct groups such that each group receives at least a and at most b items and internal arrangement of items within groups doesn't matter.For example suppose there are 2 groups and 3 items A, B, C. The distributions (AB, C) and (BA, C) must not be counted twice.Or in other words find the number of ways of distributing k distinct candies to r distinct kids. Each kid wants atleast a and atmost b candies. The order in which the kids receive candies doesn't matter.I've read a...Read more

Find all ways to write a number as multiply of numbers (different from 1).For example: 12 = 12, 12 = 2 * 6, 12 = 3 * 4, 12 = 2 * 2 * 3I have no idea how to this problem and I have spend days reading about factors, sieves and similar topics...Read more

So I was asked a question in uni and after a having a look I really couldn't find an answer. Why does a full adder takes in 3 number and not 2. Is it so that it can retain the carry from the 1st half adder?Thanks....Read more

I have items I1, I2, I3, I4 with weights W1...W4 and Values V1...V4. I want to maximize values with minimum weights. This is a traditional Knapsack. However there is small constraint some items cannot go together. So lets say I2 and I3 cannot go together. Can anyone provide a dynamic programming solution or any other solution for the same....Read more

. Is there any Direct formula or System to find out the Numbers of Zero's between a Distinct Range ... Let two Integer M & N are given . if I have to find out the total number of zero's between this Range then what should I have to do ?Let M = 1234567890 & N = 2345678901And answer is : 987654304Thanks in advance ....Read more