language-agnostic

Bitwise Interval Arithmetic

I've recently read an interesting thread on the D newsgroup, which basically asks, Given two (signed) integers a [amin, amax], b [bmin, bmax], what is the tightest interval of a | b? I'm think if interval arithmetics can be applied on general bitwise operators (assuming infinite bits). The bitwise-NOT and shifts are trivial sin...

How to force myself to follow naming and other conventions

I believe, I program good, at least my code produces results... But I feel I have drawback... I hardly follow any naming conventions... neither for variables.. nor for methods... nor for classes... nor for tables, columns, SPs... Further to this, I hardly comment anything while programming... I always think that, Let me first see t...

Which kind of diagram for parallel code documentation?

I have some parallel code (implemented using MPI) that needs to be documented. I'd like to have a flow-diagram describing it's high-level strategy. What kind of diagram do you use to describe send, receive, broadcast, gather, reduction and other operations? (EDIT: I'm equally interested in Linux/LaTeX software to do them) ...

Genetic Programming Online Learning

Has anybody seen a GP implemented with online learning rather than the standard offline learning? I've done some stuff with genetic programs and I simply can't figure out what would be a good way to make the learning process online. Please let me know if you have any ideas, seen any implementations, or have any references that I can loo...

What is "branch-on-sign expressions"?

As far as I understand the "branch-on-sign" is the name of some kind of if statement that does something depending on sign. I'm not sure that it's just if (x<0) then ... else .... However, the name "branch-on-sign" seems to denote something very concrete. So, what is it? Perhaps, it's language-specific, but I don't really know. P...

What's the difference between application layer and business logic layer?

what's the difference between application layer and business logic layer? I kind of understand that business layer provides business specific services and application layer couples business services and provides services to the end user (webservice, UI, etc) am i right? ...

Why is it useful to count the number of bits?

I've seen the numerous questions about counting the number of set bits in an insert type of input, but why is it useful? For those looking for algorithms about bit counting, look here: http://stackoverflow.com/questions/1517848/counting-common-bits-in-a-sequence-of-unsigned-longs http://stackoverflow.com/questions/472325/fastest-way-t...

is there a Universal Model for languages?

Many programming languages share generic and even fairly universal features. For example, if you compared Java, VB6, .NET, PHP, Python, then you would find common functions such as control structures, numeric and string manipulation, etc. What has been done to define these features at a meta-language (or language-agnostic) level? UM...

How to determine the longest increasing subsequence using dynamic programming?

Let's say I have a set of integers. I want to find the longest increasing subsequence of that set using dynamic programming. This is simply out of practice, reviewing my old notes from my algorithms course, and I don't seem to understand how this works. Thanks ...

Code Golf: Numeric equivalent of an Excel column name

The challenge The shortest code by character count that will output the numeric equivalent of an Excel column string. For example, the A column is 1, B is 2, so on and so forth. Once you hit Z, the next column becomes AA, then AB and so on. Test cases: A: 1 B: 2 AD: 30 ABC: 731 WTF: 16074 ROFL: 326676 Code count includes ...

How to use a DHT for a social trading environment

I'm trying to understand if a DHT can be used to solve a problem I'm working on: I have a trading environment where professional option traders can get an increase in their risk limit by requesting that fellow traders lend them some of their risk limit. The lending trader can either search for traders with certain risk parameters which ...

pass by reference but reference to data and not to variable

This is psesudo code. In what programming language this is possible ? def lab(input) input = ['90'] end x = ['80'] lab(x) puts x #=> value of x has changed from ['80'] to ['90] I have written this in ruby but in ruby I get the final x value of 80 because ruby is pass-by-reference. However what is passed is the reference to the dat...

how to describe this series in code?

hello, i would like to find a formula describing this series. i need to set a boolean depending on a positive integer. it's pretty simple but i am stuck and feel a bit stupid. 0 false 1 true 2 true 3 false 4 false 5 true 6 true 7 false 8 false 9 true 10 true 11 false 12 false ... so the flag changes at every odd number ...

The woes of (sometimes) storing "date only" in datetimes

We have two fields from and to (of type datetime), where the user can store the begin time and the end time of a business trip, e.g.: From: 2010-04-14 09:00 To: 2010-04-16 16:30 So, the duration of the trip is 2 days and 7.5 hours. Often, the exact times are not known in advance, so the user enters the dates without a time: From: ...

How do i know if this is random enough?

I wrote a program in java that rolls a die and records the total number of times each value 1-6 is rolled. I rolled 6 Million times. Here's the distribution: #of 0's: 0 #of 1's: 1000068 #of 2's: 999375 #of 3's: 999525 #of 4's: 1001486 #of 5's: 1000059 #of 6's: 999487 (0 wasn't an option.) Is this distribution consistant with random...

What is an integer overflow error?

What is an integer overflow error? Why do i care about such an error? What are some methods of avoiding or preventing it? ...

Programming Technique: How to create a simple card game

Hi, as I am learning the Ruby language, I am getting closer to actual programming. I was thinking of creating a simple card game. My question isn't Ruby oriented, but I do know want to learn how to solve this problem with a genuine OOP approach. In my card game, I want to have four players, using a standard deck with 52 cards, no joker...

Algorithm to generate a segment maze

I want to generate a maze that looks like this: That is, it consists of paths in one direction that are then connected. I have looked for an algorithm to generate mazes like this without success. Specifically, I don't want a maze like this: because it doesn't "run" in only one direction. Also, it would be nice if the solution of t...

How to extract Geographic data from open street map or Google maps

Hi, i need to retrieve all the city names from a specific country using openstreet map or google maps. is there any API available? or is there any other way of getting this world geographic data? Cheers ...

Logical Matrix .... Solution

Suppose you have an NxN matrix and you have to check whether it's a upper diagonal matrix or not. Is there any generic method to solve this problem? I am elaborating my question: Some thing is like this: Suppose you have NXN matrix having the value of N=4 then matrix will look like this: |5 6 9 2| |1 8 4 9| |5 8 1 6| |7 6 3 2| Its a ...