Search Results

Search found 148 results on 6 pages for 'permutation'.

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

  • 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

  • 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

  • SQL Operators as text in where clause

    - by suggy1982
    I have the following table, which is used for storing bandings. The table is maintained via a web frontend. CREATE TABLE [dbo].[Banding]( [BandingID] [int] IDENTITY(1,1) NOT NULL, [ValueLowerLimitOperator] [varchar](10) NULL, [ValueLowerLimit] [decimal](9, 2) NULL, [ValueUpperLimitOperator] [varchar](10) NULL, [ValueUpperLimit] [decimal](9, 2) NULL, [VolumeLowerLimitOperator] [varchar](10) NULL The operator fields store values such as < = <=. I want to get to a position where I can use the operators values stored in the table in a case statement in a where clause. Like this. SELECT * FROM table WHERE CASE ValueLowerLimitOperator WHEN '<' THEN VALUE < X WHEN '>' THEN VALUE > X END rather than having to write mutiple case or if statements for each permutation. Does anyone have any suggestions how I can decode the operators values stored in the table as part of my query and then use them in a case/where statement?

    Read the article

  • Efficient synchronization of querying an array of resources

    - by Erel Segal Halevi
    There is a list of N resources, each of them can be queried by at most a single thread at a time. There are serveral threads that need to do the same thing at approximately the same time: query each of the resources (each thread has a different query), in arbitrary order, and collect the responses. If each thread loops over the resources in the same order, from 0 to N-1, then they will probably have to wait for each other, which is not efficient. I thought of letting the threads loop over the resources in a random permutation, but this seems too complex and also not so efficient, for example, for 2 resources and 2 threads, in half the cases they will choose the same order and wait for each other. Is there a simple and more efficient way to solve this?

    Read the article

  • Algorithm to generate all possible permutations of a list?

    - by LLer
    Say I have a list of n elements, I know there are n! possible ways to order these elements. What is an algorithm to generate all possible orderings of this list? Example, I have list [a, b, c]. The algorithm would return [[a, b, c], [a, c, b,], [b, a, c], [b, c, a], [c, a, b], [c, b, a]]. I'm reading this here http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations But Wikipedia has never been good at explaining. I don't understand much of it.

    Read the article

  • Can a flex app (or a portion of a flex app) be made transparent to mouse clicks?

    - by Sam Jones
    I need to superimpose my Flex app above a plain HTML control on a web page, and be able to click through the Flex app to interact with the HTML control. Is there any way to do this? No permutation of mouseEnabled="false" or mouseChildren="false" seems to have the desired effect. Context: trying to integrate Google Earth API (JavaScript/HTML) with my flex app. I am leaving a portion of the flex app transparent and empty, and positioning the Google Earth widget just below that point in the z-index. Google Earth has to be behind flex, because there are some Flex controls periodically displayed in that space.

    Read the article

  • Property Scope (Iphone)

    - by Hank
    Hello All. I am having trouble accessing a declared property and I think I am missing something fundamental about the nature of properties and perhaps view controllers. Here's what I'm doing so far: declaring a property "myPhone" in a root view controller called RootViewController. grabbing a phone number from a modally presented people picker setting "myPhone" to the value from the people picker (from within shouldContinueAfterSelectingPerson of ABPeoplePickerNavigationController) trying to access "myPhone" from another modally presented view controller "myPhone" continues to NSLog to null despite trying every permutation of self.myPhone, super, RootViewController, etc. to try and access the value I set. What am I missing?

    Read the article

  • Remove only first instance of a character from a list of characters

    - by Luke
    Hi All, Here's what I want to do. I have 2 strings and I want to determine if one string is a permutation of another. I was thinking to simply remove the characters from string A from string B to determine if any characters are left. If no, then it passes. However, I need to make sure that only 1 instance of each letter is removed (not all occurrences) unless there are multiple letters in the word. An example: String A: cant String B: connect Result: -o-nec- Experimenting with NSString and NSScanner has yielded no results so far.

    Read the article

  • permute data for a HashMap in Java

    - by tuxou
    hi i have a linkedhashmap and i need to permute (change the key of the values) between 2 random values example : key 1 value 123 key 2 value 456 key 3 value 789 after random permutation of 2 values key 1 value 123 key 2 value 789 key 3 value 456 so here I permuted values between key 2 and key 3 thank you; sample of the code of my map : Map map = new LinkedHashMap(); map =myMap.getLinkedHashMap(); Set key = map.keySet(); for(Iterator it = cles.iterator(); it.hasNext();) { Integer cle = it.next(); ArrayList values = (ArrayList)map.get(cle);//an arrayList of integers int i = 0; while(i < values.size()) { //i donno what to do here i++; } }

    Read the article

  • HELP! need to make a VoIP program for WiMAX in NS-2 work..

    - by janiemack
    I've been trying to get this working for the past 2 days and i'm completely stuck. I'm trying to make a simple VoIP program work in the NIST module for WiMAX http ://community.4gdeveloper.com/attachments/download/14/090720150504_ns2-Release-2.6.tar.gz version 2.6 , using NS-2.31 (remove space btw 'p' and ':' ) http ://downloads.sourceforge.net/nsnam/ns-allinone-2.31.tar.gz?modtime=1173548159&big_mirror=0 (remove space btw 'p' and ':' ) The installation process goes fine. When i run this program, I'm getting an error saying " OFDMAPhy : error did not find match for permutation and bw combination" Some help would be really appreciated. thanks!

    Read the article

  • two line label with expression

    - by metasequoia
    I'd like to write an axis label over two lines with an expression() statement. However, plotmath and expression won't allow this (e.g. subscript appear on the far right). I found this discussion circa 2005 of a similar issue but the work around that they offer doesn't translate to my application in ggplot2. A recent question addressed a a different permutation of multi-line expression statements, but again the work around provided doesn't apply here. Example: p <- ggplot(mtcars,aes(x=wt,y=mpg))+ geom_point()+ xlab(expression(paste("A long string of text goes here just for the purpose \n of illustrating my point Weight "[reported]))) try(ggsave(plot=p,filename=<some file>,height=4,width=6)) yields an image where subscript "reported" is kicked out to the right when I'd like it to sit next to the previous word.

    Read the article

  • Trying all permutations

    - by Malfist
    For my program, I am trying to assist the user, and reduce his or her work load. There are four input numbers. There is also an indeterminate amount of numbers they can be applied too. For example, they four input numbers could be {4,7,3,2} and the numbers they can be applied to are {4,9,23} The result should be: 4 (input) was applied to 4, leaving the sets looking like: {0,7,3,2} and then 7,2 (input) are applied to 9 leaving the sets looking like: {0,0,3,0} and {0,0,23} and because 3 or any other permutation including 3 does not match 23, 3 remains. How would I do this?

    Read the article

  • Sort vector<int>(n) in O(n) time using O(m) space?

    - by Adam
    I have a vector<unsigned int> vec of size n. Each element in vec is in the range [0, m], no duplicates, and I want to sort vec. Is it possible to do better than O(n log n) time if you're allowed to use O(m) space? In the average case m is much larger than n, in the worst case m == n. Ideally I want something O(n). I get the feeling that there's a bucket sort-ish way to do this: unsigned int aux[m]; aux[vec[i]] = i; Somehow extract the permutation and permute vec. I'm stuck on how to do 3. In my application m is on the order of 16k. However this sort is in the inner loops and accounts for a significant portion of my runtime.

    Read the article

  • Sharepoint (WSS 3.0) on SBS 2008 broken.

    - by tcv
    I recently ran the Sharepoint Products and Technologies Wizard. I had hoped this would bring up Sharepoint and allow me to access it so I could begin to learn. But it's not working. Here is some data that I hope is relevant. I am doing all my testing on the SBS 2008 server itself. I changed the hostheader in IIS to reflect an external FQDN I plan to deploy. The SBS server is remote and there are no domain-connected workstations. If I browse "localhost" SSL, I can get to the site, albeit with a self-signed cert warning. If I attempt to connect via SSL using either the internal FQDN (.local), the External FQDN (.net) or any other permutation thereof, I am prompted for credentials three times but am not allowed access. My account is a domain admin. The site is inaccessible using port 80 whether using localhost, internal FQDN (.local), and external FQDN (.net) Right now, I suspect my problem is within IIS, but I don't know. My plan to publish the sharepoint site to the web so my partner and I can check documents in/out. Can someone help me get started in current direction?

    Read the article

  • Selenium &ndash; Use Data Driven tests to run in multiple browsers and sizes

    - by Aligned
    Originally posted on: http://geekswithblogs.net/Aligned/archive/2013/11/04/selenium-ndash-use-data-driven-tests-to-run-in-multiple.aspxSelenium uses WebDriver (or is it the same? I’m still learning how it is connected) to run Automated UI tests in many different browsers. For example, you can run the same test in Chrome and Firefox and in a smaller sized Chrome browser. The permutations can grow quickly. One way to get them to run in MStest is to create  a test method for each test (ie ChromeDeleteItem_Small, ChromeDeleteItem_Large, FFDeleteItem_Small, FFDeleteItem_Large) that each call  the same base method, passing in the browser and size you’d like. This approach was causing a lot of duplicate code, so I decided to use the data driven approach, common to Coded UI or Unit test methods. 1. Create a class with a test method. 2. Create a csv with two columns: BrowserType, BrowserSize 3. Add rows for each permutation: Chrome, Large | Chrome, Small | Firefox, Large | Firefox, Small | IE, Large | IE, Small | *** 4. Add the csv to the Visual Studio Project. 5. Set the Copy to output directory to Copy always 6. Add the attribute: [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\TestMatrix.csv", "TestMatrix#csv", DataAccessMethod.Sequential), DeploymentItem("TestMatrix.csv")] 7. Run the test in the test explorer Example:[CodedUITest] public class AllTasksTests : TasksTestBase { [TestMethod] [TestCategory("Tasks")] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\TestMatrix.csv", "TestMatrix#csv", DataAccessMethod.Sequential), DeploymentItem("TestMatrix.csv")] public void CreateTask() { this.PrepForDataDrivenTest(); base.CreateTaskTest("New Task"); } } protected void PrepForDataDrivenTest() { var browserType = this.ParseBrowserType(Context.DataRow["BrowserType"].ToString()); var browserSize = this.ParseBrowserSize(Context.DataRow["BrowserSize"].ToString()); this.BrowserType = browserType; this.BrowserSize = browserSize; Trace.WriteLine("browser: " + browserType.ToString()); Trace.WriteLine("browser size: " + browserSize.ToString()); } /// <summary> /// Get the enum value from the string /// </summary> /// <param name="browserType">Chrome, Firefox, or IE</param> /// <returns>The browser type.</returns> private BrowserType ParseBrowserType(string browserType) { return (UITestFramework.BrowserType)Enum.Parse(typeof(UITestFramework.BrowserType), browserType, true); } /// <summary> /// Get the browser size enum value from the string /// </summary> /// <param name="browserSize">Small, Medium, Large</param> /// <returns>the browser size</returns> private BrowserSizeEnum ParseBrowserSize(string browserSize) { return (BrowserSizeEnum)Enum.Parse(typeof(BrowserSizeEnum), browserSize, true); }/// <summary> /// Change the browser to the size based on the enum. /// </summary> /// <param name="browserSize">The BrowserSizeEnum value to resize the window to.</param> private void ResizeBrowser(BrowserSizeEnum browserSize) { switch (browserSize) { case BrowserSizeEnum.Large: this.driver.Manage().Window.Maximize(); break; case BrowserSizeEnum.Medium: this.driver.Manage().Window.Size = new Size(800, this.driver.Manage().Window.Size.Height); break; case BrowserSizeEnum.Small: this.driver.Manage().Window.Size = new Size(500, this.driver.Manage().Window.Size.Height); break; default: break; } }/// <summary> /// Browser sizes for automation testing /// </summary> public enum BrowserSizeEnum { /// <summary> /// Large size, Maximized to the desktop /// </summary> Large, /// <summary> /// Similar to tablets /// </summary> Medium, /// <summary> /// Phone sizes... 610px and smaller /// </summary> Small } Hope it helps!

    Read the article

  • Why isn't uploadify and asp.net mvc 2 playing nice for me?

    - by Paperino
    First of all, I've checked out all the SO threads, and googled my brains out. I must be missing something obvious. I'd really appreciate some help! This is what I've got. UploadController.cs using System.Web; using System.Web.Mvc; namespace NIMDocs.Controllers { public class UploadController : Controller { public ActionResult Index() { return View(); } public string Procssed(HttpPostedFileBase FileData) { // DO STUFF return "DUHR I AM SMART"; } } } Index for Upload <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>ITS A TITLE </title> <script src="../../Content/jqueryPlugins/uploadify/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="../../Content/jqueryPlugins/uploadify/swfobject.js" type="text/javascript"></script> <script src="../../Content/jqueryPlugins/uploadify/jquery.uploadify.v2.1.0.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('#uploadify').fileUpload({ 'uploader': '../../Content/jqueryPlugins/uploadify/uploadify.swf', 'script': '/Upload/Processed', 'folder': '/uploads', 'multi': 'true', 'buttonText': 'Browse', 'displayData': 'speed', 'simUploadLimit': 2, 'cancelImg': '/Content/Images/cancel.png' }); }); </script> </head> <body> <input type="file" name="uploadify" id="uploadify" /> <p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p> </body> </html> What am I missing here? I've tried just about every path permutation for uploadify's "uploader" option. Absolute path, '/' prefixed, etc.

    Read the article

  • Google Maps v3: Enforcing min. zoom level when using fitBounds

    - by chris
    I'm drawing a series of markers on a map (using v3 of the maps api). In v2, I had the following code: bounds = new GLatLngBounds(); ... loop thru and put markers on map ... bounds.extend(point); ... end looping map.setCenter(bounds.getCenter()); var level = map.getBoundsZoomLevel(bounds); if ( level == 1 ) level = 5; map.setZoom(level > 6 ? 6 : level); And that work fine to ensure that there was always an appropriate level of detail displayed on the map. I'm trying to duplicate this functionality in v3, but the setZoom and fitBounds don't seem to be cooperating: ... loop thru and put markers on the map var ll = new google.maps.LatLng(p.lat,p.lng); bounds.extend(ll); ... end loop var zoom = map.getZoom(); map.setZoom(zoom > 6 ? 6 : zoom); map.fitBounds(bounds); I've tried different permutation (moving the fitBounds before the setZoom, for example) but nothing I do with setZoom seems to affect the map. Am I missing something? Is there a way to do this?

    Read the article

  • Lisp Style question label local functions or not?

    - by Andrew Myers
    I was wondering if there is a standard practice regarding the use of labels in Lisp. I've been messing around with a Lisp implementation of the algorithm described in the first answer here http://stackoverflow.com/questions/352203/generating-permutations-lazily My current version uses labels to break out portions of functionality. (defun next-permutation (pmute) (declare (vector pmute)) (let ((len (length pmute))) (if (> len 2) (labels ((get-pivot () (do ((pivot (1- len) (1- pivot))) ((or (= pivot 0) (< (aref pmute (1- pivot)) (aref pmute pivot))) pivot))) (get-swap (pivot) (let ((swp (1- len))) (loop for i from (1- len) downto pivot do (if (or (and (> (aref pmute i) (aref pmute (1- pivot))) (< (aref pmute i) (aref pmute swp))) (< (aref pmute swp) (aref pmute (1- pivot)))) (setf swp i))) swp)) (next (swp pivot) (rotatef (aref pmute (1- pivot)) (aref pmute swp)) (reverse-vector pmute pivot (1- len)))) (let ((piv (get-pivot))) (if (> piv 0) (next (get-swap piv) piv) nil)))))) Since each label is only called once I was wondering if this is considered bad practice since the only reason to do it in this case is for aesthetic reasons. I would argue that the current version with labels is clearer but that may go against common wisdom that I'm not aware of, being new to Lisp.

    Read the article

  • Mapping a child collection without indexing based on database primary key or using bag

    - by Colin Bowern
    I have a existing parent-child relationship I am trying to map in Fluent Nhibernate: [RatingCollection] -- [Rating] Rating Collection has: ID (database generated ID) Code Name Rating has: ID (database generated id) Rating Collection ID Code Name I have been trying to figure out which permutation of HasMany makes sense here. What I have right now: HasMany<Rating>(x => x.Ratings) .WithTableName("Rating") .KeyColumnNames.Add("RatingCollectionId") .Component(c => { c.Map(x => x.Code); c.Map(x => x.Name); ); It works from a CRUD perspective but because it's a bag it ends up deleting the rating contents any time I try to do a simple update / insert to the Ratings property. What I want is an indexed collection but not using the database generated ID (which is in the six digit range right now). Any thoughts on how I could get a zero-based indexed collection (so I can go entity.Ratings[0].Name = "foo") which would allow me to modify the collection without deleting/reinserting it all when persisting?

    Read the article

  • Using {% url ??? %} in django templates

    - by user563247
    I have looked a lot on google for answers of how to use the 'url' tag in templates only to find many responses saying 'You just insert it into your template and point it at the view you want the url for'. Well no joy for me :( I have tried every permutation possible and have resorted to posting here as a last resort. So here it is. My urls.py looks like this: from django.conf.urls.defaults import * from login.views import * from mainapp.views import * import settings # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^weclaim/', include('weclaim.foo.urls')), (r'^login/', login_view), (r'^logout/', logout_view), ('^$', main_view), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), #(r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': '/home/arthur/Software/django/weclaim/templates/static'}), (r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}), ) My 'views.py' in my 'login' directory looks like: from django.shortcuts import render_to_response, redirect from django.template import RequestContext from django.contrib import auth def login_view(request): if request.method == 'POST': uname = request.POST.get('username', '') psword = request.POST.get('password', '') user = auth.authenticate(username=uname, password=psword) # if the user logs in and is active if user is not None and user.is_active: auth.login(request, user) return render_to_response('main/main.html', {}, context_instance=RequestContext(request)) #return redirect(main_view) else: return render_to_response('loginpage.html', {'box_width': '402', 'login_failed': '1',}, context_instance=RequestContext(request)) else: return render_to_response('loginpage.html', {'box_width': '400',}, context_instance=RequestContext(request)) def logout_view(request): auth.logout(request) return render_to_response('loginpage.html', {'box_width': '402', 'logged_out': '1',}, context_instance=RequestContext(request)) and finally the main.html to which the login_view points looks like: <html> <body> test! <a href="{% url logout_view %}">logout</a> </body> </html> So why do I get 'NoReverseMatch' every time? *(on a slightly different note I had to use 'context_instance=RequestContext(request)' at the end of all my render-to-response's because otherwise it would not recognise {{ MEDIA_URL }} in my templates and I couldn't reference any css or js files. I'm not to sure why this is. Doesn't seem right to me)*

    Read the article

  • Generating all unique combinations for "drive ya nuts" puzzle

    - by Yuval A
    A while back I wrote a simple python program to brute-force the single solution for the drive ya nuts puzzle. The puzzle consists of 7 hexagons with the numbers 1-6 on them, and all pieces must be aligned so that each number is adjacent to the same number on the next piece. The puzzle has ~1.4G non-unique possibilities: you have 7! options to sort the pieces by order (for example, center=0, top=1, continuing in clockwise order...). After you sorted the pieces, you can rotate each piece in 6 ways (each piece is a hexagon), so you get 6**7 possible rotations for a given permutation of the 7 pieces. Totalling: 7!*(6**7)=~1.4G possibilities. The following python code generates these possible solutions: def rotations(p): for i in range(len(p)): yield p[i:] + p[:i] def permutations(l): if len(l)<=1: yield l else: for perm in permutations(l[1:]): for i in range(len(perm)+1): yield perm[:i] + l[0:1] + perm[i:] def constructs(l): for p in permutations(l): for c in product(*(rotations(x) for x in p)): yield c However, note that the puzzle has only ~0.2G unique possible solutions, as you must divide the total number of possibilities by 6 since each possible solution is equivalent to 5 other solutions (simply rotate the entire puzzle by 1/6 a turn). Is there a better way to generate only the unique possibilities for this puzzle?

    Read the article

  • Beginner problems with references to arrays in python 3.1.1

    - by Protean
    As part of the last assignment in a beginner python programing class, I have been assigned a traveling sales man problem. I settled on a recursive function to find each permutation and the sum of the distances between the destinations, however, I am have a lot of problems with references. Arrays in different instances of the Permute and Main functions of TSP seem to be pointing to the same reference. from math import sqrt class TSP: def __init__(self): self.CartisianCoordinates = [['A',[1,1]], ['B',[2,2]], ['C',[2,1]], ['D',[1,2]], ['E',[3,3]]] self.Array = [] self.Max = 0 self.StoredList = ['',0] def Distance(self, i1, i2): x1 = self.CartisianCoordinates[i1][1][0] y1 = self.CartisianCoordinates[i1][1][1] x2 = self.CartisianCoordinates[i2][1][0] y2 = self.CartisianCoordinates[i2][1][1] return sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2)) def Evaluate(self): temparray = [] Data = [] for i in range(len(self.CartisianCoordinates)): Data.append([]) for i1 in range(len(self.CartisianCoordinates)): for i2 in range(len(self.CartisianCoordinates)): if i1 != i2: temparray.append(self.Distance(i1, i2)) else: temparray.append('X') Data[i1] = temparray temparray = [] self.Array = Data self.Max = len(Data) def Permute(self,varray,index,vcarry,mcarry): #Problem Class array = varray[:] carry = vcarry[:] for i in range(self.Max): print ('ARRAY:', array) print (index,i,carry,array[index][i]) if array[index][i] != 'X': carry[0] += self.CartisianCoordinates[i][0] carry[1] += array[index][i] if len(carry) != self.Max: temparray = array[:] for j in range(self.Max):temparray[j][i] = 'X' index = i mcarry += self.Permute(temparray,index,carry,mcarry) else: return mcarry print ('pass',mcarry) return mcarry def Main(self): out = [] self.Evaluate() for i in range(self.Max): array = self.Array[:] #array appears to maintain the same reference after each copy, resulting in an incorrect array being passed to Permute after the first iteration. print (self.Array[:]) for j in range(self.Max):array[j][i] = 'X' print('I:', i, array) out.append(self.Permute(array,i,[str(self.CartisianCoordinates[i][0]),0],[])) return out SalesPerson = TSP() print(SalesPerson.Main()) It would be greatly appreciated if you could provide me with help in solving the reference problems I am having. Thank you.

    Read the article

  • Help with fql.multiQuery

    - by Daniel Schaffer
    I'm playing around with the Facebook API's fql.multiQuery method. I'm just using the API Test Console, and trying to get a successful response but can't seem to figure out exactly what it wants. Here's the text I'm entering into the "queries" field: {"tags" : "select subject from photo_tag where subject != 601599551 and pid in ( select pid from photo_tag where subject = 601599551 ) and subject in ( select uid2 from friend where uid1 = 601599551 )", "foo" : "select uid from user where uid = 601599551"} All it'll give me is a queries parameter: array expected. error. I've also tried just about every permutation I could think of involving wrapping the name/query pairs in their own curly braces, adding brackets, adding whitespace, removing whitespace in case it didn't want an associative array (for those watching the edits, I just found out about these wonderful things now... oy), all to no avail. Is there something painfully obvious I'm missing here, or do I need to make like Chuck Norris Jon Skeet and simply will it to do my bidding? Update: A note to anyone finding this question now: The fql.multiquery test console appears to be broken. You can test your query by clicking on the generated url in the test console and manually adding the "queries" parameter into the querystring.

    Read the article

  • permutations gone wrong

    - by vbNewbie
    I have written code to implement an algorithm I found on string permutations. What I have is an arraylist of words ( up to 200) and I need to permutate the list in levels of 5. Basically group the string words in fives and permutated them. What I have takes the first 5 words generates the permutations and ignores the rest of the arraylist? Any ideas appreciated. Private Function permute(ByVal chunks As ArrayList, ByVal k As Long) As ArrayList ReDim ItemUsed(k) pno = 0 Permutate(k, 1) Return chunks End Function Private Shared Sub Permutate(ByVal K As Long, ByVal pLevel As Long) Dim i As Long, Perm As String Perm = pString ' Save the current Perm ' for each value currently available For i = 1 To K If Not ItemUsed(i) Then If pLevel = 1 Then pString = chunks.Item(i) 'pString = inChars(i) Else pString = pString & chunks.Item(i) 'pString += inChars(i) End If If pLevel = K Then 'got next Perm pno = pno + 1 SyncLock outfile outfile.WriteLine(pno & " = " & pString & vbCrLf) End SyncLock outfile.Flush() Exit Sub End If ' Mark this item unavailable ItemUsed(i) = True ' gen all Perms at next level Permutate(K, pLevel + 1) ' Mark this item free again ItemUsed(i) = False ' Restore the current Perm pString = Perm End If Next K above is = to 5 for the number of words in one permutation but when I change the for loop to the arraylist size I get an error of index out of bounds

    Read the article

  • What does O(log n) mean exactly?

    - by Andreas Grech
    I am currently learning about Big O Notation running times and amortized times. I understand the notion of O(n) linear time, meaning that the size of the input affects the growth of the algorithm proportionally...and the same goes for, for example, quadratic time O(n2) etc..even algorithms, such as permutation generators, with O(n!) times, that grow by factorials. For example, the following function is O(n) because the algorithm grows in proportion to its input n: f(int n) { int i; for (i = 0; i < n; ++i) printf("%d", i); } Similarly, if there was a nested loop, the time would be O(n2). But what exactly is O(log n)? For example, what does it mean to say that the height of a complete binary tree is O(log n)? I do know (maybe not in great detail) what Logarithm is, in the sense that: log10 100 = 2, but I cannot understand how to identify a function with a logarithmic time.

    Read the article

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