Given are two sets of three-dimensional points, a source and a destination set. The number of points on each set is arbitrary (may be zero). The task is to assign one or no source point to every destination point, so that the sum of all distances is minimal. If there are more source than destination points, the additional points are to b...
I am writing a little library with some prime number related methods. As I've done the groundwork (aka working methods) and now I'm looking for some optimization.
Ofcourse the internet is an excellent place to do so. I've, however, stumbled upon a rounding problem and I was wondering how to solve this.
In the loop I use to test a numbe...
I have two form fields money and years that need to output a number into a third field cv .
Ideally while the first numbers are being entered but I'm OK with it happening after a button is pressed as well
<FORM name="salary">
<input type="number" size=12 name="money">
<input type="number" size=12 name="years">
<input type...
Let's say you have a set of ranges:
0 - 100: 'a'
0 - 75: 'b'
95 - 150: 'c'
120 - 130: 'd'
Obviously, these ranges overlap at certain points. How would you dissect these ranges to produce a list of non-overlapping ranges, while retaining information associated with their original range (in this case, the letter after the range)?
For ...
This is actually for a programming contest, but I've tried really hard and haven't got even the faintest clue how to do this.
Find the first and last k digits of nm where n and m can be very large ~ 10^9.
For the last k digits I implemented modular exponentiation.
For the first k I thought of using the binomial theorem upto certain po...
I have an array of dates in a one week range stored in an unusual way.
The Dates are stored in this numeric format: 12150
From left to right:
1st digit represents day: 1 = sunday, 2 = monday, 3 = tuesday, ...., 7 = saturday
next two digits represent hour in a 24 hour system: 00 = midnight, 23 = 11pm
next two digits represent minutes...
Hi, I have to following problem to solve. I have to calculate the bidding price from a total price. For example, a client wants to pay 2000$ as a total price, but from this price, there are added costs:
-usage price which is 10% from the bidding price with a minimum of 10$ and a maximum of 50$
-seller price: 2% from bidding price
-ad...
I try to determine the angle from a point (n,m) to (0,0). Without arctan2 being available, I'm running into the problem that m can be 0, which leads to a possible division by zero.
What would be an elegant, correct solution to tackling this issue?
...
Hi,
If I have a latitude or longitude reading in standard NMEA format is there an easy way / forumla to convert that reading to meters, which I can then implement in Java (J9)?
Edit:
Ok seems what I want to do is not possible /easily/, however what I really want to do is:
Say I have a lat and long of a way point and a lat and long of ...
Hi, in another post, MSN gave me a good guide on solving my algebra problem (http://stackoverflow.com/questions/639215/calculating-bid-price-from-total-cost). Now, even though I can calculate it by hand, I'm completely stuck on how to write this in pseudocode or code. Anyone could give me a quick hint? By the way, I want to calculate th...
Okay, I'm trying to write a program that could tell me if any points in a 30x100 rectangle rotated to 140 degrees are inside another 30x100 rectangle rotated to 200 degrees.
Honestly, I don't even know where to start. I thought about re-rotating them before doing normal calculations, but than they still wouldn't match up.
How can I do...
I'm trying to come up with a non brute-force solution to the following problem. Given a matrix of arbitrary size:
[6 0 3 5]
[3 7 1 4]
[1 4 8 2]
[0 2 5 9]
Transform its diagonals to a list of vectors, like so:
(0)
(1, 2)
(3, 4, 5)
(6, 7, 8, 9)
(0, 1, 2)
(3, 4)
(5)
(Working from bottom left to top right in this example)
...
The algorithm I'm using at the moment runs into extremely high numbers very quickly. A step in the algorithm I'm to raises x to the result of the totient function applied to y. The result is that you can run into very large numbers.
Eg. When calculating the multiplicative order of 10 modulo 53:
10^totient(53) == 10^52 == 1 * 10^52
...
Hi,
I need to do auto-correlation of a set of numbers, which as I understand it is just the correlation of the set with itself.
I've tried it using numpy's correlate function, but I don't believe the result, as it almost always gives a vector where the first number is not the largest, as it ought to be.
So, this question is really tw...
While reading through some lecture notes on preliminary number theory, I came across the solution to
water jug problem (with two jugs) which is summed as thus:
Using the property of the G.C.D of two numbers that GCD(a,b) is the smallest possible linear combination of a and b, and hence a certain quantity Q is only measurable by the 2 j...
Hello, I realize this might be more of a math problem.
To draw the lines for my rectangles I need to solve for their corners.
I have a rectangle center at (x,y) With a defined Width and Height.
To find the blue points on a non rotated rectangle on top (angle = 0)
It is
UL = (x-Width/2),(y+height/2)
UR = (x+Width/2),(y+height/2)
LR ...
I am programming a Tetris clone and in my game I store my tetromino blocks as 4x4 arrays of blocks. I now need to be able to rotate the integer positions in the arrays so that I get a rotated tetris block. I cannot simply rotate the texture because all my collision detection, etc has been designed to work with the 2D array. The game is w...
I know that performance never is black and white, often one implementation is faster in case X and slower in case Y, etc. but in general - are B-trees faster then AVL or RedBlack-Trees? They are considerably more complex to implement then AVL trees (and maybe even RedBlack-trees?), but are they faster (does their complexity pay off) ?
E...
Inspired by a recent TED talk, I want to write a small piece of educational software. The researcher created little miniature computers in the shape of blocks called "Siftables".
[David Merril, inventor - with Siftables in the background.]
There were many applications he used the blocks in but my favorite was when each block was a n...
I am reading the paper about seam carving for resizing an image.
Down on page 3 where they define a seam mathematically, I need help clarifying it.
The paper says that a seam is an 8-connected path of pixels. How can it be 8-connected if the pixel cannot be on the same row? Shouldn't it be 3-connected?
http://www.seamcarving.com/arik/...