I am currently using Bresenham's algorithm to draw lines but they are (of course) one pixel in thickness. My question is what is the most efficient way to draw lines of arbitrary thickness?
The language I am using is C.
...
Suppose I have some serially numbered items that are 1-n units wide, that need to be displayed in rows. Each row is m units wide. I need some pseudo-code that will output the rows, for me, so that the m-width limit is kept. This is not a knapsack problem, as the items must remain in serial number order - empty spaces at the end of rows a...
The problem: I want to be able to FIFO queue outgoing messages. For update/deletion reasons, I also want to be able to access every message in the queue based upon an object ID.
I've currently implemented a solution where data is pushed into a deque, and an iterator to that data is kept. The iterator, keyed by an object ID, is then plac...
I'm going to be starting a banner-rotation script soon and I'm getting a bit perplexed over how exactly to develop it. Suppose a client asks for
"10,000 impressions in the next 10 days for $10,000 dollars."
Another client asks for
"1,000 impressions for $100 dollars."
And a third asks for
"1,000 clicks or 10,000 impressio...
This is not really a programming question, more of an algorithmic one.
The problem: Finding the "content" section of an HTML page.
By "content" I mean the dom that contains the page content as seen by humans, without the noise, simply the "page actual content".
I know the problem is not well defined, but let's continue...
For example ...
First of all, I finally made this a wiki, but I believe a "simple," straightforward answer is highly desirable, especially since the result would define a unified IDE behavior for everyone. More on the simple later.
In the past, I've blogged about what it means to have a well-behaved member selection drop down. If you haven't read it, d...
Do you just base your STL container selections on the following attributes?
Searching/Updating
Insertion and
Deletion
If not, what else do you base your selections upon?
Is there any reference out there that lists how each container performs across all these different attributes?
...
What is the algorithm - seemingly in use on domain parking pages - that takes a spaceless bunch of words (eg "thecarrotofcuriosity") and more-or-less correctly breaks it down into the constituent words (eg "the carrot of curiosity") ?
...
Can someone give an example for finding greatest common divisor algorithm for more then two numbers?
I believe programming language doesn't matter.
...
Hi,
I have a situation whereby I'm populating an ArrayList with "TransactionEvent"s. TransactionEvent has a property "transaction ID". In the large majority of cases each new event has a transaction ID greater the previous event's ID - However, this is not guaranteed; i.e. the data is almost sorted.
My question is this: How can I per...
Hi,
I am looking for PRBS Pattern Generating C/C++ API, So that i can insert it in Payload of UDP.
If anybody know the procedure for generating PRBS pattern it would be greatfull.
...
Hi,
I'm sorry for the generic title of this question but I wish I was able to articulate it less generically. :-}
I'd like to write a piece of software (in this case, using C++) which translates a stream of input tokens into a stream of output tokens. There are just five input tokens (lets call them 0, 1, 2, 3, 4) and each of them can ...
I have a method that gets a number of objects of this class
class Range<T>
{
public T Start;
public T End;
}
In my case T is DateTime, but lets use int for simplicity. I would like a method that collapses those ranges into ones that cover the same "area" but that do not overlap.
So if I had the following ranges
1 to 5
3 to ...
I know that the Random class can generate pseudo-random numbers but is there a way to generate truly random numbers?
...
I have just finished creating a custom role provider using LINQ to SQL for data access. One of the functions you need to write for the provider is to remove users from roles;
public void RemoveUsersFromRoles(string[] usernames, string[] rolenames);
Now one approach would be;
return a list of roles
iterate for each role and remove t...
Hello,
I'm building a boggle game in vb .net. Right now, my dices are as a 2d array (0,0 0,1 ) etc...
What I want it to do is, as I'm typing the word, that it hilights it on the board using the button(x,y).doclick sub which highlights it. Right now my implementation finds the first letter, then keeps trying each letter until it meets t...
Hello,
Im making a game that involves a 4*4 grid
the user enters letters and the game has to highlight the letters and they have to be next to one another.
I have a sub that checks if the current letter is next to (or neighbouring) the last letter. Basically what needs to happen is :
for each letter
iterate through the grid and try ev...
Reading a paper, I'm having difficulty understanding the algorithm described:
Given a black and white digital image of a handwriting sample, cut out a single character to analyze. Since this can be any size, the algorithm needs to take this into account (if it will be easier, we can assume the size is 2^n x 2^m).
Now, the description s...
I'm trying to solve a knapsack like problem from MIT OCW.
It's problem set 5.
I need use branch and bound algorithm to find the optimal states.
So I need implement a state-space tree.
I understand the idea of this algorithm, but I find it's not so easy to implement.
If I find a node that with it, the budget is not enough, I should stop...
Was thinking I could test the various answers I got in my question about an algorithm for collapsing ranges. So I was thinking I should create a method that creates a whole bunch of ranges and see how the various methods handles it.
But when it comes to generating random stuff I am not very good. I created something like this:
pri...