Showing posts with label Test your Programming Skill. Show all posts
Showing posts with label Test your Programming Skill. Show all posts

## Wednesday, 20 January 2016

### Pattern Search using Regular Expression in Python

In our daily life we found lots of problem of pattern search. like find all mobile numbers, or emails etc  from  given web page or from any file.

Writing manual code for that is not efficient and also very messy. Regular Expression is very popular technique used for pattern search (All compiler & interpreter use it ) & it is very easy to implement & it is very efficient .

I suggest you to write a code for extracting all emails from a webpage without using regular expression & test it .
Emails found on a webpage may follow some of these pattern like

 abc_7@gmail.com abcd(at)hotmail.in abcd@@stanford.edu.org abcd@mnp(dot)com

## Saturday, 5 September 2015

### Finding First and Last occurrence in sorted list

Finding first and last occurrence of given number in sorted list is a very easy problem and can easily solved by leaner search with worse case Time complexity O(n) .
But We can Achieve faster search of first and last occurrence of a number by exploiting sorted feature of list.
We can  search  occurrence of any number in sorted list in O(log(n)) Time Complexity by using Binary search Algorithm.

## Monday, 30 March 2015

### n'th Prime Number

The first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 5th prime is 11.
What is the 10001st prime number???

This Question is quit direct but we try to solve it in very effective way.
i.e with less complexity .

First Of all we need to know best way to check a number is prime or not. Read this .

## Friday, 27 March 2015

### Find the largest palindrome made from the product of two 3-digit numbers.

This Is  very easy ProjectEuler Problem. but it worth trying. First of all Try it by yourself then back to us even if you succeed because getting answer should not be our only objective. How efficient is our approach also matters.

First Approach People try is find largest palindrome in range 100*100 to 999*999 this is a very obvious but wrong approach because all numbers in this range are not multiple of 2 3 digit number .

## Thursday, 26 March 2015

### Play With Binomial coefficient

Binomial Series has Very important role in mathematics .
Today we are going to discuss different approach of finding binomial coefficient . Mathematical Formula to find binomial Coefficient

Directly implement this mathematical formula  to find Binomial Coefficient

## Wednesday, 25 March 2015

### Largest Prime Divisor of a Number

Problem Statement :
Prime factors of 830297 are  13 and 17.
Here 17 is largest prim divisor

What is the largest prime factor of the number 580851475758 ?

Prequisite :

• You must need To know Fastest way to check a number is Prime or Not. (Play-with-prime)
• Concept of factorization

We know all numbers can be factorize in term of prime numbers. we gonna use this Property to solve this problem

How we gonna solve this problem lets Solve By an Example

### Fibonacci Series

Fibonacci series => 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ...

I`th number in series is sum of (i-1)th & (i-2)th number in series where first two number in series are 0 & 1 ,these are base case for Fibonacci series.

If Fibonacci(n) represent n`th number in Fibonacci series .
then
Fibonacci(0) = 0
Fibonacci(1) = 1
.
.
.
Fibonacci(n) = Fibonacci(n-1)+Fibonacci(n-2)

Using Iteration you can easily find nth Fibonacci number .

Recursive Method for Finding n`th fibonacci Number .

## Thursday, 8 January 2015

### Play With Prime

Prime numbers :- Numbers that are only divisible by 1 and by itself .

Now think how to check number is prime or not

#### Basic Approach

Check Divisibility of number form 2 to n-1 is it is not divisible then prime .

## Queue:

A queue is a linear list of element in which
è Deletion can take place at one end that is Front .

è Insertion take place at one end that is Rear ..

That's why Also known as FILO :-first in last out

### Queue:

A queue is a linear list of element in which
è Deletion can take place at one end that is Front .

è Insertion take place at one end that is Rear ..

That's why Also known as FILO :-first in last out

## Monday, 7 July 2014

### Palindrome Number

Palindrome number are very common question we face in programming field .

### Palindrome number :

Numbers that remain the same when digit is reversed .
Example : 2, 202 , 101 ,191, 99599, 76567 these are palindrome number

Not palindrome : 123, 3452, 6789, 23434 4561, 34546

#### How check Number Is Palindrome Or Not :

There are many ways to  check number is palindrome :

## Tuesday, 25 March 2014

### Fastest Way to check divisibility by 3

When the number is small directly check its divisibility by 3 by dividing it . works fine but if number is large this technique is no more best technique to check divisibility ..

Other way is by checking divisibility of sum of its digit . but this technique is also not effective because to find each digit we need to divide again & again by 10.

But there exist a much faster way to check this .

Now think about binary representation of a number in binary . Since we generally  ignore property of number in binary that's why you did't find this till now .

## Concept :

find out number of set odd position  bit from right  (let say it odd_set ) & find number of set even position bit from right (let say is even_set ). set bit means has value 1.

Now if difference of odd_set & even_set divisible by 3 than it is divisible otherwise not divisible by 3 .
& treat 0 & 1 as special case ..

## Saturday, 22 March 2014

### TOWER OF HANOI

This is a famous game for programmer .

Object of the game is to move all the disks over to tower C (final destination let say D )   from tower A (source tower let say S ) with the help of tower B (temporary Tower let say T) .

## Wednesday, 5 March 2014

### Effective Way to test Number is Prime or Not .

Prime number is one of most frequent thing we face in programming  Problems . But you know most time we use algorithm to test number is prime or not is is very slow if number is too big . In other word our algorithm is not efficient .

But little bit change to that algorithm make it more efficient .

#### Prime number :

A integer that has no integral factor except 1 and itself . ( 1 is not treated as prime number )

Now normal Way to solve this is make a for loop from 2 to N/2 & check divisibility for each integer .

Take a look of C code :

## Thursday, 27 February 2014

### Test your Programming Skill : P-2

Our today's Programming Problem is quite  easier . It uses your Basic mathematics skill of School level But Really This Problem Test your skills .

You Have to Find Number of Zeros at end of factorial of a number without using real factorisation
example : let No be 15 then 15 ! (15 factorial ) =1*2*3* ..........*13*14*15
and you have to find out number of Zero's at end of 15 ! = 3
as 15!=1307674368000 .

I Gave you some results  to check your Program output .  So hurry Up .

## Friday, 14 February 2014

### Print n time Without Loop

How to print any thing n times Without Using any LOOP :

this is very easy & very common question : ask to check your recursion Programming  Basics .

It is really very easy : you just have to make a simple function

I gave you source code for this program in C & Python I hope it definitely  help you  if you are unable to get it .

### Test your Programming Skill : P-1

Write a Program to calculate Sum of Two number Without Using Any operator like +,-,* ... etc.

You can solve it in many different ways : But you need to consider binary operation like XOR , AND .

Blogger Widgets