├── howdy.py ├── .mypy_cache └── 3.8 │ ├── @plugins_snapshot.json │ ├── sudoko.data.json │ ├── leap_year.data.json │ ├── sudoko.meta.json │ ├── Kruskal.meta.json │ ├── Nqueens.meta.json │ ├── abc.meta.json │ ├── sudoku.meta.json │ ├── leap_year.meta.json │ ├── AddTwoIntegers.meta.json │ ├── prim.meta.json │ ├── Matrix_Transpose.meta.json │ ├── _ast.meta.json │ ├── mmap.meta.json │ ├── ast.meta.json │ ├── AddTwoIntegers.data.json │ ├── posix.meta.json │ ├── os │ ├── path.meta.json │ └── __init__.meta.json │ ├── builtins.meta.json │ ├── codecs.meta.json │ ├── typing.meta.json │ ├── _importlib_modulespec.meta.json │ ├── types.meta.json │ ├── _thread.meta.json │ ├── importlib │ ├── __init__.meta.json │ ├── abc.meta.json │ └── __init__.data.json │ ├── io.meta.json │ ├── queue.meta.json │ ├── collections │ ├── abc.meta.json │ ├── __init__.meta.json │ └── abc.data.json │ ├── threading.meta.json │ ├── sys.meta.json │ ├── Nqueens.data.json │ ├── Matrix_Transpose.data.json │ ├── sudoku.data.json │ ├── Kruskal.data.json │ └── prim.data.json ├── PYTHON ├── hello_world.py ├── CoverDistance.py ├── AddTwoIntegers.py ├── ascii.py ├── README.md ├── sum of array ├── palindrome.py ├── Factorial.py ├── ArmstrongNo.py ├── leap_year.py ├── Matrix_Transpose.py ├── StrongNumber.py ├── largest element in array ├── gcd.cpp ├── LIS.py ├── Distance.py ├── min_coins.py ├── Ways_to_Cover_a_Distance.py ├── Transpose_Matrix.py ├── max_pairwise_product.py ├── LCS.py ├── edit_distance.py ├── minimumCoin.py ├── Minimum_Partition.py ├── mysql-python.py ├── Prim's.py ├── BFS.py ├── Nqueens.py ├── sudoku.py ├── Kruskal.py └── prim.py ├── JAVA ├── Main.class ├── EditDistance.java ├── README.md ├── LongestIncreasingSubsequence.class ├── out │ └── production │ │ └── Project-alpha │ │ ├── BFS.class │ │ ├── Node.class │ │ ├── Graph.class │ │ ├── README.md │ │ ├── Factorial.class │ │ ├── TreeNode.class │ │ ├── HelloWorld.class │ │ ├── AddTwoIntegers.class │ │ ├── CheckLeapYear.class │ │ ├── ASCIIofCharacter.class │ │ ├── DepthFirstSearch.class │ │ ├── MatrixTranspose.class │ │ ├── MinimumPartition.class │ │ ├── PalindromeNumber.class │ │ ├── WaysToCoverDistance.class │ │ ├── tempPack │ │ └── hacktober.class │ │ ├── DjikstraShortestPathFromSource.class │ │ ├── .idea │ │ ├── vcs.xml │ │ ├── .gitignore │ │ ├── misc.xml │ │ ├── JAVA.iml │ │ └── modules.xml │ │ └── Project-alpha.iml ├── HelloWorld.java ├── .idea │ ├── vcs.xml │ ├── .gitignore │ ├── misc.xml │ ├── JAVA.iml │ └── modules.xml ├── ASCIIofCharacter.java ├── AddTwoIntegers.java ├── Factorial.java ├── Project-alpha.iml ├── MatrixTransposition │ ├── MatrixTransposition.java │ └── Main.java ├── WaysToCoverDistance.java ├── MinimumPartition.java ├── PalindromeNumber.java ├── CheckLeapYear.java ├── MatrixTranspose.java ├── LCS.java ├── RootsOfQuadraticEquation.java ├── MergeSort.java ├── LongestIncreasingSubsequence.java ├── DepthFirstSearch.java ├── TransposeMatrix.java ├── BFS.java ├── MinimumSpanningTree.java └── DjikstraShortestPathFromSource.java ├── C ├── hello_world.c ├── README.md ├── Ways_to_cover_distance.c ├── squaring up using arrays from 1 to 10.c ├── AddTwoIntegers.c ├── LeapYear.c ├── factorial.c ├── calculator switch case.c ├── array insertionAtPosnAndBeginning.c ├── GuessingGame.c ├── longest_common_subsequence.c ├── MinimumSpanningTree-Prim-InC.c ├── Calender.c └── dijkstra.c ├── CPP ├── README.md ├── hello_world.cpp ├── CharacterToASCII.cpp ├── Find ASCII Value of a Character C ├── add_two_integers.cpp ├── Multiplication table.cpp ├── leap_year_cpp.cpp ├── recusion.cpp ├── Calculator.cpp ├── Factorial of number using recursion.cpp ├── largestNumber.cpp ├── fact.cpp ├── simpleCalculator.cpp ├── palindrome.cpp ├── RotateImage90Degree.cpp ├── sort-elements-in-lexicographical-order.cpp ├── largest_element_in_array.cpp ├── ways_to_cover_distance.cpp ├── factorial.cpp ├── Factorial.cpp ├── sorting in dictionary order ├── transpose_matrix.cpp ├── Calculator.hpp ├── transpose.cpp ├── frequency of characters in string in C++ ├── Matrix_Transpose.cpp ├── store student info in structure ├── longest_common_subsequence.cpp ├── factorial_recursive.cpp ├── edit-distance.c ├── longest_increasing_subsequence.cpp ├── Roots of a Quadratic Equation.cpp ├── countingSort.cpp ├── Mergesort.cpp ├── minimum_partition.cpp ├── breadth_first_search.cpp ├── rotate_image.cpp ├── Dijkstra.cpp ├── edit_Dist.cpp ├── MinimumSpanningTree.cpp └── matrixoperationusing2d.cpp ├── .idea ├── misc.xml ├── vcs.xml ├── .gitignore ├── inspectionProfiles │ └── profiles_settings.xml ├── modules.xml └── Project-alpha.iml ├── factorial.py ├── factorial.cpp ├── sum using recursion in C++ ├── .github └── workflows │ ├── greetings.yml │ └── label.yml ├── transpose_of_matrix.c ├── .all-contributorsrc ├── LICENSE ├── bfs.c └── README.md /howdy.py: -------------------------------------------------------------------------------- 1 | print("howdy") -------------------------------------------------------------------------------- /.mypy_cache/3.8/@plugins_snapshot.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /PYTHON/hello_world.py: -------------------------------------------------------------------------------- 1 | print("Hello World!") -------------------------------------------------------------------------------- /PYTHON/CoverDistance.py: -------------------------------------------------------------------------------- 1 | def distance(): 2 | pass -------------------------------------------------------------------------------- /PYTHON/AddTwoIntegers.py: -------------------------------------------------------------------------------- 1 | a=10 2 | b=20 3 | sum=a+b 4 | print("sum: ", sum) -------------------------------------------------------------------------------- /JAVA/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/Main.class -------------------------------------------------------------------------------- /JAVA/EditDistance.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/EditDistance.java -------------------------------------------------------------------------------- /C/hello_world.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | prinf("Hello World!"); 4 | return 0; 5 | } -------------------------------------------------------------------------------- /CPP/README.md: -------------------------------------------------------------------------------- 1 | # CPP Programs 2 | 3 | -------------------------------------------------------------------------------- /PYTHON/ascii.py: -------------------------------------------------------------------------------- 1 | c = input("Enter the character ") 2 | 3 | print("The ASCII value of '" + c + "' is", ord(c)) 4 | -------------------------------------------------------------------------------- /JAVA/README.md: -------------------------------------------------------------------------------- 1 | # Java Programs 2 | 3 | -------------------------------------------------------------------------------- /JAVA/LongestIncreasingSubsequence.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/LongestIncreasingSubsequence.class -------------------------------------------------------------------------------- /C/README.md: -------------------------------------------------------------------------------- 1 | # C Programs 2 | 3 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/BFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/BFS.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/Node.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/Graph.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/Graph.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/README.md: -------------------------------------------------------------------------------- 1 | # Java Programs 2 | 3 | -------------------------------------------------------------------------------- /JAVA/HelloWorld.java: -------------------------------------------------------------------------------- 1 | class HelloWorld { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/Factorial.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/Factorial.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/TreeNode.class -------------------------------------------------------------------------------- /CPP/hello_world.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main(){ 5 | cout<<"Hello World!"; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/HelloWorld.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/HelloWorld.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/AddTwoIntegers.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/AddTwoIntegers.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/CheckLeapYear.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/CheckLeapYear.class -------------------------------------------------------------------------------- /PYTHON/README.md: -------------------------------------------------------------------------------- 1 | # Python Programs 2 | 3 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/ASCIIofCharacter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/ASCIIofCharacter.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/DepthFirstSearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/DepthFirstSearch.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/MatrixTranspose.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/MatrixTranspose.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/MinimumPartition.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/MinimumPartition.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/PalindromeNumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/PalindromeNumber.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/WaysToCoverDistance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/WaysToCoverDistance.class -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/tempPack/hacktober.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/tempPack/hacktober.class -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/DjikstraShortestPathFromSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniket762/Project-alpha/HEAD/JAVA/out/production/Project-alpha/DjikstraShortestPathFromSource.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PYTHON/sum of array: -------------------------------------------------------------------------------- 1 | 2 | def _sum(arr,n): 3 | return(sum(arr)) 4 | 5 | 6 | arr=[] 7 | arr = [12, 3, 4, 15] 8 | n = len(arr) 9 | ans = _sum(arr,n) 10 | print ('Sum of the array is ', ans) 11 | 12 | -------------------------------------------------------------------------------- /JAVA/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /factorial.py: -------------------------------------------------------------------------------- 1 | def factorial(n): 2 | if n<=1: 3 | return 1 4 | else: 5 | return n*factorial(n-1) 6 | 7 | n=int(input("Enter thr number :")) 8 | print("Factorial of", n ,"is :",factorial(n)) 9 | -------------------------------------------------------------------------------- /JAVA/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /CPP/CharacterToASCII.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | char c; 7 | cout << "Enter a character: "; 8 | cin >> c; 9 | cout << "ASCII Value of " << c << " is " << int(c); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /JAVA/ASCIIofCharacter.java: -------------------------------------------------------------------------------- 1 | public class ASCIIofCharacter 2 | { 3 | public static void main(String[] args) { 4 | char ch = 'A'; 5 | int ascii = ch; 6 | System.out.println("The ASCII value of " + ch + " is: " + ascii); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /C/Ways_to_cover_distance.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() 3 | { 4 | int n; 5 | printf("enter n: "); 6 | scanf("%d",&n); 7 | int steps=(n*(n-1)/2)+1; 8 | printf("steps: %d",steps); 9 | } 10 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /CPP/Find ASCII Value of a Character C: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | char c; 7 | cout << "Enter a character: "; 8 | cin >> c; 9 | cout << "ASCII Value of " << c << " is " << int(c); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /CPP/add_two_integers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | int x,y; 5 | cout<<"Enter first integer:"; 6 | cin>>x; 7 | cout<<"Enter second integer:"; 8 | cin>>y; 9 | cout<<"Result: "<0): 5 | dig=n%10 6 | rev=rev*10+dig 7 | n=n//10 8 | if(temp==rev): 9 | print("The number is a palindrome!") 10 | else: 11 | print("The number isn't a palindrome!") 12 | -------------------------------------------------------------------------------- /JAVA/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PYTHON/Factorial.py: -------------------------------------------------------------------------------- 1 | def factorial(n): 2 | fact = 1 3 | for i in range(1, n + 1): 4 | fact = fact * i 5 | return fact 6 | 7 | 8 | def main(): 9 | number = 6 10 | print(factorial(number)) 11 | 12 | 13 | if __name__ == "__main__": 14 | main() 15 | 16 | -------------------------------------------------------------------------------- /PYTHON/ArmstrongNo.py: -------------------------------------------------------------------------------- 1 | #program to check if a number is an Armstong Number 2 | n=int(input("Enter any number:")) 3 | a=list(map(int,str(n))) 4 | b=list(map(lambda x:x**3,a)) 5 | if(sum(b)==n): 6 | print("The number is an Armstrong Number.") 7 | else: 8 | print("The number isn't an Armstrong Number.") 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/Project-alpha.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CPP/Multiplication table.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | 8 | cout << "Enter a positive integer: "; 9 | cin >> n; 10 | 11 | for (int i = 1; i <= 10; ++i) 12 | { 13 | cout << n << " * " << i << " = " << n * i << endl; 14 | } 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CPP/leap_year_cpp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int year; 6 | cout<<"Enter the year you want to check: "; 7 | cin>> year; 8 | if( year%4 == 0) 9 | cout<< year<<" is leap year"<< endl; 10 | else 11 | cout<< year <<" is not a leap year"<< endl; 12 | } -------------------------------------------------------------------------------- /JAVA/AddTwoIntegers.java: -------------------------------------------------------------------------------- 1 | public class AddTwoIntegers 2 | { 3 | public static void main(String[] args) { 4 | int first = 10; 5 | int second = 20; 6 | 7 | System.out.println("Two numbers: " + first + " " + second); 8 | int sum = first + second; 9 | 10 | System.out.println("The sum is: " + sum); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /C/squaring up using arrays from 1 to 10.c: -------------------------------------------------------------------------------- 1 | //Squaring up the values of no.s from 1 to 10 2 | #include 3 | int main(void){ 4 | int array_values[10]={0,1,4,9,16}; 5 | int x; 6 | for(x=5;x<10;++x) 7 | array_values[x]=x*x; 8 | for(x=0;x<10;++x){ 9 | printf("array_values[%d]=%d\n",x,array_values[x]); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /PYTHON/leap_year.py: -------------------------------------------------------------------------------- 1 | # A leap year satisfies either of the following conditions : 2 | # 1. Year is multiple of 400. 3 | # 2. Year is multiple of 4 and not multiple of 100. 4 | 5 | year = int(input("Enter the year ")) 6 | if (year % 400) == 0 or (year % 4 == 0 and year % 100 != 0): 7 | print("Leap year") 8 | else: 9 | print("Not a leap year") 10 | -------------------------------------------------------------------------------- /C/AddTwoIntegers.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | int number1, number2, sum; 5 | 6 | printf("Enter two integers: "); 7 | scanf("%d %d", &number1, &number2); 8 | 9 | // calculating sum 10 | sum = number1 + number2; 11 | 12 | printf("%d + %d = %d", number1, number2, sum); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | unsigned int factorial(unsigned int n){ 5 | if(n<=1)return 1; 6 | else return n*factorial(n-1); 7 | } 8 | int main(){ 9 | unsigned int n=0; 10 | cout <<"Enter the number : ": 11 | cin >> n; 12 | cout <<"Factorial of number"< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PYTHON/Matrix_Transpose.py: -------------------------------------------------------------------------------- 1 | # Program to transpose a matrix 2 | 3 | X = [[12,7], 4 | [4 ,5], 5 | [3 ,8]] 6 | 7 | result = [[0,0,0], 8 | [0,0,0]] 9 | 10 | # iterate through rows 11 | for i in range(len(X)): 12 | # iterate through columns 13 | for j in range(len(X[0])): 14 | result[j][i] = X[i][j] 15 | 16 | for r in result: 17 | print(r) -------------------------------------------------------------------------------- /CPP/recusion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int add(int n); 5 | 6 | int main() 7 | { 8 | int n; 9 | 10 | cout << "Enter a positive integer: "; 11 | cin >> n; 12 | 13 | cout << "Sum = " << add(n); 14 | 15 | return 0; 16 | } 17 | 18 | int add(int n) 19 | { 20 | if(n != 0) 21 | return n + add(n - 1); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /PYTHON/StrongNumber.py: -------------------------------------------------------------------------------- 1 | #program to check a number is a Strong number 2 | sum1=0 3 | num=int(input("Enter anumber:")) 4 | temp=num 5 | while(num): 6 | i=1 7 | f=1 8 | r=num%10 9 | while(i<=r): 10 | f=f*i 11 | i+=1 12 | sum1=sum1+f 13 | num=num//10 14 | if(sum1==temp):print("the number is a strong number") 15 | else:print("the number is not a strong number") 16 | -------------------------------------------------------------------------------- /sum using recursion in C++: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int add(int n); 5 | 6 | int main() 7 | { 8 | int n; 9 | 10 | cout << "Enter a positive integer: "; 11 | cin >> n; 12 | 13 | cout << "Sum = " << add(n); 14 | 15 | return 0; 16 | } 17 | 18 | int add(int n) 19 | { 20 | if(n != 0) 21 | return n + add(n - 1); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/.idea/JAVA.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JAVA/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JAVA/Factorial.java: -------------------------------------------------------------------------------- 1 | public class Factorial { 2 | 3 | public static long factorial(long number) { 4 | long prod = 1; 5 | for(long i=2;i<=number;i++) { 6 | prod *= i; 7 | } 8 | return prod; 9 | } 10 | 11 | public static void main(String[] args) { 12 | long number = 6; 13 | System.out.print(factorial(number)); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /CPP/Calculator.cpp: -------------------------------------------------------------------------------- 1 | #include "Calculator.hpp" 2 | #include 3 | 4 | using namespace std; 5 | 6 | string Calculator::sub(string a, string b) 7 | { 8 | return "Please, enter a number"; 9 | } 10 | 11 | string Calculator::mult(string a, string b) 12 | { 13 | return "Please, enter a number"; 14 | } 15 | 16 | string Calculator::div(string a, string b) 17 | { 18 | return "Please, enter a number"; 19 | } -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PYTHON/largest element in array: -------------------------------------------------------------------------------- 1 | def largest(arr,n): 2 | 3 | # Initialize maximum element 4 | max = arr[0] 5 | 6 | # Traverse array elements from second and compare every element with current max 7 | for i in range(1, n): 8 | if arr[i] > max: 9 | max = arr[i] 10 | return max 11 | 12 | # Driver Code 13 | arr = [10, 324, 45, 90, 9808] 14 | n = len(arr) 15 | Ans = largest(arr,n) 16 | print Ans 17 | -------------------------------------------------------------------------------- /PYTHON/gcd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int gcd_naive(int a, int b) { 4 | int current_gcd = 1; 5 | for (int d = 2; d <= a && d <= b; d++) { 6 | if (a % d == 0 && b % d == 0) { 7 | if (d > current_gcd) { 8 | current_gcd = d; 9 | } 10 | } 11 | } 12 | return current_gcd; 13 | } 14 | 15 | int main() { 16 | int a, b; 17 | std::cin >> a >> b; 18 | std::cout << gcd_naive(a, b) << std::endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /PYTHON/LIS.py: -------------------------------------------------------------------------------- 1 | #return the size of Longest Increasing Subsequence in O(N^2) 2 | def LIS(a): 3 | if(len(a)== 0) : 4 | return 0 5 | # we make a list dp[i] = size of lis for elements 0 to i 6 | dp=[] 7 | dp.append(int(1)) 8 | n=len(a) 9 | for i in range (1,n): 10 | dp.append(1) 11 | for j in range (0,i): 12 | if(a[j] 2 | using namespace std; 3 | 4 | int factorial(int n); 5 | 6 | int main() 7 | { 8 | int n; 9 | 10 | cout << "Enter a positive integer: "; 11 | cin >> n; 12 | 13 | cout << "Factorial of " << n << " = " << factorial(n); 14 | 15 | return 0; 16 | } 17 | 18 | int factorial(int n) 19 | { 20 | if (n > 1) 21 | return n * factorial(n - 1); 22 | else 23 | return 1; 24 | } -------------------------------------------------------------------------------- /JAVA/Project-alpha.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JAVA/out/production/Project-alpha/Project-alpha.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JAVA/MatrixTransposition/MatrixTransposition.java: -------------------------------------------------------------------------------- 1 | package com.company.MatrixTransposition; 2 | 3 | // Square Matrix Transposition 4 | public class MatrixTransposition { 5 | static final int dimensions = 3; 6 | 7 | // storing the transpose for A[][] in B[][] 8 | static void transpose(int[][] A, int[][] B){ 9 | int i, j; 10 | for (i = 0; i< dimensions; i++){ 11 | for (j = 0; j < dimensions; j++){ 12 | B[i][j]= A[j][i]; 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PYTHON/Distance.py: -------------------------------------------------------------------------------- 1 | def dist(n): 2 | 3 | # Base conditions 4 | if (n == 0): 5 | return 1 6 | if (n <= 2): 7 | return n 8 | 9 | # Last stages 10 | s0 = 1 11 | s1 = 1 12 | s2 = 2 13 | sol = 0 14 | 15 | # Find the numbers of steps 16 | for i in range(3, n + 1): 17 | sol = s0 + s1 + s2 18 | s0 = s1 19 | s1 = s2 20 | s2 = sol 21 | 22 | # Return the required answer 23 | return sol 24 | 25 | # Driver code 26 | n = 4 27 | 28 | print(dist(n)) 29 | 30 | -------------------------------------------------------------------------------- /CPP/largestNumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cout<<"Enter the size of the array: "; 9 | cin>>n; 10 | int* arr= new int[n]; 11 | int max=INT_MIN; 12 | cout<<"Enter the elements of the array"<>arr[i]; 15 | if(max 2 | 3 | int main(void) { 4 | 5 | int year; 6 | scanf("%d", &year); 7 | if(year % 4 == 0){ 8 | if(year % 100 != 0){ 9 | printf("Yes, %d is a leap year!", year); 10 | } 11 | else if(year % 400 != 0){ 12 | printf("No, %d is not a leap year!", year); 13 | } 14 | else{ 15 | printf("Yes, %d is a leap year!", year); 16 | } 17 | } 18 | else{ 19 | printf("No, %d is not a leap year!", year); 20 | } 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /PYTHON/min_coins.py: -------------------------------------------------------------------------------- 1 | import sys 2 | def minCoins(coins, m, V): 3 | if (V == 0): 4 | return 0 5 | res = sys.maxsize 6 | for i in range(0, m): 7 | if (coins[i] <= V): 8 | sub_res = minCoins(coins, m, V-coins[i]) 9 | if (sub_res != sys.maxsize and sub_res + 1 < res): 10 | res = sub_res + 1 11 | 12 | return res 13 | 14 | c= [map(int,input().split())] 15 | m = len(c) 16 | V = input() 17 | print("Minimum coins required is: ",minCoins(coins, m, V)) 18 | -------------------------------------------------------------------------------- /.github/workflows/label.yml: -------------------------------------------------------------------------------- 1 | # This workflow will triage pull requests and apply a label based on the 2 | # paths that are modified in the pull request. 3 | # 4 | # To use this workflow, you will need to set up a .github/labeler.yml 5 | # file with configuration. For more information, see: 6 | # https://github.com/actions/labeler 7 | 8 | name: Labeler 9 | on: [pull_request] 10 | 11 | jobs: 12 | label: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/labeler@v2 18 | with: 19 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 20 | -------------------------------------------------------------------------------- /CPP/fact.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | unsigned long long factorial(int num) { 5 | if(num == 0) { 6 | return 1; 7 | } 8 | return num * factorial(num - 1); 9 | } 10 | 11 | int main() { 12 | int num; 13 | cout << "Enter a number upto 20:-" << endl; 14 | cin >> number; 15 | 16 | if (number < 0) { 17 | cout << "Invalid input." << endl; 18 | } else if (number > 20) { 19 | cout << "Invalid Input. Too long." << endl; 20 | } else { 21 | cout << factorial(num) << endl; 22 | } 23 | 24 | return 0; 25 | -------------------------------------------------------------------------------- /CPP/simpleCalculator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int num1,num2; 7 | char op; 8 | cout<<"Enter first number:"; 9 | cin>>num1; 10 | cout<<"Enter operator:"; 11 | cin>>op; 12 | cout<<"Enter second number:"; 13 | cin>>num2; 14 | int result; 15 | if(op == '+'){ 16 | result = num1 + num2; 17 | } 18 | if(op == '-'){ 19 | result = num1 - num2; 20 | } 21 | if(op == '*'){ 22 | result = num1 * num2; 23 | } 24 | if(op == '/'){ 25 | result = num1 / num2; 26 | } 27 | if(op == '%'){ 28 | result = num1 % num2; 29 | } 30 | cout<<"Result is:"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n, num, digit, rev = 0; 7 | 8 | cout << "Enter a positive number: "; 9 | cin >> num; 10 | 11 | n = num; 12 | 13 | do 14 | { 15 | digit = num % 10; 16 | rev = (rev * 10) + digit; 17 | num = num / 10; 18 | } while (num != 0); 19 | 20 | cout << " The reverse of the number is: " << rev << endl; 21 | 22 | if (n == rev) 23 | cout << " The number is a palindrome."; 24 | else 25 | cout << " The number is not a palindrome."; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /JAVA/WaysToCoverDistance.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class WaysToCoverDistance 4 | { 5 | 6 | static int printCountRec(int dist) 7 | { 8 | 9 | if (dist<0) 10 | return 0; 11 | if (dist==0) 12 | return 1; 13 | 14 | 15 | return printCountRec(dist-1) + 16 | printCountRec(dist-2) + 17 | printCountRec(dist-3); 18 | } 19 | 20 | public static void main (String[] args) 21 | { Scanner sc = new Scanner(System.in); 22 | int dist = (sc.nextInt()); 23 | System.out.println(printCountRec(dist)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CPP/RotateImage90Degree.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace cv; 6 | using namespace std; 7 | 8 | Mat rotate(Mat src) // Function to rotate the image 9 | { 10 | Mat dst; 11 | Point2f pt(src.cols/2., src.rows/2.); 12 | Mat r = getRotationMatrix2D(pt, 90, 1.0); 13 | warpAffine(src, dst, r, Size(src.cols, src.rows)); 14 | return dst; 15 | } 16 | 17 | int main() 18 | { 19 | Mat src = imread("blob.jpg"); 20 | Mat dst; 21 | dst = rotate(src); 22 | imshow("src", src); 23 | imshow("dst", dst); 24 | waitKey(0); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /transpose_of_matrix.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int a[10][10], transpose[10][10], r, c, i, j; 4 | 5 | scanf("%d %d", &r, &c); 6 | 7 | for (i = 0; i < r; ++i) 8 | for (j = 0; j < c; ++j) { 9 | 10 | scanf("%d", &a[i][j]); 11 | } 12 | 13 | 14 | 15 | // Finding the transpose of matrix a 16 | for (i = 0; i < r; ++i) 17 | for (j = 0; j < c; ++j) { 18 | transpose[j][i] = a[i][j]; 19 | } 20 | 21 | 22 | for (i = 0; i < c; ++i) 23 | for (j = 0; j < r; ++j) { 24 | printf("%d ", transpose[i][j]); 25 | if (j == r - 1) 26 | printf("\n"); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /JAVA/MinimumPartition.java: -------------------------------------------------------------------------------- 1 | public class MinimumPartition { 2 | 3 | public int calculateMinimumPartition(int[] input) { 4 | int min = 100000; 5 | int endIndex = input.length - 1; 6 | int[] left = new int[endIndex]; 7 | int[] right = new int[endIndex]; 8 | left[0] = input[0]; 9 | right[endIndex - 1] = input[endIndex]; 10 | 11 | for (int i = 1; i < endIndex; i++) { 12 | int tempEnd = endIndex - i; 13 | left[i] = input[i] + left[i - 1]; 14 | right[tempEnd - 1] = right[tempEnd] + input[tempEnd]; 15 | } 16 | 17 | for(int i = 0; i < left.length; i++) { 18 | int temp = Math.abs(left[i] - right[i]); 19 | if(temp < min) { 20 | min = temp; 21 | } 22 | } 23 | 24 | return min; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /CPP/sort-elements-in-lexicographical-order.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string str[10], temp; 7 | 8 | cout << "Enter 10 words: " << endl; 9 | for(int i = 0; i < 10; ++i) 10 | { 11 | getline(cin, str[i]); 12 | } 13 | 14 | for(int i = 0; i < 9; ++i) 15 | for( int j = i+1; j < 10; ++j) 16 | { 17 | if(str[i] > str[j]) 18 | { 19 | temp = str[i]; 20 | str[i] = str[j]; 21 | str[j] = temp; 22 | } 23 | } 24 | 25 | cout << "In lexicographical order: " << endl; 26 | 27 | for(int i = 0; i < 10; ++i) 28 | { 29 | cout << str[i] << endl; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /C/factorial.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long factorial(int number) { 4 | if(number == 0) { 5 | return 1; 6 | } 7 | return number * factorial(number - 1); 8 | } 9 | 10 | int main() { 11 | int number; 12 | printf("Enter a number between the range of 0 to 20:-\n"); 13 | scanf("%d", &number); 14 | 15 | if (number < 0) { 16 | printf("Invalid Input. The entered number cannot be negative.\n"); 17 | } else if (number > 20) { 18 | printf("Invalid Input. The entered number cannot exceed 20. As 20! is lasrgest factorial result that \"unsigned long long\" data type can store."); 19 | } else { 20 | printf("%lld \n", factorial(number)); 21 | } 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CPP/largest_element_in_array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(void) 5 | { 6 | int size; 7 | cout << "Enter the size of the new array: " << endl; 8 | cin >> size; 9 | 10 | // creating new array 11 | int *arr = new int[size]; 12 | 13 | // getting inout form stdin 14 | for (int i = 0; i < size; i++) 15 | { 16 | cin >> arr[i]; 17 | } 18 | 19 | // finding the largest element in the array 20 | int max = arr[0]; 21 | 22 | for (int i = 0; i < size; i++) 23 | { 24 | if (arr[i] > max) 25 | { 26 | max = arr[i]; 27 | } 28 | } 29 | 30 | // printing the maximum element of the array to stdout 31 | cout << "The maximum element of the enterred array is : " << max << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /CPP/ways_to_cover_distance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int distance; 7 | cin>>distance; 8 | 9 | /*algorithm: 10 | We will use dynamic programming to solve this problem 11 | lets suppose we are on an intermediate distance say x 12 | then number of ways to reach x will be sum of number of ways 13 | to reach x-1, x-2 and x-3 14 | */ 15 | 16 | int dp[distance+1]; 17 | for(int i=1; i=0){ 25 | dp[i] += dp[i-j]; 26 | } 27 | } 28 | } 29 | cout< 2 | using namespace std; 3 | 4 | unsigned long long factorial(int number) { 5 | if(number == 0) { 6 | return 1; 7 | } 8 | return number * factorial(number - 1); 9 | } 10 | 11 | int main() { 12 | int number; 13 | cout << "Enter a number between the range of 0 to 20:-" << endl; 14 | cin >> number; 15 | 16 | if (number < 0) { 17 | cout << "Invalid Input. The entered number cannot be negative." << endl; 18 | } else if (number > 20) { 19 | cout << "Invalid Input. The entered number cannot exceed 20. As 20! is lasrgest factorial result that \"unsigned long long\" data type can store." << endl; 20 | } else { 21 | cout << factorial(number) << endl; 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /CPP/Factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | unsigned long long factorial(int number) { 5 | if(number == 0) { 6 | return 1; 7 | } 8 | return number * factorial(number - 1); 9 | } 10 | 11 | int main() { 12 | int number; 13 | cout << "Enter a number between the range of 0 to 20:-" << endl; 14 | cin >> number; 15 | 16 | if (number < 0) { 17 | cout << "Invalid Input. The entered number cannot be negative." << endl; 18 | } else if (number > 20) { 19 | cout << "Invalid Input. The entered number cannot exceed 20. As 20! is largest factorial result that \"unsigned long long\" data type can store." << endl; 20 | } else { 21 | cout << factorial(number) << endl; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /JAVA/PalindromeNumber.java: -------------------------------------------------------------------------------- 1 | public class PalindromeNumber { 2 | 3 | public static void main(String[] args) { 4 | 5 | int num = 121, reversedInteger = 0, remainder, originalInteger; 6 | 7 | originalInteger = num; 8 | 9 | // reversed integer is stored in variable 10 | while( num != 0 ) 11 | { 12 | remainder = num % 10; 13 | reversedInteger = reversedInteger * 10 + remainder; 14 | num /= 10; 15 | } 16 | 17 | // palindrome if orignalInteger and reversedInteger are equal 18 | if (originalInteger == reversedInteger) 19 | System.out.println(originalInteger + " is a palindrome."); 20 | else 21 | System.out.println(originalInteger + " is not a palindrome."); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CPP/sorting in dictionary order: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cout<<"enter number of words to order" ; 8 | cin>>n; 9 | string str[n], temp; 10 | 11 | cout << "Enter words: " << endl; 12 | for(int i = 0; i < n ; ++i) 13 | { 14 | getline(cin, str[i]); 15 | } 16 | 17 | for(int i = 0; i < n-1 ; ++i) 18 | for( int j = i+1; j < n ; ++j) 19 | { 20 | if(str[i] > str[j]) 21 | { 22 | temp = str[i]; 23 | str[i] = str[j]; 24 | str[j] = temp; 25 | } 26 | } 27 | 28 | cout << "In lexicographical order: " << endl; 29 | 30 | for(int i = 0; i < n ; ++i) 31 | { 32 | cout << str[i] << endl; 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /CPP/transpose_matrix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int rows, columns; 7 | cin>>rows>>columns; 8 | 9 | int matrix[rows][columns]; 10 | 11 | for(int i=0; i>matrix[i][j]; 14 | } 15 | } 16 | 17 | /* transpose of a matrix means that: 18 | matrix[i][j] = transpose[j][i] 19 | */ 20 | 21 | int transpose[rows][columns]; 22 | 23 | for(int i=0; i 3 | 4 | using namespace std; 5 | 6 | class Calculator 7 | { 8 | public: 9 | //Addition 10 | template 11 | T add(T a, T b) 12 | { 13 | return (a + b); 14 | } 15 | 16 | //Subtraction 17 | template 18 | T sub(T a, T b) 19 | { 20 | return (a - b); 21 | } 22 | string sub(string a, string b); 23 | 24 | //Multiplication 25 | template 26 | T mult(T a, T b) 27 | { 28 | return (a * b); 29 | } 30 | string mult(string a, string b); 31 | 32 | //Division 33 | template 34 | float div(T a, T b) 35 | { 36 | return ((float)a / (float)b); 37 | } 38 | string div(string a, string b); 39 | }; -------------------------------------------------------------------------------- /JAVA/CheckLeapYear.java: -------------------------------------------------------------------------------- 1 | public class CheckLeapYear { 2 | 3 | public static void main(String[] args) { 4 | 5 | int year = 1900; 6 | boolean leap = false; 7 | 8 | if(year % 4 == 0) 9 | { 10 | if( year % 100 == 0) 11 | { 12 | // year is divisible by 400, hence the year is a leap year 13 | if ( year % 400 == 0) 14 | leap = true; 15 | else 16 | leap = false; 17 | } 18 | else 19 | leap = true; 20 | } 21 | else 22 | leap = false; 23 | 24 | if(leap) 25 | System.out.println(year + " is a leap year."); 26 | else 27 | System.out.println(year + " is not a leap year."); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /JAVA/MatrixTransposition/Main.java: -------------------------------------------------------------------------------- 1 | package com.company.MatrixTransposition; 2 | 3 | import static com.company.MatrixTransposition.MatrixTransposition.*; 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | // write your code here 8 | int[][] firstMatrix = {{1,2,3},{4,5,6}, {7,8,9}}; 9 | int[][] transposedMatrix = new int[dimensions][dimensions]; 10 | int i; 11 | int j; 12 | 13 | transpose(firstMatrix, transposedMatrix); 14 | 15 | System.out.println("The transposed matrix is: \n"); 16 | 17 | for (i = 0; i< dimensions; i++){ 18 | for (j = 0; j< dimensions; j++){ 19 | System.out.print(transposedMatrix[i][j] + " "); 20 | 21 | } 22 | System.out.print("\n"); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CPP/transpose.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int a[10][10], transpose[10][10], row, column, i, j; 8 | 9 | cout << "Enter rows and columns of matrix: "; 10 | cin >> row >> column; 11 | 12 | cout << "\nEnter elements of matrix: " << endl; 13 | 14 | // Storing matrix elements 15 | for (int i = 0; i < row; ++i) { 16 | for (int j = 0; j < column; ++j) { 17 | cout << "Enter element a" << i + 1 << j + 1 << ": "; 18 | cin >> a[i][j]; 19 | } 20 | } 21 | 22 | // Printing the a matrix 23 | cout << "\nEntered Matrix: " << endl; 24 | for (int i = 0; i < row; ++i) { 25 | for (int j = 0; j < column; ++j) { 26 | cout << " " << a[i][j]; 27 | if (j == column - 1) 28 | cout << endl << endl; 29 | } 30 | } -------------------------------------------------------------------------------- /CPP/frequency of characters in string in C++: -------------------------------------------------------------------------------- 1 | A string is a one-dimensional character array that is terminated by a null character. Frequency of characters in a string is the number of times they occur in a string. 2 | For example − 3 | 4 | String: Football is a sport 5 | The frequency of alphabet o in the above string is 3 6 | 7 | A program to find the frequency of a particular alphabet is given as follows. 8 | #include 9 | using namespace std; 10 | int main() { 11 | char str[100] = "this string contains many alphabets"; 12 | char c = 'a'; 13 | int count = 0; 14 | for(int i = 0; str[i] != '\0'; i++) { 15 | if(str[i] == c) 16 | count++; 17 | } 18 | cout<<"Frequency of alphabet "< 2 | using namespace std; 3 | 4 | int main() { 5 | int a[10][10], transpose[10][10], row, column, i, j; 6 | 7 | cout << "Enter rows and columns of matrix: "; 8 | cin >> row >> column; 9 | 10 | cout << "\nEnter elements of matrix: " << endl; 11 | 12 | // Storing matrix elements 13 | for (int i = 0; i < row; ++i) { 14 | for (int j = 0; j < column; ++j) { 15 | cout << "Enter element a" << i + 1 << j + 1 << ": "; 16 | cin >> a[i][j]; 17 | } 18 | } 19 | 20 | // Printing the a matrix 21 | cout << "\nEntered Matrix: " << endl; 22 | for (int i = 0; i < row; ++i) { 23 | for (int j = 0; j < column; ++j) { 24 | cout << " " << a[i][j]; 25 | if (j == column - 1) 26 | cout << endl << endl; 27 | } 28 | } -------------------------------------------------------------------------------- /PYTHON/Transpose_Matrix.py: -------------------------------------------------------------------------------- 1 | r = int(input("Enter number of Rows")) 2 | c = int(input("Enter number of Columns")) 3 | 4 | #transpose function 5 | def transpose(A,B): 6 | for i in range(c): 7 | for j in range(r): 8 | B[i][j] = A[j][i] 9 | 10 | #original matrix 11 | A = [] 12 | for i in range(r): 13 | a =[] 14 | for j in range(c): 15 | a.append(int(input())) 16 | A.append(a) 17 | 18 | print("Original Matrix A :-") 19 | for i in range(r): 20 | for j in range(c): 21 | print(A[i][j], end=' ') 22 | print() 23 | 24 | # Creating B matrix 25 | B = [[0 for x in range(r)] for y in range(c)] 26 | 27 | transpose(A,B) # B = A(transpose) 28 | 29 | print("\nResult matrix B :-") 30 | for i in range(c): 31 | for j in range(r): 32 | print(B[i][j], end=' ') 33 | print() 34 | -------------------------------------------------------------------------------- /C/calculator switch case.c: -------------------------------------------------------------------------------- 1 | //Calculator case 2 | #include 3 | int main(void){ 4 | float value1,value2; 5 | char operator; 6 | printf("Enter the expression including '+','-','*','/' operators:"); 7 | scanf("%f%c%f",&value1,&operator,&value2); 8 | switch(operator) 9 | { 10 | case '+': 11 | { 12 | printf("%.2f\n",value1+value2); 13 | break; 14 | } 15 | case'-': 16 | { 17 | printf("%.2f\n",value1-value2); 18 | break; 19 | } 20 | case'*': 21 | { 22 | printf("%.2f\n",value1*value2); 23 | break; 24 | } 25 | case'/': 26 | { 27 | if(value2==0) 28 | { 29 | printf("The value is 0."); 30 | break; 31 | } 32 | else 33 | printf("%.2f\n",value1/value2); 34 | break; 35 | } 36 | default: 37 | printf("Wrong operator input."); 38 | break; 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | all-contributors/add-SayantanMaiti 10 | "login": "SayantanMaiti", 11 | "name": "Sayantan Maiti", 12 | "avatar_url": "https://avatars3.githubusercontent.com/u/68146055?v=4", 13 | "profile": "https://github.com/SayantanMaiti", 14 | 15 | "login": "Aniket762", 16 | "name": "Aniket Pal", 17 | "avatar_url": "https://avatars2.githubusercontent.com/u/67703407?v=4", 18 | "profile": "http://aliferous.xyz/", 19 | 20 | "contributions": [ 21 | "doc" 22 | ] 23 | } 24 | ], 25 | "contributorsPerLine": 7, 26 | "projectName": "Project-alpha", 27 | "projectOwner": "Aniket762", 28 | "repoType": "github", 29 | "repoHost": "https://github.com", 30 | "skipCi": true 31 | } 32 | -------------------------------------------------------------------------------- /PYTHON/max_pairwise_product.py: -------------------------------------------------------------------------------- 1 | # Uses python3 2 | result = 0 3 | 4 | 5 | def max_pairwise_product(n, a): 6 | for i in range(0, n): 7 | for j in range(i + 1, n): 8 | if a[i] * a[j] > result: 9 | result = a[i] * a[j] 10 | return result 11 | 12 | 13 | def max_pairwise_product_fast(n, numbers): 14 | max_index1 = -1 15 | for i in range(n): 16 | if max_index1 == -1 or numbers[i] > numbers[max_index1]: 17 | max_index1 = i 18 | 19 | max_index2 = -1 20 | for i in range(n): 21 | if i != max_index1 and (max_index2 == -1 or numbers[i] > numbers[max_index2]): 22 | max_index2 = i 23 | 24 | return numbers[max_index1] * numbers[max_index2] 25 | 26 | 27 | if __name__ == '__main__': 28 | n = int(input()) 29 | a = [int(x) for x in input().split()] 30 | assert (len(a) == n) 31 | 32 | print(max_pairwise_product_fast(n, a)) -------------------------------------------------------------------------------- /.mypy_cache/3.8/sudoko.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "sudoko", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoko.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoko.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoko.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoko.__package__", "name": "__package__", "type": "builtins.str"}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\sudoko.py"} -------------------------------------------------------------------------------- /CPP/store student info in structure: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | struct student 5 | { 6 | int roll; 7 | char name[100]; 8 | float marks; 9 | } s[20]; 10 | 11 | int main() 12 | { 13 | cout << "Enter information of students: " << endl; 14 | 15 | // storing information 16 | for(int i = 0; i < 20; ++i) 17 | { 18 | s[i].roll = i+1; 19 | cout << "For roll number" << s[i].roll << "," << endl; 20 | 21 | cout << "Enter name: "; 22 | cin >> s[i].name; 23 | 24 | cout << "Enter marks: "; 25 | cin >> s[i].marks; 26 | 27 | cout << endl; 28 | } 29 | 30 | cout << "Displaying Information serially: " << endl; 31 | 32 | // Displaying information 33 | for(int i = 0; i < 20; ++i) 34 | { 35 | cout << "\n Roll number: " << i+1 << endl; 36 | cout << "Name: " << s[i].name << endl; 37 | cout << "Marks: " << s[i].marks << endl; 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /PYTHON/LCS.py: -------------------------------------------------------------------------------- 1 | # Longest Common Subsequence 2 | # Solution using Dynamic programming 3 | 4 | text1 = input("Enter a string ") # text1 is the 1st string input 5 | text2 = input("Enter a string ") # text2 is the 2nd string input 6 | 7 | # finding the length of the strings 8 | len1 = len(text1) 9 | len2= len(text2) 10 | dp=[] 11 | 12 | # declaring the array for storing the dp values 13 | for i in range(len1 + 1): 14 | dp.append([0]*(len2+1)) 15 | 16 | """Following steps build dp[m+1][n+1] using bottom up approach 17 | where dp[i][j] contains length of LCS of text1[0..i-1] and text2[0..j-1]""" 18 | for i in range(1, len1 + 1): 19 | for j in range(1, len2 + 1): 20 | if text1[i - 1] == text2[j - 1]: 21 | dp[i][j] = dp[i - 1][j - 1] + 1 22 | else: 23 | dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) 24 | 25 | # dp[m][n] contains the length of LCS of text1[0..n-1] and text2[0..m-1] 26 | print("Length of Longest Common Subsequence : ",dp[len1][len2]) -------------------------------------------------------------------------------- /CPP/longest_common_subsequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | //creating a global 2D array to store the values 11 | int static t[1001][1001]; 12 | 13 | 14 | //LCS function 15 | int lcs(string text1, string text2) { 16 | int n= text1.size(); 17 | int m= text2.size(); 18 | 19 | //Base Condition 20 | for(int i=0; i>s1>>s2; 39 | 40 | //calling LCS 41 | int ans = lcs(s1, s2); 42 | 43 | //printing the output 44 | std::cout< 10 | 11 | using namespace std; 12 | 13 | int recursive_factorial(int number) 14 | { 15 | if (number == 0 || number == 1) 16 | { 17 | return 1; 18 | } 19 | 20 | return number * recursive_factorial(number - 1); 21 | } 22 | 23 | int main() 24 | { 25 | int number; 26 | cout<<"Include a number to have it's factorial calculated (must be greater or equal to 0)"<< endl; 27 | cin >> number; 28 | 29 | int factorial = recursive_factorial(number); 30 | 31 | cout << "Factorial of " << number << " is: " << factorial << endl; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /PYTHON/edit_distance.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | def edit_distance(str1, str2): 5 | if len(str1) > len(str2): 6 | str1, str2 = str2, str1 7 | 8 | distances = range(len(str1) + 1) 9 | 10 | for count1, letter1 in enumerate(str2): 11 | distances_ = [count1+1] 12 | 13 | for count2, letter2 in enumerate(str1): 14 | if letter2 == letter1: 15 | distances_.append(distances[count2]) 16 | else: 17 | distances_.append(1 + min((distances[count2], distances[count2 + 1], distances_[-1]))) 18 | 19 | distances = distances_ 20 | 21 | cost = distances[-1] 22 | return cost 23 | 24 | 25 | if __name__ == "__main__": 26 | if len(sys.argv) == 3: 27 | str1 = sys.argv[1] 28 | str2 = sys.argv[2] 29 | else: 30 | str1 = "Cat" 31 | str2 = "Rats" 32 | 33 | no_operations = edit_distance(str1, str2) 34 | print(f"Levenshtein distance between < {str1} > and < {str2} >") 35 | print(f"Number of operations required : {no_operations}") 36 | -------------------------------------------------------------------------------- /JAVA/LCS.java: -------------------------------------------------------------------------------- 1 | package tempPack; 2 | 3 | import java.util.*; 4 | import java.lang.*; 5 | import java.io.*; 6 | 7 | class hacktober { 8 | public static int LCS(String s1, int m, String s2, int n) { 9 | int dp[][] = new int[m+1][n+1]; 10 | for(int i = 1; i <= m; i++) { 11 | for(int j = 1; j <= n; j++) { 12 | if(s1.charAt(i-1) == s2.charAt(j-1)) { 13 | dp[i][j] = dp[i-1][j-1] + 1; 14 | } else { 15 | dp[i][j] = Math.max(Math.max(dp[i-1][j], dp[i-1][j-1]), dp[i][j-1]); 16 | } 17 | } 18 | } 19 | return dp[m][n]; 20 | } 21 | 22 | public static void main (String[] args) { 23 | Scanner s = new Scanner(System.in); 24 | int t = s.nextInt(); 25 | while(t-- > 0) { 26 | int m = s.nextInt(); 27 | int n = s.nextInt(); 28 | String enter = s.nextLine(); 29 | String s1 = s.nextLine(); 30 | String s2 = s.nextLine(); 31 | System.out.println(LCS(s1,m,s2,n)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /JAVA/RootsOfQuadraticEquation.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class RootsOfQuadraticEquation{ 3 | public static void main(String args[]){ 4 | Scanner s = new Scanner(System.in); 5 | 6 | int a,b,c,root1=0,root2=0,sqrt=0; 7 | 8 | System.out.print("input the value of a (coefficient of x^2) : "); 9 | a = s.nextInt(); 10 | System.out.print("input the value of b (coefficient of x) : "); 11 | b = s.nextInt(); 12 | System.out.print("input the value of c (constant) : "); 13 | c = s.nextInt(); 14 | 15 | sqrt = b*b - (4*a*c); 16 | 17 | if (sqrt>0){ 18 | root1 = (int) (-b +(Math.sqrt(sqrt))/2*a); 19 | root2 = (int) (-b - (Math.sqrt(sqrt)) / 2 * a); 20 | } 21 | 22 | System.out.println("root 1 = "+root1); 23 | System.out.println("root 2 = "+root2); 24 | 25 | if (sqrt<0){ 26 | System.out.println("root 1 = "+(-b)+" + squrt("+sqrt+") /"+2*a); 27 | System.out.println("root 2 = "+(-b)+" - squrt("+sqrt+") /"+2*a); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aniket Pal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.mypy_cache/3.8/leap_year.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "leap_year", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "leap_year.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "leap_year.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "leap_year.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "leap_year.__package__", "name": "__package__", "type": "builtins.str"}}, "year": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "leap_year.year", "name": "year", "type": "builtins.int"}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\leap_year.py"} -------------------------------------------------------------------------------- /CPP/edit-distance.c: -------------------------------------------------------------------------------- 1 | int min(int i,int j,int k){ 2 | if(i0){ 16 | num-=1; 17 | int i,j,k,l,m,n,l1,l2; 18 | char str1[1000],str2[1000]; 19 | scanf("%d %d\n",&l1,&l2); 20 | scanf("%s %s",str1,str2); 21 | int dp[l1+1][l2+1]; 22 | //memset(dp,0,sizeof(dp)); 23 | for(i=0;i<=l1;i++){ 24 | for(j=0;j<=l2;j++){ 25 | if(i==0){ 26 | dp[i][j]=j; 27 | } 28 | else if(j==0){ 29 | dp[i][j]=i; 30 | } 31 | else if(str1[i-1]==str2[j-1]){ 32 | dp[i][j]=dp[i-1][j-1]; 33 | } 34 | else{ 35 | k=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]); 36 | dp[i][j]=k+1; 37 | } 38 | } 39 | } 40 | printf("%d\n",dp[l1][l2]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CPP/longest_increasing_subsequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int length; //number of elements 7 | cin >> length; 8 | 9 | int value[length]; //array to store value of elements 10 | for(int i=0; i>value[i]; 12 | } 13 | 14 | /*algorithm: 15 | This problem can be solved using Dynamic Programming. 16 | Time complexity of the algorithm will be O(n^2) 17 | Each state of DP will store the longest increasing subsequence 18 | ending at that position 19 | */ 20 | 21 | int dp[length]; 22 | 23 | //initialising dp[i] = 1; since in any case we can have a single element 24 | for(int i=0; i=value[j]){ 31 | dp[i]=max(dp[i], dp[j]+1); 32 | } 33 | } 34 | } 35 | 36 | int answer =0; //answer is going to be maximum of all dp[i] 37 | 38 | for(int i=0; i c[index - 1]) and (future_sum <= m): 20 | coins_list.append(c[index - 1]) 21 | else: 22 | index -= 1 23 | 24 | return len(coins_list) 25 | 26 | 27 | if __name__ == "__main__": 28 | input_list = [] 29 | n = int(input("Enter number of elements, thus enter coin values one by one : ")) 30 | 31 | for i in range(0, n): 32 | ele = int(input()) 33 | 34 | input_list.append(ele) 35 | m = int(input("Enter M: ")) 36 | 37 | print("Minimum coins required is ", coinExchange(input_list, m)) 38 | -------------------------------------------------------------------------------- /C/array insertionAtPosnAndBeginning.c: -------------------------------------------------------------------------------- 1 | //Array insertion at position and at beginning 2 | 3 | #include 4 | int main(){ 5 | int a[50],size,i,num,pos; 6 | printf("Enter the size of array:"); 7 | scanf("%d",&size); 8 | printf("Enter elements of array:\n"); 9 | for(i=0;isize) 18 | { 19 | printf("\nInvalid position."); 20 | } 21 | else 22 | for(i=size-1;i>=pos-1;i--) 23 | { 24 | a[i+1]=a[i]; 25 | } 26 | a[pos-1]=num; 27 | size++; 28 | 29 | printf("\nThe linked list is:"); 30 | for(i=0;i=0;i--) 38 | { 39 | a[i+1]=a[i]; 40 | } 41 | a[0]=num; 42 | size++; 43 | 44 | printf("\nThe linked list is:"); 45 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | 8 | float a, b, c, x1, x2, discriminant, realPart, imaginaryPart; 9 | cout << "Enter coefficients a, b and c: "; 10 | cin >> a >> b >> c; 11 | discriminant = b * b - 4 * a * c; 12 | 13 | if (discriminant > 0) 14 | { 15 | x1 = (-b + sqrt(discriminant)) / (2 * a); 16 | x2 = (-b - sqrt(discriminant)) / (2 * a); 17 | cout << "Roots are real and different." << endl; 18 | cout << "x1 = " << x1 << endl; 19 | cout << "x2 = " << x2 << endl; 20 | } 21 | 22 | else if (discriminant == 0) 23 | { 24 | cout << "Roots are real and same." << endl; 25 | x1 = -b / (2 * a); 26 | cout << "x1 = x2 =" << x1 << endl; 27 | } 28 | 29 | else 30 | { 31 | realPart = -b / (2 * a); 32 | imaginaryPart = sqrt(-discriminant) / (2 * a); 33 | cout << "Roots are complex and different." << endl; 34 | cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl; 35 | cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl; 36 | } 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /PYTHON/Minimum_Partition.py: -------------------------------------------------------------------------------- 1 | #Given a set of integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum. 2 | #If there is a set S with n elements, then if we assume Subset1 has m elements, Subset2 must have n-m elements and the value of abs(sum(Subset1) – sum(Subset2)) 3 | 4 | 5 | def findMinRecursive(arr, i, sumCalculated, sumTotal): 6 | #For last element, return absolute difference of two sums 7 | #The sum of 2nd subset is calculatedd as difference between two sums 8 | if (i == 0): 9 | return abs((sumTotal-sumCalculated) - sumCalculated) 10 | 11 | #Recursively iterate through all possible subsets 12 | #Return minimum subset 13 | arr = list(arr) 14 | return min(findMinRecursive(arr, i - 1, sumCalculated + arr[i-1], sumTotal), 15 | findMinRecursive(arr, i - 1, sumCalculated, sumTotal)); 16 | 17 | #Return minimum possible difference between sums of two subsets 18 | def findMin(arr, n): 19 | sumTotal = sum(arr) 20 | #Recursively iterate through all possible subsets 21 | return findMinRecursive(arr, n, 0, sumTotal); 22 | 23 | #Test the code 24 | arr = [20, 30, 45, 50] 25 | n = len(arr) 26 | print(findMin(arr, n)) 27 | -------------------------------------------------------------------------------- /PYTHON/mysql-python.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | import pyautogui 3 | 4 | mypasswd=pyautogui.prompt('Enter your mysql password') 5 | mydb=mysql.connector.connect(host='localhost', user='root', password=mypasswd) 6 | cur=mydb.cursor() 7 | cur.execute('create database if not exists rdm123') 8 | 9 | mydb1=mysql.connector.connect(host='localhost', 10 | user='root', 11 | password=mypasswd, 12 | database='rdm123') 13 | cur1=mydb1.cursor() 14 | cur1.execute('create table if not exists abc(number int(2) primary key not null auto_increment, name varchar(20), gender varchar(1))') 15 | 16 | name=pyautogui.prompt('Enter Name') 17 | gender=pyautogui.prompt('Enter Gender') 18 | 19 | print(name) 20 | 21 | if name!=None or gender!=None: 22 | data1=(name,gender) 23 | cur1.execute('insert into abc(name , gender) values (%s,%s)',data1) 24 | mydb1.commit() 25 | pyautogui.alert('Data Filled Successfully.') 26 | else: 27 | pyautogui.alert('Data Filling Cancelled') 28 | 29 | show=pyautogui.confirm(text='Would you like to show the databases?', buttons=['Yes','No']) 30 | 31 | if show == 'Yes': 32 | cur1.execute('select * from abc') 33 | shwd=cur1.fetchall() 34 | pyautogui.alert(shwd) 35 | print('SUCCED!') 36 | else: 37 | print('NOT SUCCED!') -------------------------------------------------------------------------------- /C/GuessingGame.c: -------------------------------------------------------------------------------- 1 | //Guess the no.(Guessing game) 2 | #include 3 | #include 4 | #include//for random no. generator seed 5 | int main(){ 6 | int n=0; 7 | int guess=0; 8 | int no_OfGuess=5; 9 | time_t t; 10 | //Initialization of random no. 11 | srand((unsigned)time(&t)); 12 | //get the random no. 13 | n=rand()%21; //to ensure tht no. is between 0-20 14 | printf("\n This is a guessing game."); 15 | printf("I've a chosen a random no. between 0-20,that you've to guess.\n"); 16 | 17 | for (no_OfGuess=5;no_OfGuess>0;--no_OfGuess) 18 | { 19 | printf("\n You've %d tr%s left.",no_OfGuess,no_OfGuess==1?"y":"ies"); 20 | printf("\nEnter a guess:"); 21 | scanf("%d",&guess); 22 | 23 | if(guess==n) 24 | { 25 | printf("\nCongratulations!You guessed it correct.\n"); 26 | return; 27 | } 28 | else if(guess<0||guess>20)//checking for invalid guess 29 | { 30 | printf("I said the no. is between 0-20.\n"); 31 | } 32 | else if(n>guess) 33 | { 34 | printf("Sorry,%d is wrong.My no. is greater than that.\n",guess); 35 | } 36 | else if(n 2 | using namespace std; 3 | 4 | // function for counting sort 5 | static void countingsort(int Array[], int n) 6 | { 7 | int max = 0; 8 | //find largest element in the Array 9 | for (int i=0; i0) 31 | { 32 | Array[j] = i; 33 | j++; 34 | freq[i]--; 35 | } 36 | } 37 | } 38 | 39 | // function to print array 40 | static void PrintArray(int Array[], int n) 41 | { 42 | for (int i=0; i 4 | #include 5 | 6 | int i,j,m,n,c[20][20]; 7 | char x[20],y[20],b[20][20]; 8 | 9 | void print(int i,int j) 10 | { 11 | if(i==0 || j==0) 12 | return; 13 | if(b[i][j]=='c') 14 | { 15 | print(i-1,j-1); 16 | printf("%c",x[i-1]); 17 | } 18 | else if(b[i][j]=='u') 19 | print(i-1,j); 20 | else 21 | print(i,j-1); 22 | } 23 | 24 | //Function: For finding Longest Common Subsequence 25 | void lcs() 26 | { 27 | m=strlen(x); 28 | n=strlen(y); 29 | for(i=0;i<=m;i++) 30 | c[i][0]=0; 31 | for(i=0;i<=n;i++) 32 | c[0][i]=0; 33 | 34 | //c, u and l denotes cross, upward and downward directions respectively 35 | for(i=1;i<=m;i++) 36 | for(j=1;j<=n;j++) 37 | { 38 | if(x[i-1]==y[j-1]) 39 | { 40 | c[i][j]=c[i-1][j-1]+1; 41 | b[i][j]='c'; 42 | } 43 | else if(c[i-1][j]>=c[i][j-1]) 44 | { 45 | c[i][j]=c[i-1][j]; 46 | b[i][j]='u'; 47 | } 48 | else 49 | { 50 | c[i][j]=c[i][j-1]; 51 | b[i][j]='l'; 52 | } 53 | } 54 | } 55 | 56 | int main() 57 | { 58 | //Taking user input for two different sequences 59 | printf("Enter 1st sequence:"); 60 | scanf("%s",x); 61 | printf("Enter 2nd sequence:"); 62 | scanf("%s",y); 63 | // Printing the sub sequences 64 | printf("\nThe Longest Common Subsequence is "); 65 | lcs(); 66 | print(m,n); 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /.mypy_cache/3.8/collections/abc.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602229629, "dep_lines": [4, 6, 1, 1, 1], "dep_prios": [10, 5, 5, 30, 30], "dependencies": ["sys", "collections", "builtins", "abc", "typing"], "hash": "b0e3c3c1a36db1bf4c48e1ab3d717c9045decf0dbddac902853752f38c5b0708", "id": "collections.abc", "ignore_all": true, "interface_hash": "ca6b213492e16bd1f209adb3fa67adf5f2499752f3d6a9b2e81d1417b4a44b57", "mtime": 1589794019, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\collections\\abc.pyi", "plugin_data": null, "size": 945, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/threading.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602309192, "dep_lines": [2, 6, 7, 34, 1, 1], "dep_prios": [5, 5, 10, 5, 5, 30], "dependencies": ["typing", "types", "sys", "_thread", "builtins", "abc"], "hash": "47a9fd0758cc8fb3cdad552b5bc65be28e2834610af091ae9ea4b59193c9fdc1", "id": "threading", "ignore_all": true, "interface_hash": "04825bb4a4095f59a8a471a2ee43900198bdecd1f66d417df0854b5caa308570", "mtime": 1589794018, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\2and3\\threading.pyi", "plugin_data": null, "size": 6827, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/os/__init__.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602229629, "dep_lines": [4, 5, 6, 7, 13, 14, 1], "dep_prios": [5, 5, 10, 5, 5, 10, 30], "dependencies": ["io", "posix", "sys", "typing", "builtins", "os.path", "abc"], "hash": "be66b6bd8a24226e63837a13870a9fc19fc0aaa2ba7854293384ed6d262aabbc", "id": "os", "ignore_all": true, "interface_hash": "6e1941e0e6099ce7e179e63c8c227d99b826e3b8340410c60d885e5f2d314196", "mtime": 1589794019, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\os\\__init__.pyi", "plugin_data": null, "size": 26998, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/collections/__init__.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602229629, "dep_lines": [2, 3, 9, 1, 1], "dep_prios": [10, 5, 10, 5, 30], "dependencies": ["sys", "typing", "collections.abc", "builtins", "abc"], "hash": "9acade4965b40647e5e4bdab16fdbb9dc042260ca3cf5cf0897bc990045b2af7", "id": "collections", "ignore_all": true, "interface_hash": "56dbae7a3d8d266dc12a1e60fd5ba4a82e803fb9cf14fabf20a6ebb019a4358a", "mtime": 1589794019, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\collections\\__init__.pyi", "plugin_data": null, "size": 14552, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/sys.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602229629, "dep_lines": [6, 11, 13, 1, 1, 1, 1], "dep_prios": [5, 5, 5, 5, 30, 30, 30], "dependencies": ["typing", "types", "importlib.abc", "builtins", "_importlib_modulespec", "abc", "importlib"], "hash": "ee193744d8a603bc97f6473951a80b6c4a41d77d3d6e54ab887eb288251c9fbe", "id": "sys", "ignore_all": true, "interface_hash": "3839b648040447b0118c07af204ef89280bc9e27ca0e62402a7df8905f91b5af", "mtime": 1589794018, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\sys.pyi", "plugin_data": null, "size": 5872, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/importlib/abc.meta.json: -------------------------------------------------------------------------------- 1 | {"data_mtime": 1602229629, "dep_lines": [1, 2, 3, 4, 5, 9, 1], "dep_prios": [5, 10, 10, 10, 5, 5, 5], "dependencies": ["abc", "os", "sys", "types", "typing", "_importlib_modulespec", "builtins"], "hash": "5c2a079dcbfaaa5ac5d84826c3dfbe76cb40c1dbbd82bf6604dae7abd3928652", "id": "importlib.abc", "ignore_all": true, "interface_hash": "36ae458b3afc94aea21bca5a1b70e51added637e976651f7843c1a51fee3f618", "mtime": 1589794019, "options": {"allow_redefinition": false, "allow_untyped_globals": false, "always_false": [], "always_true": [], "bazel": false, "check_untyped_defs": false, "disallow_any_decorated": false, "disallow_any_explicit": false, "disallow_any_expr": false, "disallow_any_generics": false, "disallow_any_unimported": false, "disallow_incomplete_defs": false, "disallow_subclassing_any": false, "disallow_untyped_calls": false, "disallow_untyped_decorators": false, "disallow_untyped_defs": false, "follow_imports": "silent", "follow_imports_for_stubs": false, "ignore_errors": false, "ignore_missing_imports": true, "implicit_reexport": true, "local_partial_types": false, "mypyc": false, "no_implicit_optional": false, "platform": "win32", "plugins": [], "show_none_errors": true, "strict_equality": false, "strict_optional": true, "strict_optional_whitelist": null, "warn_no_return": true, "warn_return_any": false, "warn_unreachable": false, "warn_unused_ignores": false}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\importlib\\abc.pyi", "plugin_data": null, "size": 3522, "suppressed": [], "version_id": "0.770"} -------------------------------------------------------------------------------- /CPP/Mergesort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | bool cmp(int a, int b)/// change here to change comparison 7 | { 8 | return a=mid) 17 | { 18 | temp[i]=arr[p2++]; 19 | } 20 | else if(p2>=r) 21 | { 22 | temp[i]=arr[p1++]; 23 | } 24 | else if (p1 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | int static t[1001][10001]; 11 | 12 | //funcion to find the minimum value of the subset sum diffrence 13 | int min_subset_diff(vector& nums) { 14 | int range=0, n = nums.size(); 15 | for(int i=0; i size of set 42 | //in second line: n numbers separated by space 43 | int n, ans; 44 | std::cin>>n; 45 | std::vectornums(n); 46 | for(int i=0; i>nums[i]; 47 | 48 | //calling function min_subset_diff to find the minimum difference between subset sums 49 | ans = min_subset_diff(nums); 50 | std::cout < G[i][j]: 37 | minimum = G[i][j] 38 | x = i 39 | y = j 40 | print(str(x) + "-" + str(y) + ":" + str(G[x][y])) 41 | selected[y] = True 42 | no_edge += 1 43 | -------------------------------------------------------------------------------- /CPP/breadth_first_search.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /* 6 | 7 | Breadth-first search (BFS) is an algorithm for traversing or searching 8 | tree or graph data structures. 9 | 10 | It starts at the tree root (or some arbitrary node of a graph and 11 | explores all of the neighbor nodes at the present depth prior to 12 | moving on to the nodes at the next depth level. 13 | 14 | Time Complexity - O(V + E), where V is the number of nodes and E is the number of edges. 15 | 16 | Space Complexity - O(|V|) 17 | 18 | */ 19 | 20 | vector v; 21 | vector> g; 22 | 23 | void edge(int a, int b) 24 | { 25 | g[a].emplace_back(b); 26 | } 27 | 28 | void bfs(int u) 29 | { 30 | queue q; 31 | 32 | q.push(u); 33 | v[u] = true; 34 | 35 | while (!q.empty()) 36 | { 37 | 38 | int f = q.front(); 39 | q.pop(); 40 | 41 | cout << f << " "; 42 | 43 | // Enqueue all adjacent of f and mark them visited 44 | for (auto i = g[f].begin(); i != g[f].end(); i++) 45 | { 46 | if (!v[*i]) 47 | { 48 | q.push(*i); 49 | v[*i] = true; 50 | } 51 | } 52 | } 53 | } 54 | 55 | int main() 56 | { 57 | int n, e; 58 | cout << "Enter Number of Nodes and Edges" << endl; 59 | cin >> n >> e; 60 | 61 | v.assign(n, false); 62 | g.assign(n, vector()); 63 | 64 | int a, b; 65 | for (int i = 0; i < e; i++) 66 | { 67 | cout << "Enter the edges " << endl; 68 | cin >> a >> b; 69 | edge(a, b); 70 | } 71 | 72 | for (int i = 0; i < n; i++) 73 | { 74 | if (!v[i]) 75 | bfs(i); 76 | } 77 | 78 | return 0; 79 | } -------------------------------------------------------------------------------- /JAVA/LongestIncreasingSubsequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Java Program for Longest Increasing Subsequence 3 | */ 4 | 5 | import java.util.*; 6 | 7 | class LongestIncreasingSubsequence 8 | { 9 | /* 10 | * Functiont to print Longest Increasing Subsequence and return the length of the LIS 11 | * @param arr: given array 12 | * @param n: size of the array 13 | * @return max: length of the LIS 14 | */ 15 | 16 | static int lis(int arr[], int n) 17 | { 18 | int lis[] = new int[n]; 19 | ArrayList indexes = new ArrayList(n); 20 | int i, j, max = 0; 21 | 22 | for (i = 0; i < n; i++) 23 | lis[i] = 1; 24 | 25 | for (i = 1; i < n; i++ ) 26 | { 27 | for ( j = 0; j < i; j++ ) 28 | { 29 | if ( arr[i] > arr[j] && lis[i] < lis[j] + 1) 30 | lis[i] = lis[j] + 1; 31 | } 32 | } 33 | 34 | for (i = 0; i < n; i++ ) 35 | { 36 | if ( max < lis[i]) 37 | max = lis[i]; 38 | } 39 | 40 | int tmp = max; 41 | for (i = n - 1; i >= 0; --i) 42 | { 43 | if (lis[i] == tmp) 44 | { 45 | indexes.add(i); 46 | --tmp; 47 | } 48 | } 49 | 50 | Collections.reverse(indexes); 51 | 52 | for (i = 0; i < indexes.size(); i++) 53 | { 54 | System.out.print(arr[indexes.get(i)] + " "); 55 | } 56 | System.out.println(); 57 | 58 | return max; 59 | } 60 | 61 | /* 62 | * Driver function 63 | */ 64 | public static void main(String args[]) 65 | { 66 | int testArr[] = {10, 22, 9, 33, 21, 50, 41, 60}; 67 | int n = testArr.length; 68 | 69 | System.out.print("Longest Increasing Subsequence: " ); 70 | int lengthLis = lis(testArr, n); 71 | System.out.println("Length of the LIS: " + lengthLis); 72 | } 73 | } -------------------------------------------------------------------------------- /.mypy_cache/3.8/Nqueens.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "Nqueens", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Nqueens.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Nqueens.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Nqueens.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Nqueens.__package__", "name": "__package__", "type": "builtins.str"}}, "isSafe": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0, 0], "arg_names": ["row", "col", "board", "n"], "flags": [], "fullname": "Nqueens.isSafe", "name": "isSafe", "type": null}}, "n": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Nqueens.n", "name": "n", "type": "builtins.int"}}, "printPaths": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["n"], "flags": [], "fullname": "Nqueens.printPaths", "name": "printPaths", "type": null}}, "printPathsHelper": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["row", "n", "board"], "flags": [], "fullname": "Nqueens.printPathsHelper", "name": "printPathsHelper", "type": null}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\Nqueens.py"} -------------------------------------------------------------------------------- /C/MinimumSpanningTree-Prim-InC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int count(int arr[], int n, int val){ 5 | int c=0; 6 | for(int i=0; i matrix[i][j] && dist[i]!= 0){ // if in the adjanency matrix the cost is not 0 and checks dist array to see if its already selected. If the matrix cost is less than value in distance then it is selected. 26 | dist[i] = matrix[j][i]; 27 | prev[i] = j; 28 | } 29 | } 30 | mini =10; 31 | for(int i=0; i<5; i++){ 32 | if(dist[i]!= 10 && dist[i] < mini && dist[i]!= 0){ // 10 is the maximum cost and 0 is for the path already picked 33 | mini=dist[i]; 34 | sp =i; 35 | } 36 | } 37 | dist[sp] =0; // distance value turns to 0 to indicate that this path has been picked 38 | j = sp; 39 | } 40 | for(int i=1; i<5 ; i++){ 41 | cost += matrix[i][prev[i]]; 42 | } 43 | return cost; // The minimum cost 44 | 45 | } 46 | 47 | int main() 48 | { 49 | int matrix[5][5]={ {0,0,3,0,4}, {0,0,6,0,1},{3,6,0,5,0},{0,0,5,0,7},{4,1,0,7,0} }; 50 | printf("%d", prim(matrix)); // This will print the minimum cost that we get from using the Prim's Algo 51 | return 0; 52 | } 53 | //This code is contributed by Vaishnavi Shah 54 | -------------------------------------------------------------------------------- /JAVA/DepthFirstSearch.java: -------------------------------------------------------------------------------- 1 | import java.util.Stack; 2 | 3 | class TreeNode { 4 | String val; 5 | TreeNode left; 6 | TreeNode right; 7 | 8 | public TreeNode(String val, TreeNode left, TreeNode right) { 9 | this.val = val; 10 | this.left = left; 11 | this.right = right; 12 | } 13 | 14 | public String getValue() { 15 | return this.val; 16 | } 17 | 18 | public TreeNode getLeft() { 19 | return this.left; 20 | } 21 | 22 | public TreeNode getRight() { 23 | return this.right; 24 | } 25 | } 26 | 27 | public class DepthFirstSearch { 28 | 29 | public static void executeDFS(TreeNode root) { 30 | Stack stack = new Stack<>(); 31 | TreeNode current = root; 32 | stack.push(current); 33 | 34 | while (!stack.isEmpty()) { 35 | current = stack.pop(); 36 | System.out.println(current.getValue()); 37 | if (current.getLeft() == null && current.getRight() == null) { 38 | continue; 39 | } else { 40 | if (current.getRight() != null) { 41 | stack.push(current.getRight()); 42 | } 43 | if (current.getLeft() != null) { 44 | stack.push(current.getLeft()); 45 | } 46 | } 47 | } 48 | } 49 | 50 | public static void main(String[] args) { 51 | TreeNode node4 = new TreeNode("4", null, null); 52 | TreeNode node5 = new TreeNode("5", null, null); 53 | TreeNode node6 = new TreeNode("6", null, null); 54 | TreeNode node3 = new TreeNode("3", null, node6); 55 | TreeNode node2 = new TreeNode("2", node4, node5); 56 | TreeNode root = new TreeNode("1", node2, node3); 57 | 58 | DepthFirstSearch.executeDFS(root); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /PYTHON/BFS.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | 3 | # This class represents a directed graph 4 | # It is using adjacency list representation 5 | class Graph: 6 | 7 | # Constructor 8 | def __init__(self, number_of_nodes): 9 | # default dictionary to store graph 10 | self.graph = defaultdict(list) 11 | self.nodes = number_of_nodes 12 | 13 | # Function to add an edge to graph 14 | def addEdge(self,u,v): 15 | self.graph[u].append(v) 16 | 17 | # Function to print a BFS of graph 18 | def BFS(self, s): 19 | 20 | # Mark all the vertices as not visited 21 | visited = [False] * (self.nodes) 22 | 23 | # Create a queue for BFS 24 | queue = [] 25 | 26 | # Mark the source node as 27 | # visited and enqueue it 28 | queue.append(s) 29 | visited[s] = True 30 | 31 | while queue: 32 | 33 | # Dequeue a vertex from 34 | # queue and print it 35 | s = queue.pop(0) 36 | print str(s) + " " 37 | 38 | # Get all adjacent vertices of the 39 | # dequeued vertex s. If a adjacent 40 | # has not been visited, then mark it 41 | # visited and enqueue it 42 | for i in self.graph[s]: 43 | if visited[i] == False: 44 | queue.append(i) 45 | visited[i] = True 46 | 47 | def main(): 48 | g = Graph(6) 49 | g.addEdge(0, 1) 50 | g.addEdge(0, 2) 51 | g.addEdge(1, 3) 52 | g.addEdge(1, 4) 53 | g.addEdge(2, 4) 54 | g.addEdge(3, 4) 55 | g.addEdge(3, 5) 56 | g.addEdge(4, 5) 57 | 58 | print "Following is Breadth First Traversal (starting from vertex 1)" 59 | g.BFS(0) 60 | 61 | 62 | if __name__ == "__main__": 63 | main() 64 | -------------------------------------------------------------------------------- /PYTHON/Nqueens.py: -------------------------------------------------------------------------------- 1 | # Given N, and for a given N x N chessboard, find a way to place N queens such that no queen can attack any other queen on the chess board. A queen can be killed when it lies in the same row, or same column, or the same diagonal of any of the other queens.Print all such configurations. 2 | 3 | 4 | # Input format: 5 | # N 6 | 7 | 8 | #Output format: 9 | #One Line for every board configuration.Every line will have N*N board elements printed row wise and separated by space 10 | 11 | 12 | #Code: 13 | 14 | def isSafe (row,col,board,n): 15 | #check vertically 16 | i=row-1 17 | while i>=0: 18 | if board[i][col]==1: 19 | return False 20 | i-=1 21 | 22 | i=row-1 23 | j=col-1 24 | while i>=0 and j>=0: 25 | if board[i][j]==1: 26 | return False 27 | i-=1 28 | j-=1 29 | i=row-1 30 | j=col+1 31 | while i>=0 and j 2 | #include 3 | #include 4 | #define MAXLIMIT 100 5 | 6 | struct queue 7 | { 8 | int front, rear; 9 | int data[MAXLIMIT]; 10 | }; 11 | 12 | void create(struct queue *q) 13 | { 14 | q->front=-1; 15 | q->rear=-1; 16 | } 17 | 18 | bool isEmpty(struct queue *q) 19 | { 20 | if (q->front==-1) 21 | return true; 22 | else 23 | return false; 24 | } 25 | 26 | void enqueue(struct queue *q,int d) 27 | { 28 | if (isEmpty(q)) 29 | { 30 | q->front++; 31 | q->rear++; 32 | q->data[q->rear]=d; 33 | } 34 | else 35 | { 36 | if (q->rear==MAXLIMIT-1) 37 | return; 38 | else 39 | { 40 | q->rear++; 41 | q->data[q->rear]=d; 42 | } 43 | } 44 | } 45 | int dequeue(struct queue *q) 46 | { 47 | int temp = q->data[q->front]; 48 | if(q->front==-1) 49 | return 0; 50 | if (q->front == q->rear) 51 | { 52 | q->front=q->rear=-1; 53 | } 54 | else 55 | { 56 | q->front++; 57 | } 58 | return temp; 59 | } 60 | 61 | void creategraph(int adjmat[][50]) 62 | { 63 | int i,x,y; 64 | while(1) 65 | { 66 | scanf("%d %d",&x,&y); 67 | if(x==-1 && y==-1) 68 | break; 69 | else 70 | adjmat[x][y]=1; 71 | } 72 | } 73 | 74 | void BFS(int adjmat[][50],int n,int svertex) 75 | { 76 | int v,i,visited[50]={0}; 77 | struct queue q; 78 | create(&q); 79 | 80 | enqueue(&q,svertex); 81 | visited[svertex]=1; 82 | 83 | while(!isEmpty(&q)) 84 | { 85 | v=dequeue(&q); 86 | printf("%d ",v); 87 | for(i=1;i<=n;i++) 88 | if(adjmat[v][i]==1 && visited[i]==0) 89 | { 90 | enqueue(&q,i); 91 | visited[i]=1; 92 | } 93 | } 94 | } 95 | 96 | void main() 97 | { 98 | int adjmat[50][50]={0}; 99 | int n,svertex; 100 | printf("\nEnter the number of vertices in the graph\n"); 101 | scanf("%d",&n); 102 | creategraph(adjmat); 103 | printf("Enter the starting vertex\n"); 104 | scanf("%d",&svertex); 105 | BFS(adjmat,n,svertex); 106 | } 107 | -------------------------------------------------------------------------------- /JAVA/TransposeMatrix.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class TransposeMatrix { 3 | public static void transpose(int[][] matrix1,int rowvalue,int colvalue) 4 | { 5 | int row = rowvalue; 6 | int col = colvalue; 7 | 8 | int loop1,loop2,temp; 9 | int[][] matrix2 = new int [col][row]; 10 | 11 | for(loop1=0;loop1 3 | using namespace std; 4 | void displayMatrix(unsigned int const *p, 5 | unsigned int row, 6 | unsigned int col); 7 | 8 | void rotate(unsigned int *pS, 9 | unsigned int *pD, 10 | unsigned int row, 11 | unsigned int col); 12 | 13 | void displayMatrix(unsigned int const *p, 14 | unsigned int r, 15 | unsigned int c) 16 | { 17 | unsigned int row, col; 18 | cout << "\n\n"; 19 | 20 | for (row = 0; row < r; row++) 21 | { 22 | for (col = 0; col < c; col++) 23 | cout << * (p + row * c + col) << "\t"; 24 | cout << "\n"; 25 | } 26 | 27 | cout << "\n\n"; 28 | } 29 | 30 | void rotate(unsigned int *pS, 31 | unsigned int *pD, 32 | unsigned int row, 33 | unsigned int col) 34 | { 35 | unsigned int r, c; 36 | for (r = 0; r < row; r++) 37 | { 38 | for (c = 0; c < col; c++) 39 | { 40 | *(pD + c * row + (row - r - 1)) = 41 | *(pS + r * col + c); 42 | } 43 | } 44 | } 45 | 46 | int main() 47 | { 48 | 49 | // declarations 50 | unsigned int image[][4] = {{1, 2, 3, 4}, 51 | {5, 6, 7, 8}, 52 | {9, 10, 11, 12}}; 53 | unsigned int *pSource; 54 | unsigned int *pDestination; 55 | unsigned int m, n; 56 | 57 | // setting initial values 58 | // and memory allocation 59 | m = 3, n = 4, pSource = (unsigned int *)image; 60 | pDestination = (unsigned int *)malloc 61 | (sizeof(int) * m * n); 62 | 63 | // process each buffer 64 | displayMatrix(pSource, m, n); 65 | 66 | rotate(pSource, pDestination, m, n); 67 | 68 | displayMatrix(pDestination, n, m); 69 | 70 | free(pDestination); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /.mypy_cache/3.8/Matrix_Transpose.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "Matrix_Transpose", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "X": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Matrix_Transpose.X", "name": "X", "type": {".class": "Instance", "args": [{".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}], "type_ref": "builtins.list"}}}, "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Matrix_Transpose.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Matrix_Transpose.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Matrix_Transpose.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Matrix_Transpose.__package__", "name": "__package__", "type": "builtins.str"}}, "i": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Matrix_Transpose.i", "name": "i", "type": "builtins.int"}}, "j": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Matrix_Transpose.j", "name": "j", "type": "builtins.int"}}, "r": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Matrix_Transpose.r", "name": "r", "type": {".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}}}, "result": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Matrix_Transpose.result", "name": "result", "type": {".class": "Instance", "args": [{".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}], "type_ref": "builtins.list"}}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\Matrix_Transpose.py"} -------------------------------------------------------------------------------- /PYTHON/sudoku.py: -------------------------------------------------------------------------------- 1 | # Given a 9*9 sudoku board, in which some entries are filled and others are 0 (0 indicates that the cell is empty),found out whether the Sudoku puzzle can be solved or not i.e. return true or false. 2 | 3 | # Input Format : 4 | # 9 Lines where ith line contains ith row elements separated by space 5 | 6 | # Output Format : 7 | # true or false 8 | 9 | 10 | def isBoxSafe(row, col, num, board): 11 | rowstart = row - row%3 12 | colstart = col - col%3 13 | for i in range(rowstart, rowstart+3): 14 | for j in range(colstart, colstart+3): 15 | if board[i][j] == num: 16 | return False 17 | return True 18 | 19 | def isColSafe(col, num, board): 20 | for i in range(8): 21 | if board[i][col] == num: 22 | return False 23 | return True 24 | 25 | def isRowSafe(row, num, board): 26 | for i in range(8): 27 | if board[row][i] == num: 28 | return False 29 | return True 30 | 31 | def canPlaceNum(row, col, num, board): 32 | if not isRowSafe(row, num, board): 33 | return False 34 | if not isColSafe(col, num, board): 35 | return False 36 | if not isBoxSafe(row, col, num, board): 37 | return False 38 | return True 39 | 40 | def solveSudoku(board): 41 | row, col = -1, -1 42 | isEmpty = False 43 | for i in range(9): 44 | for j in range(9): 45 | if board[i][j] == 0: 46 | row = i 47 | col = j 48 | isEmpty = True 49 | break 50 | if isEmpty: 51 | break 52 | if row == -1: 53 | return True 54 | for num in range(1, 10): 55 | if canPlaceNum(row, col, num, board): 56 | board[row][col] = num 57 | if(solveSudoku(board)): 58 | return True 59 | else: 60 | board[row][col] = 0 61 | return False 62 | i=0 63 | print('Enter 9 Lines where ith line contains ith row elements separated by space') 64 | board = [[ int(ele) for ele in input().split() ]for i in range(9)] 65 | ans = solveSudoku(board) 66 | if ans is True: 67 | print('Sudoku can be solved') 68 | else: 69 | print('Sudoku cannot be solved') -------------------------------------------------------------------------------- /JAVA/BFS.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | class BFS 5 | { 6 | 7 | private int noOfVertices; 8 | private LinkedList adjLst[]; 9 | 10 | //This constructor will automatically create a graph with noOfVertices vertices 11 | //It will also make noOfVertices adjacency lists corresponding to each vertex 12 | //An adjaceny list corresponding to vertex u will have the vertices which are neighbours of u 13 | BFS(int noOfVertices) { 14 | this.noOfVertices = noOfVertices; 15 | adjLst = new LinkedList[noOfVertices + 1]; 16 | for (int i=1; i <= noOfVertices; i++) 17 | adjLst[i] = new LinkedList(); 18 | } 19 | 20 | //Function to add an edge into the graph 21 | //Depending upon your use case, i.e directed or undirected graph, comment/uncomment the second line 22 | //I have considered an undirected graph here 23 | void addEdge(int u, int v) { 24 | adjLst[u].add(v); 25 | adjLst[v].add(u); 26 | } 27 | 28 | //prints BFS traversal from a given source vertex -> start 29 | void bfs(int start) 30 | { 31 | //Mark all the vertices as not visited, i.e false 32 | boolean visited[] = new boolean[noOfVertices + 1]; 33 | 34 | LinkedList queue = new LinkedList(); 35 | 36 | //We mark the source node as visited and add it inside the queue 37 | visited[start]=true; 38 | queue.add(start); 39 | 40 | while (queue.size() != 0) 41 | { 42 | //We will dequeue this vertex and start traversing through its neighbours 43 | int next = queue.poll(); 44 | System.out.print(next + " -> "); 45 | 46 | //Now we are traversing through each neighbour of next 47 | //If it is not marked visited, we will add it in the queue 48 | for(int n : adjLst[next]) { 49 | if (!visited[n]) { 50 | visited[n] = true; 51 | queue.add(n); 52 | } 53 | } 54 | } 55 | } 56 | 57 | public static void main(String args[]) 58 | { 59 | BFS b = new BFS(5); 60 | 61 | b.addEdge(1, 2); 62 | b.addEdge(2, 4); 63 | b.addEdge(4, 1); 64 | b.addEdge(3, 5); 65 | b.addEdge(2, 3); 66 | 67 | b.bfs(3); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /CPP/Dijkstra.cpp: -------------------------------------------------------------------------------- 1 | //There are many ways to find the shortest path, but 2 | //this program is used to implement Dijkstra's Algorithm using priority queue(min heap) 3 | 4 | //Time Complexity: O(ElogV) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | typedef pair ipair; 14 | 15 | class Graph{ 16 | int v; 17 | list *adj; 18 | public: 19 | Graph(int v); 20 | void Edge(int edge,int weight,int vertex); 21 | void dijkstra_pq(int src); 22 | }; 23 | 24 | Graph::Graph(int v){ 25 | this->v=v; 26 | adj=new list [v]; 27 | 28 | } 29 | void Graph::Edge(int u, int v, int w) 30 | { 31 | adj[u].push_back(make_pair(v, w)); 32 | adj[v].push_back(make_pair(u, w)); 33 | } 34 | 35 | void Graph::dijkstra_pq(int src){ 36 | priority_queue,greater> pq; //This is the syntax of creating a min heap using priority queue 37 | 38 | // Create a vector for distances and initialize all 39 | // distances as infinite (INF) 40 | 41 | vector dist(v,INT16_MAX); 42 | 43 | //Insert source itself in priority queue and initialize 44 | // its distance as 0. 45 | 46 | pq.push(make_pair(0,src)); 47 | dist[src]=0; 48 | while(!pq.empty()){ 49 | int u=pq.top().second; 50 | pq.pop(); 51 | 52 | for(auto i=adj[u].begin();i!=adj[u].end();i++){ 53 | int V=(*i).first; 54 | int w=(*i).second; 55 | if(dist[V]>dist[u]+w){ // Edge Relaxation 56 | dist[V]=dist[u]+w; 57 | pq.push(make_pair(dist[V],V)); 58 | } 59 | } 60 | } 61 | 62 | // Print shortest distances stored in dist[] 63 | 64 | cout<<"Vertex\t\tDistance"< 2 | int chkleap(int y) 3 | { 4 | if((y%400)==0||((y%100!=0)&(y%4==0))) 5 | { 6 | //printf("Leap year\n"); 7 | return 1; 8 | } 9 | else return 0; 10 | } 11 | int reyear(int y) 12 | { 13 | int re=0; 14 | y=y-1; 15 | int mod=y%400; 16 | re=(mod +( mod/4)); 17 | if(mod<100) 18 | { 19 | re=re; 20 | //printf("odd days in year 0 calculation %d\n",re); 21 | } 22 | else if(mod<200) 23 | { 24 | re=re-1; 25 | //printf("odd days in year1 calculation %d\n",re); 26 | } 27 | else if(mod<300) 28 | { 29 | 30 | re=re-2; 31 | //printf("odd days in year 2calculation %d\n",re); 32 | } 33 | else if(mod<400) 34 | { 35 | 36 | re=re-3; 37 | //printf("odd days in year3 calculation %d\n",re); 38 | } 39 | re=re%7; 40 | //printf("odd days in year calculation %d\n",re); 41 | return re; 42 | } 43 | int remonth(int m,int y,int d) 44 | { 45 | int re=0; 46 | if(m>1) 47 | re=re+31; 48 | 49 | if (m>2) 50 | {if(chkleap(y)) 51 | re=re+29; 52 | else re=re+28;} 53 | 54 | if (m>3) 55 | re =re+31; 56 | 57 | if(m>4) 58 | re=re+30; 59 | 60 | if(m>5) 61 | re=re+31; 62 | 63 | if(m>6) 64 | re=re+30; 65 | if(m>7) 66 | re=re+31; 67 | if(m>8) 68 | re=re+31; 69 | if(m>9) 70 | re=re+30; 71 | if(m>10) 72 | re=re+31; 73 | if(m>11) 74 | re=re+30; 75 | //printf("odd days in month calculation %d\n day=%d\n",re%7,(d%7)); 76 | re=re+d; 77 | re=re%7; 78 | 79 | return re; 80 | 81 | } 82 | void prDay(int rem) 83 | { 84 | if(rem==0) 85 | { 86 | printf("Sunday\n"); 87 | return; 88 | } 89 | if(rem==1) 90 | { 91 | printf("Monday\n"); 92 | return; 93 | } 94 | if(rem==2) 95 | { 96 | printf("Tuesday\n"); 97 | return; 98 | } 99 | if(rem==3) 100 | { 101 | printf("Wednesday\n"); 102 | return; 103 | } 104 | if(rem==4) 105 | { 106 | printf("Thursday\n"); 107 | return; 108 | } 109 | if(rem==5) 110 | { 111 | printf("Friday\n"); 112 | return; 113 | } 114 | if(rem==6) 115 | { 116 | printf("Saturday\n"); 117 | return; 118 | } 119 | 120 | } 121 | int main() 122 | { 123 | int d,m,y,t; 124 | printf("How many dates you want to find ? ( no of test cases)\n"); 125 | scanf("%d",&t); 126 | while(t--) 127 | { 128 | printf("Enter Date in DD:MM:YYYY format (eg 14:10:2020)\n"); 129 | scanf("%d:%d:%d",&d,&m,&y); 130 | prDay((reyear(y)+remonth(m,y,d))%7); 131 | } 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /PYTHON/Kruskal.py: -------------------------------------------------------------------------------- 1 | #Given an undirected, connected and weighted graph G(V, E) with V number of vertices (which are numbered from 0 to V-1) and E number of edges. 2 | # I have found and printed the Minimum Spanning Tree (MST) using Kruskal's algorithm. 3 | #For printing MST I have followed the steps - 4 | #1. In one line, print an edge which is part of MST in the format -v1 v2 w ,where, v1 and v2 are the vertices of the edge which is included in MST and whose weight is w. And v1 <= v2 i.e. print the smaller vertex first while printing an edge. 5 | #2. Print V-1 edges in above format in different lines. 6 | 7 | 8 | 9 | #Input Format : 10 | #Line 1: Two Integers V and E (separated by space) 11 | #Next E lines : Three integers ei, ej and wi, denoting that there exists an edge between vertex ei and vertex ej with weight wi (separated by space) 12 | 13 | 14 | 15 | #Output Format : 16 | #MST 17 | class Edge: 18 | def __init__(self,src,dest,wt): 19 | self.src=src 20 | self.dest=dest 21 | self.wt=wt 22 | 23 | def getParent(v,parent): 24 | if (v==parent[v]): 25 | return v 26 | return getParent(parent[v],parent) 27 | 28 | def kruskal(edges,nVertices): 29 | parent=[i for i in range(nVertices)] 30 | edges=sorted(edges,key=lambda edge:edge.wt) 31 | count=0 32 | output=[] 33 | i=0 34 | while count<(nVertices-1): 35 | currentEdge=edges[i] 36 | srcParent=getParent(currentEdge.src,parent) 37 | destParent=getParent(currentEdge.dest,parent) 38 | if srcParent!=destParent: 39 | output.append(currentEdge) 40 | count+=1 41 | parent[srcParent]=destParent 42 | i=i+1 43 | 44 | return output 45 | print("Enter the vertices and edges separated by space") 46 | li=[int(ele) for ele in input().split()] 47 | n=li[0] 48 | E=li[1] 49 | edges=[] 50 | print("Enter Next E lines : Three integers ei, ej and wi, denoting that there exists an edge between vertex ei and vertex ej with weight wi (separated by space)") 51 | for i in range(E): 52 | curr_input=[int(ele)for ele in input().split()] 53 | src=curr_input[0] 54 | dest=curr_input[1] 55 | wt=curr_input[2] 56 | edge=Edge(src,dest,wt) 57 | edges.append(edge) 58 | output=kruskal(edges,n) 59 | print("\nMST:: \n") 60 | for edge in output: 61 | if (edge.src 3 | 4 | 5 | The aim of the project is to include all the basic code snippets for competitive programming so that when a beginner gets stuck for any syntax or algorithm this repo will help out. 6 | 7 | 8 | 9 | # Ways to contribute: 10 | 1. Solve the issues which are listed 11 | 2. Create your own issue and then send PR. 12 | 13 | Please refer to the project's style and contribution guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow. 14 | 15 | 1. **Fork** the repo on GitHub 16 | 2. **Clone** the project to your own machine 17 | 3. **Commit** changes to your own branch 18 | 4. **Push** your work back up to your fork 19 | 5. Submit a **Pull request** so that we can review your changes 20 | 21 | NOTE 1: Please abide by the [Contributing Guidelines](https://github.com/Webwiznitr/MilkERP/blob/master/CONTRIBUTING.md). 22 | 23 | NOTE 2: Please abide by the [Code of Conduct](https://github.com/Webwiznitr/MilkERP/blob/master/CODE_OF_CONDUCT.md). 24 | 25 |
26 | 27 | 28 | 29 | ## Admins 🤟🏻 30 | 31 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

