language-agnostic

How to draw paths specified in terms of straight and curved motion.

I have information on paths I would like to draw. The information consists of a sequence of straight sections and curves. For straight sections, I have only the length. For curves, I have the radius, direction and angle. Basically, I have a turtle that can move straight or move in a circular arc from the current position (after which mov...

What type of chart would you choose for this problem, and what charting library can provide it?

Suppose I have N segments, each one having a start and a end value, for example: [1,40],[40,80],[80,100],[90,110] I'd like to create a chart where I can display all of them, in such a way that I can see that the fourth segment overlaps the values of the third one. I'm new to charting, can you suggest which chart type I could use for...

Would there ever be a reason to write code in pure binary?

Is there ever a situation when ASM just isn't low-level enough? After all, assembler still has to be assembled. Has anyone ever written a program in binary? I'm just wondering if there's ever a theoretical reason why doing so might be practical or even if it's possible on modern computers. ...

An algorithm to find a pair of sums from a list of numbers?

Suppose you have the following list of numbers, {3,6,10,9,13,16,19}, not necessarily in that order. Now, not knowing that this is the set of the possible combination of the set {3,6,10}, is there an algorithm, in any programming language that can be used to find these combination efficiently. Basically, I want to recover the list from th...

How to organize files in the filesystem for an upload-type site?

I'm wondering if there are any best practices for organizing files on the filesystem for a site that centers around users uploading files. (Not a hosting site like Imageshack, more like addons.mozilla.org) Or am I over-analyzing this and should put everything in one folder? ...

Which data clustering algorithm is appropriate to detect an unknown number of clusters in a time series of events?

Here's my scenario. Consider a set of events that happen at various places and times - as an example, consider someone high above recording the lightning strikes in a city during a storm. For my purpose, lightnings are instantaneous and can only hit certain locations (such as high buildings). Also imagine each lightning strike has a uniq...

What is the optimal winning strategy for this modified blackjack game?

Questions Is there a best value to stay on so that I win the greatest percentage of games possible? If so, what is it? Edit: Is there an exact probability of winning that can be calculated for a given limit, independent of whatever the opponent does? (I haven't done probability & statistics since college). I'd be interested in seeing t...

How can I keep track of character positions after I remove elements from a string?

Let us say I have the following string: "my ., .,dog. .jumps. , .and..he. .,is., .a. very .,good, .dog" 1234567890123456789012345678901234567890123456789012345678901 <-- char pos Now, I have written a regular expression to remove certain elements from the string above, in this example, all whitespace, all periods, and all commas....

Why are Super-class and Sub-class reversed?

In set theory, a set is a superset if it contains everything in the original set and possibly more. A subset however is does not contain everything of the initial set. With that in mind, in most object-oriented programming languages (I'm thinking Objective-C but I know the same is true for Java and others), the parent class is called th...

How to write a good README

I guess everyone has seen a README file, but I would like the definitive guide on how to write an excellent README file with the least amount of energy spent on it. What's a README file? What should I write in it? How exactly should I format it? ...

An Ideal Keyboard Layout for Programming

I often hear complaints that programming languages that make heavy use of symbols for brevity, most notably C and C++ (I'm not going to touch APL), are difficult to type because they require frequent use of the shift key. A year or two ago, I got tired of it myself, downloaded Microsoft's Keyboard Layout Creator, made a few changes to my...

Design pattern frustrations

Hi, I am a developer having 4 years of .Net coding experience, And never cared much about design patterns in my carreer. Recently i have been called for an interview with one of the biggies in the IT, have done 5 rounds (problem solving, pair prograaming , logical reasoning, 2 rounds of tech interview) of interview and didnt offer a j...

Purpose of Unions in C and C++

I have used unions earlier comfortably; today I was alarmed when I read this post and came to know that this code union ARGB { uint32_t colour; struct componentsTag { uint8_t b; uint8_t g; uint8_t r; uint8_t a; } components; } pixel; pixel.colour = 0xff040201; /* ---- somewhere down the...

How to create endless stories for telenovela or tv-series programmatically?

Do you know any (web) sources that describe ways to continually produce stories from an initial base of parameters/objects and some given relationships? I'm interested in - theory and algorithms - real projects where it was done - how to measure redundance in such a system - (fun) sites with examples of something comparable ...

Procedural snare drum

So I've got something like: void createSinewave( short * array, int duration, int startOffset, float freq, float amp ) ; void createSquarewave( short * array, int duration, int startOffset, float freq, float amp ) ; Other functions "slide" a wave form from some low frequency to some high frequency, and accept two frequency pa...

History of trailing comma in programming language grammars

Many programming languages allow trailing commas in their grammar following the last item in a list. Supposedly this was done to simplify automatic code generation, which is understandable. As an example, the following is a perfectly legal array initialization in Java (JLS 10.6 Array Initializers): int[] a = { 1, 2, 3, }; I'm curious...

How to factor static call out of a class

Let's say I have a static method called Logger.log(), which calls another static method, CurrentUser.getName(), to get some additional information to log: public static void log(text) { String[] itemsToLog = { text, todaysDate, ipAddress, CurrentUser.getName() }; Now obviously this isn't an ideal situation, especially with the stati...

What is the algorithm to search an index for multiple values?

This is actually a real problem I'm working on, but for simplicity, let's pretend I'm Google. Say the user searches for "nanoscale tupperware". There aren't very many pages with both words... only about 3k. But there are ~2 million pages with "nanoscale" and ~4 million with "tupperware". Still, Google finds the 3k for me in 0.3 seconds....

resources for sound and music processing

i find it very hard to find good texts about sound and music when looking in the programming area the hardest part being "what part of it have i learnt yet?", since i have never found anything describing the part already documented against the great unknown (=things no-one has well understood yet) from sound synthesis to automatic musi...

First-Occurrence Parallel String Matching Algorithm

To be up front, this is homework. That being said, it's extremely open ended and we've had almost zero guidance as to how to even begin thinking about this problem (or parallel algorithms in general). I'd like pointers in the right direction and not a full solution. Any reading that could help would be excellent as well. I'm working on ...