Hi,
I want to create an object, let's say a Pie.
class Pie
def initialize(name, flavor)
@name = name
@flavor = flavor
end
end
But a Pie can be divided in 8 pieces, a half or just a whole Pie. For the sake of argument, I would like to know how I could give each Pie object a price per 1/8, 1/4 or per whole. I could d...
In my graduate class on compiler construction we've been introduced to the concept of a lattice. Three lectures have been devoted to lattices and so far it seems like an interesting tangent, but the dilemma is that it doesn't really help explain how a compiler uses a lattice to solve a concrete problem.
We have already covered parsing ...
This is not a homework. I am asking to see if problem is classical (trivial) or non-trivial. It looks simple on a surface, and I hope it is truly a simple problem.
Have N points (N >= 2) with
coordinates Xn, Yn on a surface of
2D solid body.
Solid body has some small rotation (below Pi/180)
combined with small shifts (below 1% of di...
Is there any tricky way to implement a set data structure (a collection of unique values) in C? All elements in a set will be of the same type and there is a huge RAM memory.
As I know, for integers it can be done really fast'N'easy using value-indexed arrays. But I'd like to have a very general Set data type. And it would be nice if a...
We're making this web app in PHP and when working in the reports we have Excel files to compare our results to make sure our coding is doing the right operations.
Now we're running into some differences due floating point arithmetics. We're doing the same divisions and multiplications and running into slightly different numbers, that ad...
Hi,
I am doing a lot of image processing in C and I need a good, reasonably lightweight, and above all FAST matrix manipulation library with a permissive license. I am mostly focussing on affine transformations and matrix inversions, so i do not need anything too sophisticated or bloated.
Primarily I would like something that is very f...
Does Actionscript have a function that would tell me what number the input is a square root of. For example:
4 //output 2, because 4 is the square root of 2
16 //output 4, because 16 is the square root of 4
...
I need an formula for determining a debt payoff plan where the following are known: number of payments, amount per payment, and principal and need to figure out what the interest rate would be from that. I am re-factoring existing code and the current method uses the following (compounded = 12;interest rate starts at .1) :
while (count...
I wrote a program in java that rolls a die and records the total number of times each value 1-6 is rolled. I rolled 6 Million times. Here's the distribution:
#of 0's: 0
#of 1's: 1000068
#of 2's: 999375
#of 3's: 999525
#of 4's: 1001486
#of 5's: 1000059
#of 6's: 999487
(0 wasn't an option.)
Is this distribution consistant with random...
I'm writing a custom dice rolling parser (snicker if you must) in python. Basically, I want to use standard math evaluation but add the 'd' operator:
#xdy
sum = 0
for each in range(x):
sum += randInt(1, y)
return sum
So that, for example, 1d6+2d6+2d6-72+4d100 = (5)+(1+1)+(6+2)-72+(5+39+38+59) = 84
I was using regex to replace all...
I am trying to embed Maths Symbols and Equations in Ajax Editor.
or provide some solution to implement maths symbols and equations in my application using rich textbox or some controls/plugins.
Thank you.
...
I am using the following code to work out an inc and ext VAT price:
$('#totalexvat').text(totalprice);
var vat = totalprice / 100 * 17.5;
vat = roundNumber(vat,2);
$('#totalincvat').text(totalprice-vat);
Sometimes i get .3 or .9 instead of what I would like to be .30 or .90 because it's money, is there a way to do this?
...
This is a homework, but please give me some ideas, i have no idea what to do. Here's the task:
For given integers N and K (1 <= N, K <= 2000000000) you have to find the number of digits of N^K.
Is there any formula or something ? Because i tried solving it by simply powering N**K but it's not working for large values and the program si...
In our software we have a camera based on mouse movement, and a quarternion at its heart.
We want to fire projectiles from this position, which we can do, however we want to use the camera to aim. The projectile takes a vector which it will add to its position each game frame.
How do we acquire such a vector from a given camera/quatern...
I've inherited a Visual Studio/VB.Net numerical simulation project that has a likely inefficient calculation. Profiling indicates that the function is called a lot (1 million times plus) and spends about 50% of the overall calculation within this function. Here is the problematic portion
Result = (A * (E ^ C)) / (D ^ C * B) (where A-C...
i have latitude and longitude of particular place and i want to calculate the distance so how can i calculate it?
...
Well, we all know that if N is given it's easy to calculate N!. But what about reversing?
N! is given and you are about to find N - Is that possible ? I'm curious.
...
I want to make a function in C that can return PI to X places..
I'm just not sure how...
Thanks
Edit: I don't care how slow it is I really just want an algorithm that will return PI at X decimal... Iv been looking at http://bellard.org/pi/ but I don't understand how to get the nth of Pi from this. Thanks
...
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...
Given the triangle with vertices (a,b,c):
c
/ \
/ \
/ \
a - - - - b
Which is then subdivided into four triangles by halving each of the edges:
c
/ \
/ \
ca / \ bc
_ _ _
/\ /\
/ \...