language-agnostic

Best logic for creating a (true) random labyrinth

I've been trying to make a little simple game just to test my logics, and it's a simple labyrinth, it's ugly, and so far sucky. The engine works pretty well, given that the labyrinth already exists (a matrix), it could be even enjoyable, but I have no intention on drawing a bunch of maps, which might be setting values on 400 (20x20) fie...

Effective data structure for overlapping spatial areas

I'm writing a game where a large number of objects will have "area effects" over a region of a tiled 2D map. Required features: Several of these area effects may overlap and affect the same tile It must be possible to very efficiently access the list of effects for any given tile The area effects can have arbitrary shapes but will u...

In what situations is an OOP design approach suboptimal?

Possible Duplicate: Pitfalls of Object oriented programming I recently had an argument with a friend who believed that every application should be designed in an OOP manner. I know that there are definitely applications where OOP would not fit well over the design but could not think of any specific example. Can someone give m...

What are some pieces of code that exemplify the power/functionality/style of their language of implementation?

I don't mean to say that any turing-complete programming language can be less powerful than another in terms of computation, but using "terseness" instead would not fufill the entire meaning of my question. Power in my mind is a combination of terseness and clarity. ...

Seeking quoted string generator

Does anyone know of a free website or program which will take a string and render it quoted with the appropriate escape characters? Let's say, for instance, that I want to quote It's often said that "devs don't know how to quote nested "quoted strings"". And I would like to specify whether that gets enclosed in single or double quo...

Managing updates to nested immutable data structures in functional languages

I've noticed while on my quest to lean functional programming that there are cases when parameter lists start to become excessive when using nested immutable data structures. This is because when making an update to an object state, you need to update all the parent nodes in the data structure as well. Note that here I take "update" to m...

Finding the maximum subsequence binary sets that have an equal number of 1s and 0s

I found the following problem on the internet, and would like to know how I would go about solving it: You are given an array ' containing 0s and 1s. Find O(n) time and O(1) space algorithm to find the maximum sub sequence which has equal number of 1s and 0s. Examples: 10101010 - The longest sub sequence that satisfies...

IP addresses range

Given an IP address and mask like 192.168.10.30/24 on STDIN, return the matching range of addresses. i.e. input : 192.168.10.30/24 output: 192.168.10.0-192.168.10.255 input : 127.0.0.0/31 output: 127.0.0.0-127.0.0.1 libraries/packages/... are NOT allowed ...

Design problem : Project management

I designing a project management tool, where you can track current status and such. Let's say a typical project flows like: Create Project > Deliver Specs > Approve Specs > Start Development > End Development > Delivered (another flow from Deliver Specs could be > Reject Specs > Rework Specs > Re-deliver Specs) There are many steps in ...

A good Object-Oriented analogy

I'm looking for a good way to describe OO to beginners, though an analogy. Currently I'm likening a Class to a shopping list, and a shopping trolley full of items to an object. But I feel it's a bit confusing. Preferably the analogy would be reflected well in the code example (Ruby), currently I have this, and it feels klunky. # First...

Determining the intersection of a triangle and a plane

I have a single triangle and a plane (in 3 dimensional space), How would I calculate the line segment where the two cross, if there is no crossing then I need to detect this case. The end result I'm looking for is two 3 dimensional vectors, which define the start and end points of the line segment. To help you out a little, I have alre...

Compute rank of a combination?

I want to pre-compute some values for each combination in a set of combinations. For example, when choosing 3 numbers from 0 to 12, I'll compute some value for each one: >>> for n in choose(range(13), 3): print n, foo(n) (0, 1, 2) 78 (0, 1, 3) 4 (0, 1, 4) 64 (0, 1, 5) 33 (0, 1, 6) 20 (0, 1, 7) 64 (0, 1, 8) 13 (0, 1, 9) 24 (0, 1, 10...

How do they write different language wrappers for same library?

Generally a library will be released in a single language (for example C). If the library tuns out to be useful then many language wrappers for that library will be written. How exactly do they do it? Kindly someone throw little light on this topic. If it is too language dependent pick language of your choice and explain it. ...

Does anybody still use Client Server Architecture

I have been writing software for several decades now and these days everything is web. Before the web we had Client Server apps that were basically thick client applications that spoke directly to the database. They had some disadvantages, such as deployment was cumbersome, Did not scale because DB handled all traffic. Of course back th...

Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?

I read some articles discouraging of the use of DYLD_LIBRARY_PATH, as the the path of dynamic library should be fixed using -install_name, @rpath, and @loader_path. In terms of making a program that runs both on Linux and Mac OS X, DYLD_LIBRARY_PATH of Mac OS X does exactly what LD_LIBRARY_PATH of Linux. And, we can share (almost) the ...

Mac OS X programming forum?

Are there actively working Mac OS X programming forums? Of course, SO is one of the best, but it would be better if I know some dedicated forums for Mac OS X programming issues. ...

TDD - Refactoring into black-box?

I have a nontrivial service object developed with TDD. It started with a simple task: For an object from queue, construct an attempt for asynchronous processing. So I wrote a test around my constructAttempt() method: void constructAttempt() {...} There are numerous possible scenarios that need to be taken into consideration, so I have...

UTF-8 tuple storage using lowest common technological denominator, append-only

What's the most low-tech but reliable way of storing tuples of UTF-8 strings on disk? Storage should be append-only for reliability. As part of a document storage system I'm experimenting with I have to store UTF-8 tuple data on disk. Obviously, for a full-blown implementation, I want to use something like Amazon S3, Project Voldemort, ...

How to divide a set of values into two sets of fixed size, such that their sums approach a particular value

I have a set of 18 values (it will always be 18) which I need to distribute into two sets, one of 10 items, and one of 8 items. The rule for distribution is that the values of each set must be equal (or as close as possible) to a particular known value - so in the first set the sum of the values must be as close as possible to 1500000 ...

Are global static classes and methods bad?

It's generally agreed upon that relying heavily on global stuff is to be avoided. Wouldn't using static classes and methods be the same thing? ...