I am actually doing coding for a grid solver in C.
Now i have defined a function called void get_target(void){} which has to set the target_x and target_y coordinates to a value on 5*5 coordinate system. I want to traverse the grid in least possible time covering all points with minimum number of turns( only 90deg turns, 180 deg turns...
How to merge two splay tree with amortized cost of log(n)?
...
Suppose I have an int x = 54897, old digit index (0 based), and the new value for that digit. What's the fastest way to get the new value?
Example
x = 54897
index = 3
value = 2
y = f(x, index, value) // => 54827
Edit: by fastest, I definitely mean faster performance. No string processing.
...
What's the best way to compress or encode a list of numbers of arbitrary length and sizes into a single alphanumeric string?
The goal is to be able to convert something like 1,5,8,3,20,212,42 into something like a8D1jN to be used in a URL, and then back to 1,5,8,3,20,212,42.
For the resulting string I'm fine with any number and any asc...
If this is Bubble sort then what is this?
Do you see the placement of Swap()?
...
Input: a set of rectangles within the area (0, 0) to (1600, 1200).
Output: a point which none of the rectangles contains.
What's an efficient algorithm for this? The only two I can currently think of are:
Create a 1600x1200 array of booleans. Iterate through the area of each rectangle, marking those bits as True. Iterate at the end a...
The challenge: Write a program which implements John Conway's Game of Life cellular automaton - in reverse!
The rules of life are explained on the Wiki page, in this question from last month, and will probably be familiar to any person crazy enough to take the challenge.
In this week's challenge, the goal is not to apply the rules of ...
Hi
I am wondering what other bitwise and logical operations you've used that saved your day.
For example, my last great time (and resources') saver has been
if(!((A^B) & B))
reads: if A has at least B's access rights, where rights were saved in the bit fields A and B.
Please use the classical operators: binary & (and) | (or), ^ (xo...
can anyone tell me whats the algorithm used for this function:
http://stat.ethz.ch/R-manual/R-devel/library/utils/html/combn.html ? I want to implement the same for php, so any pointers to php implementation of the same function would also be helpful. Thanks.
...
I have N scalable square tiles (buttons) that need to be placed inside of fixed sized rectangular surface (toolbox). I would like to present the buttons all at the same size.
How could I solve for the optimal size of the tiles that would provide the largest area of the rectangular surface being covered by tiles.
...
Let's assume I have a table full of teachers.
every teacher has these parameters:
Experience
Hourly Cost
Distance
Last Login
Total Rating (like an eBay score given by student)
the fact is, that I would avoid to give my users those dropdown menus to choose the sorting option, but i would build a search engine smart enough to compute t...
What is wrong with the following code? How come it does not found the letter using my implementation of a binary search?
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cwctype>
using namespace std;
bool contains(string s, char a){
int m = 0;
int n = s.length()-1;
while (m != n) {
int k...
I'm reading through SICP, and the authors brush over the technique of average damping in computing the fixed points of functions. I understand that it's necessary in certain cases, ie square roots in order to damp out the oscillation of the function y = x/y however, I don't understand why it magically aids the convergence of the fixed po...
Does any one know which is the algorithm used by the browser google-chrome for searching strings [shortcut:CTRL+F] ? Is it Boyer-moore algorithm ?
...
Currently, my algorithm is someValue + x. I am trying to figure out how I can transform x to 1 if its greater than 0, or to 0 if its equal to 0.
I don't want to use an if-else to produce this, but rather just transform x in my algorithm by itself.
For example: If someValue = 20, x = 4. It would produce 20 + 1 = 21. But if x = 0. It wou...
I have a table which needs to be sorted by several columns - let's say music which is sorted by genre, then by artist, album and so on. Or you can sort by artist/album/track. This is what I came up with in jquery:
function tableSort (by) {
var mylist = $('#...
Hi,
I am looking for an algorithm to move a set of objects using Perlin Noise in a spherical manner, if that makes sense.
Thanks!
...
I need to implement a function which normalizes coordinates. I define normalize as (please suggest a better term if Im wrong):
Mapping entries of a data set from their natural range to values between 0 and 1.
Now this was easy in one dimension:
static List<float> Normalize(float[] nums)
{
float max = Max(nums);
...
I need a simple Algorithm of permutation generator which could be apply on simple C language.
...
I am implementing a Harris corner detector for educational purposes but I'm stuck at the harris response part. Basically, what I am doing, is:
Compute image intensity gradients in x- and y-direction
Blur output of (1)
Compute Harris response over output of (2)
Suppress non-maximas in output of (3) in a 3x3-neighborhood and threshold ou...