Tag Info

Hot answers tagged

17

Do some bookkeeping about the already taken calls and calculate their distribution over the n lines. This gives you n percentage values (your already achieved distribution), which can be compared to the n percentages you want to achieve. Whenever a new call comes in, assign that call to the line with the highest deviation from the target value (note that as ...


10

A Helper class is a lesser known code smell where a coder has identified some miscellaneous, commonly used operations and attempted to make them reusable by lumping them together in an unnatural grouping. Successive developers have then come onto the project and not realised that the helper class exists, and have consequently rewritten the same common ...


5

This is a classic machine learning problem. It's an example of regression. You'd want to split your set of "knowns" into two groups, one to train with, and one to test against. Set up the appropriate machine learning algorithm* and train with part of your knowns. Then input the other set of inputs to check the reliability of the answer against the known ...


4

If Solver is appropriate depends primarily on how you build your model for the given problem, and if the problem size stays within the boundaries of the solver. According to this site, the limit for Excel Solver is 200 decision variables and 100 constraints (they are also promoting their premium solver product for bigger problem sizes). But when you use ...


4

This is a common problem in games programming. I know of two approaches, which I think of as Forwards and Backwards. Forwards means that you generate a game by adding random things (asteroids) using some heuristics, and then you check that it has any solution (within the order of difficulty required). You keep randomly adding and checking until it gets too ...


4

Please define the terms mesh and linear array of processors, and/or provide online references to such definitions. There are different flavors of mergesort algorithms. One remarkable difference is: For merging two sorted halves of size N/2 arrays into a fully sorted N array, does it take exactly one stage (performing exactly N or O(N) comparisons), or ...


4

You should definitely get more experience in theoretical computer science. This function is trivial to define. Say you have pairs p_i = (I_i, O_i) of input/output pairs, then you can define f(I) by a simple chained if-else, in which you test whether I == I_i and then return O_i for each i. Given that your I_i are unique (i.e. your pairs show determinism of ...


3

If you make 26X26 matrix to represent directed graph of vertex as each alphabet and words as edge. For example word - APPLE connect vertex A and E with edge directed from A to E. Now the problem reduces to finding largest Eulerian trail (path which includes maximum number of edges, visiting each edge once wit possible repetition of vertices) in the graph. ...


3

If the number of hours each person is available is constant (e.g. it's always 1 hour), then your problem can be modeled as a Network Flow, easily solvable in polynomial time with Ford-Fulkerson's algorithm. To build your flow network, create two layers of nodes; the first layer represents your balls, the second layer represents your buckets. Add an edge ...


3

What you're looking for is a the set of contiguous high-order bits in the address that don't change across the entire set of addresses. IPv4 addresses are, at their core, 32-bit unsigned integers. The dotted-quad notation is a convenience for humans. It's best to deal with them in that form. Conversion is easy: integer_ip = (octet1 << 24) | ...


2

I would make the minimum = 0 when 0 questions were answered and time elapsed was 60 mins. From there, add points for every question answered and total time left, e.g. Let's say each correct answer = 200 points. Each unused minute = 20 points. 5 questions answered in 60 mins = 1000 points. 5 questions answered in 30 mins = 1000 + 600 = 1600 points. 10 ...


2

I would choose one coordinate (x/y) and find dividing line that divides returned points to two parts, ideally 5/5. This way you don't call api extremely lot of time if there are dots clustered really close to corner of your original rectangle. Another thing, if you have some good heuristic for density, you could skip calls for large rectangles and start ...


2

How you divide the bounding box is a matter of optimizing API calls. Break it into quadrants and you risk to have to subdivide those further for not being small enough. Break it into grid and you risk to make superfluous API calls when quadrants would do. Ideally you'd want to break it into a number of boxes that divides the number of points into 10 ...


2

Let's suposse the number of workers is less than 100 Create an array of workers with a capacity of 100 Put in that array a worker a number of times equal to the percentage of calls he should get, for example if worker1 should get 30% of all calls, then put him in positions 0 to 29 of the array. At the end every position of the array should be used, and the ...


2

I agree with @DocBrown's solution. Placing it into an algorithm form: for each incomming call: sort lines ascending by delta* (see footnote below) // first element in array gets the call increase number of calls for first element by 1 Delta is determined by the actual percentage minus the expected percentage of a line. In this way, those ...


2

What determines the size of the space? I think you're focusing on the vertices when you should be focusing on the lines. Since you've changed the shape as well as the size, it would seem to be pretty easy. Given a gap width W, slice W/2 each side of all internal lines and W away from all borders. Then revise the vertices locations to match the new ...


2

A helper is a harmless additional class or method, as long as it complements an external component. When it does the contrary, then it indicates bad design because the code has been excluded from its authority, if there is any authority at all. Here is an example of a harmless helper, I use a method called FindRep that counts the number of leading zeros. ...


2

you can extract the adjacency matrix by from the path matrices by using the following property. There is a edge between 2 vertexes s and d if and only if the shortest path between them contains only s and d. For non-uniform length you will only get the unique solution if the triangle inequality holds. Otherwise a graph with d(p1,p2)=1 d(p2,p3)=2 and ...


2

The algorithm seems simple enough, apart from rounding errors. Add up all the weights => Wt. Allocate each user a number of tasks = N times user weight Wx / Wt, rounded down. There should be about N/2 task left over due to rounding. Allocate 1 task to each user in descending order of magnitude of rounding error (or any other algorithm if you prefer).


1

Put all integers from 0 to NxM-1 into an array, shuffle that array randomly and pick the results one after another (mapping to row/column could be anything trivial like row=idx mod M , col=idx/M). A good shuffle algorithm is Fisher-Yates shuffling, see here.


1

It is trivial to generate functions that map the known inputs to known outputs and the other inputs to some outputs. It is, however, impossible to generate functions that map the other inputs to the "right" outputs, simply because you don't know what the "right" outputs are. Or, put another way: since you don't know what the outputs should be, I can give ...


1

This problem can be interpreted as a variant of the travelling salesman problem, as @randomA has noted in a comment. The bands form the nodes of a graph to be visited, the "distance" between two bands is the number of musicians they don't have in common (the number of musicians which has to change for a band change). The goal is to minimize the total cost of ...


1

Assumptions as OP stated The number of lines, n, is known and; The % of each line is known Algorithm Design Define each line by its % Sort each line by its position away from 0 defined as (current % of workers - assigned % of workers) or by random assignation if all lines = 0 Forward each call to largest line away from 0 Example: 3 lines with a % of ...


1

It is a bit unclear in your question whether you ask about how to parallelize the Random Forests™ 1 algorithm, or you ask which other algorithm would perform better. On the first issue, it seems that the Random Forests™ algorithm is embarrassingly parallel, and that there is a readily parallel implementation of the algorithm within scikit-learn, ...


1

You can add dummy nodes to B having edges with weight 0 to nodes in A and then invert the weights of edges. Check http://en.wikipedia.org/wiki/Assignment_problem and I think you can apply Hungarian algorithm to this problem with the modification and after finding the minimum total cost you can invert the weights again.


1

An interesting computer science problem. An encoding strategy that achieved this would necessarily have more or less the following features. The sign is represented in such a way that the high order bit is 1 for positive values, and all following bits are complemented for negative. The exponent is encoded as its magnitude, preceded by its length (which ...


1

The general scheme for sorting BigDecimal works as follows: Sort the sign bit. Note: if the sign bit is negative, the sort order of the subsequent steps must be negated. Remove the sign bit and convert the remaining bits into absolute value. In other words, a sign-magnitude representation is used. Sort by the position of the "highest bit set". If A ...


1

I do not think that there is much you can do about it. If you know the point density, you could break down the quadrants accordingly. If the points do not change you could cache them, so initially you would have a relatively high amount of calls to the API which will eventually minimize itself as your application matures.


1

The Windows copy/paste function has several components. A cute GUI interface Pre-analysis of the work to be done, to help the GUI provide nice feedback and detect conflicts Essentially single tasking A very fast internal API for copying files. In my opinion you are unlikely to be able to write code that can beat the Windows CopyFile() API function. You ...


1

Copying the comments to get the problem out of the unanswered problems queue, and making it community wiki. This sounds like the travelling salesman problem. See Algorithm for an exact solution to the Travelling Purchaser Problem This is known as the assignment problem: en.wikipedia.org/wiki/Assignment_problem - Wikipedia lists some algorithms to solve it ...



Only top voted, non community-wiki answers of a minimum length are eligible