I would like to generate some pseudorandom numbers and up until now I've been very content with the .Net library's Random.Next(int min, int max) function. PRNGs of this variety are supposed to be using a Uniform distribution, but I would very much like to generate some numbers using an Exponential Distribution.
I'm programming in C#, a...
I have a couple of questions about searching in graphs/trees:
Let's assume I have an empty chess board and I want to move a pawn around from point A to B.
A. When using depth first search or breadth first search must we use open and closed lists ? This is, a list that has all the elements to check, and other with all other elements tha...
Hi. It seems I can't compare 2 date values with time.
When I compare just date part - year, month and day - everything works fine. But when I add comparing times everything breaks down and not even month fits.
So what's some basic algorithm for comparing 2 dates? I mean generally, I can't juse use dateTime1.CompareTo(dateTime2). Prefer...
(This is not exactly the problem that I have, but it's isomorphic, and I think that this explanation will be easiest for others to understand.)
Suppose that I have a set of points in an n-dimensional space. Using 3 dimensions for example:
A : [1,2,3]
B : [4,5,6]
C : [7,8,9]
I also have a set of vectors that describe possible movement...
I have an application that performs various tasks that can take up to a minute each. I wanted to make sure that I was setting the application to a "working status" in a consistent way, so I set up a class (we'll call it "LockI") that when initialized records the current state of various things (the cursor, the status bar, screen updating...
I think this is a dumb question but I hear and see the term exception handling a lot. I have used try/catch, but i am still wondering what on earth 'handling' means. Can anyone kindly give some example that we can say the exception is actually 'handled'?
sorry for poor English, hope i made myself clear.
...
I'm looking for real figures and experiences, please don't take this too subjectively:
While looking for something else, I happened on an interesting statement, which partially reads as follows:
[...]the national average is 9,000
lines of code per year per
person.[...]
I write a lot of code, but not full-time. When I look back...
Let's take some regular house with a man, which has to go to the toilet every n minutes, requiring the seat to be up, and a woman, which has to do it every m minutes, requiring a seat to be down. Is there a possibility to create a O(1) algorithm which will output the exact number of toilet seat movements for a given period of X minutes? ...
in certain applications, I have need to collapse nested loops into one while retaining individual index information.
for j in N:
for i in M:
... A(i,j) ...
// Collapse the loops
for ij in MN:
... A(i,j) ...
so have looked at the obvious ways to recover i,j from ij using division/modulo (expensive operation) and using if stat...
I'm working on a highly-specialized search engine for my database. When the user submits a search request, the engine splits the search terms into an array and loops through. Inside the loop, each search term is examined against several possible scenarios to determine what it could mean. When a search term matches a scenario, a WHERE con...
i have a bit of code that i wrote a few weeks ago (the code's purpose isn't so much important as its structure):
if (_image.Empty)
{
//Use the true image size if they haven't specified a custom size
if (_glyphSize.Width > 0)
imageSize.Width = _glyphSize.Width //override
else
imageSize.Width = _image.GetWidth;
if...
When you're writing an application that needs to read and work with two versions of data in the same way, what is the best way to structure your classes to represent that data. I have come up with three scenarios:
Common Base/Specific Children
Data Union
Distinct Structures
Version 1 Car Example
byte DoorCount
int Color
byte HasMoon...
Hi all,
I've got a (proprietary) output from a software that I need to parse. Sadly, there are unescaped user names and I'm scratching my hairs trying to know if I can, or not, describe the files I need to parse using a BNF (or EBNF or ABNF).
The problem, oversimplified (it's really just an example), may look like this:
(data) ::= <...
This may sound ridiculous but I need to send something like <policy-file-request/> followed by a nul byte from a terminal to a XML socket server.
I am using PUTTY but I tried all sorts of combinations like \0 or /0 or \u0000 but to no avail.
I'm wondering if there is a specific key combination for this or am I messing up somewhere?
...
Hi there.
How should a program handle errors? Example:
A program needs the file text.txt. It must exist and be writable. What should it do if it's not writable or doesn't exist? Should it try to chown/chmod the file? Should it try to create it or just display an error message?
Or: Should it try to find a solution or just display an er...
I've done consulting work for years and I've got code snippets in various languages lying around that I'll re-use for various projects. The collection is getting pretty large and I want to set up a code bank for myself.
What code banks do people use? Do you find it helps, or is there some better way of organising my reusable code snippe...
This is not a subjective nor an argumentative question but a question that needs a yes/no answer and, if the answer is positive, the name(s) of said editor(s).
Imagine the company guideline mandates committed code to use the K&R style and that I prefer Allman (for example). Are there editors (either standalone or part of an IDE) that al...
I am looking for an algorithm to merge two sorted lists,
but they lack a comparison operator between elements of one list and elements of the other.
The resulting merged list may not be unique, but any result which satisfies the relative sort order of each list will do.
More precisely:
Given:
Lists A = {a_1, ..., a_m}, and B = {b_1, ....
Hi there
I don't know why, but i was thinking that IRC communities aren't popular anymore. I've sen the contrary after joining cakephp irc support channel.
Can you recommend me an agnostic IRC programming channel? Or, how do you meet others programmers, when your not involved in a IT company.
...
I'm currently improving the part of our COM component that logs all external calls into a file. For pointers we write something like (IInterface*)0x12345678 with the value being equal to the actual address.
Currently no difference is made for null pointers - they are displayed as 0x0 which IMO is suboptimal and inelegant. Changing this ...