algorithm

2D smoke/fire/mist algorithm

Where can I find a good algorithm, or where is just a good place to start, to implement real-time, non-interactive smoke or fire or mist, in 2D? I've come across this simple one and this complex 3D one but I was hoping for something in between. Anyone know of any good algorithms? ...

How does the MapReduce sort algorithm work?

Hi, One of the main examples that is used in demonstrating the power of MapReduce is the Terasort benchmark. I'm having trouble understanding the basics of the sorting algorithm used in the MapReduce environment. To me sorting simply involves determining the relative position of an element in relationship to all other elements. So sor...

Number of combinations in configurator

I have been asked to program a routine to decide the number of possible combinations in a product configurator. The configurator is really simple. Even though it has more features than this, it can be modeled as several "radio groups" (like the UI control) where one of n options has to be selected. The only kind of constraints that can...

What bizarre averaging algorithm is my bike computer using?

My bike computer can show me various figures such as distance travelled, time elapsed, max speed, average speed, current speed etc. I usually have it set to display the current and average speeds. You can reset the distance and time (both together) at any point; the max and average speeds are calculated since the last reset. The distanc...

C# Algorithm to Tint a Color a Certain Percent

I have a color and I want get a tint of that color by a certain percent. So 100% is the color itself, 90% is a slightly lighter color, etc. Basically, it's like adding 10% of opacity to the color, if the color is on a white background. I need to convert the color into a hex HTML color value, so I don't want transparency. Is there an alg...

Good Source for Learning How to Work with XML in F#

Does anyone have a good source for learning how to work with XML in F#? Multiple sources would be nice if available. ...

Algorithm for BFS traveral of an acylic directed graph

I'm looking for an elegant Python program that does a BFS traveral of a DAG: Node A is connected to B (A->B) if A "depends on" B (think of python package Foo "depending upon" Bar: Foo->Bar). In a graph of about 7000 such nodes, I want to sort all nodes such that for all possible (i, j) where 1>=i<j<=7000 .. depends(Ni, Nj) is False. d...

Algorithm to determine the effective "phase difference" between two signals with different frequencies?

The quick version: What algorithm could I use to determine the "phase difference" between two square wave signals with different frequencies, if the only information that I have is the time at which each rising edge occurs? The detailed version: I'm working on an embedded software project, and I have run across an interesting proble...

Is there a O(nlog(n)) algorithm for inverting a simply linked list?

In comments to this answer an idea is brought up that inverting a simply linked list could only be done in O(nlog(n)), not O(n) time. This is definitely wrong – an O(n) inversion is not a problem - just traverse the list and change pointers as you go. Three temporary pointers are required - that's constant extra memory. I understand co...

EngineYard SHA1 Contest Approaches

EngineYard is holding a constest here, where given a phrase and a dictionary of words, come up with a 12 word phrase whose SHA1 hash has the smallest hamming distance from the SHA1 hash of the given phrase. A couple of sites are using cloud/crowd-sourcing to try to bruteforce it, while others are using CUDA and GPUs. Some reports hav...

Voice Alteration Algorithm

Could somebody point me to a voice alteration algorithm? Preferably in Java or C? Something that I could use to change a stream of recorded vocals into something that sounds like Optimus Prime. (FYI- Optimus Prime is the lead Autobot from transformers with a very distinctive sounding voice... not everybody may know this.) Is there an ope...

How can I find if a lat long coordinate is valid in a coordinate system?

If I have a point in latitude/longitude and I want to find out if it is a valid for use within a particular coordinate system, how can I do it? As an example. Say I am working in Swiss Grid (CH 1903, EPSG 21781) and have a point representing something in London in the UK, I want to know if that point is valid in the Swiss Grid coordinat...

.NET testing a string for numeric value

Consider the need for a function in C# that will test whether a string is a numeric value. The requirements: must return a boolean. function should be able to allow for whole numbers, decimals, and negatives. assume no using Microsoft.VisualBasic to call into IsNumeric(). Here's a case of reinventing the wheel, but the exercise is goo...

Symmetric Bijective String Algorithm?

I'm looking for an algorithm that can do a one-to-one mapping of a string onto another string. I want an algorithm that given an alphabet I can perform a symmetric mapping function. For example: Let's consider that I have the alphabet "A","B","C","D","E","F". I want something like F("ABC") = "CEA" and F("CEA") = "ABC" for every N letter...

algorithm to determine minimum payments amongst a group

The Problem I was recently asked to calculate the money owed amongst a group of people who went on a trip together and came upon an interesting problem: given that you know the amounts that each person owes another, what is a general algorithm to consolidate the debts between people so that only the minimum number of payments needs to b...

Finding the longest chain of same-type nodes

I have a tree structure of interconnected nodes of various types. Each node keeps track of which nodes it is connected to. In this structure I need to find the longest unconnected chain or path of same type nodes. I've read up on graphs and breadth/depth first searches but these don't quite yield the results I need. (they'll find a chai...

how to check if a string looks randomized, or human generated and pronouncable?

For the purpose of identifying [possible] bot-generated usernames. Suppose you have a username like "bilbomoothof" .. it may be nonsense, but it still contains pronouncable sounds and so appears human-generated. I accept that it could have been randomly generated from a dictionary of syllables, or word parts, but let's assume for a mom...

Patterns/Principles for thread-safe queues and "master/worker" program in Java

I have a problem which I believe is the classic master/worker pattern, and I'm seeking advice on implementation. Here's what I currently am thinking about the problem: There's a global "queue" of some sort, and it is a central place where "the work to be done" is kept. Presumably this queue will be managed by a kind of "master" object. ...

Definition of C# data structures and algorithms

This may be a silly question (with MSDN and all), but maybe some of you will be able to help me sift through amazing amounts of information. I need to know the specifics of the implementations of common data structures and algorithms in C#. That is, for example, I need to know, say, how Linked Lists are handled and represented, how the...

Fastest/easiest way to average ARGB color ints?

I have five colors stored in the format #AARRGGBB as unsigned ints, and I need to take the average of all five. Obviously I can't simply divide each int by five and just add them, and the only way I thought of so far is to bitmask them, do each channel separately, and then OR them together again. Is there a clever or concise way of av...