sets

Finding a subset of numbers that equals a single number

Hi. First time user. The reason I place this post is that I am looking to reconcile customer accounts receivable accounts where "payments" are posted to accounts instead of matched with the open invoices and cleared. So here is my issue: Have a single number (payment) that should equal a subset of a given set of numbers (invoice am...

Generic sub-set algorithm problem

I have the following problem. I've got a set of items {a1, a2, a3, ... aN}. Each one of those items can contain another set of items {b1, b2, b3, ... bN}. So the end result looks something like this: a1 b4 b22 b40 b11 b9 a2 b30 b23 b9 b4 b11 a3 b22 b4 b60 b9 As a result of the execution of the algorithm I ...

Playing with geometry?

Does anyone have some useful beginner tutorials and code snippets for playing with basic geometric shapes and geometric proofs in code? In particular something with the ability to easily create functions and recursively draw them on the screen. Additional requirements, but not absolute, support for Objective-C and basic window drawing r...

Pass a Delphi set to an external Delphi function from C#

I'm trying to call an external Delphi function from C# which takes a Delphi set as a parameter: Delphi code type tStatus = (sIn, sOut, sAbsent, sSick); tStatusSet = set of tStatus; function LoadEmployees(tStatusSet aStatusSet): tEmpList; I need to marshall a C# array of enum values (that is elements from tStatus) into a format t...

Optimal solution for non-overlapping maximum scoring sequences

While developing part of a simulator I came across the following problem. Consider a string of length N, and M substrings of this string with a non-negative score assigned to each of them. Of particular interest are the sets of substrings that meet the following requirements: They do not overlap. Their total score (by sum, for simplici...

random and unique subsets generation

Lets say we have numbers from 1 to 25 and we have to choose sets of 15 numbers. The possible sets are, if i'm right 3268760. Of those 3268760 options, you have to generate say 100000 What would be the best way to generate 100000 unique and random of that subsets? Is there a way, an algorithm to do that? If not, what would be the bes...

Why doesn't .Net have a Set data structure?

One of my biggest issues dealing with a move from Java to .Net is the fact that there isn't a Set interface in .Net. I know there are libraries I could go and download but what is the reason for not having it built in? There are Maps (Dictionary) and Lists but why not a Set? Edit: I should clarify that not everyone uses .Net 3.5 yet -- ...

Order sets of numbers for maximum distance

You have (up to 100) distinct sets of (2-4) numbers. The order of the sets or numbers in the sets does not matter. The highest number relates to the number of sets and goes up to 30. Like: {1 2 3 4} {1 2 3 5} {1 2 3} {1 2 4 5} {6 2 4} {6 7 8 9} {6 7 9} {7 8 9} {2 4 8 9} The goal is, to arrange these sets in a particular order, where tw...

Algorithm for solving set problem

If I have a set of values (which I'll call x), and a number of subsets of x: What is the best way to work out all possible combinations of subsets whose union is equal to x, but none of whom intersect with each other. An example might be: if x is the set of the numbers 1 to 100, and I have four subsets: a = 0-49 b = 50-100 c = 50-75...

Non-geek in despair over menus in one site with different iframes on 2 different pages

THE SITE: http://pocketresumeguide.50webs.com/index.html THE PROBLEM: Hello, everyone. I am running into a problem with targeting pages into iframes. I am self-taught in what little HTML I know (as you will probably be able to see for yourselves.) Problem #1: My main TEXT menu that runs across the bottom works fine when I'm on the in...

how do I get the difference between two R named lists?

OK, I've got two named lists, one is "expected" and one is "observed". They may be complex in structure, with arbitrary data types. I want to get a new list containing just those elements of the observed list that are different from what's in the expected list. Here's an example: Lexp <- list(a=1, b="two", c=list(3, "four")) Lobs <- lis...

How can I code this problem? (C++)

I am writing a simple game which stores datasets in a 2D grid (like a chess board). Each cell in the grid may contain a single integer (0 means the cell is empty). If the cell contains a number > 0, it is said to be "filled". The set of "filled" cells on the grid is known as a "configuration". My problems is being able to "recognize" a ...

Enumerating Permutations of a set of subsets

I have sets S1 = {s11,s12,s13), S2 = {s21,s22,s23) and so on till SN.I need to generate all the permutations consisting elements of S1,S2..SN.. such that there is only 1 element from each of the sets. For eg: S1 = {a,b,c} S2 = {d,e,f} S3 = {g,h,i} My permuations would be: {a,d,g}, {a,d,h}, {a,d,i}, {a,e,g}, {a,e,h}.... How would ...

Finding the minimum set of properties that describe a referent in a set of entities

Hello. I was wondering if someone could help me get pointers to solve this problem. A link to algorithms would be great, but pointers to papers/info is also good. The problem is as follows. Suppose I have a set E of entities E={car1, car2, bicycle} and a set of properties P ={red, blue, small}. I also have a knowledge base such that red...

union/intersection of 2 sets, where each set are defined by it's subsets

We know every set's definition from the union of other sets. For example A = B union {1,2} B = C union D C = {5,6} D = {5,7} E = {4} then A = {1,2,5,6,7} A union E = {1,2,4,5,6,7} Are the any efficient algorithms to do that. Suppose the hierarchy of unions can be really deep, and the subsets can change pretty often(not that much...

Overriding set methods in Python

I want to create a custom set that will automatically convert objects into a different form for storage in the set (see Using a Python Dictionary as a key non-nested) for background. If I override add, remove, __contains__, __str__, update, __iter__ will that be sufficient to make the other operations behave properly, or do I need to o...

Create groups from sets of nodes

I have a list of sets (a,b,c,d,e in below example). Each of the sets contains a list of nodes in that set (1-6 below). I was wondering that there probably is a general known algorithm for achieving the below, and I just do not know about it. sets[ a[1,2,5,6], b[1,4,5], c[1,2,5], d[2,5], e[1,6], ] I would like to generate a new s...

Does Python have an ordered set?

Python has an ordered dictionary, what about an ordered set? This question previously had a warning that there was going to be a self-answer. ...

A case of outwardly equal lists of sets behaving differently under Python 2.5 (I think ...)

Four years ago I wrote a Sudoku puzzle solver, and now I'm trying to understand how it works so that I can reuse parts of it for a KenKen puzzle solver. I thought I'd better compactify loops into list comprehensions and pick more self-explanatory names for variables. There's a class Puz which contains the input puzzle as a list of (8...

Is there a way to inspect the (differing) internal structures of Python objects that test as equal (==)?

Yesterday I asked ("A case of outwardly equal lists of sets behaving differently under Python 2.5 (I think …)") why list W constructed as follows: r_dim_1_based = range( 1, dim + 1) set_dim_1_based = set( r_dim_1_based) def listW_fill_func( val): if (val == 0): return set_dim_1_based else: return set( [val]) W...