Hi,
I have a list of email address which I want to distribute evenly by domain.
For example:
let the list be,
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
The output should be
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
The source list is not sorted by domain as in example, but can be sorted by domain, if that can help...
I have written a CSS sprite auto-generator which takes selected images out of the HTML page and converts them to CSS sprites, but right now it does not attempt to lay them out optimally but rather just stacks them, which wastes a lot of space. What would be the best algorithm for determining the optimal layout?
To state the problem mor...
I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive.
What would be the best algorithm to compress this?
I tried the deflate algorithm but that gives me only 50% compression.
Note that the algorithm cannot be lossy.
All numbers are unique and progressively increasing...
Inspired by this question, I wanted to try my hand at the latest ponder this challenge, using F#
My approach is probably completely off course, but in the course of solving this problem, I'm trying to get a list of all the permutations of the digits 0-9.
I'm looking at solving it using a n-ary tree like so:
type Node =
| Branch o...
I have a text file with a series of commands each one is on a diferent line what I need to do is go through the text file line by line and for each line perform a set of operations. How would I loop through line by line?
Example:
Text file contains:
johndoe.log
Apples and organes.log
monkies and zebras.log
script would grab line 1(...
I have to sort a number of integers, which can have values between 30.000.000 and 350.000.000. There will be between 0 and 65.535 integers, with the average count being 20.000. RAM usage is irrelevant and speed only is important.
Later on i will also have to split them into groups, with the divide always being set whenever the gap betwe...
Given a week-day (1-7), how can I calculate what that week-day's last date was?
Example: Today is Wednesday, 2008/11/12, and I want to know what last Friday's date was.
...
I have a number of string arrays. The string in every array are ordered the same way, according the same criteria. However, some string may be missing from some arrays, and there may be no array that has a complete set of strings. Moreover, the criteria used to compare the strings is not available to me: outside of the context of the arr...
Does anyone know of an algorithm that I could use to find an "interesting" representative thumbnail for a video?
I have say 30 bitmaps and I would like to choose the most representative one as the video thumbnail.
The obvious first step would be eliminate all black frames. Then perhaps look for the "distance" between the various fram...
Inspired by this question and answer, how do I create a generic permutations algorithm in F#? Google doesn't give any useful answers to this.
EDIT: I provide my best answer below, but I suspect that Tomas's is better (certainly shorter!)
...
Hi all,
I have this routine that calculates the seconds-to-date for a struct tm. On Linux my implementation using mktime works fine, but
mktime on windows VS2003/.NET 1.1 returns -1 for pre-epoch datetimes.
How do I calculate meaningful time_t values (i.e.
value + secondsToEpoch == secondsToDatetime
) from a for pre-epoch dates...
Say we are traversing a graph and want to quickly determine if a node has been seen before or not. We have a few set preconditions.
Nodes have been marked with integers values 1..N
Graph is implemented with nodes having an adjacency list
Every integer value from 1..N occurs in the graph, which is of size N
Any ideas for doing this in...
In graph theory, what is the distinction between minimal distance (which Dijkstra's algorithm finds), and minimal path (which I'm not sure what it is)?
...
How would you describe the running time of this sort, given a function sorted which returns True if the list is sorted that runs in O(n):
def sort(l):
while not sorted(l): random.shuffle(l)
Assume shuffling is perfectly random.
Would this be written in big-O notation? Or is there some other way of categorizing algorithms with ra...
Hi,
Does anyone know a simple algorithm to check if a Sudoku-Configuration is valid? The simplest algorithm I came up with is (for a board of size n) in Pseudocode
for each row
for each number k in 1..n
if k is not in the row (using another for-loop)
return not-a-solution
..do the same for each column
But I'm quite sure ...
Over the years, I think I have seen and tried every conceivable way of generating stub data structures (fake data) for complex object graphs. It always gets hairy in java.
* * * *
A---B----C----D----E
(Pardon cheap UML)
The key issue is that there are certain relationships between the values, so a certain instance of C m...
I need an algorithm to determine if a sentence, paragraph or article is negative or positive in tone... or better yet, how negative or positive.
For instance:
Jason is the worst SO user I have ever witnessed (-10)
Jason is an SO user (0)
Jason is the best SO user I have ever seen (+10)
Jason is the be...
Suppose I have an interval (a,b), and a number of subintervals {(ai,bi)}i whose union is all of (a,b). Is there an efficient way to choose a minimal-cardinality subset of these subintervals which still covers (a,b)?
...
I need to sanitize HTML submitted by the user by closing any open tags with correct nesting order. I have been looking for an algorithm or Python code to do this but haven't found anything except some half-baked implementations in PHP, etc.
For example, something like
<p>
<ul>
<li>Foo
becomes
<p>
<ul>
<li>Foo</li>
</ul...
Is there a site like "language shootout"'s (shootout.alioth.debian.org and dada.perl.it/shootout/), which show how to do simple/advanced things in different languages? I.e. how to use hashes in different languages, how to sort, how to write classes, how to connect to sites, etc.. Well, those two above ARE in fact examples of what I'd lik...