Which is the best way to store a symmetric matrix in memory?
It would be good to save half of the space without compromising speed and complexity of the structure too much. This is a language-agnostic question but if you need to make some assumptions just assume it's a good old plain programming language like C or C++..
It seems a thin...
I need to loop through a number (xx). xx always starts at zero. My problem is that if the moveDirection variable is +1 then xx increases until it reaches the positive of range. If moveDirection is -1, then xx decreases until reaching the negative of range.
In the code below, I have done this by having an if statement test for moveDirect...
I recently found a "DNA Computing" Algorithm (not genetic programming or genetic algorithms) that attempts to find the Hamiltonian Path in a graph, but I'm a little confused by the pseudo code... note that the notation is a little messed up because I copied it from a PDF paper on DNA computing:
Input: for each node v and edge (u; v),
...
Challenge:
Take a sentence of input of any length and convert all the words in that sentence to pig latin. If you do not know what pig latin is please read Wikipedia: Pig Latin.
Specifications:
Assume all words are separated by spaces and all sentences either end with a exclamation, question mark or period.
Do not use the variant for...
I'm looking for an extended answer to the question asked here:
http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap
where any of the dates in either date range can be null. I've come up with the following solution, but I'm not sure if it can be simplified further.
(StartA == NULL || StartA <= EndB) &&
(E...
i have a process that downloads a file from a webbrower. it has the same name always (can't change that) so each file gets downloaded as file([latestnumber])
so in this directory i have:
joe.pdf
joe(1).pdf
joe(2).pdf
etc . . .
I now would like a script to take the "latest file" (joe(2).pdf in this case) and copy it to another direc...
In an application that accepts, stores, processes, and displays Unicode text (for the purpose of discussion, let's say that it's a web application), which characters should always be removed from incoming text?
I can think of some, mostly listed in the C0 and C1 control codes Wikipedia article:
The range 0x00-0x19 (mostly control char...
So I'm stuck. I am working on a credit system with expirations. Similar to credit card miles but not exactly. By the way I am sorry for the book ahead but I needed to add enough detail to help get the whole picture.
What I need is a system where a user accumulates credits for doing activities. But they can also spend these credits on ac...
If you were trying to design a language binding to a restful web api, how would you do it? What would you take into consideration? What resources would you consult first? Would you try to mock the web api interlace 1:1 or would you try to use your language idioms instead? How would you prevent making excessive HTTP requests? Etc
I've be...
I have a connected, directed, cyclic graph. The task is to discover every single node in the graph without falling into an infinite loop, as a regular tree traversal algorithm will do.
You can assume that I already know what node to start at so as to reach all points in the directed graph, and that for each node I have a function that w...
Possible Duplicate:
Why print your code?
For the first time in probably over 10 years I printed some source code. The reason why was so my non-programming wife could use it as a reference for a novel she's writing.
Twenty years ago when I worked for a major bank we had to print the source code of every major release.
Do you ...
What is the structure of a generic (or device independent) physical location? My guess is it might be a struct with two long fields, or something similar.
Also, given one destination location, and two candidate locations, is there a simple algorithm for determining which candidate is closest to the destination? I'm not really looking ...
Hi,
Currently, I have a more or less organized set of projects I work or worked on. Some are refactored, documented and unit-tested, others are not.
When I want to reuse a code I've written before, I spend a few minutes searching for the project where I've written this code, than copy-paste this code to a new one, refactoring, document...
I'm fairly new to GUI programming and I'm trying to write a plotting lib in D to use with some otherwise console-based scientific apps. I'm using DFL as my GUI library.
Assume my plot form has a method called showPlot() that's supposed to display the plot on the screen. I would like to be able to have any thread in my app throw up a p...
I need to add dictionary facilities to an Asp.net MVC app. Does anyone know a library that I could use? Where can I get word definitions from?
Any help is appreciated.
...
I suck at math, so I can't figure this out: how many combinations of k neighboring pixels are there in an image? Combinations of k pixels out of n * n total pixels in the image, but with the restriction that they must be neighbors, for each k from 2 to n * n. I need the sum for all values of k for a program that must take into account th...
Hello, I'm developing a programming language for which I want to provide a Range data type which for now is, not as usually, a list of pairs of int values (x,y) with the constraint that x < y. I say not as usually because usually a range is just a pair but in my case it is more than than, allowing to have for example
1 to 5, 7 to 11, 13...
Having a dataset and calculating statistics from it is easy. How about the other way around?
Let's say I know some variable has an average X, standard deviation Y and assume it has normal (Gaussian) distribution. What would be the best way to generate a "random" dataset (of arbitrary size) which will fit the distribution?
EDIT: This ki...
Hi,
Assuming you have a Unix timestamp, what would be an easy and/or elegant way to check if that timestamp was some time yesterday?
I am mostly looking for solutions in Javascript, PHP or C#, but pseudo code and language agnostic solutions (if any) are welcome as well.
...
Possible Duplicate:
Ive heard i++ isnt thread safe, is ++i thread-safe?
Hi all,
Yesterday I did interesting investigation on behavior of ++ operator in multithreaded environment. I knew for a long time that this code is not thread safe: (C-like pseudocode)
int i = 0;
thread()
{
for (int j = 0;j < 1000000;j++)
{
...