@.         
                @@         
          :     :@         
          .@     @         
           :@    @+        
            +@   @@        
        `@@@;'@` +@        
       '@@'+@@@@; @        
               @@@@'       
                +@@@.      
                 `@@@+     
       :@@:@.     :@@@     
        .@@@@:     @       
          @#@@@    @:      
          .@ '@@@  @@      
           ;@  #@@@`.      
            @+  @@@@@      
             @   +@@@@:    
        @@@@@@.    +@@@+   
        @@.@@@        .    
         @,                
         `@                
          +@               
        #@@;               
       :@:@@@              
       .@ #+#@             
       `@  @ @+            
        @'  @ @            
        :@  :@@            
         @@  #;            
          @:               
           @:              
                .          
                @+         
        ;:      `@         
       +@@@      ::        
        #@@@'     @        
         :@@@@    :;       
          `@@@@:   @       
           .@@@@#  @`      
             @;@@@`+@      
              @ @@@@@      
               @ '@@#      
                @  ;       
                 @         
         @@@:    :@        
        @@@@@@:   ##       
        +  :@@@@.  @`      
         @   :@@@@ ;@      
         +@    ;@@@@@      
          @#     #@@@      
           @       +.      
        @@@@@              
       @@@@@@+             
       @   ;@@             
       #,   ;@+            
        @`   @@            
        :@# @+@            
         .@@@:`            
                           
           :               
         . #;              
        @@@@@              
       @.`#@@@             
       @    @@.            
       :#    @@            
        @#   @@            
         @@@@##            
          @@@              
                           
                           
                           
       .@@@@@#`            
       @+:;;@@@@:          
       ;@ @ @@ @@@`        
        @@@@ @@` @@#       
         ;@@  :@; :@@`     
          @+    @@  @@+    
          #@     `@+ .@#   
           @:      .@#:@;  
            @         :@   
                     
 
 

Popular Posts

Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Django 'Unresolved import' Error of Pydev in Ubuntu Fix

Recently I switched from Windows to Ubuntu and being a beginner I had to face a few problems setting up everything . For writing Django apps I use Aptana IDE that in turn uses the Pydev plugin. I downloaded the tar ball from aptana official site .Installed Django using the terminal. Extracted Aptana tar ball in home directory and Ran it by double clicking on 'AptanaStudio3'. Everything looked nice until I imported a django app in the workspace . All the Djano import when marked as error and they could not be resolved . There was nothing wrong with the Python path variable and when running the Project from the terminal everything worked .The Problem was with Aptana/Eclipse that it could not resolve the path. I found the reason after some time and this is how i solved it .

The problem:


Continue Reading

Prime no are one of the most mysterious no. in the Number theory . There are a lot on method of checking if a no is Prime or not, two most famous are the Probabilistic and Naive method . Naive method is simple and efficient this.
Before know the better let's discuss what not to do, here is the python code for checking Prime that is less efficient.

def is_prime(num):
    c=0
    for i in range(2,num):
        if num % i==0:
            c+=1
        if c==0:
            return True
        else:
            return False


here the loop iterates till the given number, which is useless.
This can be optimized by running the first loop untill the square root of the number abd checking for the factors. This works because any composite number can be factorized and written into product of number in which one number is less than the square root of the number.
HERE is the better optimized NAIVE Method for checking primes 


def NaivePrime(n):
    check=True
    for i in range(2,int(n**0.5)+1):
        if i%2==0 and i !=2:
            continue
        else:
            if n%i==0:
                check=False
                print "%d is factor" % i 
                break
    return check

this runs much fast and in the conventional way if very large numbers are tested then an overflow can be encountered .
And then comes the Sieve of Eratosthenes which is much faster than previous methods given.Its modification the Sieve of Atkins is even more efficient. If space complexity is also to be taken into account then a segmented Sieve is the best method.
This is the code for Sieve of Eratosthenes

def p(n):
  is_p=[False]*2 + [True]*(n-1)
  for i in range(2, int(n**0.5)):
    if is_p[i]:
        for j in range(i*i, n, i):
            is_p[j] = False
  for i in range(2, n):
    if is_p[i]:
      yield i

print list(p(102))



Continue Reading

Recently I was asked by my friend to write a simple code to check if two strings are anagram or not.I wrote three different approach to it in python.I was not allowed to change the input format so i had to do some extra work and write a function to get input.
Here is the question that was given:

Anagram

--------------------------
In this problem, you are given two strings S1 and S2, your task is to determine whether one string is an anagram of the other. An anagram of a string is a string obtained by permuting the letters of a string. For example aaba and aaab are anagrams, while abcd and deba are not.
Continue Reading


Before moving on with this I would before you can actually do that in one click you have to take a little bit of pain to set up the system, I promise it’s a one time setup and won’t poke you ever after ,just a click and that
Ugly addition to the title and filename removed in a click. So far if you are not getting as to what i am upto ; in plane and simple words: many time you must have downloaded songs that has this ugly thing like “songname_www.xyz.com” now what it will do is that it will just remove that www.xyz.com  stuff from the title and filename in a click. Just follow the steps

Continue Reading