text
stringlengths
0
27.6k
python
int64
0
1
DeepLearning or NLP
int64
0
1
Other
int64
0
1
Machine Learning
int64
0
1
Mathematics
int64
0
1
Trash
int64
0
1
I'm trying to make the ball bounce off of the top and bottom 'Walls' of my UI when creating a 2D Pong Clone. This is my Game.cs public void CheckBallPosition() { if (ball.Position.Y == 0 || ball.Position.Y >= graphics.PreferredBackBufferHeight) ball.Move(true); else ball.Move(false); if (ball.Position.X < 0 || ball.Position.X >= graphics.PreferredBackBufferWidth) ball.Reset(); } At the moment I'm using this in my Ball.cs public void Move(bool IsCollidingWithWall) { if (IsCollidingWithWall) { Vector2 normal = new Vector2(0, 1); Direction = Vector2.Reflect(Direction,normal); this.Position += Direction; Console.WriteLine("WALL COLLISION"); } else this.Position += Direction; } It works, but I'm using a manually typed Normal and I want to know how to calculate the normal of the top and bottom parts of the screen?
0
0
0
0
1
0
Can the Stanford Parser find instances of cataphora and anaphora in a given set of sentences? Are there any alternative open-source (or proprietary) software packages that are capable of coreference resolution?
0
1
0
0
0
0
I've a huge list (60 000+) of coordinates and I haven't found a way for recognizing the outer borders. The list of coordinates are quite random, but they're defining some really specific area. I should be able to draw an area by using that list by using OpenLayers, so they also should in order. This seemed to be relatively easy nut to break but has proven to be quite challenging. What might be the best approach for this problem? Heikki
0
0
0
0
1
0
What's the best way to convert the quotient of two C# BigIntegers while retaining as much precision as possible? My current solution is: Math.Exp(BigInteger.Log(dividend) - BigInteger.Log(divisor)); I'm guessing this is suboptimal.
0
0
0
0
1
0
EDIT I don't know is it important, but destination triangle angles may be different than these of source. Does that fact makes transformation non-affine ? (i'm not sure) I have two triangles in 3D space. Given that i know (x,y,z) of point in first triangle and i know vectors V1,V2,V3. I need to find point (x',y',z'). What transformation i should do to point (x,y,z) with vectors V1,V2,V3 to get that transformed point in the second triangle ? Thanks for help !!!
0
0
0
0
1
0
It seems my Google-fu is failing me. Does anyone know of a freely available word base dictionary that just contains bases of words? So, for something like strawberries, it would have strawberry. But does NOT contain abbreviations or misspellings or alternate spellings (like UK versus US)? Anything quickly usable in Java would be good but just a text file of mappings or anything that could be read in would be helpful.
0
1
0
0
0
0
Basically, I need to generate a list of all seven-digit numbers (for example, 1461979) from 0000000 to 9999999. I know there are 10^7 of them (ten million), but I can't think of an efficient function to output them. I'm sure there's a generic function out there that can do it - preferably in PHP, but I can port it if need be.
0
0
0
0
1
0
I have two histograms. int Hist1[10] = {1,4,3,5,2,5,4,6,3,2}; int Hist1[10] = {1,4,3,15,12,15,4,6,3,2}; Hist1's distribution is of type multi-modal; Hist2's distribution is of type uni-modal with single prominent peak. My questions are Is there any way that i could determine the type of distribution programmatically? How to quantify whether these two histograms are similar/dissimilar? Thanks
0
0
0
0
1
0
I'm making a simple program in Java. Given a set of letters it'll list all the words (with more than 2 letters) that match the combinations of the letters. For example: Is the given word is ward. The result should be: ward. raw, daw, war, rad I have in a sqlite database a huge list o English words in the original form and sorted by letter, this make the selections faster. The database schema looks like: dictionary: {id, word, length} anagram: {id, anagram, length} anagram_dictionary: {id, word_id, anagram_id} With the same example: When the word raw is inserted It search for arw, and the results give back raw, war My problem resides that every time I do a search it do the math of the combinations of the letters I given. For the example it makes this math: 4!/(4!*1!) + 4!/(3!*1!) = 5 My problem is that the given letters length is 16. So I have to make combinations of 16 in 16 + combinations of 16 in 15 + ... + combinations of 16 in 1 I need to improve the method because it takes ages to give a simple result, but I don't now how? So I try to store in the database, but can't figure out how? Thanks in advance
0
0
0
0
1
0
I've been doing some preliminary research in the area of message digests. Specifically collision attacks of cryptographic hash functions such as MD5 and SHA-1, such as the Postscript example and X.509 certificate duplicate. From what I can tell in the case of the postscript attack, specific data was generated and embedded within the header of the postscript file (which is ignored during rendering) which brought about the internal state of the md5 to a state such that the modified wording of the document would lead to a final MD value equivalent to the original postscript file. The X.509 took a similar approach where by data was injected within the comment/whitespace sections of the certificate. Ok so here is my question, and I can't seem to find anyone asking this question: Why isn't the length of ONLY the data being consumed added as a final block to the MD calculation? In the case of X.509 - Why is the whitespace and comments being taken into account as part of the MD? Wouldn't a simple processes such as one of the following be enough to resolve the proposed collision attacks: MD(M + |M|) = xyz MD(M + |M| + |M| * magicseed_0 +...+ |M| * magicseed_n) = xyz where : M : is the message |M| : size of the message MD : is the message digest function (eg: md5, sha, whirlpool etc) xyz : is the pairing of the acutal message digest value for the message M and |M|. <M,|M|> magicseed_{i}: Is a set of random values generated with seed based on the internal-state prior to the size being added. This technqiue should work, as to date all such collision attacks rely on adding more data to the original message. In short, the level of difficulty involved in generating a collision message such that: It not only generates the same MD But is also comprehensible/parsible/compliant and is also the same size as the original message, is immensely difficult if not near impossible. Has this approach ever been discussed? Any links to papers etc would be nice. Further Question: What is the lower bound for collisions of messages of common length for a hash function H chosen randomly from U, where U is the set of universal hash functions ? Is it 1/N (where N is 2^(|M|)) or is it greater? If it is greater, that implies there is more than 1 message of length N that will map to the same MD value for a given H. If that is the case, how practical is it to find these other messages? bruteforce would be of O(2^N), is there a method of time complexity less than bruteforce?
0
0
0
0
1
0
Giving a distance an a waypoint, how to i determine the new waypoint? 106642.947 feet from N 43° 11.543 W 073° 39.451 38425.157 feet from N 42° 50.883 W 073° 53.350 22804.598 feet from N 42° 54.613 W 073° 41.477 89405.494 feet from N 43° 08.800 W 073° 52.700 52595.477 feet from N 42° 47.361 W 073° 40.521 63324.857 feet from N 43° 03.150 W 073° 55.050 252303.651 feet fromN 43° 32.983 W 073° 24.283 No directions/headings or (azimuths) Answer is great! Hints are good, your choice how you want to answer it this is not homework, this is a g e o c a c h e p u z z l e
0
0
0
0
1
0
This should be very simple. I have a function f(x), and I want to evaluate f'(x) for a given x in MATLAB. All my searches have come up with symbolic math, which is not what I need, I need numerical differentiation. E.g. if I define: fx = inline('x.^2') I want to find say f'(3), which would be 6, I don't want to find 2x
0
0
0
0
1
0
Assuming you are working with two 8-bit unsigned values like from a timer. If you record a stop time and a start time, and subtract start from stop to get the elapsed time, do you need to use mod to handle roll overs or does the subtraction just work out? For example say start time = 11111100 and the end time = 00000101 would (00000101 - 11111100) give you the correct result?
0
0
0
0
1
0
I'm trying to figure out how to make a test in my xsl transformation using absolute values. Something like this: <xsl:when test="abs(/root/values/mean) &lt; /root/thresholds/min"> <xsl:attribute name="style">background-color:red;</xsl:attribute> </xsl:when> Is that possible. I've tried using templates, but it seemed the wrong path. Moving to XSLT 2.0 did not work for me either (I guess Firefox 3.6 do not support it). Any thoughts?
0
0
0
0
1
0
This is an interview question I came across: find K first digits of the decimal representation of 1/N. It looks like we need just calculate 10^K/N to solve the problem. Does it make sense ? It looks like I am missing something because the solution is too easy.
0
0
0
0
1
0
Can you simplify this Math.Ceiling expression decimal total decimal? quantity, multiplier int? days total = (decimal)Math.Ceiling((double)quantity.Value * (double)days.Value * (double)multiplier); EDIT I forgot to mention that this is Silverlight code, hence all the casts into double.
0
0
0
0
1
0
a=2^Power[10^6, 10^9] 3^Power[4^9, 7^5] TwoTower[n_] := Nest[2^# &, 1, n] What's the smallest n such that TwoTower[n]>a? This question had a pen-and-paper answer on Quora, is there a way to use Mathematica here?
0
0
0
0
1
0
I have 160 bits of random data. Just for fun, I want to generate pseudo-English phrase to "store" this information in. I want to be able to recover this information from the phrase. Note: This is not a security question, I don't care if someone else will be able to recover the information or even detect that it is there or not. Criteria for better phrases, from most important to the least: Short Unique Natural-looking The current approach, suggested here: Take three lists of 1024 nouns, verbs and adjectives each (picking most popular ones). Generate a phrase by the following pattern, reading 20 bits for each word: Noun verb adjective verb, Noun verb adjective verb, Noun verb adjective verb, Noun verb adjective verb. Now, this seems to be a good approach, but the phrase is a bit too long and a bit too dull. I have found a corpus of words here (Part of Speech Database). After some ad-hoc filtering, I calculated that this corpus contains, approximately 50690 usable adjectives 123585 nouns 15301 verbs 13010 adverbs (not included in pattern, but mentioned in answers) This allows me to use up to 16 bits per adjective (actually 16.9, but I can't figure how to use fractional bits) 15 bits per noun 13 bits per verb 13 bits per adverb For noun-verb-adjective-verb pattern this gives 57 bits per "sentence" in phrase. This means that, if I'll use all words I can get from this corpus, I can generate three sentences instead of four (160 / 57 ≈ 2.8). Noun verb adjective verb, Noun verb adjective verb, Noun verb adjective verb. Still a bit too long and dull. Any hints how can I improve it? What I see that I can try: Try to compress my data somehow before encoding. But since the data is completely random, only some phrases would be shorter (and, I guess, not by much). Improve phrase pattern, so it would look better. Use several patterns, using the first word in phrase to somehow indicate for future decoding which pattern was used. (For example, use the last letter or even the length of the word.) Pick pattern according to the first bytes of the data. ...I'm not that good with English to come up with better phrase patterns. Any suggestions? Use more linguistics in the pattern. Different tenses etc. ...I guess, I would need much better word corpus than I have now for that. Any hints where can I get a suitable one?
0
1
0
0
0
0
I'm more than half way through learning assembly and I'm familiar with the concept of how signed and unsigned integers are presented in bits, I know that it might seem a weird question of which the answer would be pretty obvious, but I'm wondering if using an arithmetic operation like addition makes sense for a pair of numbers that one of them is considered signed and the other one unsigned, I've thought of multiple examples like below that will yield a correct result: 10000001 (1-byte integer and considered unsigned, equivalent to 129) + 11111111 (1-byte integer and considered signed(two's complement system), equivalent to -1) 10000000 (1-byte integer and in unsigned logic equivalent to 128) Now if the upper value was in AL register and we had the following instruction code(in GAS format): addb -1, %al then the carry flag(CF) of EFLAGS register will be set after the operation's been done and would inform of an overflow that actually has not happened and maybe because there's one unsigned number in terms of an overflow the overflow flag(OF) of EFLAGS register should be referenced. So I'm confused if doing such thing is ever sensible.
0
0
0
0
1
0
Possible Duplicate: Is OOP based on any branch of mathematics? This is, allegedly, a strange question: are there any mathematical/logic foundations for the object-oriented paradigm? And, if so, is there a paper/book about it? Thanks.
0
0
0
0
1
0
If two circles intersect, how can I move inner circle upwards on Y axis untill it becomes tangent to the outer circle
0
0
0
0
1
0
what i'm trying to do is write a quadratic equation solver but when the solution should be -1, as in quadratic(2, 4, 2) it returns 1 what am i doing wrong? #!/usr/bin/python import math def quadratic(a, b, c): #a = raw_input("What's your `a` value?\t") #b = raw_input("What's your `b` value?\t") #c = raw_input("What's your `c` value?\t") a, b, c = float(a), float(b), float(c) disc = (b*b)-(4*a*c) print "Discriminant is: " + str(disc) if disc >= 0: root = math.sqrt(disc) top1 = b + root top2 = b - root sol1 = top1/(2*a) sol2 = top2/(2*a) if sol1 != sol2: print "Solution 1: " + str(sol1) + " Solution 2: " + str(sol2) if sol1 == sol2: print "One solution: " + str(sol1) else: print "No solution!" EDIT: it returns the following... >>> import mathmodules >>> mathmodules.quadratic(2, 4, 2) Discriminant is: 0.0 One solution: 1.0
0
0
0
0
1
0
I've tried to port the following sum in a php for loop this way: $prod = 1; for($i=0;$i<$_POST["capacity"];$i++){ $prod = $prod * (($_POST["capacity"] - (i+1)) / $toffered); } ?> p(c) is: <?php echo floatval(1.00/floatval((1+ floatval($prod)))); ?><br /> <br /> but for some reason it seems to give me the wrong result. Any hints on what is wrong? EDIT: i've modified the initial value of prod as well as adding brackets for i+1 which is subtracted from the capacity. The results aren't better still.
0
0
0
0
1
0
I have a bunch of points in a graph, and for every pair of these points I have "weight" value indicating what their proximity should be, between -1 and 1. I want to choose XY coordinates for these points such that those that have a proximity of 1 are in the same position, and those with a proximity of -1 are distant from each-other. All points must reside within a bounded area. What algorithms should I investigate to achieve this?
0
0
0
0
1
0
I have an object with which I would like to make follow a bezier curve and am a little lost right now as to how to make it do that based on time rather than the points that make up the curve. .::Current System::. Each object in my scene graph is made from position, rotation and scale vectors. These vectors are used to form their corresponding matrices: scale, rotation and translation. Which are then multiplied in that order to form the local transform matrix. A world transform (Usually the identity matrix) is then multiplied against the local matrix transform. class CObject { public: // Local transform functions Matrix4f GetLocalTransform() const; void SetPosition(const Vector3f& pos); void SetRotation(const Vector3f& rot); void SetScale(const Vector3f& scale); // Local transform Matrix4f m_local; Vector3f m_localPostion; Vector3f m_localRotation; // rotation in degrees (xrot, yrot, zrot) Vector3f m_localScale; } Matrix4f CObject::GetLocalTransform() { Matrix4f out(Matrix4f::IDENTITY); Matrix4f scale(), rotation(), translation(); scale.SetScale(m_localScale); rotation.SetRotationDegrees(m_localRotation); translation.SetTranslation(m_localTranslation); out = scale * rotation * translation; } The big question I have are 1) How do I orientate my object to face the tangent of the Bezier curve? 2) How do I move that object along the curve without just setting objects position to that of a point on the bezier cuve? Heres an overview of the function thus far void CNodeControllerPieceWise::AnimateNode(CObject* pSpatial, double deltaTime) { // Get object latest pos. Vector3f posDelta = pSpatial->GetWorldTransform().GetTranslation(); // Get postion on curve Vector3f pos = curve.GetPosition(m_t); // Get tangent of curve Vector3f tangent = curve.GetFirstDerivative(m_t); } Edit: sorry its not very clear. I've been working on this for ages and its making my brain turn to mush. I want the object to be attached to the curve and face the direction of the curve. As for movement, I want to object to follow the curve based on the time this way it creates smooth movement throughout the curve.
0
0
0
0
1
0
I would like to move some point a in two dimensional search space to another point b with some stepsize (_config.StepSize = 0.03). Point a = agent.Location; Point b = agentToMoveToward.Location; //--- important double diff = (b.X - a.X) + (b.Y - a.Y); double euclideanNorm = Math.Sqrt(Math.Pow((b.X - a.X), 2) + Math.Pow((b.Y - a.Y), 2)); double offset = _config.StepSize * ( diff / euclideanNorm ); agent.NextLocation = new Point(a.X + offset, a.Y + offset); //--- Is it correct?
0
0
0
0
1
0
Have an application using database persistence (entity framework, but not sure that matters) Given the following hypothetical layout: Where all of these objects derive from the AbstractBase. Container is an object that acts as a collection for an arbitrary number of AbstractBase-derived objects. Problem I want to create a restriction subsystem that will allow us to define the quantity of individual AbstractBase items that can be in a Container. For instance, Container can have zero Containers, can have zero or one Objects, must have exactly one AnotherObject, can have many AbstractObjects, etc. Simple way A field in AbstractBase called CountRestrictor that's a small int. This corresponds to an enum outside of the database holding an attribute. Problem: This is not contained in the database. A change to the database requires a change in that enum container (and thus a rebuild) of that assembly. Plus, I have to write math translation code elsewhere. Class-based way So, what about a class? The problem is that classes in the database require datatypes, so can we express this mathematical restriction as a datatype? Can I make a class that holds part of a lambda expression that can be later translated into an Expression item, for instance? I don't think so. Things I've Considered Embedded mathematical logic Maybe a CountObject with a CountObject.Restrictor attribute of type string that could be programmatically translated into an Expression object: CountObject lessThanTwo = new CountObject { Restrictor = "< 2" }; CountObject exactlyOne = new CountObject { Restrictor = "= 1" }; While inside the Container object I can have logic something like: … private Bool IsValidEntry<T>(T obj) where T : AbstractBase { Int count = this.AbstractBases.OfType<T>().Count; Expression expression = new Expression(); // No constructors defined, so not sure how // use obj.Restrictor to build the expression if (expression) // Add element else // throw Exception/Message dialog … } Is this possible? Is it advisable (since I'm injecting math into my database, though, not a lot) Manual string to math translation Another thing I considered is just using CountObject.Restrictor as a human readable string "Less that Two", "Exactly One", etc. and having another object outside the database that does translation: public class CountTranslator { private String _lessThanTwo = "Less than Two"; private String _exactlyOne = "Exactly One"; public String LessThanTwo { get { return _lessThanTwo; } } … } This would cleanly allow the use of Module.CountTranslator.LessThanTwo, but wouldn't be stored in the database, requiring a rebuild for changes. It would be sensitive to misspelling ("Less Than Two" != "Less than Two"), and would still require the building of "human to math" code: … Int count = container.AbstractBase.OfType<T>(); Int restrictor = obj.CountObject.Restrictor; switch(restrictor) { case CountTranslator.ExactlyOne // Have to make sure database record string spelled correctly if (count != 1) // do something … } But this strikes me as horribly ugly with a lot of conditional checking. Additive conditions Finally, I've considered additive conditions. AbstractBase has a many-to-many relationship with CountObject. public class CountObject { private Int _value; private String _expression; public Int Value { get { return _value; } } public String Expression { get { return _Expression; } } } public partial class Container : AbstractBase { … private Bool IsValidEntry<T>(T obj) where T : AbstractBase { Int count = AbstractBases.OfType<T>().Count; foreach (CountObject counter in obj.CountObjects) { switch(counter.Expression) { case "<": if (count > counter.Value) throw Exception; case "=": if (count != counter.Value) throw Exception; … } } } } Again, this is a lot of conditionals and switch statements. Coda Are there other ways to skin the cat? Perhaps a "Mathematical translation class" hidden in .NET somewhere? Is there one way that exemplifies Best Practices?
0
0
0
0
1
0
Possible Duplicates: How do you set, clear and toggle a single bit in C? Removing lowest order bit n is a positive integer. How can its rightmost set bit be unset? Say n= 7 => n = 0111. I want 0110 as the output. Is there any simple bitwise hack to achieve the goal?
0
0
0
0
1
0
The algorithm to convert input 8 digit hex number into 10 digit are following: Given that the 8 digit number is: '12 34 56 78' x1 = 1 * 16^8 * 2^3 x2 = 2 * 16^7 * 2^2 x3 = 3 * 16^6 * 2^1 x4 = 4 * 16^4 * 2^4 x5 = 5 * 16^3 * 2^3 x6 = 6 * 16^2 * 2^2 x7 = 7 * 16^1 * 2^1 x8 = 8 * 16^0 * 2^0 Final 10 digit hex is: => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 => '08 86 42 98 E8' The problem is - how to go back to 8 digit hex from a given 10 digit hex (for example: 08 86 42 98 E8 to 12 34 56 78) Some sample input and output are following: input output 11 11 11 11 08 42 10 84 21 22 22 33 33 10 84 21 8C 63 AB CD 12 34 52 D8 D0 88 64 45 78 96 32 21 4E 84 98 62 FF FF FF FF 7B DE F7 BD EF P.S. The problem I think is not limited to 8 or 10 digits. If the input is 11, the output would be 08.
0
0
0
0
1
0
Does anybody have any information about priority queues based on the 2-4 tree structure? I have been searching all day.. Any references from anyone who knows would be really appreciated.. Thank you.
0
0
0
0
1
0
so i got three variables, my location, my target location and the compass heading. how can i calculate where the target location should be represented on a virtual radar? i guess i first must calculate the distance between the two gps points and the angle of them relative to north or so. and then there should be a formula with sin or cos to place that point on a coordinate system...? ps: in javascript...
0
0
0
0
1
0
There is an automatic summarization tool in Winword. Does anybody know the background, i.e. which algorithms are used or where I can find additional background information concerning this feature? Thank you
0
1
0
0
0
0
I have a grass texture: I use it in my 2d-game. I want to animate it by code, without any predefined animations. The grass should interact with wind. So when the wind is stronger, the grass should stoop into need side more. First version of animation I made using sinusoid function, but such animation is a bit ugly, because the base of the grass moves left/right like all another part of picture. And with sinusoid I'm not able to regulate stoop of the image. Any advices?
0
0
0
0
1
0
I'm doing an expression valuation program, just like this. My problem is that I can't figure out how to handle operation precedences. I used recursion to find the innermost couple of parenthesis and, when found, solve the expression inside them, like this: Evaluate("2 + (3 * 5)") will re-call itself this way: Evaluate("3 * 5") now, since there aren't parenthesis, it calculates the result and calls itself another time: Evaluate("2 + 15") Ok, the return value is 17, as expected. But if I call Evaluate("2 + 3 * 5") the result is: Evaluate("2 + 3 * 5") Evaluate("5 * 5") Which is clearly wrong. Basically I'm solving operations from left to right. How can I chose the operations that must be performed first? I was thinking to add a couple of parenthesis surrounding every operation, but it doesn't look so good. So, do I need to parse the whole expression first o there's another way?
0
0
0
0
1
0
Hi I am trying to sum two function handles, but it doesn't work. for example: y1=@(x)(x*x); y2=@(x)(x*x+3*x); y3=y1+y2 The error I receive is "??? Undefined function or method 'plus' for input arguments of type 'function_handle'." This is just a small example, in reality I actually need to iteratively sum about 500 functions that are dependent on each other. EDIT The solution by Clement J. indeed works but I couldn't manage to generalize this into a loop and ran into a problem. I have the function s=@(x,y,z)((1-exp(-x*y)-z)*exp(-x*y)); And I have a vector v that contains 536 data points and another vector w that also contains 536 data points. My goal is to sum up s(v(i),y,w(i)) for i=1...536 Thus getting one function in the variable y which is the sum of 536 functions. The syntax I tried in order to do this is: sum=@(y)(s(v(1),y,z2(1))); for i=2:536 sum=@(y)(sum+s(v(i),y,z2(i))) end
0
0
0
0
1
0
Could somebody explain why the average number of steps for finding an item in an unsorted array data-structure is N/2?
0
0
0
0
1
0
i am drawing Arc through CGCOntext.I want to draw a string in the center Point of Arc.how can i fond the center point in the Arc which has been drawn through CGContext. CGContextSetAlpha(ctx, 0.5); CGContextSetRGBFillColor(ctx, color.red, color.green, color.blue, color.alpha ); CGContextMoveToPoint(ctx, cX, cY); CGContextAddArc(ctx, cX, cY, radious+10, (startDeg-90)*M_PI/180.0, (endDeg-90)*M_PI/180.0, 0); CGContextClosePath(ctx); CGContextFillPath(ctx);
0
0
0
0
1
0
I have the following code - private static void convert() { webservice.Sum[] test = new webservice.Sum[1]; webservice.feed CallWebService = new webservice.feed(); foreach(XElement el in turnip.Descendants("row")) { test[0].person = el.Descendants("var").Where ( x => (string)x.Attribute("name") == "person" ).SingleOrDefault().Attribute("value").Value; test[0].time = System.Convert.ToInt32(el.Descendants("var").Where ( x => (string)x.Attribute("name") == "time" ).SingleOrDefault().Attribute("value").Value); test[0].erase = System.Convert.ToInt32(el.Descendants("var").Where ( x => (string)x.Attribute("name") == "erase" ).SingleOrDefault().Attribute("value").Value); test[0]. available = el.Descendants("var").Where ( x => (string)x.Attribute("name") == "available" ).SingleOrDefault().Attribute("value").Value; test[0].external = el.Descendants("var").Where ( x => (string)x.Attribute("name") == "external" ).SingleOrDefault().Attribute("value").Value; CallWebService.updateFeed(test, year); } } What I need to do is to get the 'person' and 'time' elements in the test array to add up seperately. For instance they are getting read in from a csv, so if the csv had account with the values of , 10, 20 and 30. I would want it to show account as having the desired value of 60. Then the same with erase. These would be the desired values to be presented in the form when run, then the person values would be returned from the web service, if it came back 40 for account and not 60, that would show an error occuring. To make it clear right now I am getting a response from the web service, however it will not always be the desired value returned. The reulst from the webservice are returned on a web form, I want to have the results from the web service on the form (which I have) and what the results should definately be to compare or confirm the reults are correct. So on run time the form will tell me what the added up values of account are from the csv, then what the web service results have returned.
0
0
0
0
1
0
A colleague came to me with a problem that I managed to answer but I don't know if my answer is right or even good... He is creating a program to compare data in various files - in this case excel spreadsheets. He has a list of comparisons which will boil down to two files with references to cells in them. For each comparison it is necessary to open the files, do the comparison and then close the files. Of course this can be optimised if you order the comparisons such that you can keep one file and just change the other. So how should you sort the files to minimise the number of times you need to close and open files? It should be noted that the idea of just having all files open is not feasible since there could be over 500 different spreadsheets being compared. My solution was to find the table that occurs in most comparisons and process all the comparisons involving that first. Then repeat the process ignoring all the comparisons that have already been done. I am wondering if when you process that first batch you want to do the least common ones first, ending up with the most common appearing table - this is then the table you process next (meaning still only one file change). So can anybody either give me a better option or confirm that my idea is good (or good enough)? Concrete example: Here is an example list of comparisons with a note next to them showing how many files need to be unloaded and loaded each time. eg after Comparing fileA and fileB it only needs to unload FileB and load FileC to do the next compariosn. After comparing FileA and FileF it needs to unload both to load FileB and FileC. FileA FileB FileA FileC One file change FileA FileD One file change FileA FileE One file change FileA FileF One file change FileB FileC Two file changes FileB FileF One file change FileC FileD Two file changes FileC FileE One file change FileD FileF Two file changes FileE FileF One file change In theory in this example the order of the comparisons can be rearranged to make it so that at each step you only need to unload and reload one file. FileA FileB FileA FileD One file change FileA FileE One file change FileA FileF One file change FileA FileC One file change FileB FileC One file change FileC FileD One file change FileC FileE One file change FileE FileF One file change FileB FileF One file change FileD FileF One file change So what I want to know is what the best algorithm is to sort the file pairs to get the minimum number of total file unload/load operations. I should note that it is not always going to be posible to get it down to one file change each time as demonstrated by the trivial pair of comparisons below: FileA FileB FileC FileD Two file changes
0
0
0
0
1
0
I have a high traffic web site. I want to create software which analyses client requests on-the-fly and decide if they come from a real user or a botnet bot. For training the neural network to identify legitimate ("good") users I can use logs when there are no DDoS activity. Once trained, the network would distinguish real users from bots. What I have: request URI (and order) cookie user agent request frequency. Any ideas on how to best design ANN for this task and how to tune it? Edit: [in response to comments about the overly broad scope of this question] I currently have a working C# program which blocks clients on the basis the frequency of identical requests. Now I'd like to improve its "intelligence" with a classifier based on neural network. I don't know how to normalize these inputs for ANN and I need suggestions in this specific area.
0
1
0
0
0
0
I'm writing an RSS reader in python as a learning exercise, and I would really like to be able to tag individual entries with keywords for searching. Unfortunately, most real-world feeds don't include keyword metadata. I currently have about 60,000 entries in my test database from about 600 feeds, so manually tagging is not going to be effective. So far I have only been able to find two solutions: 1: Use Natural Language Toolkit to extract keywords: Pros: flexible; no dependencies on external services; Cons: can only index the article summary, not the article; non-trivial: writing a high quality keyword extraction tool is a project in itself; 2: Use the Google Adwords API to fetch keyword suggestions from the article url: Pros: Super high quality keywords; based on entire article text; easy to use; Cons: Not free(?); Query rate limits unknown; I'm terrified of getting my account banned and not being able to run adwords campaigns for my commercial sites; Can anyone offer any suggestions? Are my fears about getting my adwords account banned unfounded?
0
1
0
0
0
0
I have a string variable, $operation, that can have values like + or - and two integer variables $initial and $unit. So to echo the result of the arithmetic operation between them I have to use something like if($operation == '+') echo ($initial + $unit); if($operation == '-') echo ($initial - $unit); Is there a way I can do this without the IF?
0
0
0
0
1
0
if anyone could answer me why this works, it would be greatly appreciated. The exercise (chapter 4, ex 7 and 8) says that if you have the expression: 9 - ((total - 1) % 10) then, you could be tempted to simplify it like this: 10 - (total % 10) But this would not work. Instead he offers the alternative: (10 - (total % 10)) % 10 Now, I understand how he got to the first simplification, but not why it's wrong, or why does the second one works. Thanks in advance
0
0
0
0
1
0
How come the number N! can terminate in exactly 1,2,3,4, or 6 zeroes by never 5 zeroes?
0
0
0
0
1
0
I have to finding any solution (there may exist many or none) of any number of given liner equations with any number of variables. In Java. What libraries and method use? What to implement? I want to make it with at least work as possible.
0
0
0
0
1
0
Assuming an alphanumeric password of 8 characters the amount of permutations by my understanding would be. 26 lowercase 26 uppercase 10 digits So if you were to do a brute force attack on this password the amount of tries on average would be (62 ^ 8) / 2 However assuming you knew that the password was at least 4 digits long and therefore excluded any attempts on the first 4 digits would the answer to the remaining permutations not be ((62 ^ 8) – (62 ^ 4)) / 2 ? Am I missing something here or is that the correct answer?
0
0
0
0
1
0
I have decided to play around with some simple concepts involving neural networks in Java, and in adapting somewhat useless code I found on a forum, I have been able to create a very simple model for the typical beginner's XOR simulation: public class MainApp { public static void main (String [] args) { Neuron xor = new Neuron(0.5f); Neuron left = new Neuron(1.5f); Neuron right = new Neuron(0.5f); left.setWeight(-1.0f); right.setWeight(1.0f); xor.connect(left, right); for (String val : args) { Neuron op = new Neuron(0.0f); op.setWeight(Boolean.parseBoolean(val)); left.connect(op); right.connect(op); } xor.fire(); System.out.println("Result: " + xor.isFired()); } } public class Neuron { private ArrayList inputs; private float weight; private float threshhold; private boolean fired; public Neuron (float t) { threshhold = t; fired = false; inputs = new ArrayList(); } public void connect (Neuron ... ns) { for (Neuron n : ns) inputs.add(n); } public void setWeight (float newWeight) { weight = newWeight; } public void setWeight (boolean newWeight) { weight = newWeight ? 1.0f : 0.0f; } public float getWeight () { return weight; } public float fire () { if (inputs.size() > 0) { float totalWeight = 0.0f; for (Neuron n : inputs) { n.fire(); totalWeight += (n.isFired()) ? n.getWeight() : 0.0f; } fired = totalWeight > threshhold; return totalWeight; } else if (weight != 0.0f) { fired = weight > threshhold; return weight; } else { return 0.0f; } } public boolean isFired () { return fired; } } In my main class, I've created the simple simulation in modeling Jeff Heaton's diagram: However, I wanted to ensure my implementation for the Neuron class is correct..I've already tested all possible inputs ( [true true], [true false], [false true], [false false]), and they all passed my manual verification. Additionally, since this program accepts the inputs as arguments, it also seems to pass manual verification for inputs such as [true false false], [true true false], etc.. But conceptually speaking, would this implementation be correct? Or how can I improve upon it before I start further development and research into this topic? Thank you!
0
1
0
0
0
0
I have N points in a set V given by their coordinates and a number K (0 < K < N). I need to determine K circles (disks) with the same radius R, with their centers in points in the V set. These circles have to 'cover' all the N points and R is the smallest possible. Can anyone help me with this?
0
0
0
0
1
0
I am trying to run the coreNLP package with the following program package corenlp; import edu.stanford.nlp.pipeline.*; import java.io.IOException; /** * * @author Karthi */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException, ClassNotFoundException { // TODO code application liogic here String str="-cp stanford-corenlp-2010-11-12.jar:stanford-corenlp-models-2010-11-06.jar:xom-1.2.6.jar:jgrapht-0.7.3.jar -Xms3g edu.stanford.nlp.pipeline.StanfordCoreNLP [ -props <Main> ] -file <input.txt>"; args=str.split(" "); StanfordCoreNLP scn=new StanfordCoreNLP(); scn.main(args); } } I am not sure if the code itself is correct, but am getting the following error Searching for resource: StanfordCoreNLP.properties Searching for resource: edu/stanford/nlp/pipeline/StanfordCoreNLP.properties Loading POS Model [edu/stanford/nlp/models/pos-tagger/wsj3t0-18-left3words/left3words-distsim-wsj-0-18.tagger] ... Loading default properties from trained tagger edu/stanford/nlp/models/pos-tagger/wsj3t0-18-left3words/left3words-distsim-wsj-0-18.tagger Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/wsj3t0-18-left3words/left3words-distsim-wsj-0-18.tagger ... Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:704) at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:649) at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:268) at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:228) at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:57) at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:44) at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:441) at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:434) at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:62) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:309) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:347) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:337) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:329) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:319) at corenlp.Main.main(Main.java:22) Java Result: 1 I tried giving these values in VM options in netbeans, but for each value i am getting error -Xms3g run: Error occurred during initialization of VM Incompatible initial and maximum heap sizes specified Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) -Xmx3g run: Error occurred during initialization of VM Could not create the Java virtual machine. Could not reserve enough space for object heap Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) -Xms3g -Xmx4g run: Could not create the Java virtual machine. Invalid maximum heap size: -Xmx4g The specified size exceeds the maximum representable size. Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)
0
1
0
0
0
0
To move objects with a variable time step I just have to do: ship.position += ship.velocity * deltaTime; But when I try this with: ship.velocity += ship.power * deltaTime; I get different results with different time steps. How can I fix this? EDIT: I am modelling an object falling to the ground on one axis with a single fixed force (gravity) acting on it.
0
0
0
0
1
0
I can not find anything wrong with the following code, whence the MSVC# compiler stores NAN in "c": double c = Math.Pow(-8d, 1d / 3d); While I think this line should calculate -2 for "c", the compiler stores NAN in "c"? Am i wrong about anything?
0
0
0
0
1
0
I am following a probably well-known tutorial about Kalman filter. From these lines of code: figure; plot(t,pos, t,posmeas, t,poshat); grid; xlabel('Time (sec)'); ylabel('Position (feet)'); title('Figure 1 - Vehicle Position (True, Measured, and Estimated)') I understand that x is the true position, y is measured position, xhat is estimated position. Then, if we can compute x (this code: x = a * x + b * u + ProcessNoise;), why do we need to estimated x anymore?
0
0
0
0
1
0
I'm trying a very simple case using a Python library called pyBrain and I can't get it to work. There is likely to be a very simple reason, so, I hope someone can help! 1) A simple XOR works fine. 2) Classifying the led's displayed on a digital clock to the numerical output value works fine. e.g. [ 1. 1. 1. 0. 1. 1. 1.] => [ 0.] [ 0. 0. 1. 0. 0. 1. 0.] => [ 1.] [ 1. 0. 1. 1. 1. 0. 1.] => [ 2.] [ 1. 0. 1. 1. 0. 1. 1.] => [ 3.] [ 0. 1. 1. 1. 0. 1. 0.] => [ 4.] [ 1. 1. 0. 1. 0. 1. 1.] => [ 5.] [ 1. 1. 0. 1. 1. 1. 1.] => [ 6.] [ 1. 0. 1. 0. 0. 1. 0.] => [ 7.] [ 1. 1. 1. 1. 1. 1. 1.] => [ 8.] [ 1. 1. 1. 1. 0. 1. 1.] => [ 9.] 3) Classifying a numerical value to the led output to drive a digital display doesn't work. e.g. [ 0.] => [ 1. 1. 1. 0. 1. 1. 1.] etc etc (as above but reversed). I'm using a simple linear activator with 10 inputs, 1 output and i've tried >12 neurons in the hidden layer. My confusion is that, shouldn't the network be able to remember the pattern with 10 neurons in the hidden layer? I'm sure there is something obvious I'm missing, so, please feel free to enlighten my stupidity!
0
1
0
0
0
0
MathWorld page gives a simple numeric formula for e that's allegedly correct for first 10^25 digits. It states that e is approximately (1 + 9^-4^(7*6))^3^2^85 Any idea how to check whether this formula is correct even for the first 10 digits? Here's another way of writing the right hand side Power[Plus[1, Power[9, Times[-1, Power[4, Times[7, 6]]]]], Power[3, Power[2, 85]]]
0
0
0
0
1
0
I've been working in Sql server jobs since 2 years now. Although I like it, sometimes I get the feeling that at certain times, I stall too much on some tasks, and I seem to be discouraged easily from things that involve relatively simple logic. It's like, at some point I must repeat a logical condition inside my head more than 2 or 3 times in order to understand it completely. I have the feeling that this might be of my lack of math knowledge. Can anyone please let me know what area of mathematics I can study, that would improve my Sql server coding skills? Thank you.
0
0
0
0
1
0
Challenge Here is the task, inspired by the well-known British TV game show Countdown. The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications. And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late Richard Whitely in 1997. You are given 6 numbers, chosen at random from the set {1, 2, 3, 4, 5, 6, 8, 9, 10, 25, 50, 75, 100}, and a random target number between 100 and 999. The aim is to use the six given numbers and the four common arithmetic operations (addition, subtraction, multiplication, division; all over the rational numbers) to generate the target - or as close as possible either side. Each number may only be used once at most, while each arithmetic operator may be used any number of times (including zero.) Note that it does not matter how many numbers are used. Write a function that takes the target number and set of 6 numbers (can be represented as list/collection/array/sequence) and returns the solution in any standard numerical notation (e.g. infix, prefix, postfix). The function must always return the closest-possible result to the target, and must run in at most 1 minute on a standard PC. Note that in the case where more than one solution exists, any single solution is sufficient. Examples: {50, 100, 4, 2, 2, 4}, target 203 e.g. 100 * 2 + 2 + (4 / 4) (exact) e.g. (100 + 50) * 4 * 2 / (4 + 2) (exact) {25, 4, 9, 2, 3, 10}, target 465 e.g. (25 + 10 - 4) * (9 * 2 - 3) (exact) {9, 8, 10, 5, 9, 7}, target 241 e.g. ((10 + 9) * 9 * 7) + 8) / 5 (exact) {3, 7, 6, 2, 1, 7}, target 824 e.g. ((7 * 3) - 1) * 6 - 2) * 7 (= 826; off by 2) Rules Other than mentioned in the problem statement, there are no further restrictions. You may write the function in any standard language (standard I/O is not necessary). The aim as always is to solve the task with the smallest number of characters of code. Saying that, I may not simply accept the answer with the shortest code. I'll also be looking at elegance of the code and time complexity of the algorithm! My Solution I'm attempting an F# solution when I find the free time - will post it here when I have something! Format Please post all answers in the following format for the purpose of easy comparison: Language Number of characters: ??? Fully obfuscated function: (code here) Clear (ideally commented) function: (code here) Any notes on the algorithm/clever shortcuts it takes.
0
0
0
0
1
0
I got the idea for this question from numerous situations where I don't understand what the person is talking about and when others don't understand me. So, a "smart" solution would be to speak a computer language. :) I am interested how far a programming language can go to get near to (English) natural language. When I say near, I mean not just to use words and sentences, but to be able to "do" things a natural language can "do" and by "do" I mean that it can be used (in a very limited way) as a replacement for natural language. I know that this is impossible (is it?) but I think that this can be interesting.
0
1
0
0
0
0
I am really looking for a toolkit or readymade tool which will parse a given document and then generate a brief summary of better still a mindmap of the document. I know Python has ntlk and perl has quite a few modules which will help in natural language parsing etc. It is even feasible to write a tool to do so, with using ntlk like tool kit, but for the lack of time. Would appreciate if you know of some such tool or has some pointer to such a tool, if you could post it here, with thanks in advance.
0
1
0
0
0
0
I'm facing a problem with "distance ValueError: math domain error" when using sqrt function in python. Here is my code: from math import sqrt def distance(x1,y1,x2,y2): x3 = x2-x1 xFinal = x3^2 y3 = y2-y1 yFinal = y3^2 final = xFinal + yFinal d = sqrt(final) return d
0
0
0
0
1
0
I am familiar with supervised Learning methods (SVM, Maximum Entropy, Bayes Classifiers) for textual classification, but for image I cannot figure out where I should start from. I have a set of human images (exclusively women) whom I've to classify as being beautiful or not. The first hurdle I am facing is "Feature selection". I thought to take hair shape, complexion, eye shape as features but they are becoming too complex to detect. OCR in comparison seems comparatively easier as the shapes can be put in black & white format and find best match with the known symbols. I am also ready to explore unsupervised learning methods if that is more useful. Please provide me pointers as to how should I begin with. Any free to use libraries would be really great (could be in any language)!
0
0
0
1
0
0
I need to express some numbers (for example, 1300, 500, 900) as a percentage where the total would be 1 not 100. There could 10 numbers and the could be in the range of 1 to 99,999, I guess. I need to do some maths in my program to convert these numbers into the appropriate values. I'm probably not explaining this well. Don't worry about the code, but heres what I need. [chart addSlicePortion:0.1 withName:@"Orange"]; [chart addSlicePortion:0.2 withName:@"Fandango"]; [chart addSlicePortion:0.1 withName:@"Blue"]; [chart addSlicePortion:0.1 withName:@"Cerulean"]; [chart addSlicePortion:0.3 withName:@"Green"]; [chart addSlicePortion:0.1 withName:@"Yellow"]; [chart addSlicePortion:0.1 withName:@"Pink"]; I need to produce the number 0.1, 0.2 etc. Notice that they add up to 1
0
0
0
0
1
0
Converting 0.3 is easy [mul it by 2] , if the precision is 0.1: A) 0.3 -> 0.6 - > extract 0 B) 0.6 -> 1.2 - > extract 1 C) 0.2 -> 0.4 - > extract 0 D) 0.4 -> 0.8 - > extract 0 E) 0.8 -> 1.6 - > extract 1 F) 0.6 jump to B So the 3.3 = 00000011.010011001100110011001 And Now What should We Do with 3.3333333333333333333333 ? if the precision is 0.01.
0
0
0
0
1
0
I see some code like this: float num2 = ( ( this.X * this.X ) + ( this.Y * this.Y ) ) + ( this.Z * this.Z ); float num = 1f / ( ( float ) Math.Sqrt ( ( double ) num2 ) ); this.X *= num; this.Y *= num; this.Z *= num; Does it matter if it was like this?: float num2 = ( ( this.X * this.X ) + ( this.Y * this.Y ) ) + ( this.Z * this.Z ); float num = 1 / ( ( float ) Math.Sqrt ( ( double ) num2 ) ); this.X *= num; this.Y *= num; this.Z *= num; Would the compiler use (float) / (float) or try to use (double) / (float) for the 2nd example for line 2? EDIT: Btw would there be any performance difference?
0
0
0
0
1
0
Problem: For an ordered set of edges E of a complete graph Kn, given an edge Ei, find the edge's vertices (v, w)_Ei. Note: This is likely not a problem specific to graph theory, although it was chosen to express the problem solely because of familiarity. Apologies for any incorrect notation introduced. Suppose that constructed from a complete graph K5 consisting of vertices 1, 2, 3, 4, 5, we have an ordered set E of the graph's edges, totalling 10 edges. The set E is known to always be ordered as follows: Ei = (0 < v < n, v < w =< n) E1 = (1, 2) E2 = (1, 3) E3 = (1, 4) E4 = (1, 5) E5 = (2, 3) E6 = (2, 4) E7 = (2, 5) E8 = (3, 4) E9 = (3, 5) E10 = (4, 5) For any given Ei, we must now find the vertices (v, w)_Ei using i alone. For example, given 6 we should obtain (2, 4). Update: Another, perhaps simpler way of expressing this problem is: n = 5 i = 0 for v = 1 to n - 1 for w = v + 1 to n i++ print "E" + i + " = " + v + ", " w print "E6 = " + findV(6) + ", " + findW(6) How is this done?
0
0
0
0
1
0
Let's say I have three arrays a, b, and c of equal length N. The elements of each of these arrays come from a totally ordered set, but are not sorted. I also have two index variables, i and j. For all i != j, I want to count the number of index pairs such that a[i] < a[j], b[i] > b[j] and c[i] < c[j]. Is there any way this can be done in less than O(N ^ 2) time complexity, for example by creative use of sorting algorithms? Notes: The inspiration for this question is that, if you only have two arrays, a and b, you can find the number of index pairs such that a[i] < a[j] and b[i] > b[j] in O(N log N) with a merge sort. I'm basically looking for a generalization to three arrays. For simplicity, you may assume that no two elements of any array are equal (no ties).
0
0
0
0
1
0
I have a start point(x0,y0), a end point(x2,y2) and a slope (of line between (x0,y0) and (x3,y3)) and i want to draw a parallelogram. (x0,y0) (x1,y1) __________ \ \ \ \ \_________\ (x3,y3) (x2,y2) Can somebody tell me how to do this? or suggest some algorithm or something. Edit: Here y0 = y1 and y2 = y3 Regards
0
0
0
0
1
0
Alright, so I'm working on collision detection for a 3d game, this is what I got so far: public void mapCol(Spatial map, Node model2){ Mesh m = (Mesh) ((Node) map).getChild("obj_mesh0"); int c = 0; m.updateWorldBound(true); boolean col = false; c = m.getMeshData().getPrimitiveCount(0); // System.out.println(c); Vector3[][] v3 = new Vector3[c][3]; for(int s = 0; s < c; s++){ v3[s] = null; v3[s] = m.getMeshData().getPrimitive(s, 0, v3[s]); Vector3 min = new Vector3((float)Math.min((float) Math.min(v3[s][0].getXf(), v3[s][1].getXf()), v3[s][2].getXf()), (float)Math.min((float)Math.min(v3[s][0].getYf(), v3[s][1].getYf()), v3[s][2].getYf()), (float)Math.min((float)Math.min(v3[s][0].getZf(), v3[s][1].getZf()), v3[s][2].getZf())); Vector3 max = new Vector3((float) Math.max((float)Math.max(v3[s][0].getXf(), v3[s][1].getXf()), v3[s][2].getXf()), (float)Math.max((float)Math.max(v3[s][0].getYf(), v3[s][1].getYf()), v3[s][2].getYf()), (float)Math.max((float)Math.max(v3[s][0].getZf(), v3[s][1].getZf()), v3[s][2].getZf())); Vector3 v2 = new Vector3(); v2 = max.add(min, v2); v2.divideLocal(2); if(max.getXf() > model2.getTranslation().getXf() - sp1.getRadius()&& min.getXf() < model2.getTranslation().getXf() + sp1.getRadius() && max.getZf() > model2.getTranslation().getZf() - sp1.getRadius() && min.getZf() < model2.getTranslation().getZf() + sp1.getRadius() && max.getYf() > model2.getTranslation().getYf() + sp1.getRadius()&& !col){ float cosine = (float) v2.dot(v2); float angle = (float) Math.toDegrees(Math.acos( cosine )); float pangle = (float) Math.toDegrees(Math.atan2((min.getX() + ((max.getX() - min.getX())/2)) - model2.getTranslation().getX(), (min.getZ() + ((max.getZ() - min.getZ())/2) - model2.getTranslation().getZ()))); if(min.getY() < max.getY()){ System.out.println("pangle:" + pangle + " angle:" + angle); model2.setTranslation( (min.getX() + ((max.getX() - min.getX())/2)) - (Math.sin(Math.toRadians(pangle)) * (sp1.getRadius())), model2.getTranslation().getYf(), (min.getZ() + ((max.getZ() - min.getZ())/2)) - (-Math.cos(Math.toRadians(pangle)) * (sp1.getRadius())) ); col = true; } } } } Now the part to really look at is right here: model2.setTranslation( (min.getX() + ((max.getX() - min.getX())/2)) - (Math.sin(Math.toRadians(pangle)) * (sp1.getRadius())), model2.getTranslation().getYf(), (min.getZ() + ((max.getZ() - min.getZ())/2)) - (-Math.cos(Math.toRadians(pangle)) * (sp1.getRadius())) ); Any idea why it wouldn't set model2 modle2's radius away from the wall? (making it stop at the way and able to go no further)
0
0
0
0
1
0
I'm in a class about AI right now and am required to do a project over the course of the entire semester that applies AI in some way. The professor said that it could be pretty much anything in pretty much any language. For reference, the "default" project is writing something to solve the Wumpus world, but the professor said that that would be a little bit too easy and we should try to come up with our own problem. I really don't know what to do. I'm a big chess player so I was thinking maybe simplifying the game rules a bit or writing something that would play the opening because there are really specific goals in the opening (get space, develop pieces, control the center). Any other suggestions? Thank you.
0
1
0
0
0
0
My understanding is that, in keeping with Interbase v6, Firebird 2.5 does not support the SQL-92 INTERVAL keyword. At least, so suggests this reference and my repeated SQLCODE -104 errors trying to get INTERVALs to work under Firebird's isql(1). How, then, do I account for the irregularities in our civil reckoning of time -- months aren't uniformly long, nor are days with savings time and leap adjustments, not to mention the year of confusion, etc. -- when performing TIMESTAMP arithmetic under Firebird 2.1? How can I easily determine "one month earlier" or "one week later" than a given TIMESTAMP? How about "one day later" or "two hours before"?
0
0
0
0
1
0
Are there any reliable/deployed approaches, algorithms or tools to tagging the website type by parsing some its webpages. For ex: forums, blogs, PressRelease sites, news, E-Comm etc. I am looking for some well-defined characteristics (Static rules) from which this can be determined. If not, then i hope Machine Learning model may help. Suggestions/Ideas ?
0
0
0
1
0
0
So I'm sure the answer to this will be something simple and I'll read it and immediately commence epic facepalming, but at the moment I've spent an entire day wondering why the heck this isn't working and I just can't find the problem... I'm trying to build a simple (supposed to be anyway) system to rotate 2d points around a central axis, but I've found 2 problems so far that make no sense to me whatsoever. Problem 1: The positive/negative numbers assigned to the input object are being flipflopped in a seemingly random fashion. Problem 2: The rotation math is correct, but the results are anything but. Here's the code to reproduce this problem: function doRotate(pos){ //convert angle to radians var ang = 90 * Math.PI / 180; //rotate points pos.left = Math.round(pos.left * Math.cos(ang) + pos.top * Math.sin(ang)); pos.top = Math.round(pos.top * Math.cos(ang) - pos.left * Math.sin(ang)); return pos; } var points = { 'a':{left:32,top:32}, 'b':{left:-32,top:32}, 'c':{left:-32,top:-32}, 'd':{left:32,top:-32} }; for( var k in points ){ var msg = 'Start: X:'+points[k].left+' Y:'+points[k].top+'<br />'; points[k] = doRotate(points[k]); var msg = msg+'End: X:'+points[k].left+' Y:'+points[k].top+'<br />'; document.write( '<p>'+k+':<br />'+msg+'</p>' ); } Now you'd expect to see: a: Start: X:32 Y:32 End: X:32 Y:-32 b: Start: X:-32 Y:32 End: X:-32 Y:-32 c: Start: X:-32 Y:-32 End: X:-32 Y:32 d: Start: X:-32 Y:32 End: X:32 Y:32 But instead you get this: a: Start: X:32 Y:32 End: X:32 Y:32 b: Start: X:-32 Y:-32 End: X:32 Y:32 c: Start: X:-32 Y:-32 End: X:-32 Y:-32 d: Start: X:32 Y:32 End: X:-32 Y:-32 I've triple checked the math and that is 100% accurate to rotate points around origin in 2D. I've even recreated this test in PHP and it works perfectly. What I can't figure out is why the heck JS is a) screwing up the variable assignments and b) not coming up with the correct results? Anyone who can help may rest assured that I will salute their insight with a facepalm Sir Patrick would be proud of ;)
0
0
0
0
1
0
Dose anyone know of any good libraries out there for .NET that could help pull keywords out of blocks of natural language. I'm basically trying to strip out stop words and ignore tenses, plurals and generally find words that are essentially the same. Some abilities to find synonyms would be nice, especially if it includes things like business/technology/non-dictionary words.
0
1
0
0
0
0
I'm working on a system that will send telemetry data on machine operation back to a central server for analysis. One of the machine parameters we're measuring is motor current drawn vs time. After an operation is finished we plan to send back an array of currents vs time to the server. A successful operation would have a pattern like a trapezoid, problematic operations would have a pattern completely different, more like a large spike in values. Can anyone recommend a type of neural network that would be good at classifying these 1D vectors of current values into a pass/fail type output? Thanks, Fred
0
0
0
0
1
0
private int bitToIntParser (byte[] recordData, int byteOffset, int byteLength, int bitOffset, int bitLength) { //step1:Byte[] selectedBytes = recordData[byteOffset to byteOffset + Length] //step2:BitArray selectedBits=selectdBytes.bits[bitOffset to bitOffset+bitLength] //step3:convert selectedBit to Int } The above function should be able to extract bytes[byteOffset] to bytes[byteOffset+length] from recordData and then extract bit[bitOffset] to bit[bitOffset+BitLength] from the previous result and convert it to int. Can any one please help me with this?
0
0
0
0
1
0
I am very curious about making a handwriting recognition application in a web browser. Users draw a letter, ajax sends the data to the server, neural network finds the closest match, and returns results. So if you draw an a, the first result should be an a, then o, then e, something like that. I don't know much about neural networks. What kinda data would I need to pass to the NN. Could it be an array of the x/y coordinates where the user has drawn on a pad. Or what type of data is the neural network expecting or would produce the best results for handwriting?
0
1
0
1
0
0
I need an algorithm that allows me to determine an appropriate <priority> field for my website's sitemap based on the page's views and comments count. For those of you unfamiliar with sitemaps, the priority field is used to signal the importance of a page relative to the others on the same website. It must be a decimal number between 0 and 1. The algorithm will accept two parameters, viewCount and commentCount, and will return the priority value. For example: GetPriority(100000, 100000); // Damn, a lot of views/comments! The returned value will be very close to 1, for example 0.995 GetPriority(3, 2); // Ok not many users are interested in this page, so for example it will return 0.082
0
0
0
0
1
0
I am searching for a server-side application (not a service, we need to host this ourselves) that can take a given string and translate it to another language. Open-source, paid, doesn't matter. Can anyone provide some recommendations?
0
1
0
0
0
0
I'm looking to find/create a routing algorithm that can be used to manage multiple vans performing deliveries as well as the loads of each of those vans. Here's a rough specification of what I'm looking for.. The routes should be calculated in a fast and efficient manner 100+ vans / 1000+ packages / 1000+ dropoff points could be processed in one go Each van could be a different size and have different weight restrictions Each package could be a different size and weight The packages should be organised onto the vans in a fair and economical manner, taking into account the routes, weight and size restrictions The routes the vans should take should be economical and as short as possible (or a configurable balance between the two) Vans could be limited to certain roads (low bridges, width, height and weight restrictions) Some packages may be given timeslots for delivery Has anyone seen this sort of thing before, and if so, any ideas as to what algorithm could be used to do this, or an example of how it could be done? I've seen a few university papers but they're quite old (probably fairly inefficient now) and don't handle the package management - they just presume all the vans and packages are the same size. Any thoughts would be appreciated! Rich
0
0
0
0
1
0
I would like to be able to navigate by sentence in Emacs (M-a, M-e). Here's the problem: by default, Emacs expects that each sentence is separated by two spaces, and I'm used to just putting a single space. Of course, that setting can be turned off, to allow for sentences separated by only a single space, like so: (setq sentence-end-double-space nil) But then Emacs thinks that a sentence has ended after abbreviations with a full stop ("."), e.g. after something like "...a weird command, e.g. foo...". So rather than using the above code, is there a way to define the sentence-end variable so that it counts [.!?] as marking the end of the sentence, iff what follows is one or more spaces followed by a capital letter [A-Z]? And...to also allow [.!?] to mark the end of a sentence, if followed by zero or more spaces followed by a "\"? [The reason for this latter condition is for writing LaTeX code: where a sentence is followed by a LaTeX command like \footnote{}, e.g. "...and so we can see that the point is proved.\footnote{In some alternate world, at least.}"] I tried playing around with the definition of sentence-end, and came up with: (setq sentence-end "[.!?][]'\")}]*\\(\\$\\|[ ]+[A-Z]\\|[ ]+[A-Z]\\| \\)[ ;]*") But this doesn't seem to work at all. Any suggestions?
0
1
0
0
0
0
What's going wrong with my implementation of a quartic equation solver? Here is my code on GitHub. I followed this: http://www.1728.com/quartic2.htm In fact the real implementation starts at line 271, where I create the monic poly. If I try it with a polynomial with 4 real roots it works fine (for example with 3x^4 + 6x^3 - 123x^2 - 126x + 1,080), otherwise gives wrong roots. Thanks, rubik P.S. I called the function __quartic because it is still in development
0
0
0
0
1
0
How the heck does Ruby do this? Does Jörg or anyone else know what's happening behind the scenes? Unfortunately I don't know C very well so bignum.c is of little help to me. I was just kind of curious it someone could explain (in plain English) the theory behind whatever miracle algorithm its using. irb(main):001:0> 999**999 368063488259223267894700840060521865838338232037353204655959621437025609300472231530103873614505175218691345257589896391130393189447969771645832382192366076536631132001776175977932178658703660778465765811830827876982014124022948671975678131724958064427949902810498973271030787716781467419524180040734398996952930832508934116945966120176735120823151959779536852290090377452502236990839453416790640456116471139751546750048602189291028640970574762600185950226138244530187489211615864021135312077912018844630780307462205252807737757672094320692373101032517459518497524015120165166724189816766397247824175394802028228160027100623998873667435799073054618906855460488351426611310634023489044291860510352301912426608488807462312126590206830413782664554260411266378866626653755763627796569082931785645600816236891168141774993267488171702172191072731069216881668294625679492696148976999868715671440874206427212056717373099639711168901197440416590226524192782842896415414611688187391232048327738965820265934093108172054875188246591760877131657895633586576611857277011782497943522945011248430439201297015119468730712364007639373910811953430309476832453230123996750235710787086641070310288725389595138936784715274150426495416196669832679980253436807864187160054589045664027158817958549374490512399055448819148487049363674611664609890030088549591992466360050042566270348330911795487647045949301286614658650071299695652245266080672989921799342509291635330827874264789587306974472327718704306352445925996155619153783913237212716010410294999877569745287353422903443387562746452522860420416689019732913798073773281533570910205207767157128174184873357050830752777900041943256738499067821488421053870869022738698816059810579221002560882999884763252161747566893835178558961142349304466506402373556318707175710866983035313122068321102457824112014969387225476259342872866363550383840720010832906695360553556647545295849966279980830561242960013654529514995113584909050813015198928283202189194615501403435553060147713139766323195743324848047347575473228198492343231496580885057330510949058490527738662697480293583612233134502078182014347192522391449087738579081585795613547198599661273567662441490401862839817822686573112998663038868314974259766039340894024308383451039874674061160538242392803580758232755749310843694194787991556647907091849600704712003371103926967137408125713631396699343733288014254084819379380555174777020843568689927348949484201042595271932630685747613835385434424807024615161848223715989797178155169951121052285149157137697718850449708843330475301440373094611119631361702936342263219382793996895988331701890693689862459020775599439506870005130750427949747071390095256759203426671803377068109744629909769176319526837824364926844730545524646494321826241925107158040561607706364484910978348669388142016838792902926158979355432483611517588605967745393958061959024834251565197963477521095821435651996730128376734574843289089682710350244222290017891280419782767803785277960834729869249991658417000499998999
0
0
0
0
1
0
I have this code: $previous = 0; while($row = mysql_fetch_array($result)){ $difference = $row['steam'] - $previous; $strXML .= "<set name='".date("G:i:s", strtotime($row["tstamp"])). "' value='".$difference."' color='AFD8F8' />"; $previous = $row['steam']; } This code is working great with every result after the first one. If i can explain, $previous starts at 0, so the first block on the bar chart actually comes out at 3334, as 3334 - 0 = 3334, however from then on i get exactly what i want because its doing the math between real values. how can i fix the first result? Thanks
0
0
0
0
1
0
This problems feels like it should have a name. Hopefully someone can recognize it. There is a 32 member club. Every week the members have dinner together, dividing themselves into 8 tables of 4 members each. Each week they arrange themselves such that they are always sitting with different people. Is it possible to have every person be seated with every other person exactly once? I've tried programming a greedy approach, but it didn't work for these numbers (it did work for a 16 member club with 4 tables of 4 each, but not 36 members with 6 tables of 6 people) Though this sounds like a homework problem, this is actually from my friend's mom, who is trying to organize these dinners.
0
0
0
0
1
0
I don't know how to ask but just want to ask. help me to tag it please. Anyway, my friend asked me a question that which one is faster in Java int a = 5 + 5 + 5 + 5 + 5 or int b = 5 * 5 ? Is it language dependent ? I mean, a is faster than b in java but not in C my answer is a is faster than b because of comparison of addition/multiplication in computer organization
0
0
0
0
1
0
I have a table with ID, value1, value2, value3 and tstamp (TIMESTAMP format) and i'm trying to group by each day and find a total for each day, however all values are accumulative, which poses a problem, because sum(value1) doesnt give the right output, this is my code: $sql = "select date(tstamp), sum(".$column.") from mash group by date(tstamp) order by tstamp asc limit 10"; $result = mysql_query($sql); $previous = 0; $firstRun = true; while($row = mysql_fetch_array($result)) { $difference = $row[1] - $previous; if (!$firstRun) { $strXML .= "<set name='".$row[0]."' value='".$difference."' color='AFD8F8' />"; } $previous = $row[1]; $firstRun = false; } Can anyone spot the issue in this code, its not erroring, its just giving wrong answers. EDIT: To clear up any confusion, this is the SQL: -------------------------------------------------------- -- -- Table structure for table `mash` -- CREATE TABLE IF NOT EXISTS `mash` ( `id` int(25) NOT NULL AUTO_INCREMENT, `steam` int(25) NOT NULL, `bore_water` int(25) NOT NULL, `boiler1oil` int(25) NOT NULL, `boiler2oil` int(25) NOT NULL, `tstamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5362 ; -- -- Dumping data for table `mash` -- INSERT INTO `mash` (`id`, `steam`, `bore_water`, `boiler1oil`, `boiler2oil`, `tstamp`) VALUES (2, 436, 73, 15, 1, '2010-11-25 12:28:03'), (3, 495, 74, 36, 1, '2010-11-25 12:38:04'), (4, 553, 76, 58, 1, '2010-11-25 12:48:09'), (5, 565, 77, 74, 1, '2010-11-25 12:58:05'), (6, 584, 79, 78, 1, '2010-11-25 13:08:05'), (7, 630, 82, 100, 1, '2010-11-25 13:18:11'), (8, 686, 86, 130, 1, '2010-11-25 13:28:07'), (9, 740, 89, 151, 1, '2010-11-25 13:38:07'), (10, 780, 93, 173, 1, '2010-11-25 13:48:13'), (11, 883, 100, 218, 1, '2010-11-25 14:08:10');
0
0
0
0
1
0
I have two list say L1 and L2, (minimum) sum of the lengths of the two lists. For Example: 89 145 42 20 4 16 37 58 89 20 4 16 37 58 89 Output : 5 89 145 42 20 4 16 37 58 89 56 678 123 65467 Output : 0 19 82 68 100 1 100 1 Output : 5 Thanks, PS: My language of choice is C and C++ hence the tag.
0
0
0
0
1
0
Need help with some real estate math in java this blows up each time public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // This app total real estate fees for a client selling a house Button button = (Button) findViewById(R.id.Button01); // Sample data for priceText 360000 final EditText priceText = (EditText) findViewById(R.id.EditText01); // Sample data for rateText .04 final EditText rateText = (EditText) findViewById(R.id.EditText02); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(jsclosingcost.this, "Doing Closing Cost Breakdown", Toast.LENGTH_SHORT) // Sample data for priceText 360000 float fPrice=Float.parseFloat(priceText.getText().toString() + ""); // Sample data for rateText .04 float fRate=Float.parseFloat(rateText.getText().toString() + ""); float fRealEsate = fPrice * fRate; Toast.makeText(jsclosingcost.this, "Real Estate Brokerage Fee: " + fRealEsate, Toast.LENGTH_SHORT).show(); } }); }
0
0
0
0
1
0
I'm trying to come up with an equation to mathematically determine the "flattened index" of an array from the "stacked index." Observe the following example in Ruby. matx = [[[ 1, 2, 3, 4], [ 5, 6, 7, 8]], [[ 9,10,11,12], [13,14,15,16]]] In this example, matx is a three dimensional matrix, and the element 7 is located at matx[0][1][2]. However, in the next example: matx.flatten! # => [1, 2, 3, 4, 5, 6, 7, 8, # 9, 10, 11, 12, 13, 14, 15, 16] Now the element 7 is located at matx[6]. So essentially, I'm looking for a way to, given the dimensions of the matrix and the set of indices for the particular element, convert from the stacked matrix to the flattened matrix. Reverse would be awesome, too, but I figure the way to get that is similar (but essentially reversed) to the method of obtaining this result. I realized that reverse is not actually a function, because there's no way to necessarily tell the difference as to whether 5 maps to [2,3] or [3,2], etc. So I'm not going to look into that one.
0
0
0
0
1
0
I'm trying to write a pretty heavy duty math-based project, which will parse through about 100MB+ data several times a day, so, I need a fast language that's pretty easy to use. I would have gone with C, but, getting a large project done in C is very difficult, especially with the low level programming getting in your way. So, I was about python or java. Both are well equiped with OO features, so I don't mind that. Now, here are my pros for choosing python: Very easy to use language Has a pretty large library of useful stuff Has an easy to use plotting library Here are the cons: Not exactly blazing There isn't a native python neural network library that is active I can't close source my code without going through quite a bit of trouble Deploying python code on clients computers is hard to deal with, especially when clients are idiots. Here are the pros for choosing Java: Huge library Well supported Easy to deploy Pretty fast, possibly even comparable to C++ The Encog Neural Network Library is really active and pretty awesome Networking support is really good Strong typing Here are the cons for Java: I can't find a good graphing library like matplotlib for python No built in support for big integers, that means another dependency (I mean REALLY big integers, not just math.BigInteger size) File IO is kind of awkward compared to Python Not a ton of array manipulating or "make programming easy" type of features that python has. So, I was hoping you guys can tell me what to use. I'm equally familiar with both languages. Also, suggestions for other languages is great too. EDIT: WOW! you guys are fast! 30 mins at 10 responses!
0
0
0
0
1
0
Can forces be stored as dot products? such as the gravity on a planet. And for a game, for example a 2d spaceship game. would one add a right thrust vector and a left vector to power the ship and move it around. then this would mean the angle of the ship shown on screen is computed from those vectors and the player would have no control over the actual angle of the ship. Is this correct?
0
0
0
0
1
0
So far I've implemented a gaussian blur filter entirely in the space domain, making use of the separability of the gaussian, that is, applying a 1D gaussian kernel along the rows and then along the columns of an image. That worked fine. Now, given only with the size N of the NxN convolution matrix of the space domain, I want to achieve the exact same blurred image over the frequency domain. That means that I'll load the image into a matrix (numpy, I'm using python), apply the FFT on it (then I have G(x,y)), and then I have to have also a filter H(u,v) in the frequency domain that also resembles the shape of some 2d gaussian, with its center value being 1.0 and then having values falling off to 0 the further away from the center I am. I do then the multiplication in frequency domain (before I have to consider to do a center-shift of H) and then apply the iFFT. The trouble I have is to find the exact formula (i.e. to find sigma, the std-deviation) that will result in the corresponding H(u,v). From the space domain, if I have been given a mask-size N, I know that the std-dev sigma can be approximated as sigma=(maskSize-1)/2/2.575, e.g. for a mask size N=15 I get std-dev=2.71845 for e^-(x²/2sigma²), just considering 1D cases for now. But how do I get sigma for the frequency domain? Funny thing is btw that in theory I know how to get sigma, using Mathematica, but the result is pure bogus, as I can demonstrate here: gauss1d[x_, sigma_] := Exp[-(x^2)/(2 sigma^2)] Simplify[FourierTransform[gauss1d[x, sigma], x, omega], sigma > 0] The result is E^(-(1/2) omega^2 sigma^2) * sigma This is bogus because it turns, in the exponent of the E function, the 1/sigma² into a sigma². Consequently, if you draw this, you will see that the standard deviation has become a lot smaller, since the H(u,v)-gaussian is a lot "thinner". However, it should actually be a lot wider in the frequency domain than in the space domain!! It doesn't make any sense...
0
0
0
0
1
0
I am developing an application for an oscilloscope in c# .NET, I am drawing different kinds of waves (sine, square etc..) with the help of zedgraph control. I get values from oscilloscope and stored in a buffer of size 1024(byte array) and have to calculate parameters like time period, Frequency, rise time, fall time etc at run time. for this purpose i have to extract only a single cycle of whole signal.one more problem is that values are not always rise or fall continuously mean values are stored in buffer like this[0,0,0,1,1,2,3,4,5,5,6,6,6,5,5,4,3,2,1,1,0,0,0..........]. signals are continuously receive from machine. it is not sure that waves are always oscillating around zero. Thanks Regards Nilesh
0
0
0
0
1
0
First, lets start out with my math background. I've taken calculus I - IV and Differential Equations. I've taken a first semester computer graphics course where we implemented pretty much our own graphics pipeline including shading using Phong without any graphics API. I'm taking a graduate level Advanced Computer Graphics course this semester and when reading the math involved it loses me. This class is basically an image synthesize class. We'll build a ray-tracer in our first project and build on it from there on. When reading up on advanced computer graphics, I'll usually get a bunch of math. I understand computer graphics is math heavy but I'm having problems when trying to figure out exactly how I'm suppose to implement the math into code. I'm really going to need to get the hang of this in order to excel in CG. For instance, this article from GPU Gems: http://http.developer.nvidia.com/GPUGems/gpugems_ch01.html There's a bunch of math, but I have no clue where to start implementing the math if I want to. So, is there something I'm missing? Am I suppose to look at the math and be able to derive the code? Are there tutorials/books out there that could help me understand what I'm needing to do?
0
0
0
0
1
0
Let's say I have a number of base 3, 1211. How could I check this number is divisible by 2 without converting it back to base 10? Update The original problem is from TopCoder The digits 3 and 9 share an interesting property. If you take any multiple of 3 and sum its digits, you get another multiple of 3. For example, 118*3 = 354 and 3+5+4 = 12, which is a multiple of 3. Similarly, if you take any multiple of 9 and sum its digits, you get another multiple of 9. For example, 75*9 = 675 and 6+7+5 = 18, which is a multiple of 9. Call any digit for which this property holds interesting, except for 0 and 1, for which the property holds trivially. A digit that is interesting in one base is not necessarily interesting in another base. For example, 3 is interesting in base 10 but uninteresting in base 5. Given an int base, your task is to return all the interesting digits for that base in increasing order. To determine whether a particular digit is interesting or not, you need not consider all multiples of the digit. You can be certain that, if the property holds for all multiples of the digit with fewer than four digits, then it also holds for multiples with more digits. For example, in base 10, you would not need to consider any multiples greater than 999. Notes - When base is greater than 10, digits may have a numeric value greater than 9. Because integers are displayed in base 10 by default, do not be alarmed when such digits appear on your screen as more than one decimal digit. For example, one of the interesting digits in base 16 is 15. Constraints - base is between 3 and 30, inclusive. This is my solution: class InterestingDigits { public: vector<int> digits( int base ) { vector<int> temp; for( int i = 2; i <= base; ++i ) if( base % i == 1 ) temp.push_back( i ); return temp; } }; The trick was well explained here : https://math.stackexchange.com/questions/17242/how-does-base-of-a-number-relate-to-modulos-of-its-each-individual-digit Thanks, Chan
0
0
0
0
1
0
How do I convert centimeter to pixel in c# ?
0
0
0
0
1
0
I'm trying to modulate an alpha value in a Java application I'm building on Android. Right now it goes like this: if (goingUp) { newAlpha = oldAlpha + rateOfChange; if (newAlpha > maxAlpha) { newAlpha = maxAlpha; goingUp = false; } } else { newAlpha = oldAlpha - rateOfChange; if (newAlpha < minAlpha) { newAlpha = minAlpha; goingUp = true; } } Where rateOfChange is an arbitrary int that cannot be greater than maxAlpha. The equation is evaluate every tick in a thread and is independent of time. Is there a way using only the variables given + Math.PI and other Math elements (I'm assuming Math.Sine will be in there) to get newAlpha to be a number on a Sine? I'm thinking min and max would be the amp of the wave and rateOfChange would be a product of the Sine function, I just can't figure out how it all goes together.
0
0
0
0
1
0
I have a large corpus of text-based documents (100,000+) from which I want to extract proper names (e.g. a person's name). Could anyone recommend techniques and/or software that would be useful in accomplishing this goal. I'm not particularly interested in low-level text parsing, so much as I am in more high-level things such as recognizing and/or ranking.
0
1
0
0
0
0
Would it be possible to transfer large files using only a system of checksums, and then reconstruct the original file by calculations? Say that you transfer the MD5 checksum of a file and the size of the file. By making a "virtual file" and calculating it's checksum, trying every single bit combination, you should eventually "reach" the original file. But on the way you would also get a lot of "collisions" where the checksum also match. So we change the first byte of the original file to some specified value, calculate the checksum again, and send this too. If we make the same substitution in the virtual file we can test each "collision" to see if it still matches. This should narrow it down a bit, and we can do this several times. Of course, the computing power to do this would be enormous. But is it theoretically possible, and how many checksums would you need to transfer something (say 1mb)? Or would perhaps the amount of data needed to transfer the checksums almost as large as the file, making it pointless?
0
0
0
0
1
0
If I have the length of the hypotenuse and its angle, how do I find the adjacent and opposite? I'm writing this in JavaScript and I'm just trying to find the screen coordinates (x/y) where the hypotenuse ends given a length and angle. So, additionally, I need to know how to convert from a cartesian coordinates to screen coordinates. Sorry, this is probably a pretty dumb question. Here is a sketch if I'm being unclear: So something like this: function getLineEndCoords(originX, originY, hypotenuse, angle){ // Probably something to do with tangents and cosines. return [x,y] } Additionally, if anyone knows any good JS libraries for this sort of stuff (isometric drawings, display related math) that would be convenient.
0
0
0
0
1
0
I'd like to begin tinkering around with an RTS AI, but I'm having trouble finding a good environment to work with, ie a game that has been already created. I have looked at Spring RTS and Bos Wars, but they don't seem to be conducive to creating simple examples. I am not totally opposed to writing my own game environment, it would just take a long time. Does anyone have a suggestion as to how I can get my feet wet without programming my own game?
0
1
0
0
0
0