combination

Creating multiple numbers with certain number of bits set

Problem I need to create 32 Bit numbers (signed or unsigned doesn't matter, the highest bit will never be set anyway) and each number must have a given number of Bits set. Naive Solution The easiest solution is of course to start with the number of zero. Within a loop the number is now increased by one, the number of Bits is counted, ...

key combination to select current line in vs 2008?

Hello, I just started learning c# on vs 2008. I found key combiations for select current word delete current line is there a key combination to select current line? ...

Algorithm for finding all combinations of k elements from stack of n "randomly"

Hello, I have a problem resembling the one described here: http://stackoverflow.com/questions/127704/algorithm-to-return-all-combinations-of-k-elements-from-n I am looking for something similar that covers all possible combinations of k from n. However, I need a subset to vary a lot from the one drawn previously. For example, if I wer...

Enumeration of combinations of N balls in A boxes?

Hi, I want to enumerate all possible combinations of N balls in A boxes. example: I have 8 balls to deal in 3 boxes : box_1 box_2 box_3 case-1 8 0 0 case-2 0 8 0 case-3 0 0 8 case-4 7 1 0 case-5 7 0 1 case-6 6 2 0 ...

Valid XML, Valid schema. Where have I gone wrong?

Once upon a time I had a valid doctype and valid XML. I put the former on top of the latter, cntrl-s'd and behold: all was as all should be. Nowadays I have a valid schema (custom built for my still valid XML). I tried my same tried and true approach - but alas, no success. I get different errors with each different validator I use, and...

Check if a combination matches a given set

Basically I'm looking for a solution which returns if a given combination matches a given set. Example: I have an array which stores which computer room and which workplace has which equipment. I need to find out if a given number of users with specific needs can fit into the computer room or not. The index is the workplace number in my...

one question about combination related problem

I am always confused about how to write the code about combination related problem, including combination, permutations and subset problem. There are three requests for such problems 1 just need a number of the results, for example, the number of the combination of 3 char out of 5 is 10, the number of permutation of 3 out of 5 is 60. ...

Algorithm to find optimal combination of products and shops to minimise cost.

Hello there Stackoverflow people, I run a site that finds its users the cheapest place to buy books. This is easy for a single book, but for multiple books it can sometimes be cheaper to purchase one book at one store and another book from another store. Currently I find the cheapest store that sells all books in the user's list, but I...

Path.Combine and the dot notation

I'm looking for something akin to Path.Combine method that will help me correctly combine absolute and relative paths. For example, I want Path.Combine(@"c:\alpha\beta", @"..\gamma"); to yield c:\alpha\gamma instead of c:\alpha\..\gamma as Path.Combine does. Is there any easy way of accomplishing this? Needless to say, I also want to ...

Combination without repetition

I have Collection List<Car>. How to compare each item from this collection with rest without repeatition. Ex: iteration: this car is Audi and secondCar is BMW bool IsSimilar(Car secondCar) { if(this.Name==secondCar.Name) return true; return false; } this is not permitted: n iteration this car is BMW and secondCar is Audi ...

using JQuery and Prototype in the same page; more explanation needed!

Hi everybody! I'm continuously having the problem when i use jquery lightbox (which runs prototype) and jquery news slider. I tried the "noconflict" method. The problem is I don't know the exact place to put the code. So, here, i'm putting my scripts within . So, please troubleshoot it and explain me where to put the patch. thank y...

All possible combinations of n items selected randomly from a set of x items (algorithm)

I have a set of x string items e.g("A","B","C","D","E","F") I need to know the formula that calculates how many combinations of n items and what is the algorithm that generates all possible combinations e.g if we need to select 4 items from the list randomly. those 4 items could be: ("A","B","C","D") or ("A","B","C","E") or ("A","B","C",...

[C++] next_permutation for combinations or subsets in powerset

Is there some equivalent library or function that will give me the next combination of a set of values like next_permutation in does for me? ...

List - Strings - Textfiles

I've got a few questions concerning text files,list and strings. I wonder if it is possible to put in a code which reads the text in a textfile,and then using "string line;" or something else to define each new row of the text and turn all of them into one list. So I can sort the rows, remove a row or two or even all of them or search t...

Need a SQL statement focus on combination of tables but entries always with unique ID

Hi All, I need SQL code to solve the tables combination problem, described on below: Table old data: table old name version status lastupdate ID A 0.1 on 6/8/2010 1 B 0.1 on 6/8/2010 2 C 0.1 on 6/8/2010 3 D 0.1...

Unneded number combination after replacing a number in a string.

I get an unneeded number combination. ($_COOKIE): 2, 3, 4, 5, 6, 7, 8, 901234567890123456789, 30 Should be ($_COOKIE): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... (till) 30 $_Get['id']="1"; (sorry, forgot to post it.) Why that happens? The code: <? ob_start(); $id=$_GET['id']; if (!empty($id)){ $id=str_replace('a9_',''...

C#: 0 & 1 Permutations

I want to list permutations with only 0 and 1. Similar to binary but allowing variable lengths, doesn't have to equal 8 length. For example: 0 1 00 01 10 11 000 001 010 011 100 101 110 111 All the way until the length of X is met. How can this be done? ...

output transfer to a new file

I am a complete noob to c. I have downloaded a code from internet. It generates all possible combination of characters. I want to transfer this output to a text file. I have tried few things but unable to do it. Can anybody suggest me the necessary changes? Here is the code.a EDIT: I have changed the put command to fputs. i tried all po...

PHP array combinations

Hello, I have an array of 7 numbers (1,2,3,4,5,6,7) and I want to make pairs of 5 numbers like (1,2,3,4,5),(1,2,3,4,6,),(1,2,3,4,7) . (1,2,3,4,5) is equal to (4,5,3,1,2) I would like to know if there is a function in PHP or any algorithm that can do this ? I have no idea where to start from. Can you help me ? I want all the combination...

Need to generate every unique combination of an array of files recursively

I've researched and found LOTS of similar requests, but nothing was quite what I needed. Here is my problem. I'm working in C#, and I have a FileInfo[] array with an unknown number of elements in it. FileInfo[] files = new FileInfo[] { new FileInfo(@"C:\a.jpg"), new FileInfo(@"C:\b.jpg"), new FileInfo(@"C:\c.jpg"), new...