Skip to main content

Posts

Showing posts from October, 2016

URL shortener with python and flask - chapter 1 - Installations

In this chapter we will make some important installations. We will use these modules and softwares in the upcoming chapters. I am assuming that you are beginner and so we will start with python installation.

URL shortener with python and flask- Chapter 0 - Introduction

In this tutorial series, we will use flask to create a URL shortener service. At the end of this tutorial series, I am expecting that you will be in a position to extend this knowledge for use in some other application.

Pairwise Summation algorithm implementation with python

Pairwise summation algorithm is a summation algorithm like Kahan Algorithm but does perform better when compared to the Kahan Algorithm . This is because of the Divide and Conquer approach followed by this algorithm. According to Wikipedia, this is the official sum mation algorithm used in N umpy .

Binary GCD algorithm implementation with python

Binary GCD algorithm also known as Stein's algorithm is an improved version of Euclidean Algorithm.It takes two integer inputs and finds the Greatest Common Divisor(GCD) of the two numbers. The algorithm uses recursive techniques to find the GCD of the two numbers.

Heap's Algorithm implementation with python

Heap's Algorithm is used to generate all the permutations of a given object. It was first proposed by B.R. Heap in the year 1963. In this post, we will write a program usi ng Heap 's Algorithm which will gener at e permutations for a given object. Remember that the o bject shou ld be itera ble. Otherwise, you will get an error.

Problem 61 Project Euler Solution with python

Cyclical figurate numbers Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae: Triangle P 3, n = n ( n +1)/2 1, 3, 6, 10, 15, ... Square P 4, n = n 2 1, 4, 9, 16, 25, ... Pentagonal P 5, n = n (3 n −1)/2 1, 5, 12, 22, 35, ... Hexagonal P 6, n = n (2 n −1) 1, 6, 15, 28, 45, ... Heptagonal P 7, n = n (5 n −3)/2 1, 7, 18, 34, 55, ... Octagonal P 8, n = n (3 n −2) 1, 8, 21, 40, 65, ... The ordered set of three 4-digit numbers: 8128, 2882, 8281, has three interesting properties. The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first). Each polygonal type: triangle (P 3,127 =8128), square (P 4,91 =8281), and pentagonal (P 5,44 =2882), is represented by a different number in the set. This is the only set of 4-digit numbers with this property. Find

Problem 60 Project Euler Solution with python

Prime pair sets The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property. Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime. This problem is j u st a brute force problem. If you have come here because you don't know the limit upto which you will h ave to gener ate the prime numbers t hen go ahe ad and t r y with 10,000 . When I first start ed solving the problem I chose 1 million(beca use most of the problem s on project E uler have this limit ), but it took very long for the computer to fin d the solution. After searching on the internet then I found many people choosing 10, 000 so I have changed my in put f rom 1 million to 10000 and the output was f ast. He