Sayantan Maiti

🦊

Aniket Pal

🦊
43 | 44 | 45 | 46 | 47 | 48 | ##### The whole project will be created on basic C, Cpp ,Python and Java so beginners can also contribute. 49 | 50 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 51 | -------------------------------------------------------------------------------- /.mypy_cache/3.8/sudoku.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "sudoku", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoku.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoku.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoku.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoku.__package__", "name": "__package__", "type": "builtins.str"}}, "ans": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "sudoku.ans", "name": "ans", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "board": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "sudoku.board", "name": "board", "type": {".class": "Instance", "args": [{".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}], "type_ref": "builtins.list"}}}, "canPlaceNum": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0, 0], "arg_names": ["row", "col", "num", "board"], "flags": [], "fullname": "sudoku.canPlaceNum", "name": "canPlaceNum", "type": null}}, "i": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "sudoku.i", "name": "i", "type": "builtins.int"}}, "isBoxSafe": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0, 0], "arg_names": ["row", "col", "num", "board"], "flags": [], "fullname": "sudoku.isBoxSafe", "name": "isBoxSafe", "type": null}}, "isColSafe": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["col", "num", "board"], "flags": [], "fullname": "sudoku.isColSafe", "name": "isColSafe", "type": null}}, "isRowSafe": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["row", "num", "board"], "flags": [], "fullname": "sudoku.isRowSafe", "name": "isRowSafe", "type": null}}, "solveSudoku": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["board"], "flags": [], "fullname": "sudoku.solveSudoku", "name": "solveSudoku", "type": null}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\sudoku.py"} -------------------------------------------------------------------------------- /CPP/edit_Dist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long int 4 | #define deb(x) cout<<#x<<" = "<=1;--i) 36 | { 37 | if(s1[i-1]==s2[m-1]) 38 | { 39 | dp[i][m]=min(insertCost,delCost)*(n-i); 40 | } 41 | else 42 | { 43 | dp[i][m]=insertCost + dp[i+1][m]; 44 | dp[i][m]=min(dp[i][m],delCost + dp[i+1][m]); 45 | dp[i][m]=min(replaceCost + min(insertCost,delCost)*(n-i),dp[i][m]); 46 | 47 | } 48 | 49 | } 50 | 51 | for(int j=m-1;j>=1;--j) 52 | { 53 | if(s1[n-1]==s2[j-1]) 54 | { 55 | dp[n][j]=min(insertCost,delCost)*(m-j); 56 | } 57 | else 58 | { 59 | dp[n][j]=insertCost + dp[n][j+1]; 60 | dp[n][j]=min(dp[n][j],delCost + dp[n][j+1]); 61 | dp[n][j]=min(replaceCost + min(insertCost,delCost)*(m-j),dp[n][j]); 62 | 63 | } 64 | 65 | } 66 | 67 | for(int i=n-1;i>=1;--i) 68 | { 69 | for(int j=m-1;j>=1;--j) 70 | { 71 | 72 | if(s1[i-1]==s2[j-1]) 73 | { 74 | dp[i][j]=dp[i+1][j+1]; 75 | } 76 | else 77 | { 78 | dp[i][j]= insertCost + min(dp[i+1][j],dp[i][j+1]); 79 | dp[i][j]= min(delCost + min(dp[i+1][j],dp[i][j+1]) , dp[i][j]); 80 | dp[i][j]=min(replaceCost + dp[i+1][j+1], dp[i][j]); 81 | 82 | } 83 | 84 | } 85 | } 86 | 87 | return dp[1][1]; 88 | 89 | 90 | } 91 | 92 | void solve() 93 | { 94 | string s1="sunday" , s2="saturday"; 95 | //cout<>_t;while(_t--) 105 | solve(); 106 | return 0; 107 | } -------------------------------------------------------------------------------- /C/dijkstra.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define INFINITY 9999 3 | #define MAX 10 4 | 5 | void Dijkstra(int Graph[MAX][MAX], int n, int start); 6 | 7 | void Dijkstra(int Graph[MAX][MAX], int n, int start) { 8 | int cost[MAX][MAX], distance[MAX], pred[MAX]; 9 | int visited[MAX], count, mindistance, nextnode, i, j; 10 | 11 | // Creating cost matrix 12 | for (i = 0; i < n; i++) 13 | for (j = 0; j < n; j++) 14 | if (Graph[i][j] == 0) 15 | cost[i][j] = INFINITY; 16 | else 17 | cost[i][j] = Graph[i][j]; 18 | //pred[] stores the predecessor of each node 19 | //initialize pred[],distance[] and visited[] 20 | for (i = 0; i < n; i++) { 21 | distance[i] = cost[start][i]; 22 | pred[i] = start; 23 | visited[i] = 0; 24 | } 25 | 26 | distance[start] = 0; 27 | visited[start] = 1; 28 | count = 1; 29 | 30 | while (count < n - 1) { 31 | mindistance = INFINITY; 32 | //nextnode gives the node at minimum distance 33 | for (i = 0; i < n; i++) 34 | if (distance[i] < mindistance && !visited[i]) { 35 | mindistance = distance[i]; 36 | nextnode = i; 37 | } 38 | //checking if a better path exists through nextnode 39 | visited[nextnode] = 1; 40 | for (i = 0; i < n; i++) 41 | if (!visited[i]) 42 | if (mindistance + cost[nextnode][i] < distance[i]) { 43 | distance[i] = mindistance + cost[nextnode][i]; 44 | pred[i] = nextnode; 45 | } 46 | count++; 47 | } 48 | 49 | // Printing the distance of each vertex from the source 50 | for (i = 0; i < n; i++) 51 | if (i != start) { 52 | printf("\nDistance from source to %d: %d", i, distance[i]); 53 | } 54 | } 55 | int main() { 56 | int Graph[MAX][MAX], i, j, n, u; 57 | n = 7; 58 | // Giving the graph input in the form of 2-dimensional matrix with 7 vertices. 59 | Graph[0][0] = 0; 60 | Graph[0][1] = 0; 61 | Graph[0][2] = 1; 62 | Graph[0][3] = 2; 63 | Graph[0][4] = 0; 64 | Graph[0][5] = 0; 65 | Graph[0][6] = 0; 66 | 67 | Graph[1][0] = 0; 68 | Graph[1][1] = 0; 69 | Graph[1][2] = 2; 70 | Graph[1][3] = 0; 71 | Graph[1][4] = 0; 72 | Graph[1][5] = 3; 73 | Graph[1][6] = 0; 74 | 75 | Graph[2][0] = 1; 76 | Graph[2][1] = 2; 77 | Graph[2][2] = 0; 78 | Graph[2][3] = 1; 79 | Graph[2][4] = 3; 80 | Graph[2][5] = 0; 81 | Graph[2][6] = 0; 82 | 83 | Graph[3][0] = 2; 84 | Graph[3][1] = 0; 85 | Graph[3][2] = 1; 86 | Graph[3][3] = 0; 87 | Graph[3][4] = 0; 88 | Graph[3][5] = 0; 89 | Graph[3][6] = 1; 90 | 91 | Graph[4][0] = 0; 92 | Graph[4][1] = 0; 93 | Graph[4][2] = 3; 94 | Graph[4][3] = 0; 95 | Graph[4][4] = 0; 96 | Graph[4][5] = 2; 97 | Graph[4][6] = 0; 98 | 99 | Graph[5][0] = 0; 100 | Graph[5][1] = 3; 101 | Graph[5][2] = 0; 102 | Graph[5][3] = 0; 103 | Graph[5][4] = 2; 104 | Graph[5][5] = 0; 105 | Graph[5][6] = 1; 106 | 107 | Graph[6][0] = 0; 108 | Graph[6][1] = 0; 109 | Graph[6][2] = 0; 110 | Graph[6][3] = 1; 111 | Graph[6][4] = 0; 112 | Graph[6][5] = 1; 113 | Graph[6][6] = 0; 114 | 115 | u = 0; //starting from 0th vertex i.e source 116 | Dijkstra(Graph, n, u); 117 | 118 | return 0; 119 | } -------------------------------------------------------------------------------- /CPP/MinimumSpanningTree.cpp: -------------------------------------------------------------------------------- 1 | // A C++ program for Prim's Minimum 2 | // Spanning Tree (MST) algorithm. The program is 3 | // for adjacency matrix representation of the graph 4 | #include 5 | using namespace std; 6 | 7 | // Number of vertices in the graph 8 | #define V 5 9 | 10 | // A utility function to find the vertex with 11 | // minimum key value, from the set of vertices 12 | // not yet included in MST 13 | int minKey(int key[], bool mstSet[]) 14 | { 15 | // Initialize min value 16 | int min = INT_MAX, min_index; 17 | 18 | for (int v = 0; v < V; v++) 19 | if (mstSet[v] == false && key[v] < min) 20 | min = key[v], min_index = v; 21 | 22 | return min_index; 23 | } 24 | 25 | // A utility function to print the 26 | // constructed MST stored in parent[] 27 | void printMST(int parent[], int graph[V][V]) 28 | { 29 | cout<<"Edge \tWeight\n"; 30 | for (int i = 1; i < V; i++) 31 | cout<0 and visited[i] is False : 37 | q.put(i) 38 | visited[i]=True 39 | def bfs(self): 40 | visited=[False for i in range(self.nVertices)] 41 | for i in range(self.nVertices): 42 | if visited[i] is False: 43 | self.__bfsHelper(i,visited) 44 | def removeEdge(self): 45 | if self.containsEdge(v1,v2) is False: 46 | return 47 | self.adjMatrix[v1][v2]=0 48 | self.adjMatrix[v2][v1]=0 49 | def containsEdge(self,v1,v2): 50 | return True if self.adjMatrix[v1][v2]>0 else False 51 | def _str_(self): 52 | return str(self.adjMatrix) 53 | def __getminvertex(self,visited,weight): 54 | min_vertex=-1 55 | for i in range(self.nVertices): 56 | if(visited[i] is False and (min_vertex==-1 or weight[min_vertex]>weight[i])): 57 | min_vertex=i 58 | return min_vertex 59 | def prims(self): 60 | visited=[False for i in range(self.nVertices)] 61 | parent=[-1 for i in range(self.nVertices)] 62 | weight=[sys.maxsize for i in range (self.nVertices)] 63 | weight[0]=0 64 | for i in range (self.nVertices-1): 65 | min_vertex=self.__getminvertex(visited,weight) 66 | visited[min_vertex]=True 67 | 68 | for j in range(self.nVertices): 69 | if self.adjMatrix[min_vertex][j]>0 and visited[j] is False: 70 | if(weight[j]>self.adjMatrix[min_vertex][j]): 71 | weight[j]=self.adjMatrix[min_vertex][j] 72 | parent[j]=min_vertex 73 | 74 | for i in range(1,self.nVertices): 75 | if i settledNodes = new HashSet(); 15 | Set unsettledNodes = new HashSet(); 16 | unsettledNodes.add(sourceNode); 17 | 18 | while(unsettledNodes.size() != 0) { 19 | Node currentNode = getLowestDistance(unsettledNodes); 20 | unsettledNodes.remove(currentNode); 21 | for (Entry neigborPair : currentNode.getNeighborNode().entrySet()) { 22 | if(!settledNodes.contains(neigborPair.getKey())) { 23 | minimumDistanceBetweenTwoNodes(neigborPair, currentNode); 24 | unsettledNodes.add(neigborPair.getKey()); 25 | } 26 | } 27 | settledNodes.add(currentNode); 28 | } 29 | 30 | return graph; 31 | } 32 | 33 | private static void minimumDistanceBetweenTwoNodes(Map.Entry evaluationNodeEntry, Node sourceNode) { 34 | Integer sourceDistance = sourceNode.getDistance(); 35 | Node evaluationNode = evaluationNodeEntry.getKey(); 36 | Integer distanceToNeighbor = evaluationNodeEntry.getValue(); 37 | Integer newDistance = sourceDistance + distanceToNeighbor; 38 | if(newDistance < evaluationNode.getDistance()) { 39 | evaluationNode.setDistance(newDistance); 40 | LinkedList shortestPath = new LinkedList(sourceNode.getShortestPath()); 41 | shortestPath.add(sourceNode); 42 | evaluationNode.setShortestPath(shortestPath); 43 | } 44 | } 45 | 46 | private static Node getLowestDistance(Set unsettledNodes) { 47 | Node closestNode = null; 48 | int smallestDistance = Integer.MAX_VALUE; 49 | for (Node node : unsettledNodes) { 50 | int nodeDistance = node.getDistance(); 51 | if(smallestDistance > nodeDistance) { 52 | smallestDistance = nodeDistance; 53 | closestNode = node; 54 | } 55 | } 56 | return closestNode; 57 | } 58 | 59 | } 60 | 61 | class Node { 62 | 63 | private String name; 64 | private Collection shortestPath = new LinkedList(); 65 | private Integer distance = Integer.MAX_VALUE; 66 | private Map neighborNodes = new HashMap(); 67 | 68 | public Node(String name) { 69 | this.name = name; 70 | } 71 | 72 | public void addDestination(Node destination, int distance) { 73 | neighborNodes.put(destination, distance); 74 | } 75 | 76 | public String getName() { 77 | return name; 78 | } 79 | public void setName(String name) { 80 | this.name = name; 81 | } 82 | public Collection getShortestPath() { 83 | return shortestPath; 84 | } 85 | public void setShortestPath(Collection shortestPath) { 86 | this.shortestPath = shortestPath; 87 | } 88 | public Integer getDistance() { 89 | return distance; 90 | } 91 | public void setDistance(Integer distance) { 92 | this.distance = distance; 93 | } 94 | public Map getNeighborNode() { 95 | return neighborNodes; 96 | } 97 | public void setNeighborNode(Map neighborNode) { 98 | this.neighborNodes = neighborNode; 99 | } 100 | } 101 | 102 | class Graph { 103 | 104 | private Set nodes = new HashSet(); 105 | 106 | public void addNode(Node node) { 107 | nodes.add(node); 108 | } 109 | 110 | public Set getNodes() { 111 | return nodes; 112 | } 113 | 114 | public void setNodes(Set nodes) { 115 | this.nodes = nodes; 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /.mypy_cache/3.8/Kruskal.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "Kruskal", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "E": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.E", "name": "E", "type": "builtins.int"}}, "Edge": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "TypeInfo", "_promote": null, "abstract_attributes": [], "bases": ["builtins.object"], "declared_metaclass": null, "defn": {".class": "ClassDef", "fullname": "Kruskal.Edge", "name": "Edge", "type_vars": []}, "flags": [], "fullname": "Kruskal.Edge", "metaclass_type": null, "metadata": {}, "module_name": "Kruskal", "mro": ["Kruskal.Edge", "builtins.object"], "names": {".class": "SymbolTable", "__init__": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0, 0], "arg_names": ["self", "src", "dest", "wt"], "flags": [], "fullname": "Kruskal.Edge.__init__", "name": "__init__", "type": null}}, "dest": {".class": "SymbolTableNode", "implicit": true, "kind": "Mdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.Edge.dest", "name": "dest", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "src": {".class": "SymbolTableNode", "implicit": true, "kind": "Mdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.Edge.src", "name": "src", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "wt": {".class": "SymbolTableNode", "implicit": true, "kind": "Mdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.Edge.wt", "name": "wt", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}}, "tuple_type": null, "type_vars": [], "typeddict_type": null}}, "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Kruskal.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Kruskal.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Kruskal.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "Kruskal.__package__", "name": "__package__", "type": "builtins.str"}}, "curr_input": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.curr_input", "name": "curr_input", "type": {".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}}}, "dest": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.dest", "name": "dest", "type": "builtins.int"}}, "edge": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.edge", "name": "edge", "type": "Kruskal.Edge"}}, "edges": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.edges", "name": "edges", "type": {".class": "Instance", "args": ["Kruskal.Edge"], "type_ref": "builtins.list"}}}, "getParent": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0], "arg_names": ["v", "parent"], "flags": [], "fullname": "Kruskal.getParent", "name": "getParent", "type": null}}, "i": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.i", "name": "i", "type": "builtins.int"}}, "kruskal": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0], "arg_names": ["edges", "nVertices"], "flags": [], "fullname": "Kruskal.kruskal", "name": "kruskal", "type": null}}, "li": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.li", "name": "li", "type": {".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}}}, "n": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.n", "name": "n", "type": "builtins.int"}}, "output": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.output", "name": "output", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "src": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.src", "name": "src", "type": "builtins.int"}}, "wt": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "Kruskal.wt", "name": "wt", "type": "builtins.int"}}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\Kruskal.py"} -------------------------------------------------------------------------------- /.mypy_cache/3.8/prim.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "prim", "is_partial_stub_package": false, "is_stub": false, "names": {".class": "SymbolTable", "E": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.E", "name": "E", "type": "builtins.int"}}, "Graph": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "TypeInfo", "_promote": null, "abstract_attributes": [], "bases": ["builtins.object"], "declared_metaclass": null, "defn": {".class": "ClassDef", "fullname": "prim.Graph", "name": "Graph", "type_vars": []}, "flags": [], "fullname": "prim.Graph", "metaclass_type": null, "metadata": {}, "module_name": "prim", "mro": ["prim.Graph", "builtins.object"], "names": {".class": "SymbolTable", "__bfsHelper": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["self", "sv", "visited"], "flags": [], "fullname": "prim.Graph.__bfsHelper", "name": "__bfsHelper", "type": null}}, "__getminvertex": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["self", "visited", "weight"], "flags": [], "fullname": "prim.Graph.__getminvertex", "name": "__getminvertex", "type": null}}, "__init__": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0], "arg_names": ["self", "nVertices"], "flags": [], "fullname": "prim.Graph.__init__", "name": "__init__", "type": null}}, "_str_": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["self"], "flags": [], "fullname": "prim.Graph._str_", "name": "_str_", "type": null}}, "addEdge": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0, 0], "arg_names": ["self", "v1", "v2", "wt"], "flags": [], "fullname": "prim.Graph.addEdge", "name": "addEdge", "type": null}}, "adjMatrix": {".class": "SymbolTableNode", "implicit": true, "kind": "Mdef", "node": {".class": "Var", "flags": [], "fullname": "prim.Graph.adjMatrix", "name": "adjMatrix", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "bfs": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["self"], "flags": [], "fullname": "prim.Graph.bfs", "name": "bfs", "type": null}}, "containsEdge": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0, 0, 0], "arg_names": ["self", "v1", "v2"], "flags": [], "fullname": "prim.Graph.containsEdge", "name": "containsEdge", "type": null}}, "nVertices": {".class": "SymbolTableNode", "implicit": true, "kind": "Mdef", "node": {".class": "Var", "flags": [], "fullname": "prim.Graph.nVertices", "name": "nVertices", "type": {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 1}}}, "prims": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["self"], "flags": [], "fullname": "prim.Graph.prims", "name": "prims", "type": null}}, "removeEdge": {".class": "SymbolTableNode", "kind": "Mdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["self"], "flags": [], "fullname": "prim.Graph.removeEdge", "name": "removeEdge", "type": null}}}, "tuple_type": null, "type_vars": [], "typeddict_type": null}}, "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "prim.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "prim.__file__", "name": "__file__", "type": "builtins.str"}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "prim.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "prim.__package__", "name": "__package__", "type": "builtins.str"}}, "curr_input": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.curr_input", "name": "curr_input", "type": {".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}}}, "g": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.g", "name": "g", "type": "prim.Graph"}}, "i": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.i", "name": "i", "type": "builtins.int"}}, "li": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.li", "name": "li", "type": {".class": "Instance", "args": ["builtins.int"], "type_ref": "builtins.list"}}}, "n": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": [], "fullname": "prim.n", "name": "n", "type": "builtins.int"}}, "queue": {".class": "SymbolTableNode", "cross_ref": "queue", "kind": "Gdef"}, "sys": {".class": "SymbolTableNode", "cross_ref": "sys", "kind": "Gdef"}}, "path": "c:\\Users\\Vibha\\OneDrive\\Documents\\GitHub\\Project-alpha\\PYTHON\\prim.py"} -------------------------------------------------------------------------------- /CPP/matrixoperationusing2d.cpp: -------------------------------------------------------------------------------- 1 | //Operations on matrix using 2-D array 2 | //standred run should look like this 3 | /* For First Matrix : 4 | enter row :2 5 | 6 | enter column :2 7 | Enter element a11 : 1 8 | Enter element a12 : 2 9 | Enter element a21 : 3 10 | Enter element a22 : 4 11 | 12 | For Second Matrix : 13 | enter row :2 14 | 15 | enter column :2 16 | Enter element a11 : 1 17 | Enter element a12 : 2 18 | Enter element a21 : 3 19 | Enter element a22 : 4 20 | 21 | 22 | Matrix is: 23 | 1 2 24 | 3 4 25 | 26 | 27 | Matrix is: 28 | 1 2 29 | 3 4 30 | 31 | Matrix of Sum of two matrix is: 32 | 33 | 34 | Matrix is: 35 | 2 4 36 | 6 8 37 | 38 | Matrix of Substraction of two matrix is: 39 | 40 | 41 | Matrix is: 42 | 0 0 43 | 0 0 44 | 45 | Matrix of Multiplication of two matrix is: 46 | 47 | 48 | Matrix is: 49 | 7 10 50 | 15 22 51 | 52 | Transpose of matrix is: 53 | 54 | 55 | Matrix is: 56 | 1 3 57 | 2 4 58 | */ 59 | 60 | #include 61 | 62 | using namespace std; 63 | 64 | class Matrix{ 65 | int row; 66 | int column; 67 | int m[5][5]; 68 | public: 69 | Matrix(){ 70 | column=row=0; 71 | int m[0][0]; 72 | }; 73 | Matrix(int,int); 74 | Matrix(Matrix &x); 75 | void displaydata(Matrix); 76 | void add(Matrix,Matrix); 77 | void sub(Matrix,Matrix); 78 | void mul(Matrix, Matrix); 79 | void trns(Matrix); 80 | ~Matrix(){ 81 | 82 | } 83 | }; 84 | 85 | 86 | Matrix::Matrix(int tempr,int tempc) 87 | { 88 | row=tempr; 89 | column=tempc; 90 | for(int i = 0; i < row; ++i) 91 | for(int j = 0; j < column; ++j) 92 | { 93 | cout << "Enter element a" << i + 1 << j + 1 << " : "; 94 | cin >> m[i][j]; 95 | } 96 | } 97 | 98 | Matrix::Matrix(Matrix &x){ 99 | row=x.row; 100 | column=x.column; 101 | for(int i = 0; i < row; ++i) 102 | for(int j = 0; j < column; ++j) 103 | { 104 | m[i][j] = x.m[i][j]; 105 | } 106 | } 107 | 108 | void Matrix::displaydata(Matrix x) 109 | { 110 | cout << endl << "\n Matrix is: " << endl; 111 | for(int i = 0; i < row; ++i) 112 | for(int j = 0; j < column; ++j) 113 | { 114 | cout << m[i][j] << " "; 115 | if(j == column - 1) 116 | cout << endl; 117 | } 118 | } 119 | 120 | void Matrix::add(Matrix x, Matrix y) 121 | { 122 | if(x.row==y.row && x.column==y.column) 123 | { 124 | int i,j; 125 | row=x.row; 126 | column=y.column; 127 | for(i = 0; i < row; ++i) 128 | for(j = 0; j < column; ++j) 129 | m[i][j] = x.m[i][j] + y.m[i][j]; 130 | 131 | } 132 | else{ 133 | cout<<"\n Matrix are not homogeneous "; 134 | } 135 | } 136 | 137 | void Matrix::sub(Matrix x, Matrix y) 138 | { 139 | if(x.row==y.row && x.column==y.column) 140 | { 141 | int i,j; 142 | row=x.row; 143 | column=y.column; 144 | for(i = 0; i < row; ++i) 145 | for(j = 0; j < column; ++j) 146 | m[i][j] = x.m[i][j] - y.m[i][j]; 147 | 148 | } 149 | else{ 150 | cout<<"\n Matrix are not homogeneous "; 151 | } 152 | } 153 | 154 | void Matrix::mul(Matrix x, Matrix y) 155 | { 156 | if(x.column==y.row){ 157 | column=y.column; 158 | row=x.row; 159 | int i,j,k; 160 | for (i = 0; i < x.row; i++) 161 | { 162 | for (j = 0; j < y.column; j++) 163 | { 164 | m[i][j]=0; //just a minute sir 165 | for (k = 0; k < x.column; k++) 166 | { 167 | m[i][j] += x.m[i][k] * y.m[k][j]; 168 | } 169 | } 170 | } 171 | } 172 | else{ 173 | cout<<"\n Matrix Multiplication couldn't be done "; 174 | } 175 | } 176 | 177 | void Matrix::trns(Matrix x) 178 | { 179 | row=x.column; 180 | column=x.row; 181 | for (int i = 0; i < column; ++i) 182 | for (int j = 0; j < row; ++j) { 183 | m[j][i] = x.m[i][j]; 184 | } 185 | } 186 | 187 | 188 | int main(){ 189 | int r1,r2,c1,c2; 190 | cout<<"\n For First Matrix :"; 191 | cout<<"\n enter row :"; 192 | cin>>r1; 193 | cout<<"\n enter column :"; 194 | cin>>c1; 195 | Matrix m1(r1,c1); 196 | 197 | cout<<"\n For Second Matrix :"; 198 | cout<<"\n enter row :"; 199 | cin>>r2; 200 | cout<<"\n enter column :"; 201 | cin>>c2; 202 | Matrix m2(r2,c2); 203 | 204 | m1.displaydata(m1); 205 | m2.displaydata(m2); 206 | 207 | Matrix m4; 208 | m4.add(m1, m2); 209 | cout << endl << "Matrix of Sum of two matrix is: " << endl; 210 | m4.displaydata(m4); 211 | 212 | Matrix m5; 213 | m5.sub(m1, m2); 214 | cout << endl << "Matrix of Substraction of two matrix is: " << endl; 215 | m5.displaydata(m5); 216 | 217 | Matrix m6; 218 | m6.mul(m1, m2); 219 | cout << endl << "Matrix of Multiplication of two matrix is: " << endl; 220 | m6.displaydata(m5); 221 | 222 | Matrix m7; 223 | m7.trns(m1); 224 | cout << endl << "Transpose of matrix is: " << endl; 225 | m7.displaydata(m6); 226 | } 227 | 228 | 229 | 230 | 231 | 232 | -------------------------------------------------------------------------------- /.mypy_cache/3.8/importlib/__init__.data.json: -------------------------------------------------------------------------------- 1 | {".class": "MypyFile", "_fullname": "importlib", "is_partial_stub_package": false, "is_stub": true, "names": {".class": "SymbolTable", "Any": {".class": "SymbolTableNode", "cross_ref": "typing.Any", "kind": "Gdef", "module_hidden": true, "module_public": false}, "Loader": {".class": "SymbolTableNode", "cross_ref": "_importlib_modulespec.Loader", "kind": "Gdef", "module_hidden": true, "module_public": false}, "Mapping": {".class": "SymbolTableNode", "cross_ref": "typing.Mapping", "kind": "Gdef", "module_hidden": true, "module_public": false}, "Optional": {".class": "SymbolTableNode", "cross_ref": "typing.Optional", "kind": "Gdef", "module_hidden": true, "module_public": false}, "Sequence": {".class": "SymbolTableNode", "cross_ref": "typing.Sequence", "kind": "Gdef", "module_hidden": true, "module_public": false}, "__doc__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "importlib.__doc__", "name": "__doc__", "type": "builtins.str"}}, "__file__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "importlib.__file__", "name": "__file__", "type": "builtins.str"}}, "__import__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 1, 1, 1, 1], "arg_names": ["name", "globals", "locals", "fromlist", "level"], "flags": [], "fullname": "importlib.__import__", "name": "__import__", "type": {".class": "CallableType", "arg_kinds": [0, 1, 1, 1, 1], "arg_names": ["name", "globals", "locals", "fromlist", "level"], "arg_types": ["builtins.str", {".class": "UnionType", "items": [{".class": "Instance", "args": ["builtins.str", {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 2}], "type_ref": "typing.Mapping"}, {".class": "NoneType"}]}, {".class": "UnionType", "items": [{".class": "Instance", "args": ["builtins.str", {".class": "AnyType", "missing_import_name": null, "source_any": null, "type_of_any": 2}], "type_ref": "typing.Mapping"}, {".class": "NoneType"}]}, {".class": "Instance", "args": ["builtins.str"], "type_ref": "typing.Sequence"}, "builtins.int"], "bound_args": [], "def_extras": {"first_arg": null}, "fallback": "builtins.function", "implicit": false, "is_ellipsis_args": false, "name": "__import__", "ret_type": "_importlib_modulespec.ModuleType", "variables": []}}}, "__name__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "importlib.__name__", "name": "__name__", "type": "builtins.str"}}, "__package__": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "Var", "flags": ["is_ready"], "fullname": "importlib.__package__", "name": "__package__", "type": "builtins.str"}}, "find_loader": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 1], "arg_names": ["name", "path"], "flags": [], "fullname": "importlib.find_loader", "name": "find_loader", "type": {".class": "CallableType", "arg_kinds": [0, 1], "arg_names": ["name", "path"], "arg_types": ["builtins.str", {".class": "UnionType", "items": ["builtins.str", {".class": "NoneType"}]}], "bound_args": [], "def_extras": {"first_arg": null}, "fallback": "builtins.function", "implicit": false, "is_ellipsis_args": false, "name": "find_loader", "ret_type": {".class": "UnionType", "items": ["_importlib_modulespec.Loader", {".class": "NoneType"}]}, "variables": []}}}, "import_module": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0, 1], "arg_names": ["name", "package"], "flags": [], "fullname": "importlib.import_module", "name": "import_module", "type": {".class": "CallableType", "arg_kinds": [0, 1], "arg_names": ["name", "package"], "arg_types": ["builtins.str", {".class": "UnionType", "items": ["builtins.str", {".class": "NoneType"}]}], "bound_args": [], "def_extras": {"first_arg": null}, "fallback": "builtins.function", "implicit": false, "is_ellipsis_args": false, "name": "import_module", "ret_type": "_importlib_modulespec.ModuleType", "variables": []}}}, "invalidate_caches": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [], "arg_names": [], "flags": [], "fullname": "importlib.invalidate_caches", "name": "invalidate_caches", "type": {".class": "CallableType", "arg_kinds": [], "arg_names": [], "arg_types": [], "bound_args": [], "def_extras": {"first_arg": null}, "fallback": "builtins.function", "implicit": false, "is_ellipsis_args": false, "name": "invalidate_caches", "ret_type": {".class": "NoneType"}, "variables": []}}}, "reload": {".class": "SymbolTableNode", "kind": "Gdef", "node": {".class": "FuncDef", "arg_kinds": [0], "arg_names": ["module"], "flags": [], "fullname": "importlib.reload", "name": "reload", "type": {".class": "CallableType", "arg_kinds": [0], "arg_names": ["module"], "arg_types": ["_importlib_modulespec.ModuleType"], "bound_args": [], "def_extras": {"first_arg": null}, "fallback": "builtins.function", "implicit": false, "is_ellipsis_args": false, "name": "reload", "ret_type": "_importlib_modulespec.ModuleType", "variables": []}}}, "types": {".class": "SymbolTableNode", "cross_ref": "types", "kind": "Gdef", "module_hidden": true, "module_public": false}}, "path": "C:\\Users\\Vibha\\AppData\\Roaming\\Python\\Python38\\site-packages\\mypy\\typeshed\\stdlib\\3\\importlib\\__init__.pyi"} --------------------------------------------------------------------------------