Search Results

Search found 5070 results on 203 pages for 'algorithm'.

Page 58/203 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • How to turn this simple 10 digit hex number back into 8 digits?

    - by Babil
    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

    Read the article

  • How to test if an array contains a pair of numbers whose product is odd?

    - by John
    How can I write a function that takes an array of integers and returns true if their exists a pair of numbers whose product is odd? What are the properties of odd integers? And of course, how do you write this function in Java? Also, maybe a short explanation of how you went about formulating an algorithm for the actual implementation. Yes, this is a function out of a textbook. No, this is not homework—I'm just trying to learn, so please no "do your own homework comments."

    Read the article

  • Who owes who money optimisation problem

    - by Francis
    Say you have n people, each who owe each other money. In general it should be possible to reduce the amount of transactions that need to take place. i.e. if X owes Y £4 and Y owes X £8, then Y only needs to pay X £4 (1 transaction instead of 2). This becomes harder when X owes Y, but Y owes Z who owes X as well. I can see that you can easily calculate one particular cycle. It helps for me when I think of it as a fully connected graph, with the nodes being the amount each person owes. Problem seems to be NP-complete, but what kind of optimisation algorithm could I make, nevertheless, to reduce the total amount of transactions? Doesn't have to be that efficient, as N is quite small for me.

    Read the article

  • Draw arrow on line

    - by Pete
    Hi, I have this code: CGPoint arrowMiddle = CGPointMake((arrowOne.x + arrowTo.x)/2, (arrowOne.y + arrowTo.y)/2); CGPoint arrowLeft = CGPointMake(arrowMiddle.x-40, arrowMiddle.y); CGPoint arrowRight = CGPointMake(arrowMiddle.x, arrowMiddle.y + 40); [arrowPath addLineToScreenPoint:arrowLeft]; [arrowPath addLineToScreenPoint:arrowMiddle]; [arrowPath addLineToScreenPoint:arrowRight]; [[mapContents overlay] addSublayer:arrowPath]; [arrowPath release]; with this output: http://yfrog.com/edschermafbeelding2010032p What have i to add to get the left and right the at same degree of the line + 30°. If someone has the algorithm of drawing an arrow on a line, pleas give it. It doesn't matter what programming language it is... Thanks

    Read the article

  • python parallel computing: split keyspace to give each node a range to work on

    - by MatToufoutu
    My question is rather complicated for me to explain, as i'm not really good at maths, but i'll try to be as clear as possible. I'm trying to code a cluster in python, which will generate words given a charset (i.e. with lowercase: aaaa, aaab, aaac, ..., zzzz) and make various operations on them. I'm searching how to calculate, given the charset and the number of nodes, what range each node should work on (i.e.: node1: aaaa-azzz, node2: baaa-czzz, node3: daaa-ezzz, ...). Is it possible to make an algorithm that could compute this, and if it is, how could i implement this in python? I really don't know how to do that, so any help would be much appreciated

    Read the article

  • 3D Mesh Joining

    - by morlst
    I have 2 (or more) intersecting meshes, which require joining into 1 mesh object. I want to have some control over the resulting seam vertex insertion, so looking to write myself rather than use a library. Has anyone come across some open source code to base the algorithm on / ideas on the process? Initial impressions are: 1. Present in every 3D modelling program - mostly reinventing existing process (hence search for examples) 2. Potential for fiddly-ness around the polygon face direction and just touching conditions. (see above point)

    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

  • Help with algorithm to determine phrase occurrence in string in PHP

    - by Will M.
    I have an array of phrases (max 2 words) like $words = array('barack obama', 'chicago', 'united states'); and then I have a string like: $sentence = "Barack Obama is from Chicago. Barack Obama's favorite food it pizza."; I want to find/create an efficient algorithm that would return the number of occurrences of the words in the array $words in the string $sentence. In this case it would be: 'barack obama' => 2 'chicago' => 0 How can I built this?

    Read the article

  • Make any posible combination of one string with php

    - by Johan
    I need an algorithm that return all possible combination of all characters in one string. I've tried: $langd = strlen($input); for($i = 0;$i < $langd; $i++){ $tempStrang = NULL; $tempStrang .= substr($input, $i, 1); for($j = $i+1, $k=0; $k < $langd; $k++, $j++){ if($j > $langd) $j = 0; $tempStrang .= substr($input, $j, 1); } $myarray[] = $tempStrang; } But that only returns the same amount combination as the length of the string. Say the $input is = "hey", the result would be: hey, hye, eyh, ehy, yhe, yeh.

    Read the article

  • Divide people into teams for most satisfaction

    - by Jweede
    Just a curiosity question. Remember when in class groupwork the professor would divide people up into groups of a certain number (n)? Some of my professors would take a list of n people one wants to work with and n people one doesn't want to work with from each student, and then magically turn out groups of n where students would be matched up with people they prefer and avoid working with people they don't prefer. To me this algorithm sounds a lot like a Knapsack problem, but I thought I would ask around about what your approach to this sort of problem would be.

    Read the article

  • merge three file into one big file

    - by davit-datuashvili
    suppose that we have three array int a[]=new int[]{4,6,8,9,11,12}; int b[]=new int[]{3,5,7,13,14}; int c[]=new int[]{1,2,15,16,17}; and we want to merge it into one big d array where d.length=a.length+b.length+c.length but we have memory problem it means that we must need use only this d array where we should merge these these three array of course we can use merge sort but can we use merge algorithm without sorting method? like two sorted array we can merge in one sorted array what about three or more array?

    Read the article

  • Randomly generating sequence of ints in a specific range

    - by vvv
    Hi, I am unsure how to put this and my math skills aren't that strong. But here's what I need. I want to generate a list of all the 16bit integers (0-65535). But everytime I do so I want to seed the algorithm randomly that each time the list starts with a different integer and all the subsequent integers will be generated once but also in random order. small example (1-5): ... 1, 5, 3, 2, 4 4, 3, 1, 5, 2 2, 1, 4, 5, 3 ... Any help?

    Read the article

  • Arrange 0's & 1's in a array

    - by Ganesh M
    This is one of an interview question which I had recently. I would like to know others perception of approach for this problem. Question: You are given a structure which holds an employee details with two elements as int Deptartment and string Name. struct Employee { string Name; int Dept; } You are given details of N Employees among which there are N/2 employees Dept are 0's and N/2 employees dept are 1's arranged in some random order. You need to sort the employee details based on their Dept value and it should be stable i.e., the order of 1s and 0s in the original record should be maintained. For example, given the following sample data: Name Dept X1 0 X2 1 X3 0 X4 1 X5 0 after sorting the result should be: Name Dept X2 1 X4 1 X1 0 X3 0 X5 0 The algorithm should be stable and the complexity should be o(N), with constant space for additional variables (which means sorting should be done in-place).

    Read the article

  • How do I pick the most beneficial combination of items from a set of items?

    - by Chu
    I'm designing a piece of a game where the AI needs to determine which combination of armor will give the best overall stat bonus to the character. Each character will have about 10 stats, of which only 3-4 are important, and of those important ones, a few will be more important than the others. Armor will also give a boost to 1 or all stats. For example, a shirt might give +4 to the character's int and +2 stamina while at the same time, a pair of pants may have +7 strength and nothing else. So let's say that a character has a healthy choice of armor to use (5 pairs of pants, 5 pairs of gloves, etc.) We've designated that Int and Perception are the most important stats for this character. How could I write an algorithm that would determine which combination of armor and items would result in the highest of any given stat (say in this example Int and Perception)?

    Read the article

  • Getting facts from documents

    - by dotnetdev
    Hi, I want to be able to get all the facts from webpages. But these have to be related to coding, and not, for example, about something irrelevant. For example: The Engine renders at a decent speed. May be a fact but is not what I am interested in. If the same article states: A class is a reference type. (This is C#) Then I am interested in that as it is coding related. Has an algorithm like this ever been done? How hard would this be? I'm thinking AI would come into play here. Any advice sought. Thanks

    Read the article

  • Find the period of over speed ?

    - by Vimvq1987
    Just something interesting come in my mind. Assume that we have a table (in SQL Server) like this: Location Velocity Time What is the best way to determine over speed periods (speed barrier is defined) ? My first idea was loading the table into an array, and then iterate over array to find these periods: (Pseudo C# code) bool isOverSpeed = false; for (int i =0;i<arr.Length;i++) { if (!isOverSpeed) if (arr[i].Velocity > speedBarrier) { #insert the first record into another array. isOverSpeed = true; } if(isOverSpeed) if (arr[i].Velocity < speedBarrier) { #insert the record into that array isOverSpeed = false; } } It works, but somewhat "not very effectively". Is there a "smarter" way, such as a T-SQL query or another algorithm to do this?

    Read the article

  • Creative Technical Interview Questions for Developers

    - by John Shedletsky
    I do a good number of in-person technical interviews for new developers. I like to ask technical questions where I ask people to either code something up or develop an algorithm to solve a task. I feel my current repertoire is uninspired. In my opinion, the ideal interview question has these qualities: Multiple solutions, where some are obviously better than others, and some that involve subtle trade-offs (discussing tradeoffs is a good way to gauge someone's experience, in my opinion). Novelty - asking the "insert this element into a linked list" question is only good for weeding out people who never did their homework. Elegant - I like questions where the core problem isn't hidden in a lot of details. Everyone should be able to understand the problem, even if everyone can't solve it on the whiteboard. Elegant questions are difficult without involving undue amounts of "domain knowledge" or getting too narrow. Have you been on either side of an interview where someone (maybe you!) asked a particularly good programming or algorithms question?

    Read the article

  • How can you distribute the color intensity of two images using its gradients?

    - by Jeppy-man
    Hello everyone... I am working on an automatic image stitching algorithm using MATLAB. So far, I have downloaded a source code much like the one that I had in mind and so, I'm currently studying how the code work. The problem is, when stitching two or more images together, their color intensity will most probably be different from each other so the stitched seams will be visible to the eye... So, right now, I'm trying to find out how to redistribute their color intensity using the images gradients so that the whole stitched image will have the same color intensity. I hope someone can help me out there and if so, thank you very much...

    Read the article

  • question abouut string sort

    - by davit-datuashvili
    i have question from programming pearls problem is following show how to use lomuto's partitioning scheme to sort varying length bit strings in time proportional to the sum oof their length and algorithm is following each record in x[0..n-1] has an integer length and pointer to the array bit[0..length-1] code void bsort(l,u,depth){ if (l>=u) return; for (int i=l;i<u;i++) if (x[i].length<depth) swap(i,l++); m=l; if (x[i].bit[depth] ==0) swap(i,m++); bsort(l,m-1,depth+1); bsort(m,u,depth+1); please help me i need following things 1. how this algorith works 2.how implement in java?

    Read the article

  • Having trouble getting GET variables from url.

    - by mchl
    Hey everyone, I'm having trouble with this algorithm to extract the get variables from a url and print them each on a new line like: x=y z=hello etc. but instead it prints a seemingly random section of the url with no newlines to the file. There must be a logic error of some kind but i just can't spot it. for(i_m=0;i_m<len_m;i_m++) { if(var_m[i_m]=='&') { fwrite(var_m+offset_m, 1, amp_m, echo_out); fputc('\n',echo_out); offset_m+=amp_m; amp_m=0; } amp_m++; } any help appreciated.

    Read the article

  • Permutations with extra restrictions

    - by Full Decent
    I have a set of items, for example: {1,1,1,2,2,3,3,3}, and a restricting set of sets, for example {{3},{1,2},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{2,3},{2,3}. I am looking for permutations of items, but the first element must be 3, and the second must be 1 or 2, etc. One such permutation that fits is: {3,1,1,1,2,2,3} Is there an algorithm to count all permutations for this problem in general? Is there a name for this type of problem? For illustration, I know how to solve this problem for certain types of "restricting sets". Set of items: {1,1,2,2,3}, Restrictions {{1,2},{1,2,3},{1,2,3},{1,2},{1,2}}. This is equal to 2!/(2-1)!/1! * 4!/2!/2!. Effectively permuting the 3 first, since it is the most restrictive and then permuting the remaining items where there is room.

    Read the article

  • Implementing "select distinct ... from ..." over a list of Python dictionaries

    - by daveslab
    Hi folks, Here is my problem: I have a list of Python dictionaries of identical form, that are meant to represent the rows of a table in a database, something like this: [ {'ID': 1, 'NAME': 'Joe', 'CLASS': '8th', ... }, {'ID': 1, 'NAME': 'Joe', 'CLASS': '11th', ... }, ...] I have already written a function to get the unique values for a particular field in this list of dictionaries, which was trivial. That function implements something like: select distinct NAME from ... However, I want to be able to get the list of multiple unique fields, similar to: select distinct NAME, CLASS from ... Which I am finding to be non-trivial. Is there an algorithm or Python included function to help me with this quandry? Before you suggest loading the CSV files into a SQLite table or something similar, that is not an option for the environment I'm in, and trust me, that was my first thought.

    Read the article

  • complexity of algorithms

    - by davit-datuashvili
    i have question what is complexity of this algorithm public class smax{ public static void main(String[]args){ int b[]=new int[11]; int a[]=new int[]{4,9,2,6,8,7,5}; for (int i=0;i int m=0; while (m int k=a[0]; for (int i=0;i k && b[a[i]]!=1){ b[a[i]]=1; } } m++; } for (int i=0;i for (int j=0;j //result=2 4 5 6 7 8 9 } } ?

    Read the article

  • Print all ways to sum n integers so that they total a given sum.

    - by noghead
    Im trying to come up with an algorithm that will print out all possible ways to sum N integers so that they total a given value. Example. Print all ways to sum 4 integers so that they sum up to be 5. Result should be something like: 5 0 0 0 4 1 0 0 3 2 0 0 3 1 1 0 2 3 0 0 2 2 1 0 2 1 2 0 2 1 1 1 1 4 0 0 1 3 1 0 1 2 2 0 1 2 1 1 1 1 3 0 1 1 2 1 1 1 1 2

    Read the article

  • How to get it working in O(n)?

    - by evermean
    I came across an interview task/question that really got me thinking ... so here it goes: You have an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n). I really tried to come up with a solution but I always end up with a complexity of O(n^2). Perhaps the is anyone smarter than me who can tell me an algorithm that works in O(n) or at least give me a hint...

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >