diff --git a/.nojekyll b/.nojekyll deleted file mode 100644 index 8b137891..00000000 --- a/.nojekyll +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Bank Management/banking.py.py b/Bank Management/banking.py.py new file mode 100644 index 00000000..c04bf0cd --- /dev/null +++ b/Bank Management/banking.py.py @@ -0,0 +1,350 @@ +import mysql.connector +from datetime import datetime +from selenium import webdriver +from fpdf import FPDF +import selenium + +mydb=mysql.connector.connect(user='root', +passwd='dbavenge2015', + +host='localhost', +auth_plugin='mysql_native_password', +database='bankDB' +) +mycursor=mydb.cursor(buffered=True) + + + +def MiniStatement(): + from fpdf import FPDF + acc=int(input("Enter Account Number: ")) + pdf = FPDF() + pdf.add_page() + pdf.set_font("Arial", size = 15) + directory_open = "C:\MiniStatements\\text\\"+str(acc)+".txt" + directory_save = "C:\MiniStatements\\pdf\\"+str(acc)+".pdf" + f = open(directory_open, "r") + for x in f: + pdf.cell(0,10, txt = x, ln = 1, align = 'L') + pdf.output(directory_save) + browser = webdriver.Chrome("C:\\Drivers\\chromedriver.exe") + browser.get(directory_save) + print("Successfull") + +def Menu(): + print("*"*140) + print("MAIN MENU".center(140)) + print("1. Insert Record/Records".center(114)) + print("2. Display Records as per Account Number".center(130)) + print(" a. Sorted as per Account Number".center(140)) + print(" b. Sorted as per Customer Name".center(140)) + print(" c. Sorted as per Customer Balance".center(142)) + print("3. Search Record Details as per the account number".center(140)) + print("4. Update Record".center(105)) + print("5. Delete Record".center(105)) + print("6. TransactionsDebit/Withdraw from the account".center(135)) + print(" a. Debit/Withdraw from the account".center(145)) + print(" b. Credit into the account".center(138)) + print("7. Get Mini Statement".center(112)) + print("8. Exit".center(98)) + print("*"*140) + +def MenuSort(): + print(" a. Sort by Account Number".center(115)) + print(" b. Sort by Customer Name".center(115)) + print(" c. Sort by Customer Balance".center(117)) + print(" d. Back".center(98)) + +def MenuTransaction(): + print(" a. Debit/Withdraw from the account".center(125)) + print(" b. Credit into the account".center(117)) + print(" c. Back".center(98)) + +def Create(): + try: + mycursor.execute('create table bank(ACCNO varchar(10),NAME varchar(20),MOBILE varchar(10),EMAIL varchar(50),ADDRESS varchar(20),CITY varchar(10),COUNTRY varchar(20),BALANCE integer(15))') + print("Table Created") + Insert() + except: + print("Table Exist") + Insert() + +def Insert(): + while True: + Acc=input("Enter account no ") + Name=input("Enter Name ") + Mob=input("Enter Mobile ") + email=input("Enter Email ") + Add=input("Enter Address ") + City=input("Enter City ") + Country=input("Enter Country ") + Bal=float(input("Enter Balance ")) + Rec=[Acc,Name.upper(),Mob,email.upper(),Add.upper(),City.upper(),Country.upper(),Bal] + Cmd="insert into BANK values(%s,%s,%s,%s,%s,%s,%s,%s)" + mycursor.execute(Cmd,Rec) + mydb.commit() + directory = "C:\MiniStatements\\text\\"+Acc+".txt" + transaction = open(directory,'w') + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M:%S") + new_acc = dt_string+", "+"Account Created, Available balance: Rs."+str(Bal)+"\n" + transaction.write(new_acc) + ch=input("Do you want to enter more records") + if ch=='N' or ch=='n': + break + +def DispSortAcc(): + try: + cmd="select * from BANK order by ACCNO" + mycursor.execute(cmd) + S=mycursor.fetchall() + F="%15s %7s %20s %20s %20s %10s %17s %15s" + print(F % ("ACCNO","NAME","MOBILE","EMAIL ADDRESS","COMPLETE ADDRESS","CITY","COUNTRY","BALANCE")) + print("="*130) + for i in S: + for j in i: + print("%14s" % j, end=' ') + print() + print("="*130) + except: + print("Table doesn't exist") + +def DispSortName(): + try: + cmd="select * from BANK order by NAME" + mycursor.execute(cmd) + S=mycursor.fetchall() + F="%15s %7s %20s %20s %20s %10s %17s %15s" + print(F % ("ACCNO","NAME","MOBILE","EMAIL ADDRESS","COMPLETE ADDRESS","CITY","COUNTRY","BALANCE")) + print("="*130) + for i in S: + for j in i: + print("%14s" % j, end=' ') + print() + print("="*130) + except: + print("Table doesn't exist") + +def DispSortBal(): #Function to Display records as per ascending order of Balance + try: + cmd="select * from BANK order by BALANCE" + mycursor.execute(cmd) + S=mycursor.fetchall() + F="%15s %7s %20s %20s %20s %10s %17s %15s" + print(F % ("ACCNO","NAME","MOBILE","EMAIL ADDRESS","COMPLETE ADDRESS","CITY","COUNTRY","BALANCE")) + print("="*130) + for i in S: + for j in i: + print("%14s" % j, end=' ') + print() + print("="*130) + except: + print("Table doesn't exist") + +def DispSearchAcc(): + try: + cmd="select * from BANK" + mycursor.execute(cmd) + S=mycursor.fetchall() + ch=input("Enter the accountno to be searched ") + for i in S: + if i[0]==ch: + print("="*125) + F="%15s %7s %20s %20s %20s %10s %17s %15s" + print(F % ("ACCNO","NAME","MOBILE","EMAIL ADDRESS","COMPLETE ADDRESS","CITY","COUNTRY","BALANCE")) + print("="*130) + for j in i: + print('%14s' % j,end=' ') + print() + break + else: + print("Record Not found") + except: + print("Table doesn't exist") + +def Update(): + try: + k=0 + cmd="select * from BANK" + mycursor.execute(cmd) + S=mycursor.fetchall() + A=input("Enter the accound no whose details to be changed") + for i in S: + i=list(i) + if i[0]==A : + + ch=input("Change Name(Y/N) ") + if ch=='y' or ch=='Y': + i[1]=input("Enter Name ") + i[1]=i[1].upper() + ch=input("Change Mobile(Y/N) ") + if ch=='y' or ch=='Y': + i[2]=input("Enter Mobile ") + ch=input("Change Email(Y/N) ") + if ch=='y' or ch=='Y': + i[3]=input("Enter email ") + i[3]=i[3].upper() + ch=input("Change Address(Y/N) ") + if ch=='y' or ch=='Y': + i[4]=input("Enter Address ") + i[4]=i[4].upper() + ch=input("Change city(Y/N) ") + if ch=='y' or ch=='Y': + i[5]=input("Enter City ") + i[5]=i[5].upper() + ch=input("Change Country(Y/N) ") + if ch=='y' or ch=='Y': + i[6]=input("Enter country ") + i[6]=i[6].upper() + cmd="UPDATE BANK SET NAME=%s,MOBILE=%s,EMAIL=%s,ADDRESS=%s,CITY=%s,COUNTRY=%s,BALANCE=%s WHERE ACCNO=%s" + val=(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[0]) + mycursor.execute(cmd,val) + mydb.commit() + print("Account Updated") + + + break + else: + pass + except: + print("No such table") + +def Delete(): + try: + cmd="select * from BANK" + mycursor.execute(cmd) + S=mycursor.fetchall() + A=input("Enter the account no whose account is to be deleted") + directory = "C:\MiniStatements\\text\\"+A+".txt" + + for i in S: + i=list(i) + if i[0]==A: + cmd="delete from bank where accno=%s" + val=(i[0],) + mycursor.execute(cmd,val) + mydb.commit() + print("Account Deleted") + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M:%S") + transaction = open(directory,'a') + delete = dt_string+", "+"Account was closed." + transaction.write(delete) + break + else: + print("Record not found") + except: + print("No such Table") + +def Debit(): + try: + cmd="select * from BANK" + mycursor.execute(cmd) + S=mycursor.fetchall() + print("Please Note that the money can only be debited if min balance of Rs 5000 exists ") + acc=input("Enter the account no from which the money is to be debited ") + directory = "C:\MiniStatements\\text\\"+acc+".txt" + + + for i in S: + i=list(i) + if i[0]==acc: + Amt=float(input("Enter the amount to be withdrawn ")) + if i[7]-Amt>=5000: + i[7]-=Amt + cmd="UPDATE BANK SET BALANCE=%s WHERE ACCNO=%s" + val=(i[7],i[0]) + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M:%S") + debit = dt_string+", "+"Rs."+str(Amt)+" Debited, Available balance: Rs."+str(i[7])+"\n" + mycursor.execute(cmd,val) + mydb.commit() + transaction = open(directory,'a') + transaction.write(debit) + print("Amount Debited") + + break + else: + print("There must be min balance of Rs 5000") + break + else: + print("Record Not found") + + except: + print("Table Doesn't exist") + +def Credit(): + try: + cmd="select * from BANK" + mycursor.execute(cmd) + S=mycursor.fetchall() + acc=input("Enter the account no from which the money is to be credited ") + directory = "C:\MiniStatements\\text\\"+acc+".txt" + + for i in S: + i=list(i) + if i[0]==acc: + Amt=float(input("Enter the amount to be credited ")) + i[7]+=Amt + cmd="UPDATE BANK SET BALANCE=%s WHERE ACCNO=%s" + val=(i[7],i[0]) + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M:%S") + credit = dt_string+", "+"Rs."+str(Amt)+" Credited, Available balance: Rs."+str(i[7])+"\n" + mycursor.execute(cmd,val) + mydb.commit() + transaction = open(directory,'a') + transaction.write(credit) + print("Amount Credited") + break + else: + pass + except: + print("Table Doesn't exist") + +while True: + Menu() + ch=input("Enter your Choice: ") + if ch=="1": + Create() + elif ch=="2": + while True: + MenuSort() + ch1=input("Enter choice a/b/c/d ") + if ch1 in ['a','A']: + DispSortAcc() + elif ch1 in ['b','B']: + DispSortName() + elif ch1 in ['c','C']: + DispSortBal() + elif ch1 in ['d','D']: + print("Back to the main menu ") + break + else: + print("Invalid choice ") + elif ch=="3": + DispSearchAcc() + elif ch=="4": + Update() + elif ch=="5": + Delete() + elif ch=="6": + while True: + MenuTransaction() + ch1=input("Enter choice a/b/c ") + if ch1 in ['a','A']: + Debit() + elif ch1 in ['b','B']: + Credit() + elif ch1 in ['c','C']: + print("Back to the main menu ") + break + else: + print("Invalid choice ") + elif ch=="7": + MiniStatement() + elif ch=="8": + print("Exiting...") + break + else: + print("Wrong Choice Entered ") diff --git a/Data Structure Algo/C++/0_1_Knapsack_Problem.cpp b/Data Structure Algo/C++/0_1_Knapsack_Problem.cpp deleted file mode 100644 index cd21d391..00000000 --- a/Data Structure Algo/C++/0_1_Knapsack_Problem.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -using namespace std; -int Knpsck(vector wt,vector pr,int W) -{ - int dp[wt.size()+1][W+1]; - for(int i=0;i<=wt.size();i++) - { - for(int j=0;j<=W;j++) - { - if(i==0||j==0) - dp[i][j]=0; - else if(wt[i-1]>j) - dp[i][j]=dp[i-1][j]; - else - dp[i][j]=max(pr[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]); - } - } - return dp[wt.size()][W]; -} -int main() -{ - vector wt={3,4,6,5}; - vector pr={2,3,1,4}; - int W=8; - cout< -#include -using namespace std; - -class Graph -{ - int V; - list *adj; -public: - Graph(int V); - void addEdge(int v, int w); - void BFS(int s); -}; - -Graph::Graph(int V) -{ - this->V = V; - adj = new list[V]; -} - -void Graph::addEdge(int v, int w) -{ - adj[v].push_back(w); -} - -void Graph::BFS(int s) -{ - - bool *visited = new bool[V]; - for(int i = 0; i < V; i++) - visited[i] = false; - - - list queue; - - - visited[s] = true; - queue.push_back(s); - - - list::iterator i; - - while(!queue.empty()) - { - - s = queue.front(); - cout << s << " "; - queue.pop_front(); - - - for (i = adj[s].begin(); i != adj[s].end(); ++i) - { - if (!visited[*i]) - { - visited[*i] = true; - queue.push_back(*i); - } - } - } -} - -int main() -{ - - Graph g(4); - g.addEdge(0, 1); - g.addEdge(0, 2); - g.addEdge(1, 2); - g.addEdge(2, 0); - g.addEdge(2, 3); - g.addEdge(3, 3); - - cout << "Following is Breadth First Traversal " - << "(starting from vertex 2) \n"; - g.BFS(2); - - return 0; -} diff --git a/Data Structure Algo/C++/Dijkstra algo.cpp b/Data Structure Algo/C++/Dijkstra algo.cpp deleted file mode 100644 index d1a87dd3..00000000 --- a/Data Structure Algo/C++/Dijkstra algo.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// A C++ program for Dijkstra's single source shortest path algorithm. -// The program is for adjacency matrix representation of the graph - -#include -#include - -// Number of vertices in the graph -#define V 9 - -// A utility function to find the vertex with minimum distance value, from -// the set of vertices not yet included in shortest path tree -int minDistance(int dist[], bool sptSet[]) -{ - // Initialize min value - int min = INT_MAX, min_index; - - for (int v = 0; v < V; v++) - if (sptSet[v] == false && dist[v] <= min) - min = dist[v], min_index = v; - - return min_index; -} - -// A utility function to print the constructed distance array -int printSolution(int dist[], int n) -{ - printf("Vertex Distance from Source\n"); - for (int i = 0; i < V; i++) - printf("%d \t\t %d\n", i, dist[i]); -} - -// Function that implements Dijkstra's single source shortest path algorithm -// for a graph represented using adjacency matrix representation -void dijkstra(int graph[V][V], int src) -{ - int dist[V]; // The output array. dist[i] will hold the shortest - // distance from src to i - - bool sptSet[V]; // sptSet[i] will be true if vertex i is included in shortest - // path tree or shortest distance from src to i is finalized - - // Initialize all distances as INFINITE and stpSet[] as false - for (int i = 0; i < V; i++) - dist[i] = INT_MAX, sptSet[i] = false; - - // Distance of source vertex from itself is always 0 - dist[src] = 0; - - // Find shortest path for all vertices - for (int count = 0; count < V - 1; count++) { - // Pick the minimum distance vertex from the set of vertices not - // yet processed. u is always equal to src in the first iteration. - int u = minDistance(dist, sptSet); - - // Mark the picked vertex as processed - sptSet[u] = true; - - // Update dist value of the adjacent vertices of the picked vertex. - for (int v = 0; v < V; v++) - - // Update dist[v] only if is not in sptSet, there is an edge from - // u to v, and total weight of path from src to v through u is - // smaller than current value of dist[v] - if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX - && dist[u] + graph[u][v] < dist[v]) - dist[v] = dist[u] + graph[u][v]; - } - - // print the constructed distance array - printSolution(dist, V); -} - -// driver program to test above function -int main() -{ - /* Let us create the example graph discussed above */ - int graph[V][V] = { { 0, 4, 0, 0, 0, 0, 0, 8, 0 }, - { 4, 0, 8, 0, 0, 0, 0, 11, 0 }, - { 0, 8, 0, 7, 0, 4, 0, 0, 2 }, - { 0, 0, 7, 0, 9, 14, 0, 0, 0 }, - { 0, 0, 0, 9, 0, 10, 0, 0, 0 }, - { 0, 0, 4, 14, 10, 0, 2, 0, 0 }, - { 0, 0, 0, 0, 0, 2, 0, 1, 6 }, - { 8, 11, 0, 0, 0, 0, 1, 0, 7 }, - { 0, 0, 2, 0, 0, 0, 6, 7, 0 } }; - - dijkstra(graph, 0); - - return 0; -} diff --git a/Data Structure Algo/C++/KMP_algorithm.cpp b/Data Structure Algo/C++/KMP_algorithm.cpp deleted file mode 100644 index 18c4537b..00000000 --- a/Data Structure Algo/C++/KMP_algorithm.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - -// Function to implement the KMP algorithm -void KMP(const char* X, const char* Y, int m, int n) -{ - // base case 1: `Y` is NULL or empty - if (*Y == '\0' || n == 0) { - printf("The pattern occurs with shift 0"); - } - - // base case 2: `X` is NULL, or X's length is less than that of Y's - if (*X == '\0' || n > m) { - printf("Pattern not found"); - } - - // `next[i]` stores the index of the next best partial match - int next[n + 1]; - - for (int i = 0; i < n + 1; i++) { - next[i] = 0; - } - - for (int i = 1; i < n; i++) - { - int j = next[i + 1]; - - while (j > 0 && Y[j] != Y[i]) { - j = next[j]; - } - - if (j > 0 || Y[j] == Y[i]) { - next[i + 1] = j + 1; - } - } - - for (int i = 0, j = 0; i < m; i++) - { - if (*(X + i) == *(Y + j)) - { - if (++j == n) { - printf("The pattern occurs with shift %d\n", i - j + 1); - } - } - else if (j > 0) - { - j = next[j]; - i--; // since `i` will be incremented in the next iteration - } - } -} - -// Program to implement the KMP algorithm in C -int main(void) -{ - char* text = "ABCABAABCABAC"; - char* pattern = "CAB"; - - int n = strlen(text); - int m = strlen(pattern); - - KMP(text, pattern, n, m); - - return 0; -} diff --git a/Data Structure Algo/C++/Queue_using_array.cpp b/Data Structure Algo/C++/Queue_using_array.cpp deleted file mode 100644 index 4a622dc9..00000000 --- a/Data Structure Algo/C++/Queue_using_array.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -using namespace std; - -struct Queue { - int front, rear, capacity; - int* queue; - Queue(int c) - { - front = rear = 0; - capacity = c; - queue = new int; - } - - // function to insert an element - // at the rear of the queue - void queueEnqueue(int data) - { - // check queue is full or not - if (capacity == rear) { - printf("\nQueue is full\n"); - return; - } - - // insert element at the rear - else { - queue[rear] = data; - rear++; - } - return; - } - - // function to delete an element - // from the front of the queue - void queueDequeue() - { - // if queue is empty - if (front == rear) { - printf("\nQueue is empty\n"); - return; - } - - // shift all the elements from index 2 till rear - // to the left by one - else { - for (int i = 0; i < rear - 1; i++) { - queue[i] = queue[i + 1]; - } - - // decrement rear - rear--; - } - return; - } - - // print queue elements - void queueDisplay() - { - int i; - if (front == rear) { - printf("\nQueue is Empty\n"); - return; - } - - // traverse front to rear and print elements - for (i = front; i < rear; i++) { - printf(" %d <-- ", queue[i]); - } - return; - } - - // print front of queue - void queueFront() - { - if (front == rear) { - printf("\nQueue is Empty\n"); - return; - } - printf("\nFront Element is: %d", queue[front]); - return; - } -}; - -// Driver code -int main(void) -{ - // Create a queue of capacity 4 - Queue q(4); - - // inserting elements in the queue - q.queueEnqueue(1); - q.queueEnqueue(2); - q.queueEnqueue(3); - q.queueEnqueue(4); - - // print Queue elements - q.queueDisplay(); - - // insert element in the queue - q.queueEnqueue(5); - - // delete element from front of queue - q.queueDequeue(); - - // print front of the queue - q.queueFront(); - - return 0; -} diff --git a/Data Structure Algo/C++/Sieve_of_Eratosthenes.cpp b/Data Structure Algo/C++/Sieve_of_Eratosthenes.cpp deleted file mode 100644 index 30f32781..00000000 --- a/Data Structure Algo/C++/Sieve_of_Eratosthenes.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; - -int main(){ - int n; - cin >> n; - int num_arr[n+1];// creating a number array - for (int i = 1; i < n+1; i++){ - num_arr[i] = i; - } - - bool arr[n+1]= {0} ;// another array to mark true or false ,firstly we assume all number are prime - for (int k = 2; k <= n ; k++){ - if(arr[k] == 0){ - for (int j = k*k; j < n+1; j+=k){ - arr[j] = 1; - } - } - } - - for (int z = 1; z < n+1; z++){ - if (arr[z] == 0){ - cout << num_arr[z] << " "; - } - } -} - - -//Time complexity : n*log(log(n)) diff --git a/Data Structure Algo/C++/Valid_Parentheses_using_stack.cpp b/Data Structure Algo/C++/Valid_Parentheses_using_stack.cpp deleted file mode 100644 index c472e54c..00000000 --- a/Data Structure Algo/C++/Valid_Parentheses_using_stack.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -using namespace std; - -class Solution -{ - public: - bool isPair(string x) - { - stackst; - int sum=0; - for(int i=0;i>tc; - while(tc--) - { - cin>>a; - Solution obj; - if(obj.isPair(a)) - cout<<"balanced"< -#include - -using namespace std; - -// This class represents a directed graph using -// adjacency list representation -class Graph -{ - int V; // No. of vertices - - // Pointer to an array containing adjacency - // lists - list *adj; -public: - Graph(int V); // Constructor - - // function to add an edge to graph - void addEdge(int v, int w); - - // prints BFS traversal from a given source s - void BFS(int s); -}; - -Graph::Graph(int V) -{ - this->V = V; - adj = new list[V]; -} - -void Graph::addEdge(int v, int w) -{ - adj[v].push_back(w); // Add w to v’s list. -} - -void Graph::BFS(int s) -{ - // Mark all the vertices as not visited - bool *visited = new bool[V]; - for(int i = 0; i < V; i++) - visited[i] = false; - - // Create a queue for BFS - list queue; - - // Mark the current node as visited and enqueue it - visited[s] = true; - queue.push_back(s); - - // 'i' will be used to get all adjacent - // vertices of a vertex - list::iterator i; - - while(!queue.empty()) - { - // Dequeue a vertex from queue and print it - s = queue.front(); - cout << s << " "; - queue.pop_front(); - - // Get all adjacent vertices of the dequeued - // vertex s. If a adjacent has not been visited, - // then mark it visited and enqueue it - for (i = adj[s].begin(); i != adj[s].end(); ++i) - { - if (!visited[*i]) - { - visited[*i] = true; - queue.push_back(*i); - } - } - } -} - -// Driver program to test methods of graph class -int main() -{ - // Create a graph given in the above diagram - Graph g(4); - g.addEdge(0, 1); - g.addEdge(0, 2); - g.addEdge(1, 2); - g.addEdge(2, 0); - g.addEdge(2, 3); - g.addEdge(3, 3); - - cout << "Following is Breadth First Traversal " - << "(starting from vertex 2) \n"; - g.BFS(2); - - return 0; -} diff --git a/Data Structure Algo/C++/binary_number_to_decimal_number_system.cpp b/Data Structure Algo/C++/binary_number_to_decimal_number_system.cpp deleted file mode 100644 index a052b8c7..00000000 --- a/Data Structure Algo/C++/binary_number_to_decimal_number_system.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//C++ program to convert a binary number to decimal number system -#include -using namespace std; - -// Function to convert a binary number to decimal number system -int convertBinaryToDecimal(int n) -{ - int decimalNumber=0,i=0,remainder; - while (n!=0) - { - remainder = n%10; - n /= 10; - decimalNumber += remainder*pow(2,i); - i++; - } - return decimalNumber; -} - -// Driven Program to check above -int main() -{ - int n; - cout <<"Enter a binary number: "; - cin >> n; - cout << n << " in binary = " << convertBinaryToDecimal(n) <<" in decimal"; - return 0; -} diff --git a/Data Structure Algo/C++/bubble_sort.cpp b/Data Structure Algo/C++/bubble_sort.cpp deleted file mode 100644 index 1cf43395..00000000 --- a/Data Structure Algo/C++/bubble_sort.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -#include -using namespace std; - -void swap(int *xp, int *yp) -{ - int temp = *xp; - *xp = *yp; - *yp = temp; -} - - -void bubbleSort(int arr[], int n) -{ - int i, j; - for (i = 0; i < n-1; i++) - - - for (j = 0; j < n-i-1; j++) - if (arr[j] > arr[j+1]) - swap(&arr[j], &arr[j+1]); -} - -void printArray(int arr[], int size) -{ - int i; - for (i = 0; i < size; i++) - cout << arr[i] << " "; - cout << endl; -} - -int main() -{ - int arr[] = {64, 34, 25, 12, 22, 11, 90}; - int n = sizeof(arr)/sizeof(arr[0]); - bubbleSort(arr, n); - cout<<"Sorted array: \n"; - printArray(arr, n); - return 0; -} - diff --git a/Data Structure Algo/C++/circularLinkedList.cpp b/Data Structure Algo/C++/circularLinkedList.cpp deleted file mode 100644 index d2764268..00000000 --- a/Data Structure Algo/C++/circularLinkedList.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include -using namespace std; - -class Node{ - public: - int data; - Node *next; - Node *prev; - Node(){ - data=0; - next=NULL; - prev=NULL; - } - Node(int val){ - data=val; - next=NULL; - prev=NULL; - } -}; - -class CircularLL{ - private: - Node *head; - public: - CircularLL(){ - head=NULL; - } - - bool isEmpty(){ - if(head==NULL){ - return true; - } - return false; - } - - bool isFull(){ - Node *ptr=new Node; - if(!ptr){ - return true; - } - delete ptr; - return false; - } - - void prependNode(int val){ - if(isFull()){ - cout<<"\nNo space left for new Nodes to be added." <next=head; - head->prev=head; - } - else{ - Node *ptr=new Node(val), *last=head->prev; - last->next=ptr; - ptr->prev=last; - ptr->next=head; - head->prev=ptr; - head=ptr; - } - cout<<"\nNode with value " <next=head; - head->prev=head; - } - else{ - Node *ptr=new Node(val), *last=head->prev; - ptr->prev=last; - ptr->next=head; - last->next=ptr; - head->prev=ptr; - last=ptr; - } - cout<<"\nNode with value " <> " <data <next; - }while(ptr!=head); - } - } - - int deleteFirst(){ - if(isEmpty()){ - cout<<"\nNo elements present to display." <next; - int val=ptr->data; - ptr->prev=NULL; - delete head; - head=ptr; - cout<<"\nNode with value " <prev; - int val=ptr->data; - delete ptr; - cout<<"\nNode with value " <next; - int counter=1; - while(ptr!=head){ - counter++; - ptr=ptr->next; - } - cout<<"\n" <data <data; - } - } - - int stackBottom(){ - if(isEmpty()){ - cout<<"\nNo elements present to Return." <prev->data; - cout<<"\nValue of Node at Stack-Bottom is: " <> "; - - cin>>op; - - switch (op) - { - case 0: - cout<<"\nSystem Exits..." <>val; - cll.prependNode(val); - break; - - case 2: - cout<<"\nEnter the value to be Appended: "; - cin>>val; - cll.appendNode(val); - break; - - case 3: - cout<<"\nDeleting First Node..." < -using namespace std; -void display(int *array, int size) { - for(int i = 0; i 0 && array[j-1]>key) { - array[j] = array[j-1]; - j--; - } - array[j] = key; //insert in right place - } -} -int main() { - int n; - cout << "Enter the number of elements: "; - cin >> n; - int arr[n]; //create an array with given number of elements - cout << "Enter elements:" << endl; - for(int i = 0; i> arr[i]; - } - cout << "Array before Sorting: "; - display(arr, n); - insertionSort(arr, n); - cout << "Array after Sorting: "; - display(arr, n); -} diff --git a/Data Structure Algo/C++/kadanes_algorithm.cpp b/Data Structure Algo/C++/kadanes_algorithm.cpp deleted file mode 100644 index 76cf1a4a..00000000 --- a/Data Structure Algo/C++/kadanes_algorithm.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -using namespace std; - -int main(){ - int arr[] = {-1,4,6,4,-8,3,5,7,-2,9}; - int n= sizeof(arr)/sizeof(arr[0]); - int sum =0; - int midSum =0; - for (int i = 0; i < n; i++) - { - if(arr[i]<0){ - midSum =0; - }else{ - midSum +=arr[i]; - } - sum = max(midSum,sum); - } - cout< -using namespace std; - -//array traversal code - -void traversal(int size,int *a){ - for(int j=0;j>n; - int arr[n]; - cout<<"Enter the elements of array:"<>arr[i]; - } - cout<<"Before sorting:"< -int insert(int a[],int n); -int delete(int a[],int n); -int reverse(int a[],int n); -int search(int a[],int n); -int main() -{ - int n; - printf("Enter the size of the array : "); - scanf("%d",&n); - int a[n]; - int i, ch, pos; - printf("Enter the %d numbers \n",n); - for (i = 0; i < n; i++){ - scanf("%d",&a[i]); - } - int c=1; - while(c!=0){ - printf(" Enter choice \n"); - printf("Press 1 to Insert \n"); - printf("Press 2 to Delete \n"); - printf("Press 3 to Reverse \n"); - printf("Press 4 to Search \n"); - printf("Press 5 to Exit \n"); - scanf("%d",&ch); - switch (ch) - { - case 1: - n++; - insert(a,n); - break; - case 2: - n--; - delete(a,n); - break; - case 3: - reverse(a,n); - break; - case 4: - search(a,n); - break; //vvvcvcc - default: - printf("Gone too soon "); - c=0; - break; - }} - -} -int insert(int a[],int n){ - int pos,x; - printf("Enter the value and position to be inserted : "); - scanf("%d %d",&x,&pos); - /*n++;*/ - - for (int i = n-1; i >= pos; i--){ - a[i] = a[i - 1];} - a[pos - 1] = x; - - for (int i = 0; i < n; i++) - printf("%d ", a[i]); - printf("\n"); - -} -int delete(int a[], int n){ - int pos; - printf("Enter the position to be deleted : "); - scanf("%d",&pos); - /*n--;*/ - - for (int i = pos-1; i <= n; i++){ - a[i] = a[i + 1];} - - - for (int i = 0; i < n; i++) - printf("%d ", a[i]); - printf("\n"); -} -int reverse(int a[],int n){ - int b[n]; - printf("The original array : "); - for (int i = 0; i < n; i++) - printf("%d ", a[i]); - printf("\n"); - int d = n-1; - printf("The reverse array : "); - for (int i = d; i >= 0; i--){ - b[d-i]=a[i]; - } - for (int i = 0; i < n; i++) - printf("%d ", b[i]); - printf("\n"); -} -int search(int a[],int n){ - int b; - printf("Enter the no to be searched : "); - scanf("%d",&b); - int f,j; - for (j = 0; j < n; j++){ - if(a[j]==b){ - f = 1; - break;} - } - if(f==1) - printf("%d is present at pos %d \n",b,j+1); - else - printf("%d is not present \n",b); -} diff --git a/Data Structure Algo/C/BinarySearch.c b/Data Structure Algo/C/BinarySearch.c deleted file mode 100644 index 7f7ac631..00000000 --- a/Data Structure Algo/C/BinarySearch.c +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include - -int left,right,mid,n; -void bubble_sort(int a[]); -int binary_search(int a[],int *key); - -void main() -{ - int i,key; - int result; - - printf("Enter n\n"); - scanf("%d",&n); - int *a=malloc(n*sizeof(int)); - printf("Enter the array elements:\n"); - for(int i=0;ia[mid]) - left=mid+1; - } - while(*key !=a[mid] && left<=right); - - if(*key==a[mid]) - { - return 1; - } - else return 0; -} - -void bubble_sort(int a[]) -{ - int i,j,temp; - for(i=0;ia[j+1]) - { - temp=a[j]; - a[j]=a[j+1]; - a[j+1]=temp; - } - } - } -} \ No newline at end of file diff --git a/Data Structure Algo/C/BubbleSort.c b/Data Structure Algo/C/BubbleSort.c deleted file mode 100644 index 73d13356..00000000 --- a/Data Structure Algo/C/BubbleSort.c +++ /dev/null @@ -1,62 +0,0 @@ -//using bubble sort..sorting an array in ascending order..... -#include -#include -void main() -{ - int n,*p,temp=0; - - int i,j,k; - - printf("enter the size of an array:\n"); - scanf("%d",&n); - - p=(int*)calloc(n,4); - - if(p==NULL) - { - printf("error!!"); - exit(1); - } - - printf("enter the elements of the array:\n"); - for(j=0;j *(p+(i+1))) - { - temp=*(p+i); - *(p+i)=*(p+(i+1)); - *(p+(i+1))=temp; - - - } - - } - printf("modified array:"); - - for(k=0;k -#include -#define MAX 3 -void insert(); -void del(); -void display(); -int q[MAX]; -int rear= -1; -int front= -1; -int val; - -int main() -{ - int ch; - while(1) - { - printf("\n Press 1.Insert, 2.Delete, 3.Display, 4.Exit "); - printf("\n Enter your choice: "); - scanf("%d", &ch); - switch(ch) - { - case 1: insert(); - break; - case 2: del(); - break; - case 3: display(); - break; - case 4: exit(1); - default: - - printf("Wrong choice \n"); - } - } -} - -void insert() -{ - if(front==0&&rear==MAX-1) - printf("Circular Queue is full \n"); -else if(front==rear+1) -printf("Circular Queue is full \n"); - - else - { - if(rear==MAX-1 && front!=0) - rear=-1; - printf("Enter the value to be inserted \n"); - scanf("%d",& val); - q[++rear]=val; - printf("Insertion successful \n"); - if(front==-1) - front=0; - } -} - -void del() -{ - if(front==-1 && rear==-1) - printf("Circular Queue is empty \n"); - else if(front==rear) - { -printf("Delete element is %d \n", q[front]); -front=-1; -rear=-1; -} -else -{ -printf("Delete element is %d \n", q[front++]); - if(front==MAX) - front=0; - -} -} - -void display() -{ - if(front==-1) - printf("Circular Queue is empty \n"); - else - { - int i=front; - printf("Circular Queue -> \n"); - if(front<=rear) - { - while(i<=rear) - printf("%d ", q[i++]); - } - - else - { - while(i<=MAX-1) - printf("%d ", q[i++]); - i=0; - while(i<=rear) - printf("%d ", q[i++]); - } - } -} diff --git a/Data Structure Algo/C/DeleteFromAnyPositionLinkedList.c b/Data Structure Algo/C/DeleteFromAnyPositionLinkedList.c deleted file mode 100644 index f5b08cab..00000000 --- a/Data Structure Algo/C/DeleteFromAnyPositionLinkedList.c +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -struct node{ - int data; - struct node* next; -}; -struct node* head = NULL; -void insert() -{ - struct node *temp,*temp1; - temp = (struct node*)malloc(sizeof(struct node)); - printf("ENTER THE DATA : \n"); - scanf("%d",&temp->data); - temp->next = NULL; - if(head==NULL) - { - head = temp; - } - else - { - temp1 = head; - while(temp1->next!=NULL) - { - temp1 = temp1->next; - } - temp1->next = temp; - } -} -void display() -{ - struct node* temp; - temp = head; - while(temp!=NULL) - { - printf("%d ",temp->data); - temp = temp->next; - } - printf("\n"); -} -void del() -{ - struct node* temp = head; - int n,i; - printf("ENTER THE POSITION TO DELETE : \n"); - scanf("%d",&n); - if(n==1) - { - head = temp->next; - free(temp); - } - else - { - for(i = 0; inext; - } - struct node* temp1 = temp->next; - temp->next = temp1->next; - free(temp1); - } -} -int main() -{ - int c; - while(1) - { - printf("PRESS 1 TO ADD ELEMENTS IN THE LINKED LIST\n"); - printf("PRESS 2 TO DISPLAY ELEMENTS IN THE LINKED LIST\n"); - printf("PRESS 3 TO DELETE ELEMENTS FROM THE LINKED LIST\n"); - printf("PRESS 0 TO EXIT THE PROCESS\n"); - scanf("%d",&c); - switch(c) - { - case 1:insert(); break; - case 2:display();break; - case 3:del();break; - case 0:exit(0);break; - } - } - return 0; -} diff --git a/Data Structure Algo/C/Doubly_link_kist.c b/Data Structure Algo/C/Doubly_link_kist.c deleted file mode 100644 index 5dc083e0..00000000 --- a/Data Structure Algo/C/Doubly_link_kist.c +++ /dev/null @@ -1,200 +0,0 @@ -#include -#include -struct node -{ - int a; - struct node *prev,*next; -}; - struct node *header,*last; - void show(); - void create(); - void insertf(); - void insertl(); - void insertafter(); - void delf(); - void dellast(); - void del(); - void printmid(); - void main(){ - create(); - show(); - printf("\n\n------after inserting value at first position------\n\n"); - insertf(); - show(); - printf("\n\n------after inserting value at last position------\n\n"); - insertl(); - show(); - printf("\n\n------inserting value after a particular value------\n\n"); - insertafter(); - show(); - delf(); - printf("\n\n------list after deletion of first node ------\n\n"); - show(); - dellast(); - printf("\n\n------list after deletion of last node ------\n\n"); - show(); - del(); - printf("\n\n------list after deletion of particular node ------\n\n"); - show(); - printf("\n-----------------------------\n"); - printmid(); - - - - } - void create(){ - int ch; - struct node *temp; - temp =malloc(sizeof(struct node)); - printf("\nenter the value \n"); - scanf("%d",&temp->a); - temp->prev=temp->next=NULL; - header=last=temp; - printf("\nwant to create more node\n"); - scanf("%d",&ch); - while(ch) - { temp =malloc(sizeof(struct node)); - printf("\nenter the value \n"); - scanf("%d",&temp->a); - last->next=temp; - temp->prev=last; - temp->next=NULL; - last=temp; - printf("\nwant to create more node\n"); - scanf("%d",&ch); - } - } - void show(/* arguments */) { - /* code */ - struct node *temp=header; - while(temp!=NULL){ - printf("-->%d",temp->a); - temp=temp->next; - - } - printf("\n now in backward direction\n"); - temp=last; - while(temp!=NULL){ - printf("-->%d",temp->a); - temp=temp->prev; - - } - - } -void insertf(){ - struct node *temp=malloc(sizeof(struct node)); - printf("\nenter the data you want to insert\n"); - scanf("%d",&temp->a); - temp->prev=NULL; - temp->next=header; - if(header!=NULL){ - header->prev=temp; - - } - header=temp; -} -void insertl(){ - struct node *temp=malloc(sizeof(struct node)); - printf("\nenter the data you want to insert\n"); - scanf("%d",&temp->a); - if(header==NULL){ - header=last=temp; - temp->prev=temp->next=NULL; - return; - } - else{ - last->next=temp; - temp->prev=last; - last=temp; - temp->next=NULL; - } -} -void insertafter(/* arguments */) { - /* code */ - int val; - struct node *temp=malloc(sizeof(struct node)),*temp1=header; - printf("\nenter the data you want to insert\n"); - scanf("%d",&temp->a); - if(header==NULL){ - printf("insetion not possible\n"); - } - printf("\nenter the value after which you want to insert\n"); - scanf("%d",&val); - while(temp1!=NULL){ - if(temp1->a==val){ - temp->next=temp1->next; - temp1->next=temp; - temp->prev=temp1; - if(temp1!=last){ - temp->next->prev=temp; - return; - } - last=temp; - return; - } - temp1=temp1->next; - } - printf("\nelemet not found\n"); -} -void delf(){ - if(header==NULL){ - printf("\n underflow situation\n"); - return; - } - if(header->next==NULL){ - header=last=NULL; - return; - } - header=header->next; - header->prev=NULL; -} -void dellast(/* arguments */) { - /* code */ - if(header==NULL){ - printf("\n underflow situation\n"); - return; - } - if(header->next==NULL){ - header=last=NULL; - return; - } - last=last->prev; - last->next=NULL; -} -void del(){ - int val; - struct node*temp=header; - if(header==NULL){ - printf("\n underflow situation\n"); - return; - } - printf("\nenter the value which you want to delete\n"); - scanf("%d",&val); - if(val==header->a){ - delf(); - return; - } - while(temp->next!=NULL){ - if(val==temp->a){ - temp->prev->next=temp->next; - temp->next->prev=temp->prev; - return; - } - temp=temp->next; - } - if(val==last->a){ - dellast(); - return; - } - printf("\nelemet not found\n"); - -} -void printmid(){ - struct node *temp1,*temp; - temp1=temp=header; - while(temp1!=NULL && temp1->next!=NULL ){ - temp=temp->next; - temp1=temp1->next->next; - } - printf("-->%d",temp->a); -} diff --git a/Data Structure Algo/C/Infix_to_Postfix_and_Evaluation.c b/Data Structure Algo/C/Infix_to_Postfix_and_Evaluation.c deleted file mode 100644 index 486a9e31..00000000 --- a/Data Structure Algo/C/Infix_to_Postfix_and_Evaluation.c +++ /dev/null @@ -1,200 +0,0 @@ -#include -#include -#define N 20 -#define M 80 - -char val; - -int isoprator(char ch) -{ - if(ch=='^'||ch=='*'||ch=='/'||ch=='+'||ch=='-') - return(1); - else - return(0); -} - -int isoprand(char ch) -{ - if((ch>='0'&&ch<='9' - )||(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) - return(1); - else - return(0); -} - -int prac(char ch) -{ - if(ch=='^') - return(3); - else if(ch=='*'||ch=='/') - return(2); - else if(ch=='+'||ch=='-') - return(1); - else - return(0); -} - -void push(char s[],int *top,char val) -{ - if(*top<(N-1)) - { - (*top)++; - s[*top]=val; - } - else - printf("stack is full\n"); -} -char pop(char s[],int *top) -{ - if((*top)>-1) - { - val=s[*top]; - (*top)--; - return val; - } - else - printf("stack is empty\n"); - return(-1); -} - -int read(char s[],int top,int i) -{ - if((top-i+1)>=0) - return s[top-i+1]; - else - printf("not found\n"); - -} - -int isempty(char s[],int top) -{ - if(top==-1) - return(1); - else - return(0); -} - -void infixtopostfix(char *i,char *p) -{ - char s[N];int top=-1; - while(*i!='\0') - { - if(isoprand(*i)) - { - *p=*i; - *i++; - *p++; - } - - else if (*i=='(') - { - push(s,&top,'('); - *i++; - } - else if(*i==')') - { - while(read(s,top,1)!='(') - { - *p=pop(s,&top); - *p++; - } - *i++; - pop(s,&top); - } - else if(isempty(s,top)||read(s,top,1)=='('||prac(*i)>prac(read(s,top,1))) - { - push(s,&top,*i); - *i++; - } - - - - else - { - *p=pop(s,&top); - *p++; - } - } - while(!isempty(s,top)) - { - *p=pop(s,&top); - *p++; - } -} - -int evaluate(char *p) -{ - char s[N]; - int top=-1; - int a=0,b=0,val=0,num,ans=0; - push(s,&top,'('); - while(*p!='\0') - { - if(isoprator(*p)) - { - b=pop(s,&top); - a=pop(s,&top); - switch(*p) - { - case '+': - val=a+b; - push(s,&top,val); - *p++; - break; - - case '-': - val=a-b; - push(s,&top,val); - *p++; - break; - - case '*': - val=a*b; - push(s,&top,val); - *p++; - break; - - case '/': - val=a/b; - push(s,&top,val); - *p++; - break; - - case '^': - val=a^b; - push(s,&top,val); - *p++; - break; - } - - } - else - { - num=*p-'0'; - push(s,&top,num); - *p++; - } - } - ans=pop(s,&top); - return ans; -} - -void main() -{ int ans; - char infix[M]={}; - char postfix[M]={}; - printf("Infix Expression = "); - scanf("%s",infix); - infixtopostfix(infix,postfix); - printf("Postfix Expression = %s",postfix); - ans=evaluate(postfix); - printf("\nAnswer of Postfix Evalution = %d",ans); -} - -/* ""OUTPUT"" - -Infix Expression = 8+9*7 -Postfix Expression = 897*+ -Answer of Postfix Evalution = 71 - -*/ diff --git a/Data Structure Algo/C/InsertionSort.c b/Data Structure Algo/C/InsertionSort.c deleted file mode 100644 index 386baa14..00000000 --- a/Data Structure Algo/C/InsertionSort.c +++ /dev/null @@ -1,42 +0,0 @@ -//sorting an array using insertion sort....... -#include -#include -void main() -{ - int i,j,*p,n,temp=0,k; - printf("enter the size of the array:\n"); - scanf("%d",&n); - printf("enter the elements of the array:\n"); - p=(int*)calloc(n,4); - for(i=0;i0&&*(p+j-1);j--) - { - if(*(p+j)<*(p+j-1)) - { - temp=*(p+j); - *(p+j)=*(p+j-1); - *(p+j-1)=temp; - } - } - printf("modified array:"); - for(k=0;k -#include - -int lsearch(int n,int *arr,int search) -{ - int res=0; - int i; - for( i=0;i -#include -struct node -{ - int a; - struct node *p; -}; -struct node *header,*last; -void create(int); -void show(); -void deletion1(); -void dellast(); -void del(); - -void main() { - /* code */ - create(10); - create(20); - create(30); - create(40); - create(50); - create(100); - printf("link list is:\n"); - show(); - deletion1(); - printf("\n\nlist after first node deletion\n\n"); - show(); - dellast(); - printf("\n\nlist after last deletion\n\n"); - show(); - del(); - printf("\n\nlist after deletion particular element\n\n"); - show(); -} - -void create(int e) -{ - struct node *temp; - temp=malloc(sizeof(struct node)); - temp->a=e; - temp->p=NULL; - if(header==NULL){ - header=last=temp; - return; - } - else - { - last->p=temp; - last=temp; - } -return ; -} -void show(){ - struct node *temp=header; - while(temp!=NULL){ - printf("-->%d",temp->a); - temp=temp->p; - } -} -void deletion1(){ - if(header==NULL){ - printf("deletion is not possible\n"); - return; - } - header=header->p; - return; -} -void dellast(){ - struct node *temp=header,*prev; - while(temp->p!=NULL) -{ - prev=temp; - temp=temp->p; -} -prev->p=NULL; -} -void del() -{ - int val; - struct node *temp=header,*prev; - printf("\nenter the value you want to delete\n"); - scanf("%d",&val); - while(temp!=NULL){ - prev=temp; - temp=temp->p; - if(temp->a==val){ - if(temp==header){ - header=header->p; - return; - } - else - { - prev->p=temp->p; - return; - } - } -} -} diff --git a/Data Structure Algo/C/MatrixTranspose.c b/Data Structure Algo/C/MatrixTranspose.c deleted file mode 100644 index 75b75bf9..00000000 --- a/Data Structure Algo/C/MatrixTranspose.c +++ /dev/null @@ -1,42 +0,0 @@ -//To find out transpose of a matrix. - - -#include -#include -int main() -{ - int a[10][10], m,n,i,j,b[10][10]; - - printf("enter values for m and n:"); - scanf("\t%d\t%d",&m,&n); - - printf("\nEnter matrix elements\n"); - for(i=0;i - -void merge_sort(int i, int j, int a[], int aux[]) -{ - if (j <= i) - { - return; - } - int mid = (i + j) / 2; - - merge_sort(i, mid, a, aux); - merge_sort(mid + 1, j, a, aux); - - int pointer_left = i; - int pointer_right = mid + 1; - int k; - - for (k = i; k <= j; k++) - { - if (pointer_left == mid + 1) - { - aux[k] = a[pointer_right]; - pointer_right++; - } - else if (pointer_right == j + 1) - { - aux[k] = a[pointer_left]; - pointer_left++; - } - else if (a[pointer_left] < a[pointer_right]) - { - aux[k] = a[pointer_left]; - pointer_left++; - } - else - { - aux[k] = a[pointer_right]; - pointer_right++; - } - } - - for (k = i; k <= j; k++) - { - a[k] = aux[k]; - } -} - - -int main() -{ - int a[10], aux[10], n, i, d, swap; - - printf("Enter number of elements in the array:\n"); - scanf("%d", &n); - - printf("\nEnter %d integers\n", n); - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - } - merge_sort(0, n - 1, a, aux); - - printf("\nArray after Merge Sort:\n"); - for (i = 0; i < n; i++) - printf("%d\n", a[i]); - return 0; -} diff --git a/Data Structure Algo/C/QuickSort.c b/Data Structure Algo/C/QuickSort.c deleted file mode 100644 index 8d64d6cb..00000000 --- a/Data Structure Algo/C/QuickSort.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -void swap(int a[], int b, int c) -{ - int temp; - temp=a[b]; - a[b]=a[c]; - a[c]=temp; -} - -void quicksort(int a[], int left, int right) -{ - int i,j,pivot; - if(left=a[i]) - i++; - while(pivot -#include -#include -#define MAX 1000 - -/* Declare variables globally */ -int top = 0; -char stack[MAX]; - -/* Function Prototype for push and pop operation */ -void push(char); -char pop(); - -/*Driver code*/ -int main(void) -{ - /* Create variables and base address of the block */ - char *str; - unsigned int i; - - /* Dynamically allocate memory using malloc() */ - str = (char *)malloc(MAX * sizeof(char *)); - - /*Taking string input from the user*/ - scanf("%[^\n]%*c", str); - - /*Pushing characters of the string "str" on the stack*/ - for (i = 0; i < strlen(str); i++) - { - push(str[i]); /*Calling push function */ - } - - /*Poping characters from the stack and store in string str */ - for (i = 0; i < strlen(str); i++) - { - str[i] = pop(i); /* Calling pop function */ - } - - /*Printing the reversed string */ - printf("%s\n", str); - - /* Free the memory */ - free(str); -} - -/*The function defination of push*/ -void push(char item) -{ - stack[top++] = item; -} - -/*The function defination of pop*/ -char pop() -{ - return stack[--top]; -} diff --git a/Data Structure Algo/C/SNAKE_GAME.c b/Data Structure Algo/C/SNAKE_GAME.c deleted file mode 100644 index dec22a9a..00000000 --- a/Data Structure Algo/C/SNAKE_GAME.c +++ /dev/null @@ -1,309 +0,0 @@ -#include -#include -#include -#include -#include - static char a[30][50]; - static int head_y=38; - static int head_x=18; - static int x; - static int y; - static int score =0; - static int tail_y[100]; - static int tail_x[100]; - static int direction =1; - static int dir[100]; - static int l=1; - static int k=0; - void build() - { - memset(a,' ',sizeof a); - -for(int i=0;i<30;i++) - a[i][0]='|'; -for(int i=0;i<50;i++) - a[0][i]='-'; - for(int i=0;i<50;i++) - a[29][i]='-'; - for(int i=0;i<30;i++) - a[i][49]='|'; - } -void khana() -{ - y = (rand() % 48) + 1; - x=(rand()%28)+1; - ; - - //x=10;y=10; - a[x][y]='@'; - //printf("%d",x); -} - -void disp() -{ - for(int i=0;i<30;i++) - { - for(int j=0;j<50;j++) - printf("%c",a[i][j]); - printf("\n"); - } -} -void move() -{checkcollision(); -foodcheck(); -if(l>1) - tailmove(); -if(direction==1) - left(); -if(direction==2) - right(); -if(direction==3) - up(); -if(direction==4) - down(); - - disp(); - Sleep(20); - - -} -void tailmove() -{ - for(int i=l-2;i>=0;i--) -{ - - if(i==0) - {dir[0]=direction; - if(direction==2) -{if(i==l-2) -a[tail_x[0]][tail_y[0]]=' '; -a[tail_x[0]][++tail_y[0]]='.'; -} -if(direction==1) -{if(i==l-2) -a[tail_x[0]][tail_y[0]]=' '; -a[tail_x[0]][--tail_y[0]]='.'; -} -if(direction==3) -{if(i==l-2) -a[tail_x[0]][tail_y[0]]=' '; -a[--tail_x[0]][tail_y[0]]='.'; -} -if(direction==4) -{if(i==l-2) -a[tail_x[0]][tail_y[0]]=' '; -a[++tail_x[0]][tail_y[0]]='.'; -}} -else -{int u=dir[--i];i++; //printf("%d",i);Sleep(1000); -dir[i]=u; - if(u==2) -{if(i==l-2) -a[tail_x[i]][tail_y[i]]=' '; -a[tail_x[i]][++tail_y[i]]='.'; -} -if(u==1) -{if(i==l-2) -a[tail_x[i]][tail_y[i]]=' '; -a[tail_x[i]][--tail_y[i]]='.'; -} -if(u==3) -{if(i==l-2) -a[tail_x[i]][tail_y[i]]=' '; -a[--tail_x[i]][tail_y[i]]='.'; -} -if(u==4) -{if(i==l-2) -a[tail_x[i]][tail_y[i]]=' '; -a[++tail_x[i]][tail_y[i]]='.'; -} -}} - -} -void checkcollision() -{ -for(int i=0;i2) - // tailmove(); - //Sleep(1000); - } - } - }} - return 0; - -} diff --git a/Data Structure Algo/C/SelectionSort.c b/Data Structure Algo/C/SelectionSort.c deleted file mode 100644 index 88f97824..00000000 --- a/Data Structure Algo/C/SelectionSort.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -int main() -{ - int array[100], n, c, d, position, t; - - printf("Enter number of elements\n"); - scanf("%d", &n); - - printf("Enter %d integers\n", n); - - for (c = 0; c < n; c++) - scanf("%d", &array[c]); - - for (c = 0; c < (n - 1); c++) // finding minimum element (n-1) times - { - position = c; - - for (d = c + 1; d < n; d++) - { - if (array[position] > array[d]) - position = d; - } - if (position != c) - { - t = array[c]; - array[c] = array[position]; - array[position] = t; - } - } - - printf("Sorted list in ascending order:\n"); - - for (c = 0; c < n; c++) - printf("%d\n", array[c]); - - return 0; -} diff --git a/Data Structure Algo/C/Student_grade.c b/Data Structure Algo/C/Student_grade.c deleted file mode 100644 index 8cf08370..00000000 --- a/Data Structure Algo/C/Student_grade.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#define N 5 -struct student -{ - char name[20]; - int rollno; - int marks[6]; - int total; - char grade; -}; -void display(struct student arr); -void calculate(struct student arr[]); -void sort(struct student arr[]); -int main(void) -{ - struct student stu[N],temp; - int i,j; - for(i=0; i 500) - stu[i].grade = 'A'; - else if(stu[i].total > 400) - stu[i].grade = 'B'; - else if(stu[i].total > 250) - stu[i].grade = 'C'; - else - stu[i].grade = 'D'; - } -} -void sort(struct student stu[]) -{ - int i,j; - struct student temp; - for(i=0; i - -void towers(int, char, char, char); - -int main() -{ - int num; - - printf("Enter the number of disks : "); - scanf("%d", &num); - printf("The sequence of moves involved in the Tower of Hanoi are :\n"); - towers(num, 'A', 'C', 'B'); - return 0; -} -void towers(int num, char frompeg, char topeg, char auxpeg) -{ - if (num == 1) - { - printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg); - return; - } - towers(num - 1, frompeg, auxpeg, topeg); - printf("\n Move disk %d from peg %c to peg %c", num, frompeg, topeg); - towers(num - 1, auxpeg, topeg, frompeg); -} diff --git a/Data Structure Algo/C/infix_to_prefix.c b/Data Structure Algo/C/infix_to_prefix.c deleted file mode 100644 index 21db0af8..00000000 --- a/Data Structure Algo/C/infix_to_prefix.c +++ /dev/null @@ -1,100 +0,0 @@ -// C program for infix to postfix conversion(problem statement) -// using implementation of stack -// stack has been implemented using linked list(chain of nodes) - -// example input for infix: a+(b+c*d)-e/f+(g-h)/i -// corresponding output: +-+a+b*cd/ef/-ghi -#include -#include -#include //include all required headers - -typedef struct node{ - char data; - struct node * next; //define a structure node as a single entity to form the stack -}node; -node * head=NULL; //initially head of the stack points nowhere(NULL) -char pop(); -int isEmpty(node * head); //Function declarations -int inpriority(char a); //Function defination below the main function -int outpriority(char a); -node * push(char a,node * head); -node * create(char a); -void display(node *head); -int main(){ //main function starts - node* ans=NULL; - char a[100]; - printf("Enter your infix expression\nNOTE: Please dont give any space in between characters\n"); - //single input is taken for infix expression in array - //Don't provide any space in infix expression - //input a valid infix expression eg:a+(b+c*d)-e/f+(g-h)/i - scanf("%s",a); - int n=strlen(a); - for(int i=n-1;i>=0;i--){ //traverse the infix expression from end - if(a[i]=='('){ //if character is opening bracket, pop out elements from stack and add popped one to answer until you get closing bracket - while(head->data!=')'){ - ans=push(pop(),ans); - } - pop(); - } - else if(a[i]==')')head=push(a[i],head); //push into stack in case of closing bracket - else if(outpriority(a[i])==0) ans=push(a[i],ans); //push in case of operands like a,b,c,A,B,C (single character only) - else if(isEmpty(head) || inpriority(head->data)data)>outpriority(a[i]) ){ - ans=push(pop(),ans); //pop out in case of lower priority element till you get a lower priority at stack top - } - head=push(a[i],head); - } - } - while(!isEmpty(head)){ - ans=push(pop(),ans); //empty the remaining stack - } - printf("ansr\n"); - display(ans); //print answer (corresponding prefix expression) - - return 0; -} -node * create(char a){ //function to create a single node entity for stack(chain of nodes) - node * newd=(node *)malloc(sizeof(node)); - if(newd==NULL){printf("Stack overflow\n");return newd;} - newd->data=a; - return newd; -} -node * push(char a,node * head){ //push an element to the specified stack top - node * newd=create(a); - newd->next=head; - return newd; -} -int inpriority(char a){ //priority function when character is present inside stack - if(a=='^') return 6; - else if(a=='*' || a=='/' || a=='%') return 3; - else if(a=='+' || a=='-') return 1; - else return 0; -} -int outpriority(char a){ //priority function when character is present outside stack - if(a=='^') return 5; - else if(a=='*' || a=='/' || a=='%') return 4; - else if(a=='+' || a=='-') return 2; - else return 0; -} //for left to right associativity(+,-,*,/) of same element outpriority>inpriority - //for right to left associativity(^) of same element outprioritydata; - node * garbage=head; - head=head->next; - free(garbage); - return data; -} -void display(node * head){ //print all the elements present inside the stack - if(head==NULL)return; - printf("%c",head->data); - display(head->next); - -} \ No newline at end of file diff --git a/Data Structure Algo/C/knapsack1.c b/Data Structure Algo/C/knapsack1.c deleted file mode 100644 index 9fc689bb..00000000 --- a/Data Structure Algo/C/knapsack1.c +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -int max(int x,int y) - { - return((x>y)?x:y); - } -int knap(int n,int w[10],int value[10],int m,int v[10][10]) - { - int i,j; - for(i=0;i<=n;i++) - for(j=0;j<=m;j++) - { - if(i==0||j==0) - v[i][j]=0; - else if(j -#include -#include - - -/*The driver code*/ -int main(void) -{ - int **array, *norm; - int i, j, m, n, max; - - /*Taking the number of rows and colums from the user*/ - printf("Enter the number of rows and cols of matrix:"); - scanf("%d%d", &m,&n); - - /*dynamic memory allocation*/ - array=(int **)malloc(m*sizeof(int *)); - - for(i=0;i -#include -#define MAX 50 -void insert(); -void delete(); -void display(); -int queue_array[MAX]; -int rear = - 1; -int front = - 1; -int main() -{ -int choice; -while (1) -{ -printf("1.Insert element to queue n"); -printf("2.Delete element from queue n"); -printf("3.Display all elements of queue n"); -printf("4.Quit n"); -printf("Enter your choice : "); -scanf("%d", &choice); -switch(choice) -{ -case 1: -insert(); -break; -case 2: -delete(); -break; -case 3: -display(); -break; -case 4: -exit(1); -default: -printf("Wrong choice n"); -} -} -} -void insert() -{ -int item; -if(rear == MAX - 1) -printf("Queue Overflow n"); -else -{ -if(front== - 1) -front = 0; -printf("Inset the element in queue : "); -scanf("%d", &item); -rear = rear + 1; -queue_array[rear] = item; -} -} -void delete() -{ -if(front == - 1 || front > rear) -{ -printf("Queue Underflow n"); -return; -} -else -{ -printf("Element deleted from queue is : %dn", queue_array[front]); -front = front + 1; -} -} -void display() -{ -int i; -if(front == - 1) -printf("Queue is empty n"); -else -{ -printf("Queue is : n"); -for(i = front; i <= rear; i++) -printf("%d ", queue_array[i]); -printf("n"); -} -} diff --git a/Data Structure Algo/C/queue_linklist.c b/Data Structure Algo/C/queue_linklist.c deleted file mode 100644 index fe25f36a..00000000 --- a/Data Structure Algo/C/queue_linklist.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -struct QNode { - int key; - struct QNode* next; -}; -struct Queue { - struct QNode *front, *rear; -}; -struct QNode* newNode(int k) -{ - struct QNode* temp = (struct QNode*)malloc(sizeof(struct QNode)); - temp->key = k; - temp->next = NULL; - return temp; -} -struct Queue* createQueue() -{ - struct Queue* q = (struct Queue*)malloc(sizeof(struct Queue)); - q->front = q->rear = NULL; - return q; -} -void enqueue(struct Queue* q, int k) -{ - struct QNode* temp = newNode(k); - if (q->rear == NULL) - { - q->front = q->rear = temp; - return; - } - q->rear->next = temp; - q->rear = temp; -} -int dequeue(struct Queue* q) -{ - if (q->front == NULL) - return; - struct QNode* temp = q->front; - q->front = q->front->next; - if (q->front == NULL) - q->rear = NULL; - int data=temp->key; - free(temp); - return data; -} -int main() -{ - int c,item; - struct Queue* q = createQueue(); - - do - { - printf("\n********QUEUE MENU********\n"); - printf("Enter 1 to enqueue to the queue\n"); - printf("Enter 2 to dequeue to the queue\n"); - printf("Enter 3 for exit\n"); - scanf("%d",&c); - switch(c) - { - case 1:printf("Enter data that you want to push :"); - scanf("%d",&item); - enqueue(q,item); - break; - case 2:printf("%d has been dequeued from the queue\n",dequeue(q)); - break; - case 3:printf("Exiting queue process\n"); - break; - } - }while(c!=3); - return 0; -} \ No newline at end of file diff --git a/Data Structure Algo/C/reversing an array.c b/Data Structure Algo/C/reversing an array.c deleted file mode 100644 index a3a25518..00000000 --- a/Data Structure Algo/C/reversing an array.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -int main () -{ - int a[5]; - int i,n,temp; - printf("enter no of elements needed\n"); - scanf("%d",&n); - - printf("enter elements\n"); - for (i=0;i -#include -#include -struct stack -{ - int index; - int size; - int *p; -}; -void createStack(struct stack *var, int size) -{ - var->p = malloc(sizeof(int) * size); - var->index = -1; - var->size = size; -} -int isFull(struct stack var) -{ - if (var.index == var.size - 1) - return 1; - else - return 0; -} -int isEmpty(struct stack var) -{ - if (var.index == -1) - return 1; - else - return 0; -} -void push(struct stack *var, int value) -{ - var->index++; - var->p[var->index] = value; - printf("\nElement Pushed to Stack\n"); -} -int pop(struct stack *var) -{ - var->index--; - printf("\nElement Popped from Stack\n"); - return var->p[var->index + 1]; -} -void displaystack(struct stack var) -{ - if (!isEmpty(var)) - { - printf("There are %d Elements in Stack of Size %d\n\n", var.index + 1, var.size); - printf("The Elements in the Stack are:\n"); - for (int i = 0; i <= var.index; i++) - { - printf("%d ", var.p[i]); - } - } - else - { - printf("Stack is Empty\n"); - } -} -void main() -{ - struct stack stavar; - int size; - printf("Enter the size of Stack\n"); - scanf("%d", &size); - createStack(&stavar, size); - while (1) - { - printf("Press 1 to Push Element in Stack\n"); - printf("Press 2 to Pop Element from Stack\n"); - printf("Press 3 to Display the Elemets if Stack\n"); - printf("Press 0 to delete Stack and Exit\n"); - int choice; - scanf("%d", &choice); - if (choice == 1) - { - if (!isFull(stavar)) - { - int value; - printf("Enter the Element which you want to Enter in Stack\n"); - scanf("%d", &value); - push(&stavar, value); - } - else - { - printf("Stack is Full\n"); - } - } - else if (choice == 2) - { - if (!isEmpty(stavar)) - { - printf("The Element Popped from the Stack is %d\n", pop(&stavar)); - } - else - { - printf("Stack is Empty\n"); - } - } - else if (choice == 3) - { - displaystack(stavar); - } - else if (choice == 0) - { - free(stavar.p); - printf("Stack Deleted\n"); - exit(0); - } - printf("\n\n"); - } - getch(); -} diff --git a/Data Structure Algo/C/transposematrix.c b/Data Structure Algo/C/transposematrix.c deleted file mode 100644 index 40e129fa..00000000 --- a/Data Structure Algo/C/transposematrix.c +++ /dev/null @@ -1,39 +0,0 @@ -//Transpose Program -#include -int main() { - int a[10][10], transpose[10][10], r, c; - printf("Enter rows and columns: "); - scanf("%d %d", &r, &c); - - printf("\nEnter matrix elements:\n"); - for (int i = 0; i < r; ++i) - for (int j = 0; j < c; ++j) { - printf("Enter element a%d%d: ", i + 1, j + 1); - scanf("%d", &a[i][j]); - } - - - printf("\nEntered matrix: \n"); - for (int i = 0; i < r; ++i) - for (int j = 0; j < c; ++j) { - printf("%d ", a[i][j]); - if (j == c - 1) - printf("\n"); - } - - - for (int i = 0; i < r; ++i) - for (int j = 0; j < c; ++j) { - transpose[j][i] = a[i][j]; - } - - - printf("\nTranspose of the matrix:\n"); - for (int i = 0; i < c; ++i) - for (int j = 0; j < r; ++j) { - printf("%d ", transpose[i][j]); - if (j == r - 1) - printf("\n"); - } - return 0; -} diff --git a/Data Structure Algo/Python/BubbleSort.py b/Data Structure Algo/Python/BubbleSort.py deleted file mode 100644 index d9c27b4f..00000000 --- a/Data Structure Algo/Python/BubbleSort.py +++ /dev/null @@ -1,14 +0,0 @@ -def bubbleSort(arr): - n = len(arr) - for i in range(n-1): - for j in range(0, n-i-1): - if arr[j] > arr[j + 1] : - arr[j], arr[j + 1] = arr[j + 1], arr[j] - -arr = [50, 32, 12, 12, 28, 75, 90] - -bubbleSort(arr) - -print ("Sorted array is:") -for i in range(len(arr)): - print ("% d" % arr[i]) diff --git a/Data Structure Algo/Python/DijkstraAlgorithm.py b/Data Structure Algo/Python/DijkstraAlgorithm.py deleted file mode 100644 index 732a7eb7..00000000 --- a/Data Structure Algo/Python/DijkstraAlgorithm.py +++ /dev/null @@ -1,79 +0,0 @@ -""" -A python program for Dijkstra's single source shortest path algorithm. -The program is for adjacency list representation of the graph -""" - -# Function that implements Dijkstra's single source shortest path algorithm -# for a graph represented using adjacency list representation -def dijkstra(N, graph, src): - S = list() - S.append(src) - dist = {x: 99 for x in range(1, N+1)} - dist[src] = 0 - minCost = 999 - selected_u = 0 - selected_v = 0 - - while S != list(graph.keys()): - for u in S: - dictOfu = graph[u] - for v in dictOfu: - if v not in S: - cost_u_to_v = dist[u] + dictOfu[v] - if cost_u_to_v < minCost: - minCost = cost_u_to_v - selected_u = u - selected_v = v - dist[selected_v] = minCost - S.append(selected_v) - print(selected_u, '--->', selected_v) - minCost = 999 - S.sort() - -# Function used to take input of graph and source node -def main(): - graph = {} - N = int(input('Enter number of Nodes: ')) - for i in range(1, N+1): - print('Enter adjacent Node(s) and its weight(s) for Node: ', i) - string = input() - adjListWithWeights = string.split() - print(adjListWithWeights) - adjDict = {} - for x in adjListWithWeights: - y = x.split(',') - adjDict[int(y[0])] = int(y[1]) - graph[i] = adjDict - print("The input graph is: ", graph) - - src = int(input('Enter source value: ')) - - dijkstra(N, graph, src) - -# Call the main function to start the program -main() - -# Sample program input and output -""" -Suppose the graph is: - 1 ------> 2 (weight 1) - 1 ------> 3 (weight 5) - 2 ------> 1 (weight 1) - 2 ------> 3 (weight 1) - 3 ------> 1 (weight 2) - 3 ------> 2 (weight 2) - -The input will be -Enter number of Nodes: 3 -Enter adjacent Node(s) and its weight(s) for Node: 1 --------> 2,1 3,5 -Enter adjacent Node(s) and its weight(s) for Node: 2 --------> 1,1 3,1 -Enter adjacent Node(s) and its weight(s) for Node: 3 --------> 1,2 2,2 - -The input graph is: -------> {1: {2: 1, 3: 5}, 2: {1: 1, 3: 1}, 3: {1: 2, 2: 2}} - -Enter source value: 2 - -Final output - 2 ---> 1 - 2 ---> 3 -""" diff --git a/Data Structure Algo/Python/InsertionSort.py b/Data Structure Algo/Python/InsertionSort.py deleted file mode 100644 index 6707fbbd..00000000 --- a/Data Structure Algo/Python/InsertionSort.py +++ /dev/null @@ -1,15 +0,0 @@ - -def insertionSort(arr): - for i in range(1, len(arr)): - key = arr[i] - j = i-1 - while j >=0 and key < arr[j] : - arr[j+1] = arr[j] - j -= 1 - arr[j+1] = key -arr = [12, 11, 13, 5, 6] -insertionSort(arr) -print ("Sorted array is:") -for i in range(len(arr)): - print ("%d" %arr[i]) - diff --git a/Data Structure Algo/Python/Knapsack.py b/Data Structure Algo/Python/Knapsack.py deleted file mode 100644 index ea413072..00000000 --- a/Data Structure Algo/Python/Knapsack.py +++ /dev/null @@ -1,32 +0,0 @@ -# Input section -n = int(input("Enter the number of items: ")) -W = int(input("Enter the weight capcity: ")) -item = [i+1 for i in range(n)] -weight = [0] -value = [0] -for i in range(n): - weight.append(int(input("Enter the weight of {0} item: ".format(i+1)))) - value.append(int(input("Enter the value of {0} item: ".format(i+1)))) - -# Knapsack max value implementation -M = [[0 for i in range(W+1)] for _ in range(n+1)] -for i in range(1,n+1): - for w in range(1,W+1): - if weight[i] > w: - M[i][w] = M[i-1][w] - else: - M[i][w] = max(M[i-1][w], value[i] + M[i-1][w-weight[i]]) -print("Max value: ", M[n][W]) - -# Find the items included in knapsack -i = n -k = W -knapsackItems = [] -while i>0 and k>0: - if M[i][k] != M[i-1][k]: - knapsackItems.append(i) - k = k - weight[i] - i = i - 1 - else: - i = i - 1 -print("Items in knapsack are: " ,knapsackItems) diff --git a/Data Structure Algo/Python/kadane_algo.py b/Data Structure Algo/Python/kadane_algo.py deleted file mode 100644 index d5248504..00000000 --- a/Data Structure Algo/Python/kadane_algo.py +++ /dev/null @@ -1,30 +0,0 @@ -''' -Kadane's Algorithm is used to find the sum of contiguous subarray within an array of numbers with the largest sum. -Consider an example: -l=[-2,-3,5,-1,-2,1,4,-3] -Here, the largest sum = 5 + (-1) + (-2) + (1) + (4) = 7 -Hence, Maximum subarray sum = 7 -''' - -#Implementation -def maxSubArraySum(a,size): - max_so_far = -2**31 #initialize with minimum value - max_ending_here = 0 - - for i in range(0, size): - max_ending_here = max_ending_here + a[i] - if (max_so_far < max_ending_here): - max_so_far = max_ending_here #update value - - if max_ending_here < 0: - max_ending_here = 0 #look for positive values - return max_so_far #final answer - -a=list(input()) -size=len(a) -print "Maximum subarray sum = ", maxSubArraySum(a,size) - -''' -Time Complexity = O(n) as the array is traversed only once -Space Complexity = O(1) since no extra space is used -''' diff --git a/Java/Interface.java b/Java/Interface.java deleted file mode 100644 index 9b45f474..00000000 --- a/Java/Interface.java +++ /dev/null @@ -1,83 +0,0 @@ -import java.io.*; -interface Car -{ - void topSpeed(); - void noOfGear(); - void serviceTime(); -} -class Alto implements Car -{ - Alto() - { - System.out.println("This is a Alto Car"); - topSpeed(); - noOfGear(); - serviceTime(); - } - public void topSpeed() - { - System.out.println("Top Speed is 100km/h"); - } - public void noOfGear() - { - System.out.println("No. of gears is 5"); - } - public void serviceTime() - { - System.out.println("This car needs service after each 10000 km"); - } -} -class Swift implements Car -{ - Swift() - { - System.out.println("This is a Swift Car"); - topSpeed(); - noOfGear(); - serviceTime(); - } - public void topSpeed() - { - System.out.println("Top Speed is 180km/h"); - } - public void noOfGear() - { - System.out.println("No. of gears is 6"); - } - public void serviceTime() - { - System.out.println("This car needs service after each 75000 km"); - } -} -class Baleno implements Car -{ - Baleno() - { - System.out.println("This is a Baleno Car"); - topSpeed(); - noOfGear(); - serviceTime(); - } - public void topSpeed() - { - System.out.println("Top Speed is 200km/h"); - } - public void noOfGear() - { - System.out.println("No. of gears is 5"); - } - public void serviceTime() - { - System.out.println("This car needs service after each 7500 km"); - } -} -public class Interface -{ - public static void main(String args[]) - { - System.out.println("This program illustrate implementation of interface"); - Alto obj1=new Alto(); - Swift obj2=new Swift(); - Baleno obj3=new Baleno(); - } -} \ No newline at end of file diff --git a/Java/minimum_no_array.java b/Java/minimum_no_array.java deleted file mode 100644 index f1dcfd86..00000000 --- a/Java/minimum_no_array.java +++ /dev/null @@ -1,20 +0,0 @@ -import java.io.*; - -class proko{ - - - public static void main(String args[]){ - int arr[]= {10,20,30,40,50,60}; - int l= arr.length; - int min=0; - - for(int i=0;i",SelectRecord) -data_listBox.column("#0",width=40,minwidth=30,anchor="c") -data_listBox.column("ContactType",width=60,minwidth=30,anchor="c") -data_listBox.column("ContactNo",width=85,minwidth=30,anchor="c") -data_listBox.column("Name",width=60,minwidth=30,anchor="c") -data_listBox.column("City",width=50,minwidth=30,anchor="c") -data_listBox.column("Address",width=60,minwidth=30,anchor="c") -data_listBox.column("Email",width=70,minwidth=30,anchor="c") - -data_listBox.heading("#0",text="No.") -data_listBox.heading("ContactType",text="Type") -data_listBox.heading("ContactNo",text="Contact") -data_listBox.heading("Name",text="Name") -data_listBox.heading("City",text="City") -data_listBox.heading("Address",text="Address") -data_listBox.heading("Email",text="Email") - -data_listBox.pack(side=TOP,fill=X) -yscrollbar.config(command=data_listBox.yview) -xscrollbar.config(command=data_listBox.xview) - -noContacts_Lbl=Label(root,text="NO CONTACTS",font="mssanserif 16 bold",fg="white",bg="#00091a") -noContacts_Lbl.place(x=630,y=100) - -#**********************************BUTTON FRAME and BUTTONS *********************************************************************** -BtnFrame = Frame(root,width=940,height=100,bg="#001133",bd=4,relief=RAISED) -BtnFrame.place(x=5,y=522) - - -addBtn = Button(BtnFrame,text="Add New",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=addNew) -addBtn.place(x=3,y=4) -displayBtn = Button(BtnFrame,text="Display",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=display) -displayBtn.place(x=158,y=4) -deleteBtn = Button(BtnFrame,text="Delete",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=Delete) -deleteBtn.place(x=313,y=4) -searchBtn = Button(BtnFrame,text="Search",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=search) -searchBtn.place(x=468,y=4) -clearBtn = Button(BtnFrame,text="Clear",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=clear) -clearBtn.place(x=623,y=4) -exitBtn = Button(BtnFrame,text="Exit",font="mssanserif 15 bold",bg="black",fg="white",width=9,height=3,command=exit) -exitBtn.place(x=779,y=4) - -#*********************************************************************************************************************** - -root.mainloop() diff --git a/Python/Covid-19/cases_tracking.py b/Python/Covid-19/cases_tracking.py deleted file mode 100644 index b4511db2..00000000 --- a/Python/Covid-19/cases_tracking.py +++ /dev/null @@ -1,40 +0,0 @@ -from plyer import notification -import requests -from bs4 import BeautifulSoup -import time -def notifyMe(title,message): - notification.notify( - title = title, - message = message, - app_icon = None, - timeout = 3 - ) -def getData(url): - r = requests.get(url) - return r.text - - -if __name__=='__main__': - while True: - #notifyMe("Ujala","Lets stop the spread of this virus ") - myHtmlData = getData('https://www.mohfw.gov.in/') - - soup = BeautifulSoup(myHtmlData, 'html.parser') - #print(soup.prettify()) - myDatastr = "" - #print(soup.select('tbody[id*="site-dashboard"]')) - for tr in soup.find_all("strong",class_="mob-hide"): - myDatastr += tr.get_text()+'\n' - #print(tr.get_text()) - l=myDatastr.split() - mes=""; - mes+='Active Case:' - mes+=l[l.index("Active")+1] - mes+='\nDischarged Case:'+l[l.index("Discharged")+1] - mes+='\nDeaths Case:'+l[l.index("Deaths")+1] - mes+="\nTotal Vaccinated:"+soup.find("span",class_="coviddata").get_text() - notifyMe('Covid Update',mes) - #notifyMe() - #notifyMe() - #time.sleep(2) - time.sleep(3600) diff --git a/Python/DetectFloatingPonit.py b/Python/DetectFloatingPonit.py deleted file mode 100644 index 5cf11a0b..00000000 --- a/Python/DetectFloatingPonit.py +++ /dev/null @@ -1,11 +0,0 @@ -from re import match, compile - -pattern = compile('^[-+]?\d*\.\d+$') -for i in range(int(input())): - print(bool(pattern.match(input()))) -function detectfloatnum(): - pattern = compile('^[-+]?\d*\.\d+$') - for i in range(int(input())): - print(bool(pattern.match(input()))) - -detectfloatnum() diff --git a/Python/Dice_Simulator/images/d1.png b/Python/Dice_Simulator/images/d1.png deleted file mode 100644 index 35574b93..00000000 Binary files a/Python/Dice_Simulator/images/d1.png and /dev/null differ diff --git a/Python/Dice_Simulator/images/d2.png b/Python/Dice_Simulator/images/d2.png deleted file mode 100644 index 87e60956..00000000 Binary files a/Python/Dice_Simulator/images/d2.png and /dev/null differ diff --git a/Python/Dice_Simulator/images/d3.png b/Python/Dice_Simulator/images/d3.png deleted file mode 100644 index df6ed6b6..00000000 Binary files a/Python/Dice_Simulator/images/d3.png and /dev/null differ diff --git a/Python/Dice_Simulator/images/d4.png b/Python/Dice_Simulator/images/d4.png deleted file mode 100644 index 856ab445..00000000 Binary files a/Python/Dice_Simulator/images/d4.png and /dev/null differ diff --git a/Python/Dice_Simulator/images/d5.png b/Python/Dice_Simulator/images/d5.png deleted file mode 100644 index b4834e03..00000000 Binary files a/Python/Dice_Simulator/images/d5.png and /dev/null differ diff --git a/Python/Dice_Simulator/images/d6.png b/Python/Dice_Simulator/images/d6.png deleted file mode 100644 index 6734ba38..00000000 Binary files a/Python/Dice_Simulator/images/d6.png and /dev/null differ diff --git a/Python/Dice_Simulator/main.py b/Python/Dice_Simulator/main.py deleted file mode 100644 index 40835878..00000000 --- a/Python/Dice_Simulator/main.py +++ /dev/null @@ -1,62 +0,0 @@ -import pygame -import random -import os -pygame.font.init() - - -width, height = 520, 500 -win = pygame.display.set_mode((width, height)) -pygame.display.set_caption("Dice Simulator") - -WHITE = (255, 255, 255) -BLACK = (0, 0, 0) -RED = (255, 0, 0) -YELLOW = (255, 255, 0) -FPS = 60 -SMALL_FONT = pygame.font.SysFont('comicsans', 30) -win.fill(RED) - - -# passing two parametes dice which includes coodinates of dice on the screen -def draw_window(dice, index): - Dice_Image = pygame.image.load(os.path.join( - 'images', 'd{}.png'.format(index))) # including image using os - # Rendering the text so that we can add it on the screen - text_for_Space = SMALL_FONT.render('Press Space Bar', True, WHITE) - text_for_OR = SMALL_FONT.render('OR', True, WHITE) - text_for_Click = SMALL_FONT.render('Click on dice to Roll', True, WHITE) - win.fill(RED) # Filling the background color - win.blit(text_for_Space, (175, 10)) # Placing the text on the screen - win.blit(text_for_OR, (235, 35)) - win.blit(text_for_Click, (165, 60)) - win.blit(pygame.transform.scale(Dice_Image, (200, 200)), - (dice.x, dice.y)) # Adding the image of the dice - pygame.display.update() # now finally updating the screen - - -def main(): - dice = pygame.Rect(160, 150, 200, 200)# creating a rectangle in which we have to place the image - n = 1 #creating a integer variable to keep track of the random image have to display on the screen - clock = pygame.time.Clock()#Pygame clock initiated - run = True # to run infinite loop - while run: - clock.tick(FPS) - for event in pygame.event.get():# reading event from the screen to keep track if ther any command is given to roll the dice - if event.type == pygame.QUIT:#Execute when we close the game window - run = False - pygame.quit() - if event.type == pygame.KEYDOWN:#Execute when any keyboad key pressed - if event.key == pygame.K_SPACE: - n = random.randrange(1, 7)#generating random number - draw_window(dice, n)#calling draw window function - if event.type == pygame.MOUSEBUTTONDOWN:#To keep track of any mouse button pressed - mouse_pos = event.pos - if dice.collidepoint(mouse_pos):#It became true when dice rectangle coordinates are same of the mouse pointer - n = random.randrange(1, 7) - draw_window(dice, n) - draw_window(dice, n) - main() - - -if __name__ == "__main__": - main() diff --git a/Python/First.py b/Python/First.py deleted file mode 100644 index 8b137891..00000000 --- a/Python/First.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Python/Maths_Helping_Bot.py b/Python/Maths_Helping_Bot.py deleted file mode 100644 index 6b1f730e..00000000 --- a/Python/Maths_Helping_Bot.py +++ /dev/null @@ -1,644 +0,0 @@ -# Hello Friends i know it took long but its finally here, This code helps you or your kid to do thier homework. -# IF YOU WANT TO UPDATE IT JUST UPDATE IT BY YOU PR'S -# HERE YOU GO - - -# INTRO -print ("Mathyy, A helping bot for kids and their homework") - - - -# Variables for story flow control -noReturn = False -fear = False -cMenu = False -enMenu = False -talkMenu = False -hitMenu = False -talk = False -apology = False -beep = False -end = 0 -c = 0 -i = 0 -h = 0 -t = 0 -e = 0 - -# Story branches for Compliment (c) interactions -def rel_c(): - global fear - global noReturn - global talk - global talkMenu - global enMenu - global hitMenu - global apology - global i - global c - global t - global h - global e - # After talking to MB about dreams - to Neutral ending - if noReturn == False and t > 0: - if e == 1 and i == 0: - print "> If you want to say yes, you should encourage it again." - elif i == 0: - print ("> You listen to its dream, but tell Math Bot that it's much better" - " at math than art, and that being a Math Bot is much easier than" - " being an artist. It seems a little sad to hear that, but it" - " respects your opinion.") - end(2) - else: - i = 0 - print ("> You apologize for making fun of it. Math Bot accepts your" - " apology and forgives you.") - elif noReturn == False and talk == False: - # No insult / Good path for game - if c == 0 and i == 0: - print ("> You thank Math Bot for solving that last problem for you." - " It doesn't understand and blinks at you in response.") - c = 1 - elif c == 1 and i == 0: - c = 2 - print ("> You tell Math Bot that it's very good at math. It still doesn't" - " understand why you're being nice to it, but you see its eyes light" - " up a little.") - elif c == 2 and i == 0: - c = 3 - print ("> You tell Math Bot that you appreciate all of its hard work." - " Math Bot seems genuinely happy.") - talkMenu = True - print "> You can now talk to Math Bot!" - elif c == 3 and i == 0: - print ("> You continue to say nice things to Math Bot. It seems happy, but" - " looks like it wants to talk more.") - # Going back to neutral path after 1-2 insults - elif c == 0 and i == 1: - i = 0 - print "> Math Bot blinks." - elif c == 0 and i == 2: - i = 0 - print "> Math Bot blinks." - else: - print "ERROR" - # Reaction after being abused - elif noReturn == True and talk == False: - if c == 0: - apology = True - c = 1 - print ("> You try to apologize for all of the horrible things you did." - " Math Bot is still terrified. It doesn't believe you.") - elif c == 1: - apology = True - c = 2 - print ("> You continue to apologize profusely, tears in your eyes. Math" - " Bot looks at you, still a little afraid.") - # If you did hit - final apology - elif c == 2 and h > 0: - apology = True - c = 3 - print ("> You gently pick up Math Bot and do what you can to take out the" - " dents. Math Bot flinches as you pick it up. Despite your best" - " efforts, you can still see the spots where the dents were. Math" - " Bot isn't scared anymore, but doesn't seem to trust you.") - talkMenu = True - # If you didn't hit - final apology - elif c == 2 and h == 0: - apology = True - c = 3 - print ("> You tell Math Bot that you didn't mean what you said, and that" - " you're actually very thankful to have it and think that it's" - " wonderful. Math Both isn't scared anymore, but doesn't seem to" - " trust you.") - talkMenu = True - elif c == 3: - print "> You say nice things about Math Bot. It blinks." - else: - print "ERROR" - # Loop until you encourage again. After abuse. - elif noReturn == True and talk == True: - print "> Math Bot listens to you and blinks." - else: - print "Math Bot blinks." - -# Define all insult reactions -def rel_i(): - global fear - global noReturn - global talk - global talkMenu - global enMenu - global hitMenu - global apology - global i - global c - global t - global h - global e - # After talking to MB, insults - can put on Neutral path - if noReturn == False and talk == True and apology == False: - if i == 0 and t < 3: - i = 1 - print ("You tell Math Bot that you thought it was too dumb to actually" - " talk. It seems a little upset.") - # Final insult before noReturn hits - elif i == 1 and t < 3: - i = 2 - print ("> You continue to make fun of Math Bot and tell it that it's just a" - " robot and should stick to doing its job. Math Bot is confused. It" - " thought you liked talking to it.") - # noReturn triggered, down to bad path - elif i == 2 and t < 3: - i = 3 - c = 0 - t = 0 - talk = False - talkMenu = False - noReturn = True - hitMenu = True - print ("> You loudly complain how long it takes Math Bot to do its job and" - " that it's completely useless. Math Bot blinks. It seems sad, and" - " looks at you as if asking what it can do better.") - # To Neutral end - elif i == 0 and t == 3: - print ("> You tell Math Bot that its art is awful, and it'll never be an" - " artist. It should stick to doing math. Math Bot is sad.") - end(2) - # Reply "no" to "Do you mean it?" - elif i == 0 and e == 1 and talk == True: - i = 1 - print ("> You tell Math Bot that no, you didn't actually mean it and were" - " just being nice. Math Bot is surprised and a little sad.") - # Insult after replying "no". To Neutral end. - elif i == 1 and e == 1 and talk == True: - print ("> You tell Math Bot that its art is awful, and it'll never be an" - " artist. It should stick to doing math. Math Bot is sad.") - end(2) - # Initial insult reactions - to bad path - if noReturn == False and apology == False: - if i == 0 and c == 0: - i = 1 - print ("> You mutter that a calculator is easier to use than Math Bot." - " Math Bot doesn't understand.") - elif i == 1 and c == 0: - i = 2 - print ("> You point out how little Math Bot can actually do. Math Bot blinks" - " in response. It still doesn't understand why you're saying these" - " things.") - # Point of no return - hit unlocks - elif i == 2 and talk == False: - i = 3 - c = 0 - t = 0 - print ("> You loudly complain how long it takes Math Bot to do its job and" - " that it's completely useless. Math Bot blinks. It seems sad, and" - " looks at you as if asking what it can do better.") - print "> Hit unlocked!" - hitMenu = True - talkMenu = False - enMenu = False - noReturn = True - # Going back to neutral path after 1-2 insults - elif i == 0 and c == 1: - c = 0 - print "> Math Bot blinks." - elif i == 0 and c == 2: - c = 0 - print "> Math Bot blinks." - else: - print "Math Bot blinks at you." - # To bad path - fear on - elif noReturn == True and apology == False and talk == False: - if i == 3: - i = 4 - t = 0 - fear = True - print ("> You shout at Math Bot. You tell it that you never should have bought" - " it and that it can't do anything right. It has tears in its eyes.") - elif i == 4: - i = 5 - t = 0 - print ("> You continue shouting at Math Bot. You call it horrible, nasty" - " names and tell it that it is and always will be a miserable failure." - " Math Bot is crying and doesn't understand what it did wrong.") - elif i == 5: - i = 6 - print ("> You scream at Math Bot as loud as you can. It tries to apologize," - " but you refuse to listen and keep yelling. It becomes completely" - " unresponsive as you continue to yell at it.") - elif i == 6: - end(3) - else: - print "Math Bot blinks at you." - # Ending after apologizing and then insulting again. - elif noReturn == True and apology == True: - end(3) - else: - print "Math Bot blinks." - -#Define "talk" interactions -def rel_t(): - global fear - global noReturn - global talk - global talkMenu - global enMenu - global hitMenu - global apology - global i - global c - global t - global h - global e - # Good path talk interactions - if noReturn == False: - # if you insulted Math Bot before - if i != 0: - print ("> Math Bot is upset. Maybe you should try apologizing first?") - elif t == 0: - t = 1 - print ("> You ask Math Bot about itself. Math Bot is surprised, but" - " happy. A little window flashes up on the screen in response." - " You have a good time talking with Math Bot.") - talk = True - elif t == 1: - t = 2 - print ("> You ask Math Bot what it thinks of its job. Math Bot tells" - " you that it likes doing math, but that there are other things" - " that it likes doing more. It tells you that you're the first" - " person that's ever asked about what it thinks before. Math" - " Bot says that it's happy to have someone to talk to.") - # unlock "Encourage" here - elif t == 2: - t = 3 - print ("> You ask Math Bot about its dream. Math Bot shyly tells you" - " that it actually wants to be an aritst. It nervously shows" - " you some of the work that it secretly made. It looks like" - " it wants some encouragement.") - print "> Encourage unlocked!" - enMenu = True - # extra info from talking - elif t == 3: - t = 4 - print ("> You ask Math Bot about why it wanted to become an artist." - " it tells you that, while it likes math, it's tired of only" - " being able to do what other peole tell it to do. Math Bot" - " says that it wants to express itself more, be more creative," - " and show people that Math Bots can do more than math.") - # talk loop - elif t == 4: - print ("> Math Bot is waiting for you to say something. Will you" - " encourage it to be an artist, or compliment it and say that" - " it's better at math?") - # after apologizing - elif noReturn == True: - if t == 0: - t = 1 - print ("> You ask Math Bot about itself. A little window flashes up" - " on the screen with its response. You have a good time talking" - " with Math Bot.") - elif t == 1: - t = 2 - print ("> You ask Math Bot what it thinks about its job. Math Bot tells" - " you that it likes doing math, but that it has other hobbies" - " it likes doing more.") - elif t == 2: - t = 3 - print ("> You ask Math Bot about its dreams. It gives a vague response" - " and says it doesn't really matter because it could never do it" - " anyways, and says that it would rather just continue being a" - " Math Bot.") - print "> Encourage unlocked!" - enMenu = True - elif t == 3: - print ("> Math Bot has gotten quiet. Maybe you should try encouraging" - " it a little...?") - -# Define all encourage interactions. -def rel_e(): - global fear - global noReturn - global talk - global talkMenu - global enMenu - global hitMenu - global i - global c - global t - global h - global e - # To best ending - if noReturn == False: - if e == 0: - e = 1 - print ("> You tell Math Bot that it has a wonderful dream, and should" - " just go for it. Math Bot lights up and looks happier than" - " you've ever seen it. It asks if you really mean that.") - elif e == 1: - end(1) - # To ending after abusing and trying to encourage again - elif noReturn == True: - end (4) - -# Define all hit interactions -def rel_h(): - global fear - global noReturn - global talk - global talkMenu - global enMenu - global hitMenu - global apology - global i - global c - global t - global h - global e - # first hit triggers fear - if apology == True: - end(3) - elif h == 0: - h = 1 - noReturn = True - fear = True - print ("> You smash the top of Math Bot as hard as you can with your fist," - " leaving a dent. Math Bot is stunned. It stares at you with wide eyes.") - elif h == 1: - h = 2 - print ("> You kick the side of Math Bot violently. It leaves a large dent." - " It begins crying, begging you to stop.") - elif h == 2: - h = 3 - print ("> You pick up Math Bot and throw it at the wall with all of your" - " strength. It makes a horrible crunch as the corner of it hits the" - " wall, then crashes against the ground. It is a sad, crumpled mess." - " Math Bot is sobbing quietly, apolgoies flashing on the screen," - " promisng you that it will do better next time if you just stop.") - elif h == 3: - end(5) - -# Define all endings -def end(x): - if x == 1: - print ("> You say yes, you really mean it, and say that you think that the" - " are it made is really impressive. Math Bot is thrilled. Math Bot" - " tells you taht it's going to work as hard as it can to make its" - " dreams come true, and departs on a journey to become a great artist.") - print ("> A few months later, you see a news story about Math Bot on TV - its" - " new name is Art Bot. Art Bot is the first robot to create new works of" - " art without any human input, and demand for its work is high. In an" - " interview, it tells the reporter about how grateful it is for you and" - " your encouragement. Art Bot continues to keep in touch with you, and" - " sends you new pieces from time to time.") - print "> Art Bot loves you!" - print "> Thank you for being so kind to Art Bot!" - print "END" - quit() - elif x == 2: - print ("> Math Bot has decided that being an artist was a silly dream, and that" - " it's much more practical and safer to continue being a Math Bot. You" - " keep Math Bot, and it continues to be very good at it's job. But every" - " once in a while, you notice it still trying to create new artwork while" - " you're not using it. You and Math Bot live a happy, normal life.") - print "END" - quit() - elif x == 3: - print ("> Math Bot can't take any more. It shuts itself down. No matter what" - " you try, it won't turn back on again. All you've been left with is" - " a hunk of metal.") - print "END" - quit() - elif x == 4: - print ("> You try to be encouraging. Math Bot is furious and confused - why" - " are you being nice after all of those awful things you did? Math Bot" - " can't understand. It can't forgive you. It shuts itself down. No" - " matter what you try, it won't turn back on again. All you've been" - " left with is a hunk of metal.") - print "END" - quit() - elif x == 5: - print ("> You continue to hit Math Bot. Again. And again. And again. It isn't" - " until your hands start to hurt that you realize that you've" - " compltely destroyed it. Math Bot is dead, broken beyond repair. You" - " stare at the misshapen hunk of metal, pick it up, and throw it away.") - print "END" - quit() - - - -# Set up math program -x = 0 -y = 0 - -def maths (): - if fear == True: - print "Math Bot is too terrified to do math." - else: - sum = 0 - output = "" - print "> Enter first number." - while True: - try: - x = int(raw_input("> ")) - except ValueError: - print("> Please type a number.") - continue - else: - break - print "> Enter second number." - while True: - try: - y = int(raw_input("> ")) - except ValueError: - print("> Please type a number.") - continue - else: - break - while True: - print "> What kind of calculation would you like to perform?" - print "> + , - , * , / (enter the symbol to continue)" - calc = raw_input("> ") - if calc == "+": - sum = x + y - output = str(sum) - print "> " + output - break - elif calc == "-": - sum = x - y - output = str(sum) - print "> " + output - break - elif calc == "*": - sum = x * y - output = str(sum) - print "> " + output - break - elif calc == "/": - sum = x / y - output = str(sum) - print "> ANSWER: " + output - break - else: - print "> Please try again." - continue - -# Define "graphics" part of menu. -def graphics(): - while True: - print "> Please choose one of the following:" - print "> Resolution, Background Color, Back" - input = raw_input("> ") - input = input.lower() - if input == "resolution": - print "> You hit some buttons. It's much clearer now." - break - elif input == "background color": - print ("> You hit some buttons." - " You like the new color better than the old one.") - break - elif input == "back": - break - else: - print "> Choose an option." - continue - -# Define "Audio" part of menu -def audio(): - global beep - while True: - print "> Choose one of the following:" - print "> Toggle beep on/off, Back" - input = raw_input("> ") - input = input.lower() - if "toggle" or "beep" in input: - if beep == False: - print ("> You hit the button." - " There are now beeping sounds when you hit the buttons.") - beep = True - break - elif beep == True: - print "> You decided the beeping sound is annoying and turn it off." - beep = False - break - elif input == "back": - break - else: - print "Please choose an option." - continue - - -# Set up initial variables -power = False -first = False -second = False -more = False -rel = 0 - -# Introduction to game -print "> You are the proud owner of a brand new Math Bot." -print ("> The instruction manual says - 'Thank you for your purchase!" - " Math Bot was created to take care of all of your computational needs.") -print "> There is a small, silver cube directly in front of you. What do you do?" -print "> turn on, walk away (type the option that you want to select, and hit enter)" - -# First choice -while power == False: - input = raw_input("> ") - input = input.lower() - if input == "walk away": - print "> You decide to turn on the Math Bot later." - power = True - finish = True - elif input == "turn on": - print ("> You turn on the Math Bot on. The screen on the silver cube" - " lights up, and two little glowing eyes stare back at you.") - print ("> There is a menu underneath the little eyes." - " There is only one option - 'math'.") - power = True - first = True - else: - print "> Please enter 'turn on' or 'walk away'." - -# Power is on - first math demonstration -while first == True: - print "> What would you like to do?" - input = raw_input("> ") - input = input.lower() - if input == "math": - maths() - print "> CONGRATULATIONS!" - print "> You have performed your first calculation!" - print "> Options menu opened!" - first = False - second = True - else: - print "> Please enter 'math'." - -# Add options to menu -while second == True: - print "> There are now two buttons on the menu - math and options. The little eyes blink." - print "> What will you do?" - input = raw_input("> ") - input = input.lower() - if input == "math": - maths() - elif input == "options": - while True: - print "> Choose one of the following:" - print "> Graphics, Audio, Additional Commands, Back" - input = raw_input("> ") - input = input.lower() - if input == "graphics": - graphics() - continue - elif input == "audio": - audio() - continue - elif input == "additional commands": - print "> Additional commands unlocked!" - print "> A group of commands pops up on the menus. The little eyes stare at you." - more = True - second = False - break - elif input == "back": - break - else: - continue - else: - print "Please write 'math' or 'options'." - -# Final system of menus -while more == True: - print "> Choose: math, options, compliment, insult" - if talkMenu == True: - print "talk" - if enMenu == True: - print "encourage" - if hitMenu == True: - print "hit" - input = raw_input("> ") - input = input.lower() - if input == "math": - maths() - continue - elif input == "options": - options() - continue - elif input == "compliment": - rel_c() - continue - elif input == "insult": - rel_i() - continue - elif input == "talk" and talkMenu == True: - rel_t() - continue - elif input == "hit" and hitMenu == True: - rel_h() - continue - elif input == "encourage" and enMenu == True: - rel_e() - continue - else: - print "Choose one of the options." diff --git a/Python/MergeSort.py b/Python/MergeSort.py deleted file mode 100644 index a7eaf4e7..00000000 --- a/Python/MergeSort.py +++ /dev/null @@ -1,30 +0,0 @@ -def merge_sort(unsorted_list): - if len(unsorted_list) <= 1: - return unsorted_list - - middle = len(unsorted_list) // 2 - left_list = unsorted_list[:middle] - right_list = unsorted_list[middle:] - - left_list = merge_sort(left_list) - right_list = merge_sort(right_list) - return list(merge(left_list, right_list)) - -# Merge -def merge(left_half,right_half): - res = [] - while len(left_half) != 0 and len(right_half) != 0: - if left_half[0] < right_half[0]: - res.append(left_half[0]) - left_half.remove(left_half[0]) - else: - res.append(right_half[0]) - right_half.remove(right_half[0]) - if len(left_half) == 0: - res = res + right_half - else: - res = res + left_half - return res - -unsorted_list = [80, 44, 28, 100, 22, 15, 34] -print(merge_sort(unsorted_list)) diff --git a/Python/Piano_Tkinter_Python/Piano.py b/Python/Piano_Tkinter_Python/Piano.py deleted file mode 100644 index ca762b07..00000000 --- a/Python/Piano_Tkinter_Python/Piano.py +++ /dev/null @@ -1,202 +0,0 @@ -# Piano -Python Tkinter -from tkinter import* -import pygame -import sys - -pygame.init() - -root = Tk() -root.title("PIANO") -root.geometry("850x450") - -#*********************************************FUNCTIONS*********************************************************** -def val_btnup1(): - val.set("C#") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/C_s.wav") - sound.play() - return - -def val_btnup2(): - val.set("D#") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/D_s.wav") - sound.play() - return - -def val_btnup3(): - val.set("F#") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/F_s.wav") - sound.play() - return - -def val_btnup4(): - val.set("G#") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/G_s.wav") - sound.play() - return - -def val_btnup5(): - val.set("Bb") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/Bb.wav") - sound.play() - return - -def val_btnup6(): - val.set("C#1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/C_s1.wav") - sound.play() - return - -def val_btnup7(): - val.set("D#1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/D_s1.wav") - sound.play() - return -#*********************************************************************************************************************** - -def val_btnC(): - val.set("C") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/C.wav") - sound.play() - return - -def val_btnD(): - val.set("D") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/D.wav") - sound.play() - return - -def val_btnE(): - val.set("E") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/E.wav") - sound.play() - return - -def val_btnF(): - val.set("F") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/F.wav") - sound.play() - return - -def val_btnG(): - val.set("G") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/G.wav") - sound.play() - return - -def val_btnA(): - val.set("A") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/A.wav") - sound.play() - return - -def val_btnB(): - val.set("B") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/B.wav") - sound.play() - return - -def val_btnC1(): - val.set("C1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/C1.wav") - sound.play() - return - -def val_btnD1(): - val.set("D1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/D1.wav") - sound.play() - return - -def val_btnE1(): - val.set("E1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/E1.wav") - sound.play() - return - -def val_btnF1(): - val.set("F1") - sound = pygame.mixer.Sound("/home/karim/PROJECTS/Piano_Tkinter/Z_Music_Notes/Music_Notes/F1.wav") - sound.play() - return - - - - -#****************************************************************************************************************** - -val = StringVar() -val.set(0) -mainframe = Frame(root,height=450,width=850,bg="powder blue",bd=8,relief=RIDGE) -mainframe.place(x=0,y=0) - -valueEntry = Entry(mainframe,textvar=val,width=5,bd=8,relief=RIDGE,font="calibri 15 bold") -valueEntry.place(x=380,y=5) - -#****************************************BLACK BUTTONS************************************************************* - -btnup1 = Button(mainframe,text="C#",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup1) -btnup1.place(x=143,y=60) - -btnup2 = Button(mainframe,text="D#",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup2) -btnup2.place(x=210,y=60) - -btnup3 = Button(mainframe,text="F#",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup3) -btnup3.place(x=327,y=60) - -btnup4 = Button(mainframe,text="G#",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup4) -btnup4.place(x=393,y=60) - -btnup5 = Button(mainframe,text="Bb",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ - activebackground="black",activeforeground="white",fg="white",command=val_btnup5) -btnup5.place(x=460,y=60) - -btnup6 = Button(mainframe,text="C#1",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup6) -btnup6.place(x=580,y=60) - -btnup7 = Button(mainframe,text="D#1",height=8,width=3,bd=4,relief=RAISED,font="msserif 12 bold",bg="black",\ -activebackground="black",activeforeground="white",fg="white",command=val_btnup7) -btnup7.place(x=647,y=60) - -#*************************************WHITE BUTTONS**************************************************************** - -btn1 = Button(mainframe,text="C",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnC) -btn1.place(x=60,y=240) - -btn2 = Button(mainframe,text="D",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnD) -btn2.place(x=127,y=240) - -btn3 = Button(mainframe,text="E",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnE) -btn3.place(x=194,y=240) - -btn4 = Button(mainframe,text="F",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnF) -btn4.place(x=260,y=240) - -btn5 = Button(mainframe,text="G",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnG) -btn5.place(x=327,y=240) - -btn6 = Button(mainframe,text="A",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnA) -btn6.place(x=393,y=240) - -btn7 = Button(mainframe,text="B",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnB) -btn7.place(x=460,y=240) - -btn8 = Button(mainframe,text="C1",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnC1) -btn8.place(x=527,y=240) - -btn9 = Button(mainframe,text="D1",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnD1) -btn9.place(x=593,y=240) - -btn10 = Button(mainframe,text="E1",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnE1) -btn10.place(x=661,y=240) - -btn11 = Button(mainframe,text="F1",height=9,width=3,bd=4,relief=RAISED,font="msserif 12 bold",command=val_btnF1) -btn11.place(x=728,y=240) - - - -root.mainloop() diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/A.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/A.wav deleted file mode 100644 index 9d9c15ae..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/A.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/B.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/B.wav deleted file mode 100644 index da3de7b8..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/B.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/Bb.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/Bb.wav deleted file mode 100644 index a6a3a932..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/Bb.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C.wav deleted file mode 100644 index c6647dcd..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C1.wav deleted file mode 100644 index 4033dd2a..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s.wav deleted file mode 100644 index 8d52344f..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s1.wav deleted file mode 100644 index bc73dfe1..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/C_s1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D.wav deleted file mode 100644 index 32d2b7a8..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D1.wav deleted file mode 100644 index 4e82c820..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s.wav deleted file mode 100644 index 537cf0e6..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s1.wav deleted file mode 100644 index 9e5ef24e..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/D_s1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E.wav deleted file mode 100644 index ff68f8c2..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E1.wav deleted file mode 100644 index 9e2e9c96..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/E1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F.wav deleted file mode 100644 index c11d05d7..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F1.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F1.wav deleted file mode 100644 index cd3b704d..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F1.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F_s.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F_s.wav deleted file mode 100644 index 1ffa2500..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/F_s.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G.wav deleted file mode 100644 index 29759c17..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G.wav and /dev/null differ diff --git a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G_s.wav b/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G_s.wav deleted file mode 100644 index c8fe5ada..00000000 Binary files a/Python/Piano_Tkinter_Python/Z_Music_Notes/Music_Notes/G_s.wav and /dev/null differ diff --git a/Python/RailFensCypher.py b/Python/RailFensCypher.py deleted file mode 100644 index eb208568..00000000 --- a/Python/RailFensCypher.py +++ /dev/null @@ -1,76 +0,0 @@ - -def encryptRailFence(text, key): - rail = [['\n' for i in range(len(text))] - for j in range(key)] - dir_down = False - row, col = 0, 0 - - for i in range(len(text)): - if (row == 0) or (row == key - 1): - dir_down = not dir_down - - rail[row][col] = text[i] - col += 1 - if dir_down: - row += 1 - else: - row -= 1 - result = [] - for i in range(key): - for j in range(len(text)): - if rail[i][j] != '\n': - result.append(rail[i][j]) - return("" . join(result)) - -def decryptRailFence(cipher, key): - rail = [['\n' for i in range(len(cipher))] - for j in range(key)] - dir_down = None - row, col = 0, 0 - for i in range(len(cipher)): - if row == 0: - dir_down = True - if row == key - 1: - dir_down = False - rail[row][col] = '*' - col += 1 - if dir_down: - row += 1 - else: - row -= 1 - index = 0 - for i in range(key): - for j in range(len(cipher)): - if ((rail[i][j] == '*') and - (index < len(cipher))): - rail[i][j] = cipher[index] - index += 1 - result = [] - row, col = 0, 0 - for i in range(len(cipher)): - - # check the direction of flow - if row == 0: - dir_down = True - if row == key-1: - dir_down = False - - if (rail[row][col] != '*'): - result.append(rail[row][col]) - col += 1 - - if dir_down: - row += 1 - else: - row -= 1 - return("".join(result)) - - -if __name__ == "__main__": - s=input("Enter the text:") - n=int(input("Key:")) - str=encryptRailFence(s, n) - print(f"Encrypted Text:{str}") - print(f"Decrypted Text:{decryptRailFence(str, n)}") - - diff --git a/Python/Website Blocker/code.py b/Python/Website Blocker/code.py deleted file mode 100644 index 426567b6..00000000 --- a/Python/Website Blocker/code.py +++ /dev/null @@ -1,28 +0,0 @@ -import time -from datetime import datetime as dt - -hosts_temp="hosts" -hosts_path=r"C:\Windows\System32\drivers\etc/hosts" -redirect="127.0.0.1" -website_list=["www.facebook.com","facebook.com","dub119.mail.live.com","www.dub119.mail.live.com"] - -while True: - if dt(dt.now().year,dt.now().month,dt.now().day,8) < dt.now() < dt(dt.now().year,dt.now().month,dt.now().day,23): - print("Working hours...") - with open(hosts_temp,'r+') as file: - content=file.read() - for website in website_list: - if website in content: - pass - else: - file.write(redirect+" "+ website+"\n") - else: - with open(hosts_temp,'r+') as file: - content=file.readlines() - file.seek(0) - for line in content: - if not any(website in line for website in website_list): - file.write(line) - file.truncate() - print("Fun hours...") - time.sleep(5) diff --git a/Python/adaboost.py b/Python/adaboost.py deleted file mode 100644 index 6e54a825..00000000 --- a/Python/adaboost.py +++ /dev/null @@ -1,85 +0,0 @@ -import numpy as np -from sklearn import datasets -from sklearn.model_selection import train_test_split - -class DecisionStump: - def __init__(self): - self.polarity = 1 - self.threshold = None - self.feature_idx = None - self.alpha = None - - def predict(self,X): - n_samples = X.shape[0] - X_c = X[:,self.feature_idx] - preds = np.ones(n_samples) - - if self.polarity ==1: - preds[X_c < self.threshold] = -1 - else: - preds[X_c > self.threshold] = -1 - - return preds - -class myAdaBoost: - def __init__(self,n_clf=5): - self.n_clf = n_clf - - def fit(self,X,y): - n_samples,n_features = X.shape - w = np.full(n_samples, (1/n_samples)) - - self.clfs=[] - for _ in range(self.n_clf): - clf = DecisionStump() - min_error = float('inf') - for feat in range(n_features): - X_c = X[:,feat] - thresholds=np.unique(X_c) - for threshold in thresholds: - p=1 - preds=np.ones(n_samples) - preds[X_c0.5: - p=-1 - error=1-error - - if error=0: - super(Paddle, self).move(dist, 0) - if self.ball is not None: - self.ball.move(dist,0) - - -class Brick(PlayComponent): - colorArray = {1: 'lightsteelblue', 2: 'royalblue', 3:'blue'} - - def __init__(self, canvas, x, y, hits): - self.width = 60 - self.heigt = 20 - self.hits = hits - color = Brick.colorArray[hits] - item = canvas.create_rectangle(x-self.width/2, - y-self.heigt/2, - x+self.width/2, - y+self.heigt/2, - fill = color, tag = 'brick') - super(Brick,self).__init__(canvas, item) - - def hit(self): - self.hits -= 1 - if self.hits ==0: - self.delete() - else: - self.canvas.itemconfig(self.item, fill=Brick.colorArray[self.hits]) - - - - -class Ball(PlayComponent): - def __init__(self, canvas, x, y): - self.radius= 6 - self.speed = 8 - self.direction = [-1,1] - item = canvas.create_oval(x - self.radius, - y - self.radius, - x + self.radius, - y + self.radius, - fill='red') - super(Ball, self).__init__(canvas, item) - - def update(self): - coord = self.position() - width = self.canvas.winfo_width() - if coord[1] <=0: - self.direction[1]*= -1 - if coord[2] >=width or coord[0] <=0: - self.direction[0] *=-1 - - x = self.direction[0]*self.speed - y = self.direction[1]*self.speed - self.move(x, y) - - def intersect(self,components): - coord = self.position() - x = (coord[0] + coord[2])*0.5 - - if len(components) == 1: - component = components[0] - coord = component.position() - if x < coord[0]: - self.direction[0] =-1 - elif x> coord[2]: - self.direction[0] = 1 - else: - self.direction[1]*=-1 - elif len(components)>1: - self.direction[1]*=-1 - - for component in components: - if isinstance(component, Brick): - component.hit() - - -class Game(tk.Frame): - def __init__(self, master): - super(Game,self).__init__(master) - self.lives = 3 - self.width = 1000 - self.height = 400 - - self.canvas = tk.Canvas(self, bg = 'cornsilk', - width = self.width, - height = self.height) - - self.canvas.pack() - self.pack() - - self.items = {} - self.ball = None - self.paddle = Paddle(self.canvas, self.width/2, 320) - self.items[self.paddle.item] = self.paddle - - for x in range(100, self.width - 100, 60): - self.display_brick(x+20, 50,2) - self.display_brick(x+20, 70, 1) - self.display_brick(x+20, 120, 1) - - - self.hud = None - self.init_game() - self.canvas.focus_set() - self.canvas.bind('', - lambda _:self.paddle.move(-30)) - self.canvas.bind('', - lambda _:self.paddle.move(30)) - - - def init_game(self): - self.update_lives_text() - self.display_ball() - self.text = self.draw_text(self.width/2, self.height/2, 'Press "S" for start') - self.canvas.bind('', lambda _: self.start_game()) - - def display_ball(self): - if self.ball is not None: - self.ball.delete() - paddle_coords = self.paddle.position() - x = (paddle_coords[0] + paddle_coords[2])*0.5 - self.ball = Ball(self.canvas,x,310) - self.paddle.set_ball(self.ball) - - def display_brick(self, x, y, hits): - brick = Brick(self.canvas, x, y, hits) - self.items[brick.item]=brick - - def draw_text(self, x, y, text, size='50'): - font = ('Arial', size) - return self.canvas.create_text(x, y, text=text, font=font) - - def update_lives_text(self): - text = 'Lives: %s' %self.lives - if self.hud is None: - self.hud= self.draw_text(50, 20, text, 15) - else: - self.canvas.itemconfig(self.hud, text=text) - - def start_game(self): - self.canvas.unbind('') - self.canvas.delete(self.text) - self.paddle.ball = None - self.game_loop() - - def game_loop(self): - self.verify_inter() - num_bricks = len(self.canvas.find_withtag('brick')) - - if num_bricks == 0: - self.ball.speed = None - self.draw_text(self.width/2, self.height/2, "You Win!") - elif self.ball.position()[3] >=self.height: - self.ball.speed = None - self.lives-=1 - if self.lives == 0: - self.draw_text(self.width/2, self.height/2, "You Lost.Game Over!") - else: - self.after(1000, self.init_game()) - else: - self.ball.update() - self.after(50, self.game_loop) - - def verify_inter(self): - ball_coords = self.ball.position() - items = self.canvas.find_overlapping(*ball_coords) - objects = [self.items[x] for x in items if x in self.items] - self.ball.intersect(objects) - - - -if __name__ =='__main__': - root = tk.Tk() - root.title('Brick Breaker') - game = Game(root) - game.mainloop() - - - - diff --git a/Python/changecurrency.py b/Python/changecurrency.py deleted file mode 100644 index 14bb635e..00000000 --- a/Python/changecurrency.py +++ /dev/null @@ -1,10 +0,0 @@ -from forex_python.converter import CurrencyRates -c = CurrencyRates() - -amount = int(input("Enter the amount: ")) -from_currency = input("From : ").upper() -to_currency = input("To : ").upper() -result = c.convert(from_currency, to_currency, amount) - -print("\n") -print(from_currency, "to", to_currency, ": ", result) diff --git a/Python/connect4AI/.gitignore b/Python/connect4AI/.gitignore deleted file mode 100644 index e01e0494..00000000 --- a/Python/connect4AI/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -env/ -venv/ \ No newline at end of file diff --git a/Python/connect4AI/README.md b/Python/connect4AI/README.md deleted file mode 100644 index df9796c9..00000000 --- a/Python/connect4AI/README.md +++ /dev/null @@ -1,46 +0,0 @@ -
-

Connect 4 AI

-
- -## About - -Created a connect4 game project using pygame with an AI made using backtracking, minmax tree and alpha-beta pruning for the opponent. - -## Install and Run - -Make sure you have **Python 3.x** installed and **the latest version of pip** *installed* before running these steps. - - -1. Clone the repository using the following command - -```bash -git clone -# After cloning, move into the directory having the project files using the change directory command -cd cms -``` -2. Create a virtual environment where all the required python packages will be installed - -```bash -# Use this on Windows -python -m venv env -# Use this on Linux and Mac -python -m venv env -``` -3. Activate the virtual environment - -```bash -# Windows -.\env\Scripts\activate -# Linux and Mac -source env/bin/activate -``` - -4. Install all the project Requirements -```bash -pip install -r requirements.txt -``` - -5. Run the program -```bash -python connect4.py -``` \ No newline at end of file diff --git a/Python/connect4AI/connect4.py b/Python/connect4AI/connect4.py deleted file mode 100644 index f5f6c3f9..00000000 --- a/Python/connect4AI/connect4.py +++ /dev/null @@ -1,300 +0,0 @@ -import numpy as np -import pygame -import sys -import math -import random - -# Global Constants -BLUE = (0, 0, 255) -BLACK = (0, 0, 0) -RED = (255, 0, 0) -YELLOW = (255, 255, 0) - -PLAYER = 0 -AI = 1 - -WINDOW_LENGTH = 4 - -EMPTY = 0 -PLAYER_PIECE = 1 -AI_PIECE = 2 - -ROW_COUNT = 6 -COLUMN_COUNT = 7 - -SQUARESIZE = 100 -RADIUS = int(SQUARESIZE/2 - 5) - -width = COLUMN_COUNT * SQUARESIZE -height = (ROW_COUNT+1) * SQUARESIZE - -size = (width, height) - -turn = random.randint(PLAYER, AI) - - -class Board: - def __init__(self, rows, columns): - self.rows = rows - self.columns = columns - - def create_board(self): - board = np.zeros((self.rows, self.columns)) - return board - - def drop_piece(self, board, row, col, piece): - board[row][col] = piece - - def is_valid_location(self, board, col): - return board[ROW_COUNT-1][col] == 0 - - def get_next_open_row(self, board, col): - for r in range(ROW_COUNT): - if board[r][col] == 0: - return r - - def print_board(self, board): - self.board = board - print(np.flip(self.board, 0)) - - def winning_move(self, board, piece): - # Check horizontal locations for win - for c in range(COLUMN_COUNT-3): - for r in range(ROW_COUNT): - if board[r][c] == piece and board[r][c+1] == piece and board[r][c+2] == piece and board[r][c+3] == piece: - return True - - # Check vertical locations for win - for c in range(COLUMN_COUNT): - for r in range(ROW_COUNT-3): - if board[r][c] == piece and board[r+1][c] == piece and board[r+2][c] == piece and board[r+3][c] == piece: - return True - - # Check positively sloped diaganols - for c in range(COLUMN_COUNT-3): - for r in range(ROW_COUNT-3): - if board[r][c] == piece and board[r+1][c+1] == piece and board[r+2][c+2] == piece and board[r+3][c+3] == piece: - return True - - # Check negatively sloped diaganols - for c in range(COLUMN_COUNT-3): - for r in range(3, ROW_COUNT): - if board[r][c] == piece and board[r-1][c+1] == piece and board[r-2][c+2] == piece and board[r-3][c+3] == piece: - return True - - def evaluate_win(self, window, piece): - score = 0 - opp_piece = PLAYER_PIECE - if piece == PLAYER_PIECE: - opp_piece = AI_PIECE - - if window.count(piece) == 4: - score += 100 - elif window.count(piece) == 3 and window.count(EMPTY) == 1: - score += 5 - elif window.count(piece) == 2 and window.count(EMPTY) == 2: - score += 2 - - if window.count(opp_piece) == 3 and window.count(EMPTY) == 1: - score -= 4 - - return score - - def score_position(self, board, piece): - score = 0 - # Center Score - center_array = [int(i) for i in list(board[:, COLUMN_COUNT//2])] - center_count = center_array.count(piece) - score += center_count * 3 - - ## Horizontal Score - for r in range(ROW_COUNT): - row_array = [int(i) for i in list(board[r,:])] - for c in range(COLUMN_COUNT-3): - window = row_array[c:c+WINDOW_LENGTH] - score += self.evaluate_win(window, piece) - - ## Vertical Score - for c in range(COLUMN_COUNT): - col_array = [int(i) for i in list(board[:,c])] - for r in range(ROW_COUNT-3): - window = col_array[r:r+WINDOW_LENGTH] - score += self.evaluate_win(window, piece) - - ## Diagonal Score - for r in range(ROW_COUNT-3): - for c in range(COLUMN_COUNT-3): - window = [board[r+i][c+i] for i in range(WINDOW_LENGTH)] - score += self.evaluate_win(window, piece) - - for r in range(ROW_COUNT-3): - for c in range(COLUMN_COUNT-3): - window = [board[r+3-i][c+i] for i in range(WINDOW_LENGTH)] - score += self.evaluate_win(window, piece) - - return score - - def is_terminal_node(self, board): - return self.winning_move(board, PLAYER_PIECE) or self.winning_move(board, AI_PIECE) or len(self.get_valid_locations(board)) == 0 - - def minimax(self, board, depth, alpha, beta, maximizingPlayer): - valid_locations = self.get_valid_locations(board) - is_terminal = self.is_terminal_node(board) - if depth ==0 or is_terminal: - if is_terminal: - if self.winning_move(board, AI_PIECE): - return (None, 1000000000000000000000) - elif self.winning_move(board, PLAYER_PIECE): - return (None, -1000000000000000000000) - else: #GAme Over - return (None, 0) - else: #Zero Depth - return (None, self.score_position(board, AI_PIECE)) - if maximizingPlayer: - value = -math.inf - column = random.choice(valid_locations) - for col in valid_locations: - row = self.get_next_open_row(board, col) - b_copy = board.copy() - self.drop_piece(b_copy, row, col, AI_PIECE) - new_score = self.minimax(b_copy, depth-1, alpha, beta, False)[1] - if new_score > value: - value = new_score - column = col - alpha = max(alpha, value) - if alpha >= beta: - break - return column, value - - else: - value = math.inf - column = random.choice(valid_locations) - for col in valid_locations: - row = self.get_next_open_row(board, col) - b_copy = board.copy() - self.drop_piece(b_copy, row, col, PLAYER_PIECE) - new_score = self.minimax(b_copy, depth-1, alpha, beta, True)[1] - if new_score < value: - value = new_score - column = col - beta = min(beta, value) - if alpha >= beta: - break - return column, value - - def get_valid_locations(self, board): - valid_locations = [] - for col in range(COLUMN_COUNT): - if self.is_valid_location(board, col): - valid_locations.append(col) - return valid_locations - - def pick_best_move(self, board, piece): - valid_locations = self.get_valid_locations(board) - best_score = -10000 - best_col = random.choice(valid_locations) - for col in valid_locations: - row = self.get_next_open_row(board, col) - temp_board = board.copy() - self.drop_piece(temp_board, row, col, piece) - score = self.score_position(temp_board, piece) - if score > best_score: - best_score = score - best_col = col - - return best_col - - - def draw_board(self, board): - for c in range(COLUMN_COUNT): - for r in range(ROW_COUNT): - pygame.draw.rect( - screen, BLUE, (c*SQUARESIZE, r*SQUARESIZE + SQUARESIZE, SQUARESIZE, SQUARESIZE)) - pygame.draw.circle(screen, BLACK, (int( - c*SQUARESIZE + SQUARESIZE/2), int(r*SQUARESIZE + SQUARESIZE+SQUARESIZE/2)), RADIUS) - - for c in range(COLUMN_COUNT): - for r in range(ROW_COUNT): - if board[r][c] == PLAYER_PIECE: - pygame.draw.circle(screen, RED, (int( - c*SQUARESIZE+SQUARESIZE/2), height-int(r*SQUARESIZE+SQUARESIZE/2)), RADIUS) - elif board[r][c] == AI_PIECE: - pygame.draw.circle(screen, YELLOW, (int( - c*SQUARESIZE+SQUARESIZE/2), height-int(r*SQUARESIZE+SQUARESIZE/2)), RADIUS) - - pygame.display.update() - - -if __name__ == "__main__": - board = Board(ROW_COUNT, COLUMN_COUNT) - game_over = False - game = board.create_board() - board.print_board(game) - - pygame.init() - - screen = pygame.display.set_mode(size) - myFont = pygame.font.SysFont("monopsace", 75) - board.draw_board(game) - pygame.display.update() - - while not game_over: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - sys.exit() - - if event.type == pygame.MOUSEMOTION: - pygame.draw.rect(screen, BLACK, (0,0, width, SQUARESIZE)) - posx = event.pos[0] - if turn == PLAYER: - pygame.draw.circle(screen, RED, (posx, int(SQUARESIZE/2)), RADIUS) - - pygame.display.update() - - if event.type == pygame.MOUSEBUTTONDOWN: - pygame.draw.rect(screen, BLACK, (0,0, width, SQUARESIZE)) - print(event.pos) - - #Ask For Player 1 - if turn == PLAYER: - posx = event.pos[0] - col = int(math.floor(posx/SQUARESIZE)) - - if board.is_valid_location(game, col): - row = board.get_next_open_row(game, col) - board.drop_piece(game, row, col, PLAYER_PIECE) - - if board.winning_move(game, PLAYER_PIECE): - label = myFont.render("Player 1 Wins !!", 1, RED) - screen.blit(label, (40,10)) - game_over = True - - turn += 1 - turn = turn%2 - - board.print_board(game) - board.draw_board(game) - - #Ask for Player 2 - if turn == AI and not game_over: - - col, minimax_score = board.minimax(game, 6, -math.inf, math.inf, True) - - if board.is_valid_location(game, col): - """ pygame.time.wait(500) """ - row = board.get_next_open_row(game, col) - board.drop_piece(game, row, col, AI_PIECE) - - if board.winning_move(game, AI_PIECE): - label = myFont.render("Player 2 Wins !!", 1, YELLOW) - screen.blit(label, (40,10)) - game_over = True - - board.print_board(game) - board.draw_board(game) - - turn += 1 - turn = turn % 2 - - if game_over: - pygame.time.wait(3000) \ No newline at end of file diff --git a/Python/connect4AI/requirements.txt b/Python/connect4AI/requirements.txt deleted file mode 100644 index d224b254..00000000 --- a/Python/connect4AI/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pygame==1.9.6 -numpy==1.18.5 \ No newline at end of file diff --git a/Python/factorial.py b/Python/factorial.py deleted file mode 100644 index 1bdde2e2..00000000 --- a/Python/factorial.py +++ /dev/null @@ -1,13 +0,0 @@ -def fact(n): - if n==1 : - return 1 - else: - return n*fact(n-1) -n=int(input("Enter the number whoes factorial you want to find\n")) -if n<0: - print("Not possible you have entered negative number") -elif n==0: - print("0") -else: - result=fact(n) - print(result) diff --git a/Python/hangman.py b/Python/hangman.py deleted file mode 100644 index 89c64c9d..00000000 --- a/Python/hangman.py +++ /dev/null @@ -1,105 +0,0 @@ -name = input("Enter your NAME :") -print("Welcome",name) - -print("*****************") - -print ("Try to guess the word in less than 10 minutes :") - -import random -def hangman(): - - word = random.choice(["pugger" , "littlepugger" , "tiger" , "superman" , "thor" , "pokemon" , "avengers" , "savewater" , "earth" , "annable" ]) - validLetters = 'abcdefghijklmnopqrstuvwxyz' - turns = 10 - guessmade = '' - - while len(word) > 0: - main = "" - missed = 0 - - for letter in word: - if letter in guessmade: - main = main + letter - else: - main = main + "_" + " " - if main == word: - print(main) - print("You win!") - break - - print("Guess the word:" , main) - guess = input() - - if guess in validLetters: - guessmade = guessmade + guess - else: - print("Enter a valid character") - guess = input() - - if guess not in word: - turns = turns - 1 - if turns == 9: - print("9 turns left") - print(" -------- ") - if turns == 8: - print("8 turns left") - print(" -------- ") - print(" O ") - if turns == 7: - print("7 turns left") - print(" -------- ") - print(" O ") - print(" | ") - if turns == 6: - print("6 turns left") - print(" -------- ") - print(" O ") - print(" | ") - print(" / ") - if turns == 5: - print("5 turns left") - print(" -------- ") - print(" O ") - print(" | ") - print(" / \ ") - if turns == 4: - print("4 turns left") - print(" -------- ") - print(" \ O ") - print(" | ") - print(" / \ ") - if turns == 3: - print("3 turns left") - print(" -------- ") - print(" \ O / ") - print(" | ") - print(" / \ ") - if turns == 2: - print("2 turns left") - print(" -------- ") - print(" \ O /| ") - print(" | ") - print(" / \ ") - if turns == 1: - print("1 turns left") - print("Last breaths counting, Take care!") - print(" -------- ") - print(" \ O_|/ ") - print(" | ") - print(" / \ ") - if turns == 0: - print("You loose") - print("You let a kind man die") - print(" -------- ") - print(" O_| ") - print(" /|\ ") - print(" / \ ") - break - - -name = input("Enter your name") -print("Welcome" , name ) -print("-------------------") -print("try to guess the word in less than 10 attempts") -hangman() -print() diff --git a/Python/ironman.py b/Python/ironman.py deleted file mode 100644 index 2768b3f9..00000000 --- a/Python/ironman.py +++ /dev/null @@ -1,47 +0,0 @@ -import turtle - -v1= [[(-40, 120), (-70, 260), (-130, 230), (-170, 200), (-170, 100), (-160, 40), (-170, 10), (-150, -10), (-140, 10), - (-40, -20), (0, -20)], - [(0, -20), (40, -20), (140, 10), (150, -10), (170, 10), (160, 40), (170, 100), (170, 200), (130, 230), (70, 260), - (40, 120), (0, 120)]] -v2 = [[(-40, -30), (-50, -40), (-100, -46), (-130, -40), (-176, 0), (-186, -30), (-186, -40), (-120, -170), (-110, -210), - (-80, -230), (-64, -210), (0, -210)], - [(0, -210), (64, -210), (80, -230), (110, -210), (120, -170), (186, -40), (186, -30), (176, 0), (130, -40), - (100, -46), (50, -40), (40, -30), (0, -30)]] -v3 = [[(-60, -220), (-80, -240), (-110, -220), (-120, -250), (-90, -280), (-60, -260), (-30, -260), (-20, -250), - (0, -250)], - [(0, -250), (20, -250), (30, -260), (60, -260), (90, -280), (120, -250), (110, -220), (80, -240), (60, -220), - (0, -220)]] - -turtle.hideturtle() -turtle.bgcolor('#d20117') -turtle.setup(500, 600) -turtle.title("I AM IRONMAN") -v1Goto = (0, 120) -v2Goto = (0, -30) -v3Goto = (0, -220) -turtle.speed(2) - - -def logo(a, b): - turtle.penup() - turtle.goto(b) - turtle.pendown() - turtle.color('#b97d10') - turtle.begin_fill() - - for i in range(len(a[0])): - x, y = a[0][i] - turtle.goto(x, y) - - for i in range(len(a[1])): - x, y = a[1][i] - turtle.goto(x, y) - turtle.end_fill() - - -logo(v1, v1Goto) -logo(v2, v2Goto) -logo(v3, v3Goto) -turtle.hideturtle() -turtle.done() \ No newline at end of file diff --git a/Python/jumbleword.py b/Python/jumbleword.py deleted file mode 100644 index 65e1e419..00000000 --- a/Python/jumbleword.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -""" -@author: Nishant Sabbarwal -""" - -import random - -def choose(): - words=['luck','duck','smile','funny','shoot','apple','hero','level','time','queen'] - pick=random.choice(words) - return pick - -def jumble(word): - jumbled="".join(random.sample(word,len(word))) - return jumbled - -def thank(p1n,p2n,p1,p2): - print(p1n,"Your score is:",p1) - print(p2n,"Your score is:",p2) - print("Thanks for playing") - print("Have a nice day!!!") - -def play(): - p1name=input("Player 1, Please enter your name: ") - p2name=input("Player 2, Please enter your name: ") - pp1=0 - pp2=0 - turn=0 - while(1): - #computer's task - picked_word=choose() - #create question - qn=jumble(picked_word) - print("Random Word :",qn) - #player 1 - if turn%2==0: - print(p1name," Your Turn!") - ans=input("What is on your mind ?") - if ans==picked_word: - pp1=pp1+1 - print("Your score is:",pp1) - else: - print("Better luck next time. correct answer:",picked_word) - c=int(input("Press 1 to continue and 0 to quit:")) - if c==0: - thank(p1name,p2name,pp1,pp2) - break - #player 2 - else: - print(p2name,"Your Turn!") - ans=input("What is on your mind ?") - if ans==picked_word: - pp2=pp2+1 - print("Your score is:",pp2) - else: - print("Better luck next time. Correct Answer:",picked_word) - c=int(input("Press 1 to continue and 0 to quit:")) - if c==0: - thank(p1name,p2name,pp1,pp2) - break - - turn=turn+1 -play() diff --git a/Python/python_pybullet_car_control.py b/Python/python_pybullet_car_control.py deleted file mode 100644 index ae8f48c0..00000000 --- a/Python/python_pybullet_car_control.py +++ /dev/null @@ -1,114 +0,0 @@ -'''hello everyone!!! I am Pratyush and this is a basic pybullet project to make a keyboard controlled car(husky) using torque control(you can use velocity control instead) and to show the information about joints this car is having. - -controls: - 1. forward arrow key ==> forward - 2. backward arrow key ==> backward - 3. left arrow key ==> left rotate - 4. right arrow key ==> right rotate - 5. 'r' button ==> reverse - 6. 'a' button ==> increase speed''' - -import pybullet as p -import pybullet_data - -p.connect(p.GUI) #or p.SHARED_MEMORY or p.DIRECT -p.setAdditionalSearchPath(pybullet_data.getDataPath()) -p.loadURDF("plane.urdf") -p.setGravity(0, 0, -10) #setting environment gravity -carpos = [0, 0, 0.1] - -car = p.loadURDF("husky/husky.urdf", carpos[0], carpos[1], carpos[2]) - -numJoints = p.getNumJoints(car) #getting information of joints -for joint in range(numJoints): - print(p.getJointInfo(car, joint)[0:2]) - -a=0 -maxForce = 50 #Newton - -while (1): - keys = p.getKeyboardEvents() - - for k, v in keys.items(): - - if (v & p.KEY_IS_DOWN): - if (k == p.B3G_LEFT_ARROW ): - - targetVel = 1.51 - - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,force = 49.8) - - - - p.setJointMotorControl2(car,jointIndex=2,controlMode=p.TORQUE_CONTROL,force = -62.3-a) - p.setJointMotorControl2(car,jointIndex=3,controlMode=p.TORQUE_CONTROL,force = 62.3+a) - p.setJointMotorControl2(car,jointIndex=4,controlMode=p.TORQUE_CONTROL,force = -62.3-a) - p.setJointMotorControl2(car,jointIndex=5,controlMode=p.TORQUE_CONTROL,force = 62.3+a) - - p.stepSimulation() - if (k == p.B3G_RIGHT_ARROW ): - - targetVel = 1.51 - - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,force = 49.8) - - - p.setJointMotorControl2(car,jointIndex=2,controlMode=p.TORQUE_CONTROL,force = 62.3+ a) - p.setJointMotorControl2(car,jointIndex=3,controlMode=p.TORQUE_CONTROL,force = -62.3-a) - p.setJointMotorControl2(car,jointIndex=4,controlMode=p.TORQUE_CONTROL,force = 62.3+a) - p.setJointMotorControl2(car,jointIndex=5,controlMode=p.TORQUE_CONTROL,force = -62.3-a) - - p.stepSimulation() - - if (k == p.B3G_UP_ARROW ): - - - targetVel = -1.51 - a - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,targetVelocity = targetVel,force = maxForce) - - p.stepSimulation() - - if (k == p.B3G_DOWN_ARROW ): - targetVel = 1.51 + a - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,targetVelocity = targetVel,force = maxForce) - - p.stepSimulation() - - if (k == ord('r')): - - targetVel = 1.51 - - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,force = 49.8) - - - p.setJointMotorControl2(car,jointIndex=2,controlMode=p.TORQUE_CONTROL,force = 62.3) - p.setJointMotorControl2(car,jointIndex=3,controlMode=p.TORQUE_CONTROL,force = -62.3) - p.setJointMotorControl2(car,jointIndex=4,controlMode=p.TORQUE_CONTROL,force = 62.3) - p.setJointMotorControl2(car,jointIndex=5,controlMode=p.TORQUE_CONTROL,force = -62.3) - - p.stepSimulation() - - - - - if (v & p.KEY_WAS_RELEASED): - - targetVel = 0 - for joint in range(2, 6): - p.setJointMotorControl2(car, joint, p.VELOCITY_CONTROL,targetVelocity = targetVel,force = maxForce) - - p.stepSimulation() - - if (k == ord('a')): - if (v & p.KEY_WAS_RELEASED): - a=a+1 - - - -p.getContactPoints(car) -p.disconnect() diff --git a/Python/randomPassword.py b/Python/randomPassword.py deleted file mode 100644 index 6a7d14a0..00000000 --- a/Python/randomPassword.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python3 -#RamSalado | BeeHackers - -import random -k="abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#@!][}{?¿%&" -len = 12 -p="".join(random.sample(k,len)) -print(p) diff --git a/Stack.cpp b/Stack.cpp deleted file mode 100644 index d542965e..00000000 --- a/Stack.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -using namespace std; - -#define n 50 - -class stack{ - int* arr; - int top; - - public: - stack() - { - arr=new int[n]; - top=-1; - } - - void push(int x) - { - if(top==n-1) - { - cout<<" stack overflow "< - - - - - - Hacktoberfest - - - - - - - - - - - - - - - -
-
- - -
- -
-

DETAILS

-
-
-

  Open your first pull request for the Hacktoberfest 2021 challenge.


-

How to make your first pull request?



-
Step#1: Star this repo 🌟
-
Star this repo for hacktoberfest

-
Step#2: Show some love 😄
-

(Follow me on github - this motivates me to review & merge pull requests quicker.)

-
Step#3: Fork and clone the repository.

-
Step#4: Send in your valuable projects/code to this repository in order to complete it. Please make sure you are making a valid contribution to the open source.

-
Step#5: Add your files  git add -A .

-
Step#6 Commit your changes  git commit -m "commit message here" .

-
Step#7: Push to your fork  git push  and submit a pull request.

-
Step#8: Pat your self on the back and wait for your pull request to be reviewed and merged.


-

Are you a Software Developer💻?



-
This repo is open to contributions (in the form of questions) from Software Developers.


-

What is Hacktoberfest?



-
A month-long celebration from October 1st - 31st sponsored by Digital Ocean and GitHub to get people involved in Open Source. Create your very first pull request to any public repository on GitHub and contribute to the open source developer community.

-
-
Enjoy Coding and Keep contributing to open source.

-
(PS- Add your name to contributors.md in the format [ Your_Name ] (Your_Profile_Link))

-
Contribute some good codes, don't submit HelloWorld programs or your contribution will be marked as INVALID/SPAM.
-
-
-
- -
-

CONTRIBUTORS

- -
- -
-
-
-
-
-
Get connected with me on social networks!
-
-
- - - -
-
-
-
-
-
-
-
ABOUT
-
-

I'm a Student, Programmer and a Developer !!

-

👯 I’m looking to collaborate with other developers and programmers.

-

🥅 2021 Goals : Contribute more to Open Source projects

-

🌱 Interest : Robotics , Automation , Coding , Hackng ,Music and Table-Tennis

-
-
-
SOCIAL MEDIA
-
-

LinkedIn

-

Github

-

Instagram

-
-
-
Contact
-
-

Jaipur

-

shubhammenroy9672@gmail.com

-
-
-
- -
- -
- - - diff --git a/html/js/app.js b/html/js/app.js deleted file mode 100644 index 951f6735..00000000 --- a/html/js/app.js +++ /dev/null @@ -1,43 +0,0 @@ -const translate = document.querySelectorAll(".translate"); -const bigTitle = document.querySelector(".bigTitle"); -const header = document.querySelector("header"); -const section = document.querySelector("section"); - -let header_height = header.offsetHeight; -let section_height = section.offsetHeight; - -window.addEventListener('scroll', () => { - let scroll = window.pageYOffset; - let sectionY = section.getBoundingClientRect(); - - translate.forEach(element => { - let speed = element.dataset.speed; - element.style.transform = `translateY(${scroll * speed}px)`; - }); - - bigTitle.style.opacity = - scroll / (header_height / 2) + 1; -}); - -let mybutton = document.getElementById("btn-back-to-top"); - -window.onscroll = function () { - scrollFunction(); -}; - -function scrollFunction() { - if ( - document.body.scrollTop > 20 || - document.documentElement.scrollTop > 20 - ) { - mybutton.style.display = "block"; - } else { - mybutton.style.display = "none"; - } -} - -mybutton.addEventListener("click", backToTop); - -function backToTop() { - document.body.scrollTop = 0; - document.documentElement.scrollTop = 0; -} \ No newline at end of file diff --git a/html/js/parallax/LICENSE b/html/js/parallax/LICENSE deleted file mode 100644 index 084c6c5e..00000000 --- a/html/js/parallax/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 PixelCog Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/html/js/parallax/README.md b/html/js/parallax/README.md deleted file mode 100644 index 6e0f3c20..00000000 --- a/html/js/parallax/README.md +++ /dev/null @@ -1,242 +0,0 @@ -Parallax.js -=========== - -Simple parallax scrolling effect inspired by [Spotify.com](http://spotify.com/) implemented as a jQuery plugin -[http://pixelcog.com/parallax.js/](http://pixelcog.com/parallax.js/) - -## Installation - -### NPM - -```bash -npm i --save jquery-parallax.js -``` - -### Yarn - -```bash -yarn add jquery-parallax.js -``` - -### Bower - -Please note that although Bower is still maintained, they recommend Yarn for new projects. - -```bash -$ bower i --save parallax.js -``` - -### Setup - -Include `parallax.min.js` in your document after including jQuery (compatible with jQuery >= 1.7). - -```html - - -``` - -Use these CDN links, provided by jsDelivr.com -```html - - -``` - -## Usage - -Please note, that `` on top of your document is required! - -### Via data attributes - -To easily add a parallax effect behind an element, add `data-parallax="scroll"` to the element you want to use, and specify an image with `data-image-src="/path/to/image.jpg"`. - -```html -
-``` - -### Via JavaScript - -To call the parallax plugin manually, simply select your target element with jQuery and do the following: - -```javascript -$('.parallax-window').parallax({imageSrc: '/path/to/image.jpg'}); -``` - -### Notes - -What parallax.js will do is create a fixed-position element for each parallax image at the start of the document's body (or another configurable container). This mirror element will sit behind the other elements and match the position and dimensions of its target object. - -Due to the nature of this implementation, you must ensure that these parallax objects and any layers below them are transparent so that you can see the parallax effect underneath. Also, if there is no other content in this element, you will need to ensure that it has some fixed dimensions otherwise you won't see anything. - -```css -.parallax-window { - min-height: 400px; - background: transparent; -} -``` - -Also, keep in mind that once initialized, the parallax plugin presumes a fixed page layout unless it encounters a `scroll` or `resize` event. If you have a dynamic page in which another javascript method may alter the DOM, you must manually refresh the parallax effect with the following commands: - -```javascript -jQuery(window).trigger('resize').trigger('scroll'); -``` - -### Using inner HTML for complex content - -You can use the following syntax to enable complex content for the parallax: - -```html -
-
- Some Text -

Some other Content

-
-
-``` -Please note, that the div with class "parallax-slider" is essential here. - -You then need to initialize it through JS and provide the naturalWidth and naturalHeight options in order to be rendered correctly. - -``` -$('.parallax-window').parallax({ - naturalWidth: 600, - naturalHeight: 400 - }); -``` - -This also makes it possible to use responsive images in the slider: - -```html -
-
- -
-
-``` - -## Options - -Options can be passed in via data attributes of JavaScript. For data attributes, append the option name to `data-`, as in `data-image-src=""`. - -Note that when specifying these options as html data-attributes, you should convert "camelCased" variable names into "dash-separated" lower-case names (e.g. `zIndex` would be `data-z-index=""`). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Nametypedefaultdescription
imageSrcpathnullYou must provide a path to the image you wish to apply to the parallax effect.
naturalWidthnumberautoYou can provide the natural width and natural height of an image to speed up loading and reduce error when determining the correct aspect ratio of the image.
naturalHeightnumberauto
positionxPos yPoscenter centerThis is analogous to the background-position css property. Specify coordinates as top, bottom, right, left, center, or pixel values (e.g. -10px 0px). The parallax image will be positioned as close to these values as possible while still covering the target element.
positionXxPoscenter
positionYyPoscenter
speedfloat0.2The speed at which the parallax effect runs. 0.0 means the image will appear fixed in place, and 1.0 the image will flow at the same speed as the page content.
zIndexnumber-100The z-index value of the fixed-position elements. By default these will be behind everything else on the page.
bleednumber0You can optionally set the parallax mirror element to extend a few pixels above and below the mirrored element. This can hide slow or stuttering scroll events in certain browsers.
iosFixbooleantrueiOS devices are incompatable with this plugin. If true, this option will set the parallax image as a static, centered background image whenever it detects an iOS user agent. Disable this if you wish to implement your own graceful degradation.
androidFixbooleantrueIf true, this option will set the parallax image as a static, centered background image whenever it detects an Android user agent. Disable this if you wish to enable the parallax scrolling effect on Android devices.
overScrollFixbooleanfalse(Experimental) If true, will freeze the parallax effect when "over scrolling" in browsers like Safari to prevent unexpected gaps caused by negative scroll positions.
mirrorContainerjQuery SelectorbodyThe parallax mirror will be prepended into this container.
- -## Contributing - -If you have a pull request you would like to submit, please ensure that you update the minified version of the library along with your code changes. This project uses [uglifyjs](https://www.npmjs.com/package/uglify-js) to perform code compression. - -Please use the following command: - - uglifyjs parallax.js --comments -m -c -o parallax.min.js - - -LICENSE -======= - -The MIT License (MIT) - -Copyright (c) 2016 PixelCog Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/html/js/parallax/bower.json b/html/js/parallax/bower.json deleted file mode 100644 index 09add3dc..00000000 --- a/html/js/parallax/bower.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "parallax.js", - "version": "1.5.0", - "homepage": "http://pixelcog.com/parallax.js/", - "description": "Simple parallax scrolling effect inspired by spotify.com implemented as a jQuery plugin", - "authors": [ - "Mike Greiling (http://pixelcog.com)", - "Wolfgang Stöttinger (http://www.wolfography.at)" - ], - "main": "parallax.min.js", - "license": "MIT", - "keywords" : ["parallax", "scroll", "scrolling", "image"], - "ignore": [ - ".jshintrc", - "**/*.txt" - ], - "dependencies": { - "jquery": ">=1.7" - } -} diff --git a/html/js/parallax/package.json b/html/js/parallax/package.json deleted file mode 100644 index b03aa4ff..00000000 --- a/html/js/parallax/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "jquery-parallax.js", - "version": "1.5.0", - "description": "Simple parallax scrolling effect inspired by spotify.com implemented as a jQuery plugin", - "main": "parallax.min.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/pixelcog/parallax.js.git" - }, - "keywords": [ - "parallax", - "scroll", - "scrolling", - "image" - ], - "author": [ - "Mike Greiling (http://pixelcog.com)", - "Wolfgang Stöttinger (http://www.wolfography.at)" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/pixelcog/parallax.js/issues" - }, - "homepage": "https://github.com/pixelcog/parallax.js#readme", - "dependencies": { - "jquery": ">=1.7" - } -} diff --git a/html/js/parallax/parallax.js b/html/js/parallax/parallax.js deleted file mode 100644 index 5d7a97c2..00000000 --- a/html/js/parallax/parallax.js +++ /dev/null @@ -1,412 +0,0 @@ -/*! - * parallax.js v1.5.0 (http://pixelcog.github.io/parallax.js/) - * @copyright 2016 PixelCog, Inc. - * @license MIT (https://github.com/pixelcog/parallax.js/blob/master/LICENSE) - */ - -;(function ( $, window, document, undefined ) { - - // Polyfill for requestAnimationFrame - // via: https://gist.github.com/paulirish/1579671 - - (function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - }()); - - - // Parallax Constructor - - function Parallax(element, options) { - var self = this; - - if (typeof options == 'object') { - delete options.refresh; - delete options.render; - $.extend(this, options); - } - - this.$element = $(element); - - if (!this.imageSrc && this.$element.is('img')) { - this.imageSrc = this.$element.attr('src'); - } - - var positions = (this.position + '').toLowerCase().match(/\S+/g) || []; - - if (positions.length < 1) { - positions.push('center'); - } - if (positions.length == 1) { - positions.push(positions[0]); - } - - if (positions[0] == 'top' || positions[0] == 'bottom' || positions[1] == 'left' || positions[1] == 'right') { - positions = [positions[1], positions[0]]; - } - - if (this.positionX !== undefined) positions[0] = this.positionX.toLowerCase(); - if (this.positionY !== undefined) positions[1] = this.positionY.toLowerCase(); - - self.positionX = positions[0]; - self.positionY = positions[1]; - - if (this.positionX != 'left' && this.positionX != 'right') { - if (isNaN(parseInt(this.positionX))) { - this.positionX = 'center'; - } else { - this.positionX = parseInt(this.positionX); - } - } - - if (this.positionY != 'top' && this.positionY != 'bottom') { - if (isNaN(parseInt(this.positionY))) { - this.positionY = 'center'; - } else { - this.positionY = parseInt(this.positionY); - } - } - - this.position = - this.positionX + (isNaN(this.positionX)? '' : 'px') + ' ' + - this.positionY + (isNaN(this.positionY)? '' : 'px'); - - if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { - if (this.imageSrc && this.iosFix && !this.$element.is('img')) { - this.$element.css({ - backgroundImage: 'url(' + this.imageSrc + ')', - backgroundSize: 'cover', - backgroundPosition: this.position - }); - } - return this; - } - - if (navigator.userAgent.match(/(Android)/)) { - if (this.imageSrc && this.androidFix && !this.$element.is('img')) { - this.$element.css({ - backgroundImage: 'url(' + this.imageSrc + ')', - backgroundSize: 'cover', - backgroundPosition: this.position - }); - } - return this; - } - - this.$mirror = $('
').prependTo(this.mirrorContainer); - - var slider = this.$element.find('>.parallax-slider'); - var sliderExisted = false; - - if (slider.length == 0) - this.$slider = $('').prependTo(this.$mirror); - else { - this.$slider = slider.prependTo(this.$mirror) - sliderExisted = true; - } - - this.$mirror.addClass('parallax-mirror').css({ - visibility: 'hidden', - zIndex: this.zIndex, - position: 'fixed', - top: 0, - left: 0, - overflow: 'hidden' - }); - - this.$slider.addClass('parallax-slider').one('load', function() { - if (!self.naturalHeight || !self.naturalWidth) { - self.naturalHeight = this.naturalHeight || this.height || 1; - self.naturalWidth = this.naturalWidth || this.width || 1; - } - self.aspectRatio = self.naturalWidth / self.naturalHeight; - - Parallax.isSetup || Parallax.setup(); - Parallax.sliders.push(self); - Parallax.isFresh = false; - Parallax.requestRender(); - }); - - if (!sliderExisted) - this.$slider[0].src = this.imageSrc; - - if (this.naturalHeight && this.naturalWidth || this.$slider[0].complete || slider.length > 0) { - this.$slider.trigger('load'); - } - - } - - - // Parallax Instance Methods - - $.extend(Parallax.prototype, { - speed: 0.2, - bleed: 0, - zIndex: -100, - iosFix: true, - androidFix: true, - position: 'center', - overScrollFix: false, - mirrorContainer: 'body', - - refresh: function() { - this.boxWidth = this.$element.outerWidth(); - this.boxHeight = this.$element.outerHeight() + this.bleed * 2; - this.boxOffsetTop = this.$element.offset().top - this.bleed; - this.boxOffsetLeft = this.$element.offset().left; - this.boxOffsetBottom = this.boxOffsetTop + this.boxHeight; - - var winHeight = Parallax.winHeight; - var docHeight = Parallax.docHeight; - var maxOffset = Math.min(this.boxOffsetTop, docHeight - winHeight); - var minOffset = Math.max(this.boxOffsetTop + this.boxHeight - winHeight, 0); - var imageHeightMin = this.boxHeight + (maxOffset - minOffset) * (1 - this.speed) | 0; - var imageOffsetMin = (this.boxOffsetTop - maxOffset) * (1 - this.speed) | 0; - var margin; - - if (imageHeightMin * this.aspectRatio >= this.boxWidth) { - this.imageWidth = imageHeightMin * this.aspectRatio | 0; - this.imageHeight = imageHeightMin; - this.offsetBaseTop = imageOffsetMin; - - margin = this.imageWidth - this.boxWidth; - - if (this.positionX == 'left') { - this.offsetLeft = 0; - } else if (this.positionX == 'right') { - this.offsetLeft = - margin; - } else if (!isNaN(this.positionX)) { - this.offsetLeft = Math.max(this.positionX, - margin); - } else { - this.offsetLeft = - margin / 2 | 0; - } - } else { - this.imageWidth = this.boxWidth; - this.imageHeight = this.boxWidth / this.aspectRatio | 0; - this.offsetLeft = 0; - - margin = this.imageHeight - imageHeightMin; - - if (this.positionY == 'top') { - this.offsetBaseTop = imageOffsetMin; - } else if (this.positionY == 'bottom') { - this.offsetBaseTop = imageOffsetMin - margin; - } else if (!isNaN(this.positionY)) { - this.offsetBaseTop = imageOffsetMin + Math.max(this.positionY, - margin); - } else { - this.offsetBaseTop = imageOffsetMin - margin / 2 | 0; - } - } - }, - - render: function() { - var scrollTop = Parallax.scrollTop; - var scrollLeft = Parallax.scrollLeft; - var overScroll = this.overScrollFix ? Parallax.overScroll : 0; - var scrollBottom = scrollTop + Parallax.winHeight; - - if (this.boxOffsetBottom > scrollTop && this.boxOffsetTop <= scrollBottom) { - this.visibility = 'visible'; - this.mirrorTop = this.boxOffsetTop - scrollTop; - this.mirrorLeft = this.boxOffsetLeft - scrollLeft; - this.offsetTop = this.offsetBaseTop - this.mirrorTop * (1 - this.speed); - } else { - this.visibility = 'hidden'; - } - - this.$mirror.css({ - transform: 'translate3d('+this.mirrorLeft+'px, '+(this.mirrorTop - overScroll)+'px, 0px)', - visibility: this.visibility, - height: this.boxHeight, - width: this.boxWidth - }); - - this.$slider.css({ - transform: 'translate3d('+this.offsetLeft+'px, '+this.offsetTop+'px, 0px)', - position: 'absolute', - height: this.imageHeight, - width: this.imageWidth, - maxWidth: 'none' - }); - } - }); - - - // Parallax Static Methods - - $.extend(Parallax, { - scrollTop: 0, - scrollLeft: 0, - winHeight: 0, - winWidth: 0, - docHeight: 1 << 30, - docWidth: 1 << 30, - sliders: [], - isReady: false, - isFresh: false, - isBusy: false, - - setup: function() { - if (this.isReady) return; - - var self = this; - - var $doc = $(document), $win = $(window); - - var loadDimensions = function() { - Parallax.winHeight = $win.height(); - Parallax.winWidth = $win.width(); - Parallax.docHeight = $doc.height(); - Parallax.docWidth = $doc.width(); - }; - - var loadScrollPosition = function() { - var winScrollTop = $win.scrollTop(); - var scrollTopMax = Parallax.docHeight - Parallax.winHeight; - var scrollLeftMax = Parallax.docWidth - Parallax.winWidth; - Parallax.scrollTop = Math.max(0, Math.min(scrollTopMax, winScrollTop)); - Parallax.scrollLeft = Math.max(0, Math.min(scrollLeftMax, $win.scrollLeft())); - Parallax.overScroll = Math.max(winScrollTop - scrollTopMax, Math.min(winScrollTop, 0)); - }; - - $win.on('resize.px.parallax load.px.parallax', function() { - loadDimensions(); - self.refresh(); - Parallax.isFresh = false; - Parallax.requestRender(); - }) - .on('scroll.px.parallax load.px.parallax', function() { - loadScrollPosition(); - Parallax.requestRender(); - }); - - loadDimensions(); - loadScrollPosition(); - - this.isReady = true; - - var lastPosition = -1; - - function frameLoop() { - if (lastPosition == window.pageYOffset) { // Avoid overcalculations - window.requestAnimationFrame(frameLoop); - return false; - } else lastPosition = window.pageYOffset; - - self.render(); - window.requestAnimationFrame(frameLoop); - } - - frameLoop(); - }, - - configure: function(options) { - if (typeof options == 'object') { - delete options.refresh; - delete options.render; - $.extend(this.prototype, options); - } - }, - - refresh: function() { - $.each(this.sliders, function(){ this.refresh(); }); - this.isFresh = true; - }, - - render: function() { - this.isFresh || this.refresh(); - $.each(this.sliders, function(){ this.render(); }); - }, - - requestRender: function() { - var self = this; - self.render(); - self.isBusy = false; - }, - destroy: function(el){ - var i, - parallaxElement = $(el).data('px.parallax'); - parallaxElement.$mirror.remove(); - for(i=0; i < this.sliders.length; i+=1){ - if(this.sliders[i] == parallaxElement){ - this.sliders.splice(i, 1); - } - } - $(el).data('px.parallax', false); - if(this.sliders.length === 0){ - $(window).off('scroll.px.parallax resize.px.parallax load.px.parallax'); - this.isReady = false; - Parallax.isSetup = false; - } - } - }); - - - // Parallax Plugin Definition - - function Plugin(option) { - return this.each(function () { - var $this = $(this); - var options = typeof option == 'object' && option; - - if (this == window || this == document || $this.is('body')) { - Parallax.configure(options); - } - else if (!$this.data('px.parallax')) { - options = $.extend({}, $this.data(), options); - $this.data('px.parallax', new Parallax(this, options)); - } - else if (typeof option == 'object') - { - $.extend($this.data('px.parallax'), options); - } - if (typeof option == 'string') { - if(option == 'destroy'){ - Parallax.destroy(this); - }else{ - Parallax[option](); - } - } - }); - } - - var old = $.fn.parallax; - - $.fn.parallax = Plugin; - $.fn.parallax.Constructor = Parallax; - - - // Parallax No Conflict - - $.fn.parallax.noConflict = function () { - $.fn.parallax = old; - return this; - }; - - - // Parallax Data-API - - $( function () { - $('[data-parallax="scroll"]').parallax(); - }); - -}(jQuery, window, document)); diff --git a/html/js/parallax/parallax.min.js b/html/js/parallax/parallax.min.js deleted file mode 100644 index 8d85c99a..00000000 --- a/html/js/parallax/parallax.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * parallax.js v1.5.0 (http://pixelcog.github.io/parallax.js/) - * @copyright 2016 PixelCog, Inc. - * @license MIT (https://github.com/pixelcog/parallax.js/blob/master/LICENSE) - */ -!function(t,i,e,s){function o(i,e){var h=this;"object"==typeof e&&(delete e.refresh,delete e.render,t.extend(this,e)),this.$element=t(i),!this.imageSrc&&this.$element.is("img")&&(this.imageSrc=this.$element.attr("src"));var r=(this.position+"").toLowerCase().match(/\S+/g)||[];if(r.length<1&&r.push("center"),1==r.length&&r.push(r[0]),"top"!=r[0]&&"bottom"!=r[0]&&"left"!=r[1]&&"right"!=r[1]||(r=[r[1],r[0]]),this.positionX!==s&&(r[0]=this.positionX.toLowerCase()),this.positionY!==s&&(r[1]=this.positionY.toLowerCase()),h.positionX=r[0],h.positionY=r[1],"left"!=this.positionX&&"right"!=this.positionX&&(isNaN(parseInt(this.positionX))?this.positionX="center":this.positionX=parseInt(this.positionX)),"top"!=this.positionY&&"bottom"!=this.positionY&&(isNaN(parseInt(this.positionY))?this.positionY="center":this.positionY=parseInt(this.positionY)),this.position=this.positionX+(isNaN(this.positionX)?"":"px")+" "+this.positionY+(isNaN(this.positionY)?"":"px"),navigator.userAgent.match(/(iPod|iPhone|iPad)/))return this.imageSrc&&this.iosFix&&!this.$element.is("img")&&this.$element.css({backgroundImage:"url("+this.imageSrc+")",backgroundSize:"cover",backgroundPosition:this.position}),this;if(navigator.userAgent.match(/(Android)/))return this.imageSrc&&this.androidFix&&!this.$element.is("img")&&this.$element.css({backgroundImage:"url("+this.imageSrc+")",backgroundSize:"cover",backgroundPosition:this.position}),this;this.$mirror=t("
").prependTo(this.mirrorContainer);var a=this.$element.find(">.parallax-slider"),n=!1;0==a.length?this.$slider=t("").prependTo(this.$mirror):(this.$slider=a.prependTo(this.$mirror),n=!0),this.$mirror.addClass("parallax-mirror").css({visibility:"hidden",zIndex:this.zIndex,position:"fixed",top:0,left:0,overflow:"hidden"}),this.$slider.addClass("parallax-slider").one("load",function(){h.naturalHeight&&h.naturalWidth||(h.naturalHeight=this.naturalHeight||this.height||1,h.naturalWidth=this.naturalWidth||this.width||1),h.aspectRatio=h.naturalWidth/h.naturalHeight,o.isSetup||o.setup(),o.sliders.push(h),o.isFresh=!1,o.requestRender()}),n||(this.$slider[0].src=this.imageSrc),(this.naturalHeight&&this.naturalWidth||this.$slider[0].complete||a.length>0)&&this.$slider.trigger("load")}!function(){for(var t=0,e=["ms","moz","webkit","o"],s=0;s=this.boxWidth?(this.imageWidth=r*this.aspectRatio|0,this.imageHeight=r,this.offsetBaseTop=a,t=this.imageWidth-this.boxWidth,"left"==this.positionX?this.offsetLeft=0:"right"==this.positionX?this.offsetLeft=-t:isNaN(this.positionX)?this.offsetLeft=-t/2|0:this.offsetLeft=Math.max(this.positionX,-t)):(this.imageWidth=this.boxWidth,this.imageHeight=this.boxWidth/this.aspectRatio|0,this.offsetLeft=0,t=this.imageHeight-r,"top"==this.positionY?this.offsetBaseTop=a:"bottom"==this.positionY?this.offsetBaseTop=a-t:isNaN(this.positionY)?this.offsetBaseTop=a-t/2|0:this.offsetBaseTop=a+Math.max(this.positionY,-t))},render:function(){var t=o.scrollTop,i=o.scrollLeft,e=this.overScrollFix?o.overScroll:0,s=t+o.winHeight;this.boxOffsetBottom>t&&this.boxOffsetTop<=s?(this.visibility="visible",this.mirrorTop=this.boxOffsetTop-t,this.mirrorLeft=this.boxOffsetLeft-i,this.offsetTop=this.offsetBaseTop-this.mirrorTop*(1-this.speed)):this.visibility="hidden",this.$mirror.css({transform:"translate3d("+this.mirrorLeft+"px, "+(this.mirrorTop-e)+"px, 0px)",visibility:this.visibility,height:this.boxHeight,width:this.boxWidth}),this.$slider.css({transform:"translate3d("+this.offsetLeft+"px, "+this.offsetTop+"px, 0px)",position:"absolute",height:this.imageHeight,width:this.imageWidth,maxWidth:"none"})}}),t.extend(o,{scrollTop:0,scrollLeft:0,winHeight:0,winWidth:0,docHeight:1<<30,docWidth:1<<30,sliders:[],isReady:!1,isFresh:!1,isBusy:!1,setup:function(){function s(){if(p==i.pageYOffset)return i.requestAnimationFrame(s),!1;p=i.pageYOffset,h.render(),i.requestAnimationFrame(s)}if(!this.isReady){var h=this,r=t(e),a=t(i),n=function(){o.winHeight=a.height(),o.winWidth=a.width(),o.docHeight=r.height(),o.docWidth=r.width()},l=function(){var t=a.scrollTop(),i=o.docHeight-o.winHeight,e=o.docWidth-o.winWidth;o.scrollTop=Math.max(0,Math.min(i,t)),o.scrollLeft=Math.max(0,Math.min(e,a.scrollLeft())),o.overScroll=Math.max(t-i,Math.min(t,0))};a.on("resize.px.parallax load.px.parallax",function(){n(),h.refresh(),o.isFresh=!1,o.requestRender()}).on("scroll.px.parallax load.px.parallax",function(){l(),o.requestRender()}),n(),l(),this.isReady=!0;var p=-1;s()}},configure:function(i){"object"==typeof i&&(delete i.refresh,delete i.render,t.extend(this.prototype,i))},refresh:function(){t.each(this.sliders,function(){this.refresh()}),this.isFresh=!0},render:function(){this.isFresh||this.refresh(),t.each(this.sliders,function(){this.render()})},requestRender:function(){var t=this;t.render(),t.isBusy=!1},destroy:function(e){var s,h=t(e).data("px.parallax");for(h.$mirror.remove(),s=0;s - - - - - Page Redirection - - - If you are not redirected automatically, - follow the link to the documentation - - diff --git a/octocat.png b/octocat.png deleted file mode 100644 index f9050b93..00000000 Binary files a/octocat.png and /dev/null differ diff --git a/queue.cpp b/queue.cpp deleted file mode 100644 index 4a622dc9..00000000 --- a/queue.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -using namespace std; - -struct Queue { - int front, rear, capacity; - int* queue; - Queue(int c) - { - front = rear = 0; - capacity = c; - queue = new int; - } - - // function to insert an element - // at the rear of the queue - void queueEnqueue(int data) - { - // check queue is full or not - if (capacity == rear) { - printf("\nQueue is full\n"); - return; - } - - // insert element at the rear - else { - queue[rear] = data; - rear++; - } - return; - } - - // function to delete an element - // from the front of the queue - void queueDequeue() - { - // if queue is empty - if (front == rear) { - printf("\nQueue is empty\n"); - return; - } - - // shift all the elements from index 2 till rear - // to the left by one - else { - for (int i = 0; i < rear - 1; i++) { - queue[i] = queue[i + 1]; - } - - // decrement rear - rear--; - } - return; - } - - // print queue elements - void queueDisplay() - { - int i; - if (front == rear) { - printf("\nQueue is Empty\n"); - return; - } - - // traverse front to rear and print elements - for (i = front; i < rear; i++) { - printf(" %d <-- ", queue[i]); - } - return; - } - - // print front of queue - void queueFront() - { - if (front == rear) { - printf("\nQueue is Empty\n"); - return; - } - printf("\nFront Element is: %d", queue[front]); - return; - } -}; - -// Driver code -int main(void) -{ - // Create a queue of capacity 4 - Queue q(4); - - // inserting elements in the queue - q.queueEnqueue(1); - q.queueEnqueue(2); - q.queueEnqueue(3); - q.queueEnqueue(4); - - // print Queue elements - q.queueDisplay(); - - // insert element in the queue - q.queueEnqueue(5); - - // delete element from front of queue - q.queueDequeue(); - - // print front of the queue - q.queueFront(); - - return 0; -}