This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_unique_characters(astring): | |
for char in range(len(astring)): | |
for chars in range(char+1, len(astring)): | |
if astring[chars] == astring[char]: | |
return False | |
return True | |
if __name__ == "__main__": | |
astr = input() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergeSort(alist): | |
if len(alist) > 1: | |
# Divide the given list until single element in each side | |
mid = len(alist) // 2 | |
lefthalf = alist[:mid] | |
righthalf = alist[mid:] | |
mergeSort(lefthalf) | |
mergeSort(righthalf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def BinaryIterativeSearch(alist, num): | |
start = 0 | |
end = len(alist) | |
# For finding the fisrt or last occurrence of any number | |
# res = -1 | |
while end >= start: | |
mid = (start + end) // 2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search_iterative(alist, num): | |
''' | |
This is iterative implementation of binary search algorithm. | |
Input: a list of numbers and a number to be searched | |
Output: True if number is present in the list otherwise False | |
''' | |
low = 0 | |
high = len(alist) - 1 | |
while high >= low: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def liner_search(alist, num): | |
''' | |
Input: a list of numbers and a number to be searched | |
Output: if the number present in the list then True otherwise False | |
''' | |
for i in alist: | |
if i == num: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def towersOfHanoi(n, source, destination): | |
''' | |
Calculate the moving steps for moving | |
n number of disks from Source Tower to | |
Destination Tower using one Intermidiate Tower. | |
''' | |
if n == 1: | |
printMessase(source, destination) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sieve_prime(alist): | |
# Mark all odd number as prime | |
i = 3 | |
while i <= len(alist): | |
alist[i] = True | |
# Mark Only odd numbers | |
i += 2 | |
# Multiples Mark | |
i = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script tries to figure out the reason of | |
# `ImportError` on Windows. | |
# Run it with `python check_import.py`. | |
import ctypes | |
import glob | |
import os | |
import sys | |
import subprocess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int x=7,&y=x; | |
cout<<"Whithout Increment: "; | |
cout<<&x<<" "<<&y<<endl; | |
cout<<x<<" "<<y<<endl; | |
--x; |