As I just learned from this question, .NET regexes can access individual matches within a repeated capturing group.
I. e., if I apply a regex like \b(\w+\s*)+ to a string of words, only the last word will be stored in \1 or Match.Groups(1).Value, but using Match.Groups(1).Captures I get access to all the individual matches the regex it...
I have a quadratic bezier curve described as (startX, startY) to (anchorX, anchorY) and using a control point (controlX, controlY).
I have two questions:
(1) I want to determine y points on that curve based on an x point.
(2) Then, given a line-segment on my bezier (defined by two intermediary points on my bezier curve (startX', start...
In the Kademlia protocol node IDs are 160 bit numbers. Nodes are stored in buckets, bucket 0 stores all the nodes which have the same ID as this node except for the very last bit, bucket 1 stores all the nodes which have the same ID as this node except for the last 2 bits, and so on for all 160 buckets.
What's the fastest way to find wh...
I've been told by professors and peers at my university that using the break statement is bad practice, but through my coursework haven't come up with a great reason why. Those who claim that it is bad say that it's a "get out of jail free card" and that you can always avoid using it.
My guesses for why its considered bad would be ...
Which programming language would you recommend to learn about data structures and algorithms in?
Considering the following:
Personal experience
Language features (pointers, OO, etc)
Suitability for learning DS & A concepts
I ask because there are some books out there that are programming language-agnostic (written from a Mathemati...
The entities to be stored have 25+ properties (table columns). The entities are pretty diverse, meaning that, most of the columns are empty. On average, I'd say, less than 20% (<5) properties have a value in any particular item. So, I have a lot of redundant empty columns for most of the table rows. Almost all of the columns are decimal ...
First, I love writing as little code as possible. I think, and please correct me, one of the golden rules of programming is to express your code in as few of character as possible while maintaining human readability.
But I can get a little carried away. I can pack three or four lines into one statement, something like
$startDate = $...
Greetings,
I'm working on a game project that uses a 3D variant of hexagonal tile maps. Tiles are actually cubes, not hexes, but are laid out just like hexes (because a square can be turned to a cube to extrapolate from 2D to 3D, but there is no 3D version of a hex). Rather than a verbose description, here goes an example of a 4x4x4 map...
I would like to add a certain number of leading zeroes (say up to 3) to all numbers of a string. For example:
Input: /2009/5/song 01 of 12
Output: /2009/0005/song 0001 of 0012
What's the best way to do this with regular expressions?
Edit:
I picked the first correct answer. However, all answers are worth giving a read.
...
We all hear that math at least helps a little bit with programming. My question though, does English or other natural language skills help with programming? I know it has to help with technical documentation, but what about actual programming? Are certain constructs in a programming language also there in natural languages? Does knowing ...
I'm looking for a course (preferably video, much preferably) like MIT's video course on Compiler Construction. Can someone point me to some decent resources or help material (preferably video)?
...
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common one is this, which I get when extending the Exception class:
public class NumberDivideException extends Exception {
public NumberDivideException() {
super("Illegal complex number operation!");
}
public NumberDivideException(Stri...
If I have a 4x4 gameboard which I'm representing in my program as a 1d integer array of size 16.
How can I get the indexs of the squares above, below, to the left and to the right any given index?
So, for example:
A = { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 }
Which represents this board
0 1 2 3
4 5 6 7
8 9 10 11
...
I don't really understand how modulus division works.
I was calculating 27 % 16 and wound up with 11 and I don't understand why.
I can't seem to find an explanation in layman's terms online.
Can someone elaborate on a very high level as to what's going on here?
EDIT: Thanks for all your answers. You guys are incredibly quick. It all ma...
I'm not sure if this is possible at the application layer. Can a program be written to read and analyze packets (maybe interfacing with wireshark through it's lua api) and ban MAC addresses with suspicious network traffic? (defining suspicious network traffic as packet injection patterns similar to known attacks)
...
I (and co-hackers) are building a sort of trivia game inspired by this blog post:
http://messymatters.com/calibration.
The idea is to give confidence intervals and learn how to be calibrated (when you're "90% sure" you should be right 90% of the time).
We're thus looking for, ideally, thousands of questions with unambiguous numerical an...
When using HTTP/1.1 Pipelining what does the standard say about issuing multiple requests without waiting for each request to complete? What do servers do in practice?
I ask because I once tried writing a client which would issue a batch of GET requests for multiple files and remember getting errors. I wasn't sure if it was due to me ...
How can I write an algorithm to check if the sum of any two numbers in an array/list matches a given number
with a complexity of nlogn?
...
I'm building a website that needs to support different language translations. I have strings in PHP, JavaScript and Smarty Template files that need to translated.
I want to use something like PHP's gettext() function and have a single language file for each locale.
This is easy when the translatable strings are in the PHP files but I ...
In an Object Oriented Program: How much abstraction is too much? How much is just right?
I have always been a nuts and bolts kind of guy. I understood the concept behind high levels of encapsulation and abstraction, but always felt instinctively that adding too much would just confuse the program. I always tried to shoot for an amoun...