I'd like to figure out (in runtime) whether or not two regular expressions intersect (i.e. if they do there exist one or more string the matches both regular expressions).
Algorithm needs to be pretty fast as I need to loop through a database and check existing values.
Found some theory on this but no implementations?
...
Not sure how best to explain it, other than using an example...
Imagine having a client with 10 outstanding invoices, and one day they provide you with a cheque, but do not tell you which invoices it's for.
What would be the best way to return all the possible combination of values which can produce the required total?
My current th...
I half-answered a question about finding clusters of mass in a bitmap. I say half-answered because I left it in a condition where I had all the points in the bitmap sorted by mass and left it to the reader to filter the list removing points from the same cluster.
Then when thinking about that step I found that the solution didn't jump ...
Say I have a list and I want it arranged so that the sum of a certain function operating over its consecutive elements is minimum.
For example consider the list { 1, 2, 3, 4 } and sum a^b for consecutive pairs (a,b) over the entire list. ie. 1^2 + 2^3 + 3^4 = 90. By inspection, the minimum sum is achieved when the list is arranged as {...
I have some configuration data that I'd like to model in code as so:
Key1, Key2, Key3, Value
null, null, null, 1
1, null, null, 2
9, null, null, 21
1, null, 3, 3
null, 2, 3, 4
1, 2, 3, 5
With this configuration set, I then need to do lookups on bazillion (give or take) {Key1, Key2, Key3}...
This is my first post here so be easy on me!
I'm a beginner C++ programmer, and to stretch my mind I've been trying some of the problems on projecteuler.net. Despite an interest in maths at school, I've found myself automatically going for brute force solutions to the problems, rather than looking for something streamlined or elegant. ...
i have a List, it has Foo objects, and each Foo has a start date, and an end date.
I want to insert a new Foo object, which has its own start and end date.
I want the elements in the list to update their start and end dates accordingly, when the new Foo object is inserted, and for the new Foo object to find its correct place in the List....
I have a value type that represents a gaussian distribution:
struct Gauss {
double mean;
double variance;
}
I would like to perform an integral over a series of these values:
Gauss eulerIntegrate(double dt, Gauss iv, Gauss[] values) {
Gauss r = iv;
foreach (Gauss v in values) {
r += v*dt;
}
return r;
}...
I'm interested in speed, not good looking code, that is why I'm using array and not list(of integer).
I have an array looking like: 0,1,0,1,1,0,1,0,1,1,1,0,0,1
I'm interesting in the position of each number so I can later pick one randomly.
so what I do is looping through the array to take position number of each 1 then creating a new...
As probably many people around here I read a few webcomics. Drowtales is my favorite, but that's besides the point.
For a long time a thought has been nagging me at the back of my head: webcomics are drawn pictures. They are not photographs. There should be a lot of redundancy (less colors, more flat colored areas, etc.) and thus they s...
I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs.
When the simulation runs, I would like to be able to produce random values that match the measured distribution. I'd prefer to do this without storing the original histograms...
There are enough resources on how to convert an expression tree into postfix notation, and it's not that hard.
But I have to parse a postfix expression into an expression tree.
The expression is:
A 2 ^ 2 A * B * - B 2 ^ + A B - /
I don't really have a clue on how to interpret the expression. Does someone has a clue on how to proc...
You may have noticed that we now show an edit summary on Community Wiki posts:
community wiki
220 revisions, 48 users
I'd like to also show the user who "most owns" the final content displayed on the page, as a percentage of the remaining text:
community wiki
220 revisions, 48 users
kronoz 87%
Yes, there could be top (n...
I need to check a string to see if any word in it has multiple occurences. So basically I will accept:
"google makes love"
but I don't accept:
"google makes google love" or "google makes love love google" etc.
Any ideas? Really don't know any way to approach this, any help would be greatly appreciated.
...
Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2]
What is the best way to find the minimum or maximum value in that Array?
Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is greater than the existing value:
var myArray:Array /* of Number */ = [2,3,3,4,2,2,5,6,7,2];
...
This is a generalization of the "string contains substring" problem to (more) arbitrary types.
Given an sequence (such as a list or tuple), what's the best way of determining whether another sequence is inside it? As a bonus, it should return the index of the element where the subsequence starts:
Example usage (Sequence in Sequence):...
Here is my problem. Imagine I am buying 3 different items, and I have up to 5 coupons. The coupons are interchangeable, but worth different amounts when used on different items.
Here is the matrix which gives the result of spending different numbers of coupons on different items:
coupons: 1 2 3 4 5
it...
I have taken an AI course, and the teacher asked us to implement a game that makes use of one of the AI algorithms. Here is where I need a bit of help:
I don't know to what kind of games each algorithm is applied
if you could just give an example of a game or game type and the algorithm it uses, I would appreciate it
I don't need an...
I've become interested in algorithms lately, and the fibonacci sequence grabbed my attention due to its simplicity.
I've managed to put something together in javascript that calculates the nth term in the fibonacci sequence in less than 15 milliseconds after reading lots of information on the web. It goes up to 1476...1477 is infinity a...
Given the extremely high requirements for unpredictability to prevent casinos from going bankrupt, what random number generation algorithm and seeding scheme is typically used in devices like slot machines, video poker machines, etc.?
EDIT: Related questions:
http://stackoverflow.com/questions/203382/do-stateless-random-number-generat...