algorithm

Word games algorithms, anyone know where can I find them

Hi guys I'm trying to find algorithms of games but not those 3D or 2D, I'm looking for simple games like "guess what word I'm thinking" or any kind of game that only requires basic reading of a text and the user has to choose between some options. ...

Detect local minima and maxima, java

Hi, given is any sequence of integers like 23 7 13 4 8 6. I want to detect local minima and maxima with the following rules: the first number in the sequence is a local minimum when the following number is greater the last number in the sequence is a local minimum when the previous number is greater a number in the sequence is a local...

Algorithm for creating infinite terrain/landscape/surface?

Does any have an algorithm for creating infinite terrain/landscape/surface? Constraints The algorithm should start by a random seed The algorithm should be one to one, (the same seed gives the same result) Other input parameter are allowed as long as 2 is fulfilled The algorithm may output a 2d map It suppose to create only surface wi...

How to retrieve a cluster of connected users from table of connections between two users?

Hi, The table consists of pairs of users which are connected together. The following is a hypothetical example: user1, user2 a, b a, c c, a c, d d, e a, e j, n g, n f, n By randomly picking up a user from the table (user1 or user2) I would like to retrieve the whole cluster of connections to which the selected user belongs. For examp...

Pattern Matching

I am goingto be starting work soon on a new project at work. Essentially there are many chemical compounds here each has its own prefix / identifier. For example a couple of chars followed by a few ints and that sort of thing, tho they all vary. I was wondering if there was an algorithm for matching these elements efficiently, opposed t...

How to equidistant resample a line (or curve)?

I have a line l_1 given with a point series p_1,...,p_n. I now want a new line l_2 having k points: q_1,...,q_k. But for all i \in {1,...,k-1}: abs( q_i - q_i+1 ) = const, meaning the segments of l_2 are equidistant or uniform. k >= 2 and p_1 and p_n should be in l_2. abs( p_i - p_i+1 ) not const One solution is to approximate a line...

What does "straightforward UF" refer to in the context of the solution to the "liarliar" Facebook puzzle?

I've come across the term "straightforward uf" to describe the solution (algorithm ?) to the following facebook engineering puzzle: liarliar. Does anyone know what this means? ...

Creating a spanning tree using BGL

I have a BGL graph and want to create a spanning tree using BGL. Starting from a specified vertex, I want to add the shortest edge to my graph which connects with this vertex. From there on, I want to always pick the shortest edge which connects with the graph which exists thus far. So, I want to add the constraint that every new edge ...

What's the name of this algorithm/routine?

I am writing a utility class which converts strings from one alphabet to another, this is useful in situations where you have a target alphabet you wish to use, with a restriction on the number of characters available. For example, if you can use lower case letters and numbers, but only 12 characters its possible to compress a timestamp...

Abundant - defective number code not showing results

I have this code from my professor and it's about finding abundant and defective numbers. A number x is effective if the sum of all integer divisors, except for x itself, is less than x. If it's greater than x, then it's abundant. There are no compile errors and it seems all fine, but it just doesn't print anything, it doesn't get any r...

Calculating angular rate.

Hi, I'm simulating a physical object, using a mass spring system. By means of deltas and cross products, I can easily calulate the up, forward and side vectors. I want to calculate what the angular rate (how fast it's spinning), for the object space X, Y and Z axis. Calculating the world space angle first won't help, since I need the a...

How to modify Levenshteins Edit Distance to count "adjacent letter exchanges" as 1 edit

I'm playing around with Levenshteins Edit Distance algorithm, and I want to extend this to count transpositions -- that is, exchanges of adjacent letters -- as 1 edit. The unmodified algorithm counts insertions, deletes or substitutions needed to reach a certain string from another. For instance, the edit distance from "KITTEN" to "SITTI...

Solving Kakuro puzzles

Here's a good one to reflect on: http://en.wikipedia.org/wiki/Kakuro I'm attempting to make a solver for this game. The paperwork is done (reading an initial file with a variable number of columns and rows. It's assumed the input file follows the rules of the game so the game is always solvable. Take your time to read the game rules. ...

backtracking algorithm for set cover problem

Can someone provide me with a backtracking algorithm to solve the "set cover" problem to find the minimum number of sets that cover all the elements in the universe? The greedy approach almost always selects more sets than the optimal number of sets. anything help will be greatly appreciated... thanks so much in advance. ...

Collision algorithm for 2 moving object.

Hi, this is a Math problem for a 2d game. Given 2 object ( 2 car, 2 tank, 2...), for each object i know: 1. X, Y 2. Actual Speed 3. Degree of movement (or radiant) How to calculate the "effect" of a collision for the 2 object Ps: I "move" the object with this simple formula each tick of my "game loop": ychange = Math.Sin(radiant...

algorithm for functions permutating integers

Hi, I want to write a function y = f(x) and another function x = g(y) that acts as a reversible, where y = f(g(y)) and where x and y are permutated integers. For very simple example in the range of integers in 0 to 10 it would look like this: 0->1, 1->2, 2->3,..., 9->10, 10->0 but this is the simplest method by adding 1 and reversin...

What is a good sorting algorithm that obeys conditions?

My goal is to sort a designer.cs' InitializeComponent()'s statements for merging. I used coco-r to set up a dependency graph. This gives me certain conditions that need to be true.(If calling a method on an object make sure that the order of the methods if the same before and after the sort.) I was curious if there are any sorting alg...

Trying to make an array of DirectX vertex with out knowing until run time what type they will be

Bit of background for those who don't know DirectX. A vertex is not just an XYZ position, it can have other data in it as well. DirectX uses a system known as Flexible Vertex Format, FVF, to let you define what format you want your vertexs to be in. You define these by passing a number to DirectX that use bitwise or to build it up, eg (D...

faster than binary search for ordered list

is there an algorithm that is faster than binary search, for searching in sorted values of array? in my case, I have a sorted values (could be any type values) in an A array, I need to return n if the value I was looking is in range of A[n] and A[n+1] ...

Levenshtein Distance Algorithm better than O(n*m)?

I have been looking for an advanced levenshtein distance algorithm, and the best I have found so far is O(n*m) where n and m are the lengths of the two strings. The reason why the algorithm is at this scale is because of space, not time, with the creation of a matrix of the two strings such as this one: Is there a publicly-available l...