Daily Archives

Articles indexed Sunday October 28 2012

Page 9/13 | < Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >

  • I get an "serious errors while checking the disk drives for /boot" error while booting

    - by Vaios Argiropoulos
    I have just set up my new system by creating three partitions on a whole hard disk (/boot,/home,swap and /(root)) .I saw this article and now i am getting those errors and the system provide me with some options (I to ignore, S to skip mounting or M for manual recovery). I am forced to choose skip mounting because i don't know what manual recovery is. Despite the error i get i think that the system boots ok because i can use the system but this error is very annoying.

    Read the article

  • Best Strategy for Exact Match Domain (EMD) Along Side Branded Domain

    - by ChrisInCambo
    I lucked out and managed to buy a two word .com EMD for the most important key-phrase for our b2b SaaS startup. Shutting down our branded domain isn't an option, we've already got too much invested in that brand (not in terms of SEO but in terms of other marketing efforts). The brand domain at present hasn't really been optimised for this key-phrase and we haven't invested any effort in SEO to date on that domain, but now we have some resources and want to make a big push for that key-phrase. So what is the best strategy for an EMD when you want already have a branded domain that you don't want to close or have penalised in some way?

    Read the article

  • How can I prevent another site from trying to phish my customers by cloning the look and feel of my site?

    - by NextStep
    I have a site hosted on Godaddy. Recently, another site that I don't control has copied the look and feel of my site. They look exactly like my site, except the domains are different.. Godaddy's staff said there is nothing they can do to prevent that site cloning the look and feel of my site. Is there anything I can do to stop another site from effectively cloning my site? How can I keep my customers from being duped by this?

    Read the article

  • fast 3d point -> cuboid volume intersection test

    - by user1130477
    Im trying to test whether a point lies within a 3d volume defined by 8 points. I know I can use the plane equation to check that the signed distance is always -1 for all 6 sides, but does anyone know of a faster way or could point me to some code? Thanks EDIT: I should add that ideally the test would produce 3 linear interpolation parameters which would lie in the range 0..1 to indicate that the point is within the volume for each axis (since I will have to calculate these later if the point is found to be in the volume)

    Read the article

  • Character equipment combinations

    - by JimFing
    I'm developing a 2d isometric game (typical Tolkien RPG) and wondering how to handle character/equipment combinations. So for example, the player wears leather boots with chain-mail and a wooden shield and a sword - but then picks up plate-armour instead of chain-mail. I'm using Blender3D to create objects, environments and characters in 3D, then a script runs to render all 3D meshes into 2D orthographic tile maps. So I can use this script to create all the combinations of character equipment for me, but there would be an explosion in terms of the combinations required.

    Read the article

  • Architectural approaches to creating a game menu/shell overlay on PC/Linux?

    - by Ghopper21
    I'm am working on a collection of games for a custom digital tabletop installation (similar to Microsoft Surface tables). Each game will be an individual executable that runs full-screen. In addition, there needs to be a menu/shell overlay program running simultaneously. The menu/shell will allow users to pause games, switch to other games, check their game history, etc. Some key requirements of the shell: it intercepts all user input (mainly multitouch) first before passing it on to the currently running game (so that it can, for instance, know to pop-up at a "pause" command); can reveal on arbitrary portions of the screen, with the currently running (but presumably paused) game still showing underneath, ideally with its shape/size being dynamic, to allow for creation of an animated in/out drawer effect over the game. I'm currently looking into different architectural approaches to this problem, including Fraps and DirectX overlays, but I'm sure I'm missing some ways to think about this. What are the main approaches I should be considering? (Note the table is currently being run by Windows PC, but it could potentially be a Linux box instead.)

    Read the article

  • Movement on the X an Z axis are combined?

    - by Magicaxis
    This is probably a stupid question, but I'm trying to simply move a 3D object up, down, left, and right (Not forward or backward). The Y axis works fine, but when I increment the object's X position, the object moves BOTH right and backwards! when I decrement X, left and forwards! setPosition(getPosition().X + 2/*times deltatime*/, getPosition().Y, getPosition().Z); I was astonished that XNA doesnt have its own setPosition function, so I made a parent class for all objects with a setPosition and Draw function. Setposition simply edits a variable "mPosition" and passes it to the common draw function: // Copy any parent transforms. Matrix[] transforms = new Matrix[block.Bones.Count]; block.CopyAbsoluteBoneTransformsTo(transforms); // Draw the model. A model can have multiple meshes, so loop. foreach (ModelMesh mesh in block.Meshes) { // This is where the mesh orientation is set, as well // as our camera and projection. foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(MathHelper.ToRadians(mOrientation.Y)) * Matrix.CreateTranslation(mPosition); effect.View = game1.getView(); effect.Projection = game1.getProjection(); } // Draw the mesh, using the effects set above. mesh.Draw(); } I tried to work it out by attempting to increment and decrement the Z axis, but nothing happens?! So using the X axis changes the objects x and z axis', but changing the Z does nothing. Great. So how do I seperate the X and Z axis movement?

    Read the article

  • Android Array Lag?

    - by Mike
    I am making a platform game for Android. It is sort of a tile based game. I added bullets and enemies with AI and a bunch of tile types. I created a simple map with no Enemies. Everything was running well and smooth until I shot a bunch of bullets randomly everywhere. A couple of hundreds of bullets later, the FPS lowered. I made a test to find out if the bullets were the problem so I made another simple map with just a tile to stand on and left it for a while. Minutes later, I played around with it a bit to check if the FPS changed and it didnt. I reloaded the same map and shot a lot of bullets. Minutes later, the FPS was visibly lower even after the number of bullets were zero. Points to note: Programmed FPS is 30 Tested on a Samsung Galaxy Y and Samsung Galaxy W Any tile, enemy, bullet that is off screen is not drawn to prevent lag Bullets collide with Tiles (if they dont collide with in 450 frames, they are removed from the array) I used List bullets = new ListArray(); I used bullets.add(new Bullet(x, y, params...)); I used for(...){ if(...){ bullets.remove(i); } } Code for bullet: private void drawBullets(Canvas canvas) { for (int i = 0; i < bullets.size(); i++) { Bullet b = bullets.get(i); b.update(canvas); //updates physics if (b.t > blm) { //if the bullet is past its expiry bullets.remove(i); i--; } else { if (svx((b.x)) > 0 && svx(b.x) < width && svy((b.y)) > 0 && svy(b.y) < height) { // if bullet is not off screen b.draw(canvas); // draw the bullet } } } } I tried searching for solutions and references but I have no luck. I'm guessing that the lag has something to do with the Array and the Bullets or Classes that I've loaded? I'm not sure! Someone please help! Thanks in advance! :)

    Read the article

  • Rendering multiple squares fast?

    - by Sam
    so I'm doing my first steps with openGL development on android and I'm kinda stuck at some serious performance issues... What I'm trying to do is render a whole grid of single colored squares on to the screen and I'm getting framerates of ~7FPS. The squares are 9px in size right now with one pixel border in between, so I get a few thousand of them. I have a class "Square" and the Renderer iterates over all Squares every frame and calls the draw() method of each (just the iteration is fast enough, with no openGL code the whole thing runs smootlhy at 60FPS). Right now the draw() method looks like this: // Prepare the square coordinate data GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer); // Set color for drawing the square GLES20.glUniform4fv(mColorHandle, 1, color, 0); // Draw the square GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, drawListBuffer); So its actually only 3 openGL calls. Everything else (loading shaders, filling buffers, getting appropriate handles, etc.) is done in the Constructor and things like the Program and the handles are also static attributes. What am I missing here, why is it rendering so slow? I've also tried loading the buffer data into VBOs, but this is actually slower... Maybe I did something wrong though. Any help greatly appreciated! :)

    Read the article

  • Greiner-Hormann clipping problem

    - by Belgin
    I have a set of planar polygons in 3D space defined by their vertices in counterclockwise order. Let's define the 'positive face' as being the face of the 3D polygon such as when observed, the vertices appear in counterclockwise order, and the 'negative face', the face which when observed, the vertices appear in clockwise order. I'm doing perspective projection of the set of polygons onto a projection polygon defined by the points in this order: (0, h, 0), (0, 0, 0), (w, 0, 0), and (w, h, 0), where w and h are strictly positive integers. The positive face of this projection polygon is oriented towards positive Z, and the camera point is somewhere at (0, 0, d), where d is a strictly negative number. In order to 'clip' the projected polygons into the projection polygon, I'm applying the Greiner-Hormann (PDF) clipping algorithm, which requires that the clipper and the to-be-clipped polygons be in the same order (i.e. clockwise or counterclockwise). My question is the following: How can I determine whether the projected face of the 3D polygon is the negative or the positive one? Meaning, how do I find out if I have to work with the vertices in normal or inverted order for the algorithm to work? I noticed that only if the 3D polygon is facing the projection polygon with its negative face, both of them are in the same order (counterclockwise), otherwise, a modification needs to be done. Here is a picture (PNG) that illustrates this. Note that the planes described by the polygon from the set and the projection polygon may not always be parallel.

    Read the article

  • How do I best remove an entity from my game loop when it is dead?

    - by Iain
    Ok so I have a big list of all my entities which I loop through and update. In AS3 I can store this as an Array (dynamic length, untyped), a Vector (typed) or a linked list (not native). At the moment I'm using Array but I plan to change to Vector or linked list if it is faster. Anyway, my question, when an Entity is destroyed, how should I remove it from the list? I could null its position, splice it out or just set a flag on it to say "skip over me, I'm dead." I'm pooling my entities, so an Entity that is dead is quite likely to be alive again at some point. For each type of collection what is my best strategy, and which combination of collection type and removal method will work best?

    Read the article

  • AVD Failed to Load ~ Failed to Parse Properties ~ Mac OSX

    - by C.D. OKeefe
    I'm going to say upfront, please forgive me. I'm a newbie to android development and fairly new to programming. Also on a Mac. You're going to have to talk...real...slow. I can't get an AVD to load. I've tried it from Eclipse and from the Android SDK Manager. Failed multiple times. Received the same error each time, "Failed to parse properties from Users/myname/.android/avd/nameIGaveEmulator/config.ini." I've the forum here and saw that others have had similar problems, but of the answers given, no one came back to say if they worked, and I don't see anyone with a similar problem on a Mac. If the path needs to be "changed" what exactly does that mean and how do I go about doing so?

    Read the article

  • SignalR: hub invokation request

    - by Yuriy Pogrebnyak
    I'm writing custom SignalR client and I need to implement hub invokation. As I understood from .NET client code, I need to send post request to the following url (after establishing connection with server): http://serverurl/signalr/send?transport=serverSentEvents&connectionId=<my_connection_id> . In request body I need to send json string containing basic information about the invoked method. My question is how should this json look like? I'm trying to send smth like this (again, judging by .NET client code): {"data" : {"Hub" : "hubname", "Method" : "methodname", "Args" : {"message" : "msg"} } } But I get the following error: System.ArgumentNullException: Value cannot be null. Parameter name: s. What am I doing wrong? What are required parameters of sending json and how should it be formatted?

    Read the article

  • POSIX Threads and signal masks

    - by Max
    Is there a way to change the signal mask of a thread from another thread? I am supposed to write a multithreaded C application that doesn't use mutex, semaphores and condition variables, only signals. So it would look like something like this: The main Thread sends SIGUSR1 to its process and and one of the 2 threads (not including the main thread), will respond to the signal and block SIGUSR1 from the sigmask and sleep. Then the main thread sends SIGUSR1 again, the other thread will respond, block SIGUSR1 from its sigmask, unblock SIGUSR1 from the other threads sigmask, so it will respond to SIGUSR1 again. So essentially whenever the main thread sends SIGUSR1 the two other threads swap between each other. Can somebody help?

    Read the article

  • Jaxb unmarshalls fixml object but all fields are null

    - by DUFF
    I have a small XML document in the FIXML format. I'm unmarshalling them using jaxb. The problem The process complete without errors but the objects which are created are completely null. Every field is empty. The fields which are lists (like the Qty) have the right number of object in them. But the fields of those objects are also null. Setup I've downloaded the FIXML schema from here and I've created the classes with xjc and the maven plugin. They are all in the package org.fixprotocol.fixml_5_0_sp2. I've got the sample xml in a file FIXML.XML <?xml version="1.0" encoding="ISO-8859-1"?> <FIXML> <Batch> <PosRpt> <Pty ID="GS" R="22"/> <Pty ID="01" R="5"/> <Pty ID="6U8" R="28"> <Sub ID="2" Typ="21"/> </Pty> <Pty ID="GS" R="22"/> <Pty ID="6U2" R="2"/> <Instrmt ID="GHPKRW" SecTyp="FWD" MMY="20121018" MatDt="2012-10-18" Mult="1" Exch="GS" PxQteCcy="KJS" FnlSettlCcy="GBP" Fctr="0.192233298" SettlMeth="G" ValMeth="FWDC2" UOM="Ccy" UOMCCy="USD"> <Evnt EventTyp="121" Dt="2013-10-17"/> <Evnt EventTyp="13" Dt="2013-10-17"/> </Instrmt> <Qty Long="0.000" Short="22000000.000" Typ="PNTN"/> <Qty Long="0.000" Short="22000000.000" Typ="FIN"/> <Qty Typ="DLV" Long="0.00" Short="0.00" Net="0.0"/> <Amt Typ="FMTM" Amt="32.332" Ccy="USD"/> <Amt Typ="CASH" Amt="1" Rsn="3" Ccy="USD"/> <Amt Typ="IMTM" Amt="329.19" Ccy="USD"/> <Amt Typ="DLV" Amt="0.00" Ccy="USD"/> <Amt Typ="BANK" Amt="432.23" Ccy="USD"/> </PosRpt> Then I'm calling the unmarshaller with custom event handler which just throws an exception on a parse error. The parsing complete so I know there are no errors being generated. I'm also handling the namespace as suggested here // sort out the file String xmlFile = "C:\\FIXML.XML.xml"; System.out.println("Loading XML File..." + xmlFile); InputStream input = new FileInputStream(xmlFile); InputSource is = new InputSource(input); // create jaxb context JAXBContext jc = JAXBContext.newInstance("org.fixprotocol.fixml_5_0_sp2"); Unmarshaller unmarshaller = jc.createUnmarshaller(); // add event handler so jacB will fail on an error CustomEventHandler validationEventHandler = new CustomEventHandler(); unmarshaller.setEventHandler(validationEventHandler); // set the namespace NamespaceFilter inFilter = new NamespaceFilter("http://www.fixprotocol.org/FIXML-5-0-SP2", true); inFilter.setParent(SAXParserFactory.newInstance().newSAXParser().getXMLReader()); SAXSource source = new SAXSource(inFilter, is); // GO! JAXBElement<FIXML> fixml = unmarshaller.unmarshal(source, FIXML.class); The fixml object is created. In the above sample the Amt array will have five element which matches the number of amts in the file. But all the fields like ccy are null. I've put breakpoints in the classes created by xjc and none of the setters are ever called. So it appears that jaxb is unmarshalling and creating all the correct objects, but it's never calling the setters?? I'm completely stumped on this. I've seen a few posts that suggrest making sure the package.info file that was generated by xjc is in the packags and I've made sure that it's there. There are no working in the IDE about the generated code. Any help much appreciated.

    Read the article

  • Python - Problems using mechanize to log into a difficult website

    - by user1781599
    × 139886 I am trying to log in to betfair.com by using mechanize. I have tried several ways but it always fail. This is the code I have developed so far, can anyone help me to identify what is wrong with it and how I can improve it to log into my betfair account? Thanks, import cookielib import urllib import urllib2 from BeautifulSoup import BeautifulSoup import mechanize from mechanize import Browser import re bf_username_name = "username" bf_password_name = "password" bf_form_name = "loginForm" bf_username = "xxxxx" bf_password = "yyyyy" urlLogIn = "http://www.betfair.com/" accountUrl = "https://myaccount.betfair.com/account/home?rlhm=0&" # This url I will use to verify if log in has been successful br = mechanize.Browser(factory=mechanize.RobustFactory()) br.addheaders = [("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.90 Safari/537.1")] br.open(urlLogIn) br.select_form(nr=0) print br.form br.form[bf_username_name] = bf_username br.form[bf_password_name] = bf_password print br.form #just to check username and psw have been recorded correctly responseSubmit = br.submit() response = br.open(accountUrl) text_file = open("LogInResponse.html", "w") text_file.write(responseSubmit.read()) #this file should show the home page with me logged in, but it show home page as if I was not logged it text_file.close() text_file = open("Account.html", "w") text_file.write(response.read()) #this file should show my account page, but it should a pop up with an error text_file.close()

    Read the article

  • Rewrite code from Threads to AnyEvent

    - by user1779868
    I wrote a code: use LWP::UserAgent; use HTTP::Cookies; use threads; use threads::shared; $| = 1; $threads = 50; my @urls : shared = loadf('url.txt'); my @thread_list = (); $thread_list[$_] = threads->create(\&thread) for 0 .. $threads - 1; $_->join for @thread_list; thread(); sub thread { my ($web, $ck) = browser(); while(1) { my $url = shift @urls; if(!$url) { last; } $code = $web->get($url)->code; print "[+] $url - code: $code\n"; if($code == 200) { open F, ">>200.txt"; print F $url."\n"; close F; } elsif($code == 301) { open F, ">>301.txt"; print F $url."\n"; close F; } else { open F, ">>else.txt"; print F "$url code - $code\n"; close F; } } } sub loadf { open (F, "<".$_[0]) or erroropen($_[0]); chomp(my @data = <F>); close F; return @data; } sub browser { my $web = new LWP::UserAgent; my $ck = new HTTP::Cookies; $web->cookie_jar($ck); $web->agent('Opera/9.80 (Windows 7; U; en) Presto/2.9.168 Version/11.50'); $web->timeout(5); return $web, $ck; } After its working for some time physical storage is full. Can u help me to re-write it with AnyEvent. I tried but my code didn't work. I read that it will help me to safe some memory. Thanks a lot to any helpers.

    Read the article

  • Postgresql 9.1: ERROR: type "citext" does not exist

    - by gotuskar
    I am trying to execute following query through PgAdmin utility. CREATE TABLE svcr."EventLogs" ("eventId" BIGINT NOT NULL, "eventTime" TIMESTAMP WITH TIME ZONE NOT NULL, "userid" CITEXT, "realmid" CITEXT NOT NULL, "onUserid" CITEXT, "description" TEXT, CONSTRAINT eventlogs_pkey PRIMARY KEY ("eventId")); And I get following error - ERROR: type "citext" does not exist SQL state: 42704 Character: 120 However, following query runs fine - CREATE TABLE svcr."CategoryMap" ("category" INT NOT NULL, "userData" INT NOT NULL); What is wrong with the first query?

    Read the article

  • create a model in create action from a class

    - by Pontek
    As a newbie to rails I can't find how to solve my issue ^^ I want to create a VideoPost from a form with a text field containing a video url (like youtube) I'm getting information on the video thanks to the gem https://github.com/thibaudgg/video_info And I want to save thoses information using a model of mine (VideoInformation). But I don't know how the create process should work. Thanks for any help ! I'm trying to create a VideoPost in VideoPostsController like this : def create video_info = VideoInfo.new(params[:video_url]) video_information = VideoInformation.create(video_info) #undefined method `stringify_keys' for #<Youtube:0x00000006a24120> if video_information.save @video_post = current_user.video_posts.build(video_information) end end My VideoPost model : # Table name: video_posts # # id :integer not null, primary key # user_id :integer # video_information_id :integer # created_at :datetime not null # updated_at :datetime not null My VideoInformation model (which got same attributes name than VideoInfo gem) : # Table name: video_informations # # id :integer not null, primary key # title :string(255) # description :text # keywords :text # duration :integer # video_url :string(255) # thumbnail_small :string(255) # thumbnail_large :string(255) # created_at :datetime not null # updated_at :datetime not null

    Read the article

  • C++ Loop - Need variable to accumulate sum

    - by user1780064
    I'm writing a program to ask the user to enter a value between 5 and 21 (inclusive). If the number entered is not in this range, it prints, "Please try again". If the number is within the range, I need to take that number, and print the sum of all the numbers from 1 to the value entered. So if the user entered "7", the sum would be "28". I successfully wrote the first loop, in the case of the number not being within the range, but cannot figure out how to run the second loop- whether to use a while, do-while, or for loop. Please advise. #include <iostream> int main () { int uservalue; int count; int sum; //Prompt user for input do { cout << "Enter a value from 5 to 21: "; cin >> uservalue; if (uservalue < 5 || uservalue > 21) cout << "Value out of range. Try again..." << endl; } while (uservalue < 5 || uservalue > 21); cout << endl; //Loop to accumulate sum for (count = 1, count < uservalue, count++;) { sum = uservalue + count; if (uservalue <= 5 || uservalue <= 21) cout << the sum is " << sum << endl; } return 0; }

    Read the article

  • S3 file Uploading from Mac app though PHP?

    - by Ilija Tovilo
    I have asked this question before, but it was deleted due too little information. I'll try to be more concrete this time. I have an Objective-C mac application, which should allow users to upload files to S3-storage. The s3 storage is mine, the users don't have an Amazon account. Until now, the files were uploaded directly to the amazon servers. After thinking some more about it, it wasn't really a great concept, regarding security and flexibility. I want to add a server in between. The user should authenticate with my server, the server would open a session if the authentication was successful, and the file-sharing could begin. Now my question. I want to upload the files to S3. One option would be to make a POST-request and wait until the server would receive the file. Problems here are, that there would be a delay, when the file is being uploaded from my server to the S3 servers, and it would double the uploading time. Best would be, if I could validate the request, and then redirecting it, so the client uploads it directly to the s3-storage. Not sure if this is possible somehow. Uploading directly to S3 doesn't seem to be very smart. After looking into other apps like Droplr and Dropmark, it looks like they don't do this. Btw. I did this using Little Snitch. They have their api on their own web-server, and that's it. Could someone clear things up for me? EDIT How should I transmit my files to S3? Is there a way to "forward" it, or do I have to upload it to my server and then upload it from there to S3? Like I said, other apps can do this efficiently and without the need of communicating with S3 directly.

    Read the article

  • parsing ssid with iwconfig in c

    - by user1781595
    I am about building a bar for DWM (ubuntu linux), showing wifi details such as the ssid. Thats my code: #include <stdio.h> #include <stdlib.h> int main( int argc, char *argv[] ) { FILE *fp; int status; char path[1035]; /* Open the command for reading. */ fp = popen("iwconfig", "r"); if (fp == NULL) { printf("Failed to run command\n" ); exit; } char s[500]; /* Read the output a line at a time - output it. */ while (fgets(path, sizeof(path)-1, fp) != NULL) { sprintf(s,"%s%s",s, path); } //printf("%s",s); /* close */ pclose(fp); char delimiter[1] = "s"; char *ptr; ptr = strtok(s, delimiter); printf("SSID: %s\n", ptr); return 0; } i am getting overflowerrors and dont know what to do. I dont think, thats a good way to get the ssid either... :/ Suggestions?

    Read the article

  • UnicodeDecodeError from a GET-parameter in webapp2

    - by Aneon
    I'm getting a UnicodeDecodeError when recieving a GET-parameter from webapp2 that contains unicode characters, and then using it to do a NDB query. I get the same error message when manually running a unicode() on the parameter in the handler, so there either seems to be a problem in webapp2's URL routing or I've missed something. Preferably, all GET-parameters should be converted to unicode before getting passed into the handler so I don't need to do manual conversions in all of my handlers. I actually think it's worked before in an earlier version. The full error message read: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) The GET-parameter contains the following string: göteborg. It looks fine when I raise an Exception on it, but gives me an error when I (or NDB) use unicode() on it. EDIT: In NDB, it fails on the following code: File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\datastore_types.py", line 1562, in PackString pbvalue.set_stringvalue(unicode(value).encode('utf-8')) Thanks.

    Read the article

  • String Index Out Of Bound Exception error

    - by Fd Fehfhd
    Im not really sure why a am getting this error. But here is my code it is meant to test palindromes disregarding punctuation. So here is my code import java.util.Scanner; public class PalindromeTester { public static void main(String [] args) { Scanner kb = new Scanner(System.in); String txt = ""; int left; int right; int cntr = 0; do { System.out.println("Enter a word, phrase, or sentence (blank line to stop):"); txt = kb.nextLine(); txt = txt.toLowerCase(); char yP; String noP = ""; for (int i = 0; i < txt.length(); i++) { yP = txt.charAt(i); if (Character.isLetterOrDigit(txt.charAt(yP))) { noP += yP; } } txt = noP; left = 0; right = txt.length() -1; while (txt.charAt(left) == txt.charAt(right) && right > left) { left++; right--; } if (left > right) { System.out.println("Palindrome"); cntr++; } else { System.out.println("Not a palindrome"); } } while (!txt.equals("")); System.out.println("You found " + cntr + " palindromes. Thank you for using palindromeTester."); } } And if i test it and then i put enter so it will tell me how many palindromes you found the error i am getting is javav.lang.StringIndexOutOfBoundException : String index out of range 0 at PalindromeTester.main(PalindromeTester.java:38) and line 28 is while (txt.charAt(left) == txt.charAt(right) && right > left) Thanks for the help in advance

    Read the article

  • Project Euler #18 - how to brute force all possible paths in tree-like structure using Python?

    - by euler user
    Am trying to learn Python the Atlantic way and am stuck on Project Euler #18. All of the stuff I can find on the web (and there's a LOT more googling that happened beyond that) is some variation on 'well you COULD brute force it, but here's a more elegant solution'... I get it, I totally do. There are really neat solutions out there, and I look forward to the day where the phrase 'acyclic graph' conjures up something more than a hazy, 1 megapixel resolution in my head. But I need to walk before I run here, see the state, and toy around with the brute force answer. So, question: how do I generate (enumerate?) all valid paths for the triangle in Project Euler #18 and store them in an appropriate python data structure? (A list of lists is my initial inclination?). I don't want the answer - I want to know how to brute force all the paths and store them into a data structure. Here's what I've got. I'm definitely looping over the data set wrong. The desired behavior would be to go 'depth first(?)' rather than just looping over each row ineffectually.. I read ch. 3 of Norvig's book but couldn't translate the psuedo-code. Tried reading over the AIMA python library for ch. 3 but it makes too many leaps. triangle = [ [75], [95, 64], [17, 47, 82], [18, 35, 87, 10], [20, 4, 82, 47, 65], [19, 1, 23, 75, 3, 34], [88, 2, 77, 73, 7, 63, 67], [99, 65, 4, 28, 6, 16, 70, 92], [41, 41, 26, 56, 83, 40, 80, 70, 33], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48], [63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31], [04, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23], ] def expand_node(r, c): return [[r+1,c+0],[r+1,c+1]] all_paths = [] my_path = [] for i in xrange(0, len(triangle)): for j in xrange(0, len(triangle[i])): print 'row ', i, ' and col ', j, ' value is ', triangle[i][j] ??my_path = somehow chain these together??? if my_path not in all_paths all_paths.append(my_path) Answers that avoid external libraries (like itertools) preferred.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >