Search Results

Search found 616 results on 25 pages for 'divide'.

Page 16/25 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Algorithm design: can you provide a solution to the multiple knapsack problem?

    - by MalcomTucker
    I am looking for a pseudo-code solution to what is effectively the Multiple Knapsack Problem (optimisation statement is halfway down the page). I think this problem is NP Complete so the solution doesn't need to be optimal, rather if it is fairly efficient and easily implemented that would be good. The problem is this: I have many work items, with each taking a different (but fixed and known) amount of time to complete. I need to divide these work items into groups so as to have the smallest number of groups (ideally), with each group of work items taking no longer than a given total threshold - say 1 hour. I am flexible about the threshold - it doesnt need to be rigidly applied, though should be close. My idea was to allocate work items into bins where each bin represents 90% of the threshold, 80%, 70% and so on. I could then match items that take 90% to those that take 10%, and so on. Any better ideas?

    Read the article

  • Is it a good idea to use only a key to encrypt an entire (small) filesystem?

    - by Fernando Miguélez
    This question comes as part of my doubts presented on a broader question about ideas implementing a small encrypted filesystem on Java Mobile phones (J2ME, BlackBerry, Android). Provided the litte feedback received, considering the density of the question, I decided to divide those doubts into small questions. So to sum up I plan to "create" an encrypted filesystem for for mobile phones (with the help of BoucyCastle or a subset of JCE), providing an API that let access to them in a transparent way. Encryption would be carried out on a file basis (not blocks). My question is this: Is it a good idea to use only a simmetric key (maybe AES-256) to encrypt all the files (they wouldn't be that many, maybe tens of them) and store this key in a keystore (protected by a pin) or would you rather encrypt each file with an on-the-fly generated key stored alongside each file, encrypting that key with the "master" key stored on the keystore? What are the benefits/drawbacks of each approach?

    Read the article

  • Sprint to the finish: how to keep all team-members busy in the final days of a Scrum sprint?

    - by sdg
    Given that the tasks in a specific sprint will not divide perfectly into the team, and all finish on the same date, what do you do to keep everyone working as the sprint moves into its final stages? Inevitably it seems like there will be one or two people freed-up. If all the other tasks are done-done, and the remaining tasks are already underway, then what? Do those team-members pick up items from the top of the product backlog, as they are likely to be needed in the next sprint anyways to get a head start? What do you or your teams do?

    Read the article

  • How do I hook all http get requests and distinguish downloaded (by standard download manager) files

    - by Ivan
    I want to write a Firefox add-on for advanced history tracking and bookmarking which will send URLs the browser meets during usage (and all the metadata available about the context) to a web service which will keep track of them storing in an SQL database for further access and analysis. I'd like to divide URLs tracked into 5 groups: those I explicitly click to bookmark, those I download by Firefox standard built-in download manager, all other URLs accessed, all URLs met on all viewed pages as hrefs, all other URLs mentioned in HTML sources of all viewed pages. Any ideas of how to get those in an extension?

    Read the article

  • Flexible Data source for Multi-Section Table View Controller

    - by TuanCM
    I have a TableViewController which display a list of NewsItem objects: @interface NewsItem : NSObject { NSString *feedID; NSString *title; NSDate *published; } I'm trying to implement a Table View Controller (multiple sections) that can display the list in two ways: One divide News Items into sections which based on Published Date The other would be based on FeedID (News source). And I don't know how to structure the data source so that the code is easy to maintain. I tried to put the list of News Items into a 2 dimension Array in this case is a NSMutableArray of NSArray objects. However I got some objc_exception_throw and I don't think this is flexible enough. Could you guys give me some ideas?

    Read the article

  • What is the need for normalizing a vector?

    - by Rashed Hassan
    Trying to understand vectors a bit more. What is the need for normalizing a vector? If I have a vector, N = (x, y, z) What do you actually get when you normalize it - I get the idea you have to divide x/|N| y/|N| & z/|N|. My question is, why do we do this thing, I mean what do we get out of this equation? What is the meaning or 'inside' purpose of doing this. A bit of a maths question, I apologize, but I am really not clear in this topic.

    Read the article

  • maximum of given function

    - by davit-datuashvili
    first of all i am doing programs in java language this code is merely taken from web site i have not question about divide and conqurer but about function and it's argument here is code of ternary search def ternarySearch(f, left, right, absolutePrecision): #left and right are the current bounds; the maximum is between them if (right - left) < absolutePrecision: return (left + right)/2 leftThird = (2*left + right)/3 rightThird = (left + 2*right)/3 if f(leftThird) < f(rightThird): return ternarySearch(f, leftThird, right, absolutePrecision) return ternarySearch(f, left, rightThird, absolutePrecision) i am not asking once again how implement it in java i am asking for example how define function?for example let y=x^+3 yes we can determine it as public static int y(int x){ return x*x+3; } but here return ternarySearch(f, leftThird, right, absolutePrecision) function f does not have argument and how do such?please help me

    Read the article

  • Enums With Default Throw Clause?

    - by Tom Tresansky
    I noticed the following in the Java Language spec in the section on enumerations here: link switch(this) { case PLUS: return x + y; case MINUS: return x - y; case TIMES: return x * y; case DIVIDE: return x / y; } throw new AssertionError("Unknown op: " + this); However, looking at the switch statement definition section, I didn't notice this particular syntax (the associated throw statement) anywhere. Can I use this sort of "default case is throw an exception" syntactic sugar outside of enum definitions? Does it have any special name? Is this considered a good/bad practice for short-cutting this behavior of "anything not in the list throws an exception"?

    Read the article

  • Given two lines on a plane, how to find integer points closest to their intersection?

    - by Lukasz Lew
    I can't solve it: You are given 8 integers: A, B, C representing a line on a plane with equation A*x + B*y = C a, b, c representing another line x, y representing a point on a plane The two lines are not parallel therefore divide plane into 4 pieces. Point (x, y) lies inside of one these pieces. Problem: Write a fast algorithm that will find a point with integer coordinates in the same piece as (x,y) that is closest to the cross point of the two given lines. Note: This is not a homework, this is old Euler-type task that I have absolutely no idea how to approach. Update: You can assume that the 8 numbers on input are 32-bit signed integers. But you cannot assume that the solution will be 32 bit.

    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

  • Haskell map function with predicate

    - by Paul
    I feel like this should be fairly obvious, or easy, but I just can't get it. What I want to do is apply a function to a list (using map) but only if a condition is held. Imagine you only wanted to divide the numbers which were even: map (`div` 2) (even) [1,2,3,4] And that would give out [1,1,3,2] since only the even numbers would have the function applied to them. Obviously this doesn't work, but is there a way to make this work without having to write a seperate function that you can give to map? Filter is almost there, except I also want to keep the elements which the condition doesn't hold for, and just not apply the function to them. Thanks

    Read the article

  • Automatic people counting + twittering.

    - by c2h2
    Want to develop a system accurately counting people that go through a normal 1-2m wide door. and twitter whenever people goes in or out and tells how many people remain inside. Now, Twitter part is easy, but people counting is difficult. There is some semi existing counting solution, but they do not quite fit my needs. My idea/algorithm: Should I get some infra-red camera mounting on top of my door and constantly monitoring, and divide the camera image into several grid and calculating they entering and gone? can you give me some suggestion and starting point?

    Read the article

  • Grouping data into ranges in R

    - by Maddy
    supposing i have a data frame in R that has names of students in one column and their marks in another column. these marks range from 20 to 100. > mydata id name marks gender 1 a1 56 female 2 a2 37 male i want to divide the student into groups, based on the criteria of obtained marks, so that difference between marks in each group should be more than 10. i tried to use the function table, which gives the number of students in each range from say 20-30, 30-40, but i want it to pick those students that have marks in a given range and put all their information together in a group. any help is appreciated.

    Read the article

  • From Fraction to Decimal and Back?

    - by CC
    Hi folks... Is it possible to store a fraction like 3/6 in a variable of some sort? When I try this it only stores the numbers before the /. I know that I can use 2 variables and divide them, but the input is from a single text field. Is this at all possible? I want to do this because I need to calculate the fractions to decimal odds. A bonus question ;) - Is there an easy way to calculate a decimal value to a fraction? Thanks..

    Read the article

  • A little help with MVC

    - by s0mmer
    Hi everyone, I'm working on a cocoa app for syncing data between two folders. It have profiles (so you can have multiple setups) It's possible to analyze data It's possible to sync the data Im a little confused. First of all i cant really see where to have a model? And how many controller would you suggest? 1 WindowController or AnalyzeController, SyncController etc. Its quite a while since i have worked with MVC. I've read some articles but i'm missing concrete examples on how to divide it. Best regards.

    Read the article

  • Get n Number of words using regex in Java

    - by Aymon Fournier
    I have a section of a book, complete with punctuation, line breaks etc. and I want to be able to extract the first n words from the text, and divide that into 5 parts. Regex mystifies me. This is what I am trying. I creates an array of index size 0, with all the input text: public static String getNumberWords2(String s, int nWords){ String[] m = s.split("([a-zA-Z_0-9]+\b.*?)", (nWords / 5)); return "Part One: \n" + m[1] + "\n\n" + "Part Two: \n" + m[2] + "\n\n" + "Part Three: \n" + m[3] + "\n\n" + "Part Four: \n" + m[4] + "\n\n" + "Part Five: \n" + m[5]; } Thanks!

    Read the article

  • Reading files with Java

    - by sikas
    I would like to know how can I read a file byte by byte then perform some operation every n bytes. for example: Say I have a file of size = 50 bytes, I want to divide it into blocks each of n bytes. Then each block is sent to a function for some operations to be done on those bytes. The blocks are to be created during the read process and sent to the function when the block reaches n bytes so that I don`t use much memory for storing all blocks. I want the output of the function to be written/appended on a new file. This is what I've reached to read, yet I don't know it it is right: fc = new JFileChooser(); File f = fc.getSelectedFile(); FileInputStream in = new FileInputStream(f); byte[] b = new byte[16]; in.read(b); I haven't done anything yet for the write process.

    Read the article

  • What algorithm would you use to code a parrot?

    - by Phil H
    A parrot learns the most commonly uttered words and phrases in its vicinity so it can repeat them at inappropriate moments. So how would you create a software version? Assuming it has access to a microphone and can record sound at will, how would you code it without requiring infinite resources? The best I can imagine is to divide the stream using silences in the sound, and then use some pattern recognition to encode each one as a list of tokens, storing new ones as you meet them. Hashing the token sequences and counting occurrences in a database, you could build up a picture of the most frequently uttered phrases. But given the huge variety in phrases, how do you prevent this just becoming a huge list? And the sheer number of pairs to match would surely generate lot of false positives from the combinatorial nature of matching. Would you use a neural net, since that's how a real parrot manages it? Or is there another, cleverer way of matching large-scale patterns in analogue data?

    Read the article

  • Return segmented average from SQL Query?

    - by Guillaume Filion
    Hi, I measure the load on DNS servers every minute and store that into an SQL DB. I want to draw a chart of the load for the last 48 hours. That's 69120 (48*24*60) data points but my chart's only 800 pixels wide so to make things faster I would like my SQL query to return only ~800 data points. It's seems to me like a pretty standard thing to do, but I've been searching the web and in books for such a thing for a while now and the closest I was able to find was a rolling average. What I'm looking for a more of a "segmented average": divide the 69120 data points in ~800 segments, then average each segment. My SQL table is: CREATE TABLE measurements ( ip int, measurement_time int, queries int, query_time float ) My query looks like this SELECT ip, queries FROM measurements WHERE measurement_time>(time()-172800) Thanks a lot!

    Read the article

  • Setting html controller to right side in firefox extension

    - by Yashwant Kumar Sahu
    Hi Expert, I am creating Mozilla extension. Here I need to set button controller right side in extension. Here I divide XUL file to div element. I have take a main div element and inside this i have take two more inner div. Then I have set one inner div style property float:left; and another div style property float:right. But this is not helpful for me. Here I also set Button CSS style property float:right which is inside the div which have property float:right. Awaiting for your response. Thanks in advance

    Read the article

  • Threads in PHP.

    - by Muhammad Sajid
    Hello.. I am creating a web application using zend, here i create an interface from where user-A can send email to more than one user(s) & it works excellent but it slow the execution time because of which user-A wait too much for the "acknowledged response" ( which will show after the emails have sent. ) In Java there are "Threads" by which we can perform that task (send emails) & it does not slow the rest application. Is there any technique in PHP/Zend just like in Java by which we can divide our tasks which could take much time eg: sending emails. Thanks..

    Read the article

  • How Can I Implement This In Java?

    - by davit-datuashvili
    first of all i am doing programs in java language this code is merely taken from web site i have not question about divide and conqurer algorithms but about function and it's argument here is code of ternary search def ternarySearch(f, left, right, absolutePrecision): #left and right are the current bounds; the maximum is between them if (right - left) < absolutePrecision: return (left + right)/2 leftThird = (2*left + right)/3 rightThird = (left + 2*right)/3 if f(leftThird) < f(rightThird): return ternarySearch(f, leftThird, right, absolutePrecision) return ternarySearch(f, left, rightThird, absolutePrecision) i am not asking once again how implement it in java i am asking for example how define function?for example let y=x^+3 yes we can determine it as public static int y(int x){ return x*x+3; } but here return ternarySearch(f, leftThird, right, absolutePrecision) function f does not have argument and how do such?please help me

    Read the article

  • How to detect if breaking an edge will make a graph disjoint?

    - by the_graph_guy
    I have a graph that starts off with a single, root node. Nodes are added one by one to the graph. At node creation time, they have to be linked either to the root node, or to another node, by a single edge. Edges can also be created and deleted (one by one, between any two nodes). Nodes can be deleted one at a time. Node and edge creation, deletion operations can happen in any arbitrary order. OK, so here's my question: When an edge is deleted, is it possible do determine, in constant time (i.e. with an O(1) algorithm), if doing this will divide the graph into two disjoint subgraphs? If it will, then which side of the edge will the root node belong? I'm willing to maintain, within reasonable limits, any additional data structure that can facilitate the derivation of this information. Maybe it is not possible to do it in O(1), if so any pointers to literature will be appreciated.

    Read the article

  • Breaking One Big Graphic of MutablePaths into CAShapeLayers

    - by StackOverFlowRider
    I have a class called GraphicView that takes a Graphic object and draws it in its drawRect method. This Graphic object is basically an array of mutablePaths that comprise an icon that I want drawn. For performance and other issues, I was thinking of taking this icon that is comprised of mutablePaths, and dividing it into a bunch of CAShapeLayers. I'm wondering is this possible? Considering the points for the mutablePaths of the icon are all interwoven together (ie the icon was initially an SVG file that I converted to code), is it possible to divide different parts of the icon into CAShapeLayers, and reassemble them all together when assigning to the views layer? If so how would it be done? If I assign them as sublayers to a CALayer or CAShapeLayer, will it understand to mesh them all together?

    Read the article

  • Create categorial variable in R based on range

    - by Stedy
    I have a dataframe with a column of integers that I would like to use as a reference to make a new categorical variable. I want to divide the variable into three groups and set the ranges myself (ie 0-5, 6-10, etc). I tried cut but that divides the variable into groups based on a normal distribution and my data is right skewed. I have also tried to use if/then statements but this outputs a true/false value and I would like to keep my original variable. I am sure that there is a simple way to do this but I cannot seem to figure it out. Any advice on a simple way to do this quickly?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >