Search Results

Search found 5176 results on 208 pages for 'max fraser'.

Page 102/208 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • How to check for palindrome using Python logic

    - by DrOnline
    My background is only a 6 month college class in basic C/C++, and I'm trying to convert to Python. I may be talking nonsense, but it seems to me C, at least at my level, is very for-loop intensive. I solve most problems with these loops. And it seems to me the biggest mistake people do when going from C to Python is trying to implement C logic using Python, which makes things run slowly, and it's just not making the most of the language. I see on this website: http://hyperpolyglot.org/scripting (serach for "c-style for", that Python doesn't have C-style for loops. Might be outdated, but I interpret it to mean Python has its own methods for this. I've tried looking around, I can't find much up to date (Python 3) advice for this. How can I solve a palindrome challenge in Python, without using the for loop? I've done this in C in class, but I want to do it in Python, on a personal basis. The problem is from the Euler Project, great site btw. def isPalindrome(n): lst = [int(n) for n in str(n)] l=len(lst) if l==0 || l==1: return True elif len(lst)%2==0: for k in range (l) ##### else: while (k<=((l-1)/2)): if (list[]): ##### for i in range (999, 100, -1): for j in range (999,100, -1): if isPalindrome(i*j): print(i*j) break I'm missing a lot of code here. The five hashes are just reminders for myself. Concrete questions: 1) In C, I would make a for loop comparing index 0 to index max, and then index 0+1 with max-1, until something something. How to best do this in Python? 2) My for loop (in in range (999, 100, -1), is this a bad way to do it in Python? 3) Does anybody have any good advice, or good websites or resources for people in my position? I'm not a programmer, I don't aspire to be one, I just want to learn enough so that when I write my bachelor's degree thesis (electrical engineering), I don't have to simultaneously LEARN an applicable programming language while trying to obtain good results in the project. "How to go from basic C to great application of Python", that sort of thing. 4) Any specific bits of code to make a great solution to this problem would also be appreciated, I need to learn good algorithms.. I am envisioning 3 situations. If the value is zero or single digit, if it is of odd length, and if it is of even length. I was planning to write for loops... PS: The problem is: Find the highest value product of two 3 digit integers that is also a palindrome.

    Read the article

  • how can i program this ui box

    - by silverkid
    in what way can this be programmed. a UI box that displays random number between min and max value for 2 seconds then shows blank for 2 seconds then shows another random numer for 2 seconds then shows blank for 10 seonds and then repeats the cycle infitely until form closed. Font of the text to be configurable. any help at all will be appreciated.

    Read the article

  • How can this PHP/FQL code be modified to increase the performance and usability?

    - by Kaoukkos
    I try to get some insights from the pages I am administrator on Facebook. What my code does, it gets the IDs of the pages I want to work with through mySQL. I did not include that part though.After this, I get the page_id, name and fan_count of each of those facebook IDs and are saved in fancounts[]. Using the IDs ( pages[] ) I get two messages max from each page. There may be no messages, there may be 1 or 2 messages max. Possibly I will increase it later. messages[] holds the messages of each page. I have two problems with it. It has a very slow performance I can't find a way to echo the data like this: ID - Name of the page - Fan Count Here goes the first message Here goes the second one //here is a break ID - Name of the page 2 - Fan Count Here goes the first message of page 2 Here goes the second one of page 2 My questions are, how can the code be modified to increase performance and show the data as above? I read about fql.multiquery. Can it be used here? Please provide me with code examples. Thank you $pages = array(); // I get the IDs I want to work with $pagesIds = implode(',', $pages); // fancounts[] holds the page_id, name and fan_count of the Ids I work with $fancounts = array(); $pagesFanCounts = $facebook->api("/fql", array( "q" => "SELECT page_id, name, fan_count FROM page WHERE page_id IN ({$pagesIds})" )); foreach ($pagesFanCounts['data'] as $page){ $fancounts[] = $page['page_id']."-".$page['name']."-".$page['fan_count']; } //messages[] holds from 0 to 2 messages from each of the above pages $messages = array(); foreach( $pages as $id) { $getMessages = $facebook->api("/fql", array( "q" => "SELECT message FROM stream WHERE source_id = '$id' LIMIT 2" )); $messages[] = $getMessages['data']; } // this is how I print them now but it does not give me the best output. ( thanks goes to Mark for providing me this code ) $count = min(count($fancounts),count($messages)); for($i=0; $i<$count; ++$i) { echo $fancounts[$i],'<br>'; foreach($messages[$i] as $msg) { echo $msg['message'],'<br>'; } }

    Read the article

  • How to handle choice field with JPA 2, Hibernate 3.5

    - by phmr
    I have an entity with Integer attributes that looks like this in proto code: class MyEntity: String name Integer frequency Integer type def getFrequency() def getType() get* accessors return strings according to this table. value(type) HumanReadableString(type) 1 BSD 2 Apache 3 GPL min frequency max frequency HumanReadableString(frequency) 0 1000 rare 1000 2000 frequent 2001 3000 sexy It should be possible to get all possible values that an attribute can take, example: getChoices(MyEntity, "type") returns ("rare", "frequent", "sexy") It should be possible to get the bound value from the string: getValue(MyEntity, "frequency", "sexy") returns (2000,3000)

    Read the article

  • SQL Server - In clause with a declared variable

    - by Melursus
    Let say I got the following : DECLARE @ExcludedList VARCHAR(MAX) SET @ExcludedList = 3 + ', ' + 4 + ' ,' + '22' SELECT * FROM A WHERE Id NOT IN (@ExcludedList) Error : Conversion failed when converting the varchar value ', ' to data type int. I understand why the error is there but I don't know how to solve it...

    Read the article

  • Passing a Dictionary to WCF service

    - by Sandeep
    I need to pass a Dictionary (with max 20,000 entries) to a WCF service. Can I pass it all by once? void SubmitDictionary(Dictionary<string, MyEntry> val); where MyEntry is : class MyEntry { string Name; long Age; } Is there a configuration for size of the value passed? or can we pass as large data as this?

    Read the article

  • Use database field maxlength as html layout input maxlength best practice. asp.net mvc

    - by Andrew Florko
    Hello everybody, There are string length limitations in database structure (email is declared as nvarchar[30] for instance) There are lots of html forms that has input textbox fields that should be limited in length for that reason. What is the best practice to synchronize database fields and html layout input fields length limitations ? Can it be done automatically (html layout input fields declared the same max length as database data they represent)? Thank you in advance.

    Read the article

  • Load test results VSTS 2008

    - by Julia
    Can anybody explain why load test result on Graph are different form load test result on Table Page. If compare Min and Avg page response time they are the same. But if we compare figures in Max column they are different for the same page and the same load rest run. see linked images for more details. http://cid-ee8b34c203174724.skydrive.live.com/self.aspx/.Public/3.png

    Read the article

  • Using imtophat in Matlab

    - by jaff12
    I'm trying to do top hat filtering in matlab. The imtophat function looks promising, but I have no idea how to use it. I dont have a lot of work with Matlab before. I am trying to look find basically small spots several pixels wide that are local max in my 2 dimensional array.

    Read the article

  • MATLAB image corner coordinates & referncing to cell arrays

    - by James
    Hi, I am having some problems comparing the elements in different cell arrays. The context of this problem is that I am using the bwboundaries function in MATLAB to trace the outline of an image. The image is of a structural cross section and I am trying to find if there is continuity throughout the section (i.e. there is only one outline produced by the bwboundaries command). Having done this and found where the is more than one section traced (i.e. it is not continuous), I have used the cornermetric command to find the corners of each section. The code I have is: %% Define the structural section as a binary matrix (Image is an I-section with the web broken) bw(20:40,50:150) = 1; bw(160:180,50:150) = 1; bw(20:60,95:105) = 1; bw(140:180,95:105) = 1; Trace = bw; [B] = bwboundaries(Trace,'noholes'); %Traces the outer boundary of each section L = length(B); % Finds number of boundaries if L > 1 disp('Multiple boundaries') % States whether more than one boundary found end %% Obtain perimeter coordinates for k=1:length(B) %For all the boundaries perim = B{k}; %Obtains perimeter coordinates (as a 2D matrix) from the cell array end %% Find the corner positions C = cornermetric(bw); Areacorners = find(C == max(max(C))) % Finds the corner coordinates of each boundary [rowindexcorners,colindexcorners] = ind2sub(size(Newgeometry),Areacorners) % Convert corner coordinate indexes into subcripts, to give x & y coordinates (i.e. the same format as B gives) %% Put these corner coordinates into a cell array Cornerscellarray = cell(length(rowindexcorners),1); % Initialises cell array of zeros for i =1:numel(rowindexcorners) Cornerscellarray(i) = {[rowindexcorners(i) colindexcorners(i)]}; %Assigns the corner indicies into the cell array %This is done so the cell arrays can be compared end for k=1:length(B) %For all the boundaries found perim = B{k}; %Obtains coordinates for each perimeter Z = perim; % Initialise the matrix containing the perimeter corners Sectioncellmatrix = cell(length(rowindexcorners),1); for i =1:length(perim) Sectioncellmatrix(i) = {[perim(i,1) perim(i,2)]}; end for i = 1:length(perim) if Sectioncellmatrix(i) ~= Cornerscellarray Sectioncellmatrix(i) = []; %Gets rid of the elements that are not corners, but keeps them associated with the relevent section end end end This creates an error in the last for loop. Is there a way I can check whether each cell of the array (containing an x and y coordinate) is equal to any pair of coordinates in cornercellarray? I know it is possible with matrices to compare whether a certain element matches any of the elements in another matrix. I want to be able to do the same here, but for the pair of coordinates within the cell array. The reason I don't just use the cornercellarray cell array itself, is because this lists all the corner coordinates and does not associate them with a specific traced boundary.

    Read the article

  • Fit Map onto Google Map

    - by Viplime
    I would like to fit my map onto the same place in google maps.I have max 10 gps(latitude and longitude) positions on my map and I want to fit it on google maps using the points.I think I need to use overlay features of google maps.However, I need to transform my map to fit properly.How do i transform my map(image) to be able to fit it onto google maps? Is there an google method or API for it? Thanks.

    Read the article

  • What size of folders show ls -la

    - by Bkmz
    Hi. I'm interesting in information what show me output ls -la in linux. So, default size is 4K. But if there are a lot of files, maybe with zero size, such as PHP sessions =), the size != 4K. What showing me ls -la? And after, when i clean this folder i see tha last max size.

    Read the article

  • How long is too long for a script to execute?

    - by Chris T
    What is the max time do you think is acceptable for a web script (PHP for example) to execute before it starts to become an annoyance for the user (on average)? I always thought that if the user has to wait more than 1 second for the page to load (this of course after images and css have been cached..this rule really only applies for subsequent requests) they would start to get annoyed.

    Read the article

  • Ad-hoc retreival of data from SQL Server varbinary column

    - by Daniel Fortunov
    I would like to retreive some binary data from a varbinary(max) column in a SQL Server database for debugging purposes. What is the easiest way to get this data into a local binary file, preferably without having to write a throw-away console application? I have tried using SQL Server Management Studio but this returns a hex encoded binary string, rather than raw binary data (even with the "results to file" option).

    Read the article

  • Why does firefox round-trip to the server to determine whether my files are modifed?

    - by erikkallen
    I have some static content on my web site that I have set up caching for (using Asp.NET MVC). According to Firebug, the first time I open the page, Firefox sends this request: GET /CoreContent/Core.css?asm=0.7.3614.34951 Host: 127.0.0.1:3916 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Accept: text/css,*/*;q=0.1 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://127.0.0.1:3916/Edit/1/101 Cookie: .ASPXAUTH=52312E5A802C1A079E2BA29AA2BFBC5A38058977B84452D62ED52855D4164659B4307661EC73A307BFFB2ED3871C67CB3A9AAFDB3A75A99AC0A21C63A6AADE9A11A7138C672E75125D9FF3EFFBD9BF62 Pragma: no-cache Cache-Control: no-cache Which my server replies to with this: Server: ASP.NET Development Server/9.0.0.0 Date: Mon, 23 Nov 2009 18:44:41 GMT X-AspNet-Version: 2.0.50727 X-AspNetMvc-Version: 1.0 Cache-Control: public, max-age=31535671 Expires: Tue, 23 Nov 2010 18:39:12 GMT Last-Modified: Mon, 23 Nov 2009 18:39:12 GMT Vary: * Content-Type: text/css Content-Length: 15006 Connection: Close So far, so good. However, if I refresh Firefox (not a cache-clearing refresh, just a normal one), during that refresh cycle Firefox will once again go to the server with this request: GET /CoreContent/Core.css?asm=0.7.3614.34951 Host: 127.0.0.1:3916 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Accept: text/css,*/*;q=0.1 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://127.0.0.1:3916/Edit/1/101 Cookie: .ASPXAUTH=52312E5A802C1A079E2BA29AA2BFBC5A38058977B84452D62ED52855D4164659B4307661EC73A307BFFB2ED3871C67CB3A9AAFDB3A75A99AC0A21C63A6AADE9A11A7138C672E75125D9FF3EFFBD9BF62 If-Modified-Since: Mon, 23 Nov 2009 18:39:20 GMT Cache-Control: max-age=0 to which my server responds 304 Not Modified. Why does Firefox issue this second request? In the first response, I said that the cache does not expire for a year (I intend to use query parameters whenever things change). Do I have to add another response header to prevent this extra roundtrip? Edit: It does not matter whether I press refresh, or whether I go to the page again (or a different URL, which references the same external files). Firefox does the same again. Also, I don't claim this to be a bug in FF, I just wonder if there is another header I can set which means "This document will never change, don't bother me again".

    Read the article

  • LINQ + Find count of non-null values

    - by Ashutosh
    I have a table with the below structure. ID VALUE 1 3.2 2 NULL 4 NULL 5 NULL 7 NULL 10 1.8 11 NULL 12 3.2 15 4.7 17 NULL 22 NULL 24 NULL 25 NULL 27 NULL 28 7 I would like to get the max count of consecutive null values in the table. Any help would be greatly appreciated. THanks Ashutosh

    Read the article

  • SQL inserting value of a specific column under multple case

    - by Lo Wai Lun
    Suppose I have got a table which I have to insert the description of the contract under different keys of contract. But when executing, there is a n error near then Is there any limitation of using syntax set ? The below is my SQL declare @i int, @j v nvarchar(MAX) set @i = 1 while (@i<=8) begin set @j = case when @i = 1 then 'CR' when @i = 2 then 'Facebook' else 'N/A' end INSERT INTO CostNature (CNKey, CNNDescription) VALUES (@i , @j ); set @i = @i + 1 end

    Read the article

  • PHP Session Class and $_SESSION Array

    - by Gianluca Bargelli
    Hello, i've implemented this custom PHP Session Class for storing sessions into a MySQL database: class Session { private $_session; public $maxTime; private $database; public function __construct(mysqli $database) { $this->database=$database; $this->maxTime['access'] = time(); $this->maxTime['gc'] = get_cfg_var('session.gc_maxlifetime'); session_set_save_handler(array($this,'_open'), array($this,'_close'), array($this,'_read'), array($this,'_write'), array($this,'_destroy'), array($this,'_clean') ); register_shutdown_function('session_write_close'); session_start();//SESSION START } public function _open() { return true; } public function _close() { $this->_clean($this->maxTime['gc']); } public function _read($id) { $getData= $this->database->prepare("SELECT data FROM Sessions AS Session WHERE Session.id = ?"); $getData->bind_param('s',$id); $getData->execute(); $allData= $getData->fetch(); $totalData = count($allData); $hasData=(bool) $totalData >=1; return $hasData ? $allData['data'] : ''; } public function _write($id, $data) { $getData = $this->database->prepare("REPLACE INTO Sessions VALUES (?, ?, ?)"); $getData->bind_param('sss', $id, $this->maxTime['access'], $data); return $getData->execute(); } public function _destroy($id) { $getData=$this->database->prepare("DELETE FROM Sessions WHERE id = ?"); $getData->bind_param('S', $id); return $getData->execute(); } public function _clean($max) { $old=($this->maxTime['access'] - $max); $getData = $this->database->prepare("DELETE FROM Sessions WHERE access < ?"); $getData->bind_param('s', $old); return $getData->execute(); } } It works well but i don't really know how to properly access the $_SESSION array: For example: $db=new DBClass();//This is a custom database class $session=new Session($db->getConnection()); if (isset($_SESSION['user'])) { echo($_SESSION['user']);//THIS IS NEVER EXECUTED! } else { $_SESSION['user']="test"; Echo("Session created!"); } At every page refresh it seems that $_SESSION['user'] is somehow "resetted", what methods can i apply to prevent such behaviour?

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >