Search Results

Search found 3425 results on 137 pages for 'polynomial math'.

Page 43/137 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Pretty Pixel-level Picture Painting, Programatically

    - by dreeves
    My mac laptop has 1,024,000 pixels. What's the simplest way to turn my display completely black and go nuts with writing little programs to twiddle pixels to my heart's delight? To make it more concrete, say I wanted to implement the Chaos Game to draw a Sierpinski triangle, at the pixel level, with nothing else on the screen. What are ways to do that?

    Read the article

  • C - How to implement Set data structure?

    - by psihodelia
    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 set could include itself.

    Read the article

  • Radius of multiple latitude/longitude points

    - by zekial
    I have a program that takes as input an array of lat/long points. I need to perform a check on that array to ensure that all of the points are within a certain radius. So, for example, the maximum radius I will allow is 100 miles. Given an array of lat/long (coming from a MySQL database, could be 10 points could be 10000) I need to figure out if they will all fit in a circle with radius of 100 miles. Kinda stumped on how to approach this. Any help would be greatly appreciated.

    Read the article

  • Interesting task using random numbers only

    - by psihodelia
    Given any number of the random real numbers from the interval [0,1] is there exist any method to construct a floating point number with zero decimal part? Your algorithm can use only random() function calls and no variables or constants. No constants and variables are allowed, no type casting is allowed. You can use for/while, if/else or any other programming language operands.

    Read the article

  • C++ integer floor function

    - by Thomas
    I want to implement greatest integer function. int x = 5/3; My question is with greater numbers could there be a loss of precision as 5/3 would produce a double? EDIT: Greatest integer function is integer less than or equal to X. Example: 4.5 = 4 4 = 4 3.2 = 3 3 = 3 What I want to know is 5/3 going to produce a double? Because if so I will have loss of precision when converting to int. Hope this makes sense. RE-EDIT: What OP calls 'greatest integer' most of us call 'floor'.

    Read the article

  • Code Golf: Countdown Number Game

    - by Noldorin
    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 make 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) e.g. (100 + 50) * 4 * 2 / (4 + 2) {25, 4, 9, 2, 3, 10}, target 465 e.g. (25 + 10 - 4) * (9 * 2 - 3) {9, 8, 10, 5, 9, 7), target 241 e.g. ((10 + 9) * 9 * 7) + 8) / 5 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.

    Read the article

  • Faster way to compare two sets of points in N-dimensional space?

    - by Amit
    List1 contains a high number (~7^10) of N-dimensional points (N <=10), List2 contains the same or fewer number of N-dimensional points (N <=10). My task is this: I want to check which point in List2 is closest (euclidean distance) to a point in List1 for every point in List1 and subsequently perform some operation on it. I have been doing it the simple- the nested loop way when I didn't have more than 50 points in List1, but with 7^10 points, this obviously takes up a lot of time. What is the fastest way to do this? Any concepts from Computational Geometry might help?

    Read the article

  • Fastest way to find the rotation of a vector

    - by kriss
    I have two 2D vectors, say u and v, defined by cartesian coordinates. Imagine that vectors are needles of a clock. I'm looking for the fastest way to find out, using python, if v is after or before u (or in other words find out in wich half plane is v, regarding to position of u). For the purpose of the problem if vectors are aligned answer should be before. It seems easy using some trigonometry, but I believe there should be a faster way using coordinates only. My test case: def after(u, v): """code here""" after((4,2), (6, 1)) : True after((4,2), (3, 3)) : False after((4,2), (2, 1)) : False after((4,2), (3, -3)) : True after((4,2), (-2, -5)) : True after((4,2), (-4, -2)) : False

    Read the article

  • Code Golf: All +-*/ Combinations for 3 integers

    - by Flash84x
    Write a program that takes 3 integers separated by spaces and perform every single combination of addition, subtraction, multiplication and division operations possible and display the result with the operation combination used. Example: $./solution 1 2 3 Results in the following output 1+2+3 = 6 1-2-3 = -4 1*2*3 = 6 1/2/3 = 0 (integer answers only, round up at .5) 1*2-3 = -1 3*1+2 = 5 etc... Order of operation rules apply, assume there will be no parenthesis used i.e. (3-1)*2 = 4 is not a combination, although you could implement this for "extra credit" For results where a divide by 0 occurs simply return NaN

    Read the article

  • Drawing Directed Acyclic Graphs: Using DAG property to improve layout/edge routing?

    - by Robert Fraser
    Hi, Laying out the verticies in a DAG in a tree form (i.e. verticies with no in-edges on top, verticies dependent only on those on the next level, etc.) is rather simple. However, is there a simple algorithm to do this that minimizes edge crossing? (For some graphs, it may be impossible to completely eliminate edge crossing.) A picture says a thousand words, so is there an algorithm that would suggest: instead of:

    Read the article

  • Recursion problem in algorithm

    - by Marthin
    I'm not sure if this is the right place to post this, but the problem actually belongs to a programming assignment. Solve the recursion: T(0) = 2; T(n) = T(n-1) + 2; Solution: T(n) = 2(n+1) Could someone please show me how they got to that solution?

    Read the article

  • simple rank formula

    - by Graham
    I'm looking for a mathmatical ranking formula. Sample is 2008 2009 2010 A 5 6 4 B 6 7 5 C 7 8 2 I want to add a rank column for each period code field rank 2008 2009 2010 2008 2009 2010 B 6 7 5 2 1 1 A 5 6 4 3 2 2 C 7 2 2 1 3 3 please do not reply with methods that loop thru the rows and columns, incrementing the rank value as it goes, that's easy. I'm looking for a formula much like finding the percent total (item / total). I know i've seen this before but an havning a tough time locating it. Thanks in advance!

    Read the article

  • C - Rounding number up

    - by Dave
    Hi all, I was curious to know how I can round a number to the nearest tenth. For instance If I had int a = 59 / 4 /* which would be 14.75 and how can i Store the number as 15 in "a"*/ Thanks, Dave

    Read the article

  • simple dividing

    - by dontoo
    Lets say I am dividing 2592 / 324 = 8 Practically I must guess that 324 goes 8 times in 2592 without reminder. For example, first I try with 7 ( 7*324 = 2268, reminder 324, so 7 is wrong, so I try with 8 and 8 is correct) Is there anyway to do dividing without guessing( trying ), like multiplication ( all mechanically, digit by digit )?

    Read the article

  • Efficient Multiplication of Varying-Length #s [Conceptual]

    - by Milan Patel
    Write the pseudocode of an algorithm that takes in two arbitrary length numbers (provided as strings), and computes the product of these numbers. Use an efficient procedure for multiplication of large numbers of arbitrary length. Analyze the efficiency of your algorithm. I decided to take the (semi) easy way out and use the Russian Peasant Algorithm. It works like this: a * b = a/2 * 2b if a is even a * b = (a-1)/2 * 2b + a if a is odd My pseudocode is: rpa(x, y){ if x is 1 return y if x is even return rpa(x/2, 2y) if x is odd return rpa((x-1)/2, 2y) + y } I have 3 questions: Is this efficient for arbitrary length numbers? I implemented it in C and tried varying length numbers. The run-time in was near-instant in all cases so it's hard to tell empirically... Can I apply the Master's Theorem to understand the complexity...? a = # subproblems in recursion = 1 (max 1 recursive call across all states) n / b = size of each subproblem = n / 1 - b = 1 (problem doesn't change size...?) f(n^d) = work done outside recursive calls = 1 - d = 0 (the addition when a is odd) a = 1, b^d = 1, a = b^d - complexity is in n^d*log(n) = log(n) this makes sense logically since we are halving the problem at each step, right? What might my professor mean by providing arbitrary length numbers "as strings". Why do that? Many thanks in advance

    Read the article

  • bcdiv() bcadd() bcsub() with Php

    - by Pieman
    Will this code be 'stressful' for a server? Or is it easy to bcdiv/sub/add to 10000 decimal places? I'm thinking of looping it afew times... Not Sure... $s2 = (bcdiv('1', $test, 10000)); $s = bcsub($s, $s2, 10000); $test += 2; $s3 = (bcdiv('1', $test, 10000)); $s = bcadd($s, $s3, 10000); $test += 2; Any advice? :)

    Read the article

  • How to find the largest square in the number (Java)

    - by Ypsilon IV
    Hello everyone, I want to find the largest square in the number, but I am stuck at some point. I would really appreciate some suggestions. This is what I've done so far: I take the number on the input, factorize into prime numbers, and put the sequence of prime numbers to ArrayList. Numbers are sorted, in a sense, thus the numbers in the sequence are increasing. For example, 996 is 2 2 3 83 1000 is 2 2 2 5 5 5 100000 is 2 2 2 2 2 5 5 5 5 5 My idea now is to count number of occurrences of each elements in the sequence, so if the number of occurrences is divisible by two, then this is the square. In this way, I can get another sequence, where the right most element divisible by two is the largest square. What is the most efficient way to count occurrences in the ArrayList? Or is there any better way to find the largest square? Many thanks in advance!

    Read the article

  • Uniforme distance between points

    - by Reonarudo
    Hello, How could I, having a path defined by several points that are not in a uniform distance from each other, redefine along the same path the same number of points but with a uniform distance. I'm trying to do this in Objective-C with NSArrays of CGPoints but so far I haven't had any luck with this. Thank you for any help. EDIT I was wondering if it would help to reduce the number of points, like when detecting if 3 points are collinear we could remove the middle one, but I'm not sure that would help.

    Read the article

  • Why do so many mathematicians format code so poorly? [closed]

    - by marcog
    I have done a fair amount of programming together with mathematicians. Now I am even teaching some high school kids coming from a mathematics background how to program. Most of these people format their code so hideously it's hard to believe. I've even worked with and taught mathematicians who will fight the auto-indenter! Why is this so common amongst mathematicians? BTW, this is one reason I have started teaching Python. Yet still they find ways other than indentation to produce whacked coding styles!

    Read the article

  • How to make simple mathematical operations and displaying the result in a textbox

    - by Audel
    Hi, I know is a rather simple question but I just can't find an appropriate example in google or anywhere. I've got this piece int numberOfPlays = int.Parse(textBox2.Text); numberOfPlays = (numberOfPlays++); textBox2.Text = (numberOfPlays.ToString()); MessageBox.Show(numberOfPlays.ToString()); So basically what I want to do is to get the value of the textBox2, make it an integer and then add 1 to it. I can't think of any more details right now, so if i'm not clear enough please ask Thanks in advance

    Read the article

  • getting the value of a filter at an arbitrary time

    - by Andiih
    Context: I'm trying to improve the values returned by the iPhone CLLocationManager, although this is a more generally applicable problem. The key is that CLLocationManger returns data on current velocity as and when it feels like it, rather than at a fixed sample rate. I'd like to use a feedback equation to improve accuracy v=(k*v)+(1-k)*currentVelocity where currentVelocity is the speed returned by didUpdateToLocation:fromLocation: and v is the output velocity (and also used for the feedback element). Because of the "as and when" nature of didUpdateToLocation:fromLocation: I could calculate the time interval since it was last called, and do something like for (i=0;i<timeintervalsincelastcalled;i++) v=(k*v)+(1-k)*currentVelocity which would work, but is wasteful of cycles. Especially as I probably want timeintervalsincelastcalled to be measured as 10ths of a second. Is there a way to solve this without the loop ? i.e. rework (integrate?) the formula so I put an interval into the equation and get the same answer as I would have by iteration ?

    Read the article

  • How to fix this 7% where 6% , 5% works great.

    - by Stackfan
    Case 1 (discount 6%): Subtotal: 750.00 Discount: 45.00 Handling cost: 24.32 21% VAT: 0.00 Total (this is the amount you will deposit): 729.32 Case 2 (discount 7%): Subtotal: 1250.00 Discount: 87.50 Handling cost: 39.88 21% VAT: 0.00 Total (this is the amount you will deposit): 1202.38 Where i am applying this formula: (729.32 - 0.35) / 1.034/ 0.94 = 750.00 (<<--- CORRECT ) ? (1202.38 - 0.35) / 1.034/ 0.93 = 1250.01 (<<--- My problem why not 1250.00) ? How to correct the 7% formula to get exactly 1250.00 ? Instead of fraction error.

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >