I am developing a rails application where I need a "success rate" system similar to RetailMeNot. I noticed that they use jQuery Sparkline library (http://omnipotent.net/jquery.sparkline/) to generate a success rate trend for each coupon.
For example, in their source code:
<em>84%</em> Success<br/><span class="trend">14,18,18,22,19,16,1...
How a bank calculate home loan's payments?
For example,
$1,000,000 at 5.00% over a 25 year period.
Monthly payment: $5,845.90
Current Payment To Date
Payment -------------------------- ----------------------------------------------
Number Interest Principal Inter...
I have a bunch of vectors normal to window surfaces in a 3D modelling software. Projected to the XY-Plane, I would like to know in which direction they are facing, translated to the 8 compass coordinates (North, North-East, East, South-East, South, South-West, West and North-West).
The vectors work like this:
the X axis represents Eas...
Ok, this is an interesting problem I think
I have a list of items in a db, which have authors. (1 to 1 relationship, "authorId" is the foreign key).
I need to get a list of letters in the alphabet which have a user to match it (by Surname)
For instance, lets pretend there are only 3 items in the db. They were contributed by Mr Car, Mr...
I've got a table defined like this :
create table #tbFoo
(bar float)
And I'm looking for a way to round every value contained in column bar without changing the total sum (which is known to be an integer, or very close to an integer because of float number precision).
Rounding every value to the nearest integer won't work (ex : 1,5;...
I wrote a drawing function that draws various on-screen sprites. These sprites can only overlap up to a point. If they have to much overlap, they become too obscured. As a result I need to detect when these sprites are too much overlapped. Luckily, the problem is simplified in that the sprites can be treated as orthogonal rectangles. I'd...
I'm looking for an efficient algorithm to do string tiling. Basically, you are given a list of strings, say BCD, CDE, ABC, A, and the resulting tiled string should be ABCDE, because BCD aligns with CDE yielding BCDE, which is then aligned with ABC yielding the final ABCDE.
Currently, I'm using a slightly naïve algorithm, that works as f...
Here is the problem, it is from Sedgwick's excellent Algorithms in Java (q 3.54)
Given a link to a node in a singly linked list that contains no null links (i.e. each node either links to itself or another node in the list) determine the number of different nodes without modifying any of the nodes and using no more than constant memory ...
If I have both the initial key and the hash that was created, is there any way to determine the hash algorithm?
For example:
Key: higher
Hash: df072c8afcf2385b8d34aab3362020d0
Algorithm = ?
...
In class we were given a simple decision tree for sorting 3 elements (a,b,c).
While looking at this, it makes sense to me. I was able to follow it.
However, I now have to make a decision tree for 4 elements (a,b,c,d) and the number of leafs just shot up to 24.
I'm struggling approaching the decision tree in a methodical way that h...
A complete binary tree is defined as a binary tree in which every level, except possibly the deepest, is completely filled. At deepest level, all nodes must be as far left as possible.
I'd think a simple recursive algorithm will be able to tell whether a given binary tree is complete, but I can't seem to figure it out.
...
Hello,
I have a few sets which are like
SET A(1,2,3,11,10) - $30
SET B(2,5,8) - $20
SET C(6) -$25
SET D(6,8) -$30
SET E(7,5) -$20
SET F(5,6,7,8,9,10) -$60
.
.
.
and so on...
All are random,
Now consider sets D,E and F
I want to buy the cheapest combination for a set, SET Q(7,8,6,5)
the answer ...
Can you make it more simple/elegant?
def zigzag(seq):
"""Return two sequences with alternating elements from `seq`"""
x, y = [], []
p, q = x, y
for e in seq:
p.append(e)
p, q = q, p
return x, y
...
I have data that looks like this:
my @homopol = (
["T","C","CC","G"], # part1
["T","TT","C","G","A"], #part2
["C","CCC","G"], #part3 ...upto part K=~50
);
my @prob = ([1.00,0.63,0.002,1.00,0.83],
[0.72,0.03,1.00, 0.85,1.00],
...
I need a bit of help with is this code. I know the sections that should be recursive, or at least I think I do but am not sure how to implement it. I am trying to implement a path finding program from an alignment matrix that will find multiple routes back to the zero value. For example if you excute my code and insert CGCA as the first ...
Those who have worked or working in artificial intelligence(or equivalent) area should be knowing the AO* algorithm very well.
Its pretty clear that it is a generalized algorithm.
Do anybody of you have come across any practical application of the AO* algorithm?Some of you might already have worked on it.
So it would be great if you c...
People can belong to one or many groups. What is a good algorithm to output common memberships?
ie, Persons A and B are in Groups C, D, and E ... etc
My preferred language would be Ruby (or maybe Python), but any code or pseudocode would be greatly appreciated.
...
Let's say I have a table with a bunch of dates, e.g.:
declare @tbl table {
idx int primary key,
startdate datetime,
enddate datetime
}
And I want to find the largest set of rows where startdate and enddate intersect (in the real world, the start date and end date represents start and end times for events, and I need to fin...
from Wikipedia:
Lexicographical order generation
For every number k, with 0 ≤ k < n!,
the following algorithm generates the
corresponding lexicographical
permutation of the initial sequence
sj, j = 1, ..., n:
function permutation(k, s) {
var int n:= length(s); factorial:= 1;
for j= 2 to n- 1 { // compu...
from Wikipedia: fourier division.
Here is a screenshot of the same:
(view in full-resolution)
What is the logic behind this algorithm?
I know it can be used to divide very large numbers, but how exactly does it work?
...