I am working with Dundas maps and need to overlay the map with bubbles depicting some data. I want to add shapes to the map in order to achieve this. I can add a triangle (or any straight-line-polygon) like this:
public static void AddShape(this MapControl map, List<MapPoint> points, Color color, string name)
{
if (points[0].X != po...
How would you implement a random number generator that, given an interval, (randomly) generates all numbers in that interval, without any repetition?
It should consume as little time and memory as possible.
Example in a just-invented C#-ruby-ish pseudocode:
interval = new Interval(0,9)
rg = new RandomGenerator(interval);
count = inter...
I'm looking for an "efficient" way to persist a binary state when given to two integers. Giving these two integers A an B, A is always less than B and the range of values which they will contain is 0 through N. The integer N will be greater than 2 and less than 256.
The simple solution is to create a two-dimensional array of Boolean v...
I want to decrease a value by one and if it reaches zero, set it to the maximum value. Is there a way to do this via math without resorting to if (n-1 == 0) { n = max; }
The opposite scenario of increasing a value by one and then setting it to zero when it is greater than max can easily be achieved using n = (n + 1) % (max + 1);. Furthe...
Arbitrage is the process of using discrepancies in currency exchange values to earn profit.
Consider a person who starts with some amount of currency X, goes through a series of exchanges and finally ends up with more amount of X(than he initially had).
Given n currencies and a table (nxn) of exchange rates, devise an algorithm that a pe...
Been optimizing an algorithm and came down to the last part. I have an array of integers like this:
[ 1, 1, 2, 5, 0, 5, 3, 1, 1 ]
My requirement are as follows:
input: numbers of integers to sum over
the max sum should consist of integers next to each other
if an integer has the value 0 the sum in the range would be invalid
the m...
Given a set of possible values and a number of "digits," I want to find every unique, unordered grouping of values. For example, say you have an alphabet of A, B, C. All the combinations of 3 digits would be:
AAA
AAB
ABB
BBB
BBC
BCC
CCC
CCA
CAA
ABC
The specific problem I'm trying to solve is a bit simpler. I'm doing a BlackJack game a...
Hello. I have a problem but I can't figure out a solution. It goes like this:
I have a directed graph with N nodes and M links and without cycles. I need to find out the minimum numbers of chains so every node belongs to only one chain.
Example:
7 11 7 nodes; 11 links
1 2
1 5
2 3
2 5
2 7
3 4 // link exists between 3 and...
What is the quickest way to find the first character which only appears once in a string?
...
Post your best solutions! You can find the full problem description and examples here: ACM 2010 problems (pdf)
You have a set of castles connected by roads, and you want to conquer all the castles with the minimum number of soldiers. Each castle has three properties: the minimum number of soldiers required to take it, the number of sold...
Hi,
The following python code is to traverse a 2D grid of (c, g) in some special order, which is stored in "jobs" and "job_queue". But I am not sure which kind of order it is after trying to understand the code. Is someone able to tell about the order and give some explanation for the purpose of each function? Thanks and regards!
impo...
So I heard this algorithm question today. So you have a truck that is moving around a circular track with gas stations spaced out at some distance between them. Each station has a finite amount of gas, the distance between the gas stations requires a certain amount of gas to traverse and you can only move in one direction. What is the al...
What is an efficient algorithm to remove all duplicates in a string? For example if I have aaaabbbccdbdbcd, I will get back abcd.
...
I need to implement a priority queue where the priority of an item in the queue can change and the queue adjusts itself so that items are always removed in the correct order. I have some ideas of how I could implement this but I'm sure this is quite a common data structure so I'm hoping I can use an implementation by someone smarter than...
I have two NSArrays of Movie objects called DVD and VHS. I'd like to find the symmetric difference of these arrays. I want to know which Movies are in VHS buy not in DVD, and which Movies are in DVD but not VHS.
Can anyone tell me if there is a fast algorithm to solve it (preferably in C or Objective-C)? Is it faster/easier to solve if...
Hi, I got a grid with two points. I want to calculate the amount squares each point can reach before the other. Currently I implement a FloodFill-Algoritm, which can calculate the amount of squares one point can reach.
How can I change that algorithm to do the "flooding" for both points simaltaneuosly or at least one after another?
...
Given a list of elements, how to process all elements if every element requires knowledge about states of every other element of this list?
For example, direct way to implement it in Python could be:
S = [1,2,3,4]
for e in S:
for j in S:
if e!=j:
process_it(e,j)
but it is very slow O(n²) if number of elements is huge. Th...
Is there any algorithm for projecting images onto a non-flat (deformed) surface?
It is not deformed too much. It is a really glassy surface covered with high-quality, durable tracing paper. I have a 3-dimensional model of it. How can I texturise it with a projector?
I want to write a program in C\C++\C# for Windows, which would be ...
I have a large database for solving crossword puzzles, consisting of a word and a description.
My application allows searching for words of a specific length and characters on specific positions (this is done the hard way ... go through all words and check each).
Plus a search by description (if necessary)
For instance find word _ _ A _...
Hi,
I am looking for an algorithm to get contour of a figure created by a set of non-overlapping rectangles. The figure can be of any shape but it is simply-connected, i.e. contains no holes.
I need an idea on how to write a function like that:
IEnumerable<Point> GetContour( IEnumerable<Rect> rects )
Time complexity of the algorithm...