Search Results

Search found 199 results on 8 pages for 'permutations'.

Page 5/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Unix [Homework]: Get a list of /home/user/ directories in /etc/passwd

    - by KChaloux
    I'm very new to Unix, and currently taking a class learning the basics of the system and its commands. I'm looking for a single command line to list off all of the user home directories in alphabetical order from the /etc/passwd directory. This applies only to the home directories, and not the contents within them. There should be no duplicate entries. I've tried many permutations of commands such as the following: sort -d | find /etc/passwd /home/* -type -d | uniq | less I've tried using -path, -name, removing -type, using -prune, and changing the search pattern to things like /home/*/$, but haven't gotten good results once. At best I can get a list of my own directory (complete with every directory inside it, which is bad), and the directories of the other students on the server (without the contained directories, which is good). I just can't get it to display the /home/user directories and nothing else for my own account. Many thanks in advance.

    Read the article

  • Algorithm shortest path between all points

    - by Jeroen
    Hi, suppose I have 10 points. I know the distance between each point. I need to find the shortest possible route passing trough all points. I have tried a couple of algorithms (Dijkstra, Floyd Warshall,...) and the all give me the shortest path between start and end, but they don't make a route with all points on it. Permutations work fine, but they are to resource expensive. What algorithms can you advise me to look into for this problem? Or is there a documented way to do this with the above mentioned algorithms? Tnx Jeroen

    Read the article

  • What is an efficient way to write password cracking algorithm (python)

    - by Luminance
    This problem might be relatively simple, but I'm given two text files. One text file contains all encrypted passwords encrypted via crypt.crypt in python. The other list contains over 400k+ normal dictionary words. The assignment is that given 3 different functions which transform strings from their normal case to all different permutations of capitalizations, transforms a letter to a number (if it looks alike, e.g. G - 6, B - 8), and reverses a string. The thing is that given the 10 - 20 encrypted passwords in the password file, what is the most efficient way to get the fastest running solution in python to run those functions on dictionary word in the words file? It is given that all those words, when transformed in whatever way, will encrypt to a password in the password file. Here is the function which checks if a given string, when encrypted, is the same as the encrypted password passed in: def check_pass(plaintext,encrypted): crypted_pass = crypt.crypt(plaintext,encrypted) if crypted_pass == encrypted: return True else: return False Thanks in advance.

    Read the article

  • Create many constrained, random permutation of a list

    - by Eyal
    I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as close as possible). For instance, if my elements are 0,1,2,3, y is 6, and z is 2, then one possible solution is: 0,3 1,2 3,0 2,1 0,1 2,3 Each row has only unique elements and no element has been used more than 3 times. If y were 7, then 2 elements would be used 4 times, the rest 3.

    Read the article

  • Style Switcher & Text Resizer Combined?

    - by Stephen
    Hi there, I've came across various style switchers that allow you to change the stylesheet (i.e. Light, Dark, High Contrast), and carious text-resizers that allow you to resize the test (usually with Three A's, small, medium and large). However, I can't seem to find a single switcher/resizer that works well together by allowing permutations of the two. i.e. so the user can choose a dark background with small text, or a dark background with large text, etc. I can only seem to get this working where the user can choose one or the other styles (large text or High Contrast, not a combination of the two). Any ideas on anything that may be suitable for this at all? Thanks, Stephen

    Read the article

  • Test Column exists, Add Column, and Update Column

    - by david.clarke
    I'm trying to write a SQL Server database update script. I want to test for the existence of a column in a table, then if it doesn't exist add the column with a default value, and finally update that column based on the current value of a different column in the same table. I want this script to be runnable multiple times, the first time updating the table and on subsequent runs the script should be ignored. My script currently looks like the following: IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'PurchaseOrder' AND COLUMN_NAME = 'IsDownloadable') BEGIN ALTER TABLE [dbo].[PurchaseOrder] ADD [IsDownloadable] bit NOT NULL DEFAULT 0 UPDATE [dbo].[PurchaseOrder] SET [IsDownloadable] = 1 WHERE [Ref] IS NOT NULL END SQL Server returns error "Invalid column name 'IsDownloadable'", i.e. I need to commit the DDL before I can update the column. I've tried various permutations but I'm getting nowhere fast.

    Read the article

  • pip requirements.txt with alternative index

    - by piquadrat
    I want to put all the requirements of a repoze Zope2 install in a pip requirements file. Most of the repoze packages don't seem to be on PyPi, but there's an alternative PyPi index for them here. But I can't figure out how to tell pip to use that index together with a requirements file. For single packages, it's easy pip install zopelib -i http://dist.repoze.org/zope2/2.10/simple/ I tried the following pip install -r requirements.txt -i http://dist.repoze.org/zope2/2.10/simple/ or in my requirements.txt all kind or permutations of these: zopelib -i http://dist.repoze.org/zope2/2.10/simple/ zopelib --index http://dist.repoze.org/zope2/2.10/simple/ -i http://dist.repoze.org/zope2/2.10/simple/ zopelib or (because the documentation says "Note that all these options must be on a line of their own.") --index http://dist.repoze.org/zope2/2.10/simple/ zopelib So, what's the correct way of telling pip to use http://dist.repoze.org/zope2/2.10/simple/ as index?

    Read the article

  • How would you go about tackling this problem?

    - by incrediman
    I have a programming contest coming up in about half a week, and I've been prepping :) I found a bunch of questions from this canadian competition, they're great practice: http://cemc.math.uwaterloo.ca/contests/computing/2009/stage2/day1.pdf I'm looking at problem B ("Dinner"). Any idea where to start? I can't really think of anything besides the naive approach (ie. trying all permutations) which would take too long to be a valid answer. Btw, the language there says c++ and pascal I think, but i don't care what language you use - I mean really all I want is a brief description of how to tackle the problem. Like "use X technique treating each programmer as a Y" or something :)

    Read the article

  • Graph and permutation problem

    - by user319771
    I have a graph (with nodes and edges) containing symmetry and a group of permutations to label the nodes so no edges are changed (automorphisms). Now I would like to determine for which nodes a permutation exchanges two equivalent (i.e. nodes with the same color or symmetry class) neighboring nodes. When the nodes with equivalent neighbors stay the same, simply checking if the neighbors are exchanged in the permutation is enough. However, when the nodes with equivalent neighbors are also permuted (i.e. there are multiple nodes with the same color/symmetry class with the same equivalent neighbors), the problem becomes more complex. Is there any known algorithm for such a problem? Some remarks: The graph has no coordinates, it's a topology only

    Read the article

  • Find all words containing characters in UNIX

    - by fahdshariff
    Given a word W, I want to find all words containing the letters in W from /usr/dict/words. For example, "bat" should return "bat" and "tab" (but not "table"). Here is one solution which involves sorting the input word and matching: word=$1 sortedWord=`echo $word | grep -o . | sort | tr -d '\n'` while read line do sortedLine=`echo $line | grep -o . | sort | tr -d '\n'` if [ "$sortedWord" == "$sortedLine" ] then echo $line fi done < /usr/dict/words Is there a better way? I'd prefer using basic commands (instead of perl/awk etc), but all solutions are welcome! To clarify, I want to find all permutations of the original word. Addition or deletion of characters is not allowed.

    Read the article

  • Can any genius out there turn this code from generating permutation to generating combination?

    - by mark
    #include <string> int main(int,char**) { std::string default_str = "12345"; int perm=1, digits=default_str.size(); for (int i=1;i<=digits;perm*=i++); for (int a=0;a<perm;a++) { std::string avail=default_str; for (int b=digits,div=perm;b>0; b--) { div/=b; int index = (a/div)%b; printf("%c", avail[index] ); avail.erase(index,1) ; } printf("\n"); } printf("permutations:%d\n",perm); while(1); }

    Read the article

  • total number of magic square from 9 numbers

    - by Peeyush
    9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum.(condition for diagonal has been relaxed) For example: 1 2 3 3 2 1 2 2 2 How do we calculate total number of distinct magic square from 9 numbers. Two magic number squares are distinct if they differ in value at one or more positions. For example, there is only one magic number square that can be made of 9 instances of the same number. e.g. for these 9 numbers { 4, 4, 4, 4, 4, 4, 4, 4, 4 }, answer should be 1. Also the complexity should be optimal. Do we need to iterate through all the permutations , discarding if a[0]+a[1]+a[2] %3!=0 such combinations ? moreover how do we remove duplicate magic square?

    Read the article

  • Counting problem: possible sudoko tables?

    - by Sorush Rabiee
    Hi, I'm working on a sudoko solver. my method is using a game tree and explore possible permutations for each set of digits by DFS Algorithm. in order to analyzing problem, i want to know what is the count of possible valid and invalid sudoko tables? - a 9*9 table that have 9 one, 9 two, ... , 9 nine. (this isn't exact duplicate by this question) my solution is: 1- First select 9 cells for 1s: (*) 2- and like (1) for other digits (each time, 9 cells will be deleted from remaining available cells): C(81-9,9) , C(81-9*2,9) .... = 3- finally multiply the result by 9! (permutation of 123456789 in (*)) this is not equal to accepted answer of this question but problems are equivalent. what did i do wrong?

    Read the article

  • Rolling back database changes

    - by justin
    Hi, I work in team which uses Work flow management tool. I was presented with a challenge where the user should be able to roll back the changes made anytime during the flow to a certain point in the past. Surely the toll can handle it but the additional database calls that may have made during these activities have to be manually rolled back. the challenge is that there are multiple parallel paths and there different permutations of external database calls. So is there a frame work or a way to keep track of these DB calls and rollback them?. thank you, Justin

    Read the article

  • Unable to view GWT 2.0.1 application in IE8.

    - by shyam.m
    Hi, I'm creating an application using GWT 2.0.1; it complies 6 computations and runs well in all browsers except IE8, it shows a blank page( but can be viewed in IE8 compatibility mode) . When I add the line in my gwt.xml <set-property name="user.agent" value="ie8" / > it compiles just 1 permutation and the application displays fine in IE8. However if I add the line lt;set-property name="user.agent" value="ie8,gecko,gecko1_8,safari,opera" /gt; it compiles all permutations, but the application still cannot be viewed in IE8 but runs properly in all other browsers. Is there any other method to ensure my application will run in all browsers ?

    Read the article

  • Python beginner, strange output problem

    - by Protean
    I'm having a weird problem with the following piece of code. from math import sqrt def Permute(array): result1 = [] result2 = [] if len(array) <= 1: return array for subarray in Permute(array[1:]): for i in range(len(array)): temp1 = subarray[:i]+array[0]+subarray[i:] temp2 = [0] for num in range(len(array)-1): temp2[0] += (sqrt(pow((temp1[num+1][1][0]-temp1[num][1][0]),2) + pow((temp1[num+1][1][1]-temp1[num][1][1]),2))) result1.append(temp1+temp2) return result1 a = [['A',[50,1]]] b = [['B',[1,1]]] c = [['C',[100,1]]] array = [a,b,c] result1 = Permute(array) for i in range(len(result1)): print (result1[i]) print (len(result1)) What it does is find all the permutations of the points abc and then returns them along with the sum of the distances between each ordered point. It does this; however, it also seems to report a strange additional value, 99. I figure that the 99 is coming from the computation of the distance between point a and c but I don't understand why it is appearing in the final output as it does.

    Read the article

  • What's the best way to parse RSS/Atom feeds for an iPhone application?

    - by jpm
    So I understand that there are a few options available as far as parsing straight XML goes: NSXMLParser, TouchXML from TouchCode, etc. That's all fine, and seems to work fine for me. The real problem here is that there are dozens of small variations in RSS feeds (and Atom feeds too), so supporting all possible permutations of feeds available out on the Internet gets very difficult to manage. I searched around for a library that would handle all of these low-level details for me, but came out without anything. Since one could link to an external C/C++ library in Objective-C, I was wondering if there is a library out there that would be best suited for this task? Someone must have already created something like this, it's just difficult to find the "right" option from the thousands of results in Google. Anyway, what's the best way to parse RSS/Atom feeds in an iPhone application?

    Read the article

  • Is there a way to avoid IE7 quirks mode while rendering XML + CSS?

    - by Steven Huwig
    I've got some DocBook documentation styled with a CSS xml-stylesheet declaration. It looks great in Firefox, but IE7 doesn't seem to understand the CSS child selectors (e.g. section > title { ... }). I think this is because IE is running in quirks mode to render this XML, and older versions of IE didn't support that CSS syntax at all. The pages I found on the web all seem to focus on HTML and XHTML doctypes and how IE will behave given various permutations of these values. I couldn't find any information about straight XML + CSS. Worse yet, it seems that random XML documents always end up in quirks mode, no matter what format or stylesheet directives they have. Is XML rendering in IE doomed to be IE5.5 compatible? Will I really have to rewrite my CSS?

    Read the article

  • How to have a UISwipeGestureRecognizer AND UIPanGestureRecognizer work on the same view

    - by Shizam
    How would you setup the gesture recognizers so that you could have a UISwipeGestureRecognizer and a UIPanGestureRecognizer work at the same time? Such that if you touch and move quickly (quick swipe) it detects the gesture as a swipe but if you touch then move (short delay between touch & move) it detects it as a pan? I've tried various permutations of requireGestureRecognizerToFail and that didn't help exactly, it made it so that if the SwipeGesture was left then my pan gesture would work up, down and right but any movement left was detected by the swipe gesture.

    Read the article

  • Recursion Interview Questions [closed]

    - by halivingston
    Given a string, "ABC", print all permutations Given a dollar bill, fill out possible ways it can summed up using .25, .10, .5, etc. Given a phone number (123-456), print out all it's word counter parters like (ADG-XYZ) A B C D E F G H I J K L M N O P In the above 2D matrix, print all possible words (just literally all words, and sure we could check if it's exists in a dictionary). The base case is I think here is that reaching the same i, j positions. Any others you can think of?

    Read the article

  • Best tools to parse reports

    - by Andy Schaefer
    I have a report that I need to parse/scrape for loading into an alternate or query-able data store. The report looks like something akin to: this. My gut is that PERL would do a decent job, but I have several different permutations of the report and I don't really want to make a script around each form. This report is a pretty stock type report, and I have seen where Monarch Pro can parse these types of reports, but I have had a difficult time finding alternatives to how these could be parsed since I'm looking to do this working primarily in a Linux environment. Any suggestions?

    Read the article

  • C++: concatenate ints in an array?

    - by Nate
    As part of a homework assignment I need to concatenate certain values in an array in C++. So, for example if I have: int v[] = {0,1,2,3,4} I may need at some point to concatenate v[1] - v[4] so that I get an int with the value 1234. I got it working using stringstream, by appending the values onto the stringstream and then converting back to an integer. However, throughout the program there will eventually be about 3 million different permutations of v[] passed to my toInt() function, and the stringstream seems rather expensive (at least when dealing with that many values). it's working, but very slow and I'm trying to do whatever I can to optimize it. Is there a more optimal way to concatenate ints in an array in C++? I've done some searching and nearly everywhere seems to just suggest using stringstream (which works, but seems to be slowing my program down a lot). EDIT: Just clarifying, I do need the result to be an int.

    Read the article

  • Time Complexities of recursive algorithms

    - by Peter
    Whenever I see a recursive solution, or I write recursive code for a problem, it is really difficult for me to figure out the time complexity, in most of the cases I just say its exponential? How is it exponential actually? How people say it is 2^n, when it is n!, when it is n^n or n^k. I have some questions in mind, let say find all permutations of a string (O(n!)) find all sequences which sum up to k in an array (exponential, how exactly do I calculate). Find all subsets of size k whose sum is 0 (will k come somewhere in complexity , it should come right?). Can any1 help me how to calculate the exact complexity of such questions, I am able to wrote code for them , but its hard understanding the exact time complexity.

    Read the article

  • A Combinations of Items in Given List

    - by mecablaze
    Hello stackoverflow, I'm currently in Python land. This is what I need to do. I have already looked into the itertools library but it seems to only do permutations. I want to take an input list, like ['yahoo', 'wikipedia', 'freebase'] and generate every unique combination of one item with zero or more other items... ['yahoo', 'wikipedia', 'freebase'] ['yahoo', 'wikipedia'] ['yahoo', 'freebase'] ['wikipedia', 'freebase'] ['yahoo'] ['freebase'] ['wikipedia'] A few notes. Order does not matter and I am trying to design the method to take a list of any size. Also, is there a name for this kind of combination? Thanks for your help!

    Read the article

  • Another Permutation Word Conundrum... With Linq?

    - by CraigF
    I have seen many examples of getting all permutations of a given set of letters. Recursion seems to work well to get all possible combinations of a set of letters (though it doesn't seem to take into account if 2 of the letters are the same). What I would like to figure out is, could you use linq (or not) to get all possible combinations of letters down to 3 letter combinations. For example, given the letters: P I G G Y I want an array of all possible cominations of these letters so I can check against a word list (scrabble?) and eventually get a list of all possible words that you can make using those letters (from 3 letters up to the total, in this case 5 letters).

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >