├── CODE_OF_CONDUCT.md ├── CONTRIBUTEto#30.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LogPic ├── contri.JPG ├── do.jpg ├── hac.png ├── hack.JPG ├── logo.PNG ├── new.JPG ├── new2.JPG └── pizza.PNG ├── PATTERN ├── Butterfly_Pattern.cpp ├── Floyds_Triangle.c ├── Half_Pyramid_of_Alphabets.c ├── Inverted_Pyramid_of_Numbers.py ├── Left_and_Right_Arrows.cpp ├── Pascals_Triangle.c ├── STAR_PATTERN IN JAVA ├── Sandglass_Star.c ├── Unique_Pyramid_of_Digits.py ├── diamond_inscribed_inside_rectangle.c └── half star pyramid ├── Pattern.py ├── Programs- Coder ├── .gitkeep ├── Bash │ └── disclaimer.txt ├── C# │ ├── DSA │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── C++ │ ├── DSA │ │ └── README.md │ ├── Fibonacci series │ │ ├── a.exe │ │ ├── fabinaccinum.cpp │ │ └── fibonacci_optimised.cpp │ ├── Graph │ │ └── README.md │ └── README.md ├── C │ ├── DSA │ │ ├── README.md │ │ └── josephus.c │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── Crystal │ └── disclaimer.txt ├── Fibonacci Series │ ├── IterativeFibonacciSeries.java │ └── RecursiveFibonacciSeries.java ├── Go │ ├── DSA │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── Groovy │ └── disclaimer.txt ├── JVM │ └── disclaimer.txt ├── Java │ ├── DSA │ │ ├── MajorityELements.md │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── JavaScript │ ├── absoluteValue.js │ ├── disclaimer.txt │ └── rock-paper-scissors.js ├── Kotlin │ ├── DSA │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── Lua │ └── disclaimer.txt ├── Python │ ├── DSA │ │ ├── 2_keys_keyboard.py │ │ ├── README.md │ │ ├── caesarCipher.py │ │ ├── isSubsequence.py │ │ └── unique_path.py │ ├── FC │ │ └── FCFS.py │ ├── Graph │ │ └── README.md │ ├── NumPy Basic Tutorial Codes │ │ └── NumPy_Basic_Tutorial.ipynb │ ├── README.md │ └── disclaimer.txt ├── README.md ├── Ruby │ ├── DSA │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── caesar_cypher.rb ├── Rust │ ├── DSA │ │ └── README.md │ ├── Graph │ │ └── README.md │ └── disclaimer.txt ├── Scala │ └── disclaimer.txt ├── Swift │ └── disclaimer.txt ├── TypeScript │ └── disclaimer.txt └── Zig │ └── disclaimer.txt ├── Programs └── C++ │ ├── Find_the_longest_path_in_a_matrix_with_given_constraints.cpp │ ├── TowerOfHanoi.cpp │ ├── bellmanFord-algo.cpp │ ├── frequencyofelements.cpp │ ├── minimum_spanning_tree.cpp │ └── shortest-path-directed-graph.cpp ├── Project ├── Android project │ └── README.md ├── README.md └── Web project ADD here │ ├── Maze Game │ ├── Screenshots │ │ ├── 1.JPG │ │ ├── 2.JPG │ │ ├── 3.JPG │ │ └── 4.JPG │ ├── index.html │ └── index.js │ ├── ProjectHotelManagement.py │ ├── README.md │ ├── index.html │ ├── newImage.jpeg │ ├── solid_security2-removebg-preview.png │ └── style.css ├── README.md ├── Readme.md ├── RecursionPython ├── Even.java ├── Fabonacci.py ├── MergeSort.py ├── PascalTriangle.py ├── SumOfDigits.py ├── factorial.py ├── powerOfNum.py └── towerOfHanoi.py ├── Video- Non Coder └── README.md ├── fibbonacci.py ├── main (1).cpp └── temperature converter ├── index.html ├── script.js └── style.css /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at meghwantsingh99@gmail.com . The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTEto#30.md: -------------------------------------------------------------------------------- 1 | - Name : Siddhesh Bhosale 2 | - Place : Pune 3 | - Bio : Java Programmer 4 | - GitHub : siddhesh-coder 5 | - Linkedin : https://www.linkedin.com/in/siddhesh-bhosale-99260a1b3/ 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please ensure your pull requests follows guidelines: 4 | 5 | - Fork the repo Don't make change in original repo 6 | - Start the Name with a capital. 7 | - Put Files in Given Folder according to Tag 8 | - Do NOT remove Videos, Rules, FAQs or any other helpful content. 9 | - Check your spelling and grammar. 10 | - Make sure your text editor is set to remove trailing whitespace. 11 | - Don't Make Spam/Invalid Requests otherwise you are tagged 12 | - Add your details to the contributors.html file 13 | 14 | 15 | Thank you for your Contributions✨! 16 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTORS Details 2 | 3 | > **|| Drop Your Name In this Formate |5|** 4 | >#### Name : XYZ 5 | > - Place : ABC 6 | > - Bio : Software engineer 7 | > - GitHub : [Vallenain](https://github.com/Vallenain) 8 | > - Linkedin : (Https://xyz.com/) 9 | 10 | #### Name : Siddhesh Bhosale 11 | - Place : Pune 12 | - Bio : Java Programmer 13 | - GitHub : [siddhesh-coder](https://github.com/siddhesh-coder) 14 | - Linkedin : (https://www.linkedin.com/in/siddhesh-bhosale-99260a1b3/) 15 | 16 | #### Name : Akshat Tiwari 17 | - Place : Bilaspur 18 | - Bio : Programmer 19 | - GitHub : [Git-Akshat01](https://github.com/Git-Akshat01) 20 | - Linkedin : (https://www.linkedin.com/in/akshat-tiwari-18a5a2192/) 21 | -------------------------------------------------------------------------------- /LogPic/contri.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/contri.JPG -------------------------------------------------------------------------------- /LogPic/do.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/do.jpg -------------------------------------------------------------------------------- /LogPic/hac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/hac.png -------------------------------------------------------------------------------- /LogPic/hack.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/hack.JPG -------------------------------------------------------------------------------- /LogPic/logo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/logo.PNG -------------------------------------------------------------------------------- /LogPic/new.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/new.JPG -------------------------------------------------------------------------------- /LogPic/new2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/new2.JPG -------------------------------------------------------------------------------- /LogPic/pizza.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/LogPic/pizza.PNG -------------------------------------------------------------------------------- /PATTERN/Butterfly_Pattern.cpp: -------------------------------------------------------------------------------- 1 | QUESTION : Butterfly Pattern Problem. 2 | 3 | * * 4 | * * * * 5 | * * * * * * 6 | * * * * * * * * 7 | * * * * * * * * * * 8 | * * * * * * * * * * 9 | * * * * * * * * 10 | * * * * * * 11 | * * * * 12 | * * 13 | 14 | CODE : 15 | 16 | #include 17 | using namespace std; 18 | int main() 19 | { 20 | int i, j, n; 21 | cin >> n; 22 | // upper half of the pattern 23 | for(i = 0; i < n; i++) 24 | { 25 | for(j = 0; j < (2 * n); j++) 26 | { 27 | if(i >= j) // upper left triangle 28 | cout << "*"; 29 | else 30 | cout << " "; 31 | if(i >= (2 * n - 1) - j) // upper right triangle 32 | cout << "*"; 33 | else 34 | cout << " "; 35 | } 36 | cout << "\n"; 37 | } 38 | // bottom half of the pattern 39 | for(i = 0; i < n; i++) 40 | { 41 | for(j = 0; j < (2 * n); j++) 42 | { 43 | if(i + j <= n - 1) // bottom left triangle 44 | cout << "*"; 45 | else 46 | cout << " "; 47 | if((i + n) <= j) // bottom right triangle 48 | cout << "*"; 49 | else 50 | cout << " "; 51 | } 52 | cout << "\n"; 53 | } 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /PATTERN/Floyds_Triangle.c: -------------------------------------------------------------------------------- 1 | QUESTION : Floyd's Triangle pattern Problem. 2 | 3 | 1 4 | 2 3 5 | 4 5 6 6 | 7 8 9 10 7 | 11 12 13 14 15 8 | 9 | 10 | CODE : 11 | 12 | #include 13 | int main() { 14 | int rows, i, j, number = 1; 15 | printf("Enter the number of rows: "); 16 | scanf("%d", &rows); 17 | for (i = 1; i <= rows; i++) { 18 | for (j = 1; j <= i; ++j) { 19 | printf("%d ", number); 20 | ++number; 21 | } 22 | printf("\n"); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /PATTERN/Half_Pyramid_of_Alphabets.c: -------------------------------------------------------------------------------- 1 | QUESTION : Half Pyramid of Alphabets 2 | 3 | A 4 | B B 5 | C C C 6 | D D D D 7 | E E E E E 8 | F F F F F F 9 | 10 | 11 | CODE : 12 | 13 | #include 14 | int main() { 15 | int i, j; 16 | char input, alphabet = 'A'; 17 | printf("Enter an uppercase character you want to print in the last row: "); 18 | scanf("%c", &input); 19 | for (i = 1; i <= (input - 'A' + 1); ++i) { 20 | for (j = 1; j <= i; ++j) { 21 | printf("%c ", alphabet); 22 | } 23 | ++alphabet; 24 | printf("\n"); 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /PATTERN/Inverted_Pyramid_of_Numbers.py: -------------------------------------------------------------------------------- 1 | QUESTION : Inverted Pyramid of Numbers Pattern 2 | 3 | 1 1 1 1 1 4 | 2 2 2 2 5 | 3 3 3 6 | 4 4 7 | 5 8 | 9 | CODE : 10 | 11 | rows = 5 12 | 13 | b = 0 14 | 15 | for i in range(rows, 0, -1): 16 | 17 | b += 1 18 | 19 | for j in range(1, i + 1): 20 | 21 | print(b, end=' ') 22 | 23 | print('\r') 24 | -------------------------------------------------------------------------------- /PATTERN/Left_and_Right_Arrows.cpp: -------------------------------------------------------------------------------- 1 | QUESTION : Left and Right Arrows Pattern. 2 | 3 | Right Arrow 4 | * 5 | * 6 | * 7 | * 8 | ********* 9 | * 10 | * 11 | * 12 | * 13 | Left Arrow 14 | * 15 | * 16 | * 17 | * 18 | ********* 19 | * 20 | * 21 | * 22 | * 23 | 24 | 25 | CODE : 26 | 27 | #include 28 | using namespace std; 29 | int main() 30 | { 31 | int i, j, n; 32 | cin >> n; // ‘n’ must be odd 33 | int num1 = n / 2 * 3; 34 | // right arrow 35 | cout << "Right Arrow" << endl; 36 | for(i = 0; i < n; i++) 37 | { 38 | for(j = 0; j < n; j++) 39 | { 40 | // center horizontal, upper right diagonal, bottom right diagonal 41 | if(i == n / 2 || j - i == n / 2 || i + j == num1) 42 | cout << "*"; 43 | else 44 | cout << " "; 45 | } 46 | cout << "\n"; 47 | } 48 | // left arrow 49 | cout << "Left Arrow" << endl; 50 | for(i = 0; i < n; i++) 51 | { 52 | for(j = 0; j < n; j++) 53 | { 54 | // center horizontal, bottom left diagonal, upper left diagonal 55 | if(i == n / 2 || i - j == n / 2 || i + j == n / 2) 56 | cout << "*"; 57 | else 58 | cout << " "; 59 | } 60 | cout << "\n"; 61 | } 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /PATTERN/Pascals_Triangle.c: -------------------------------------------------------------------------------- 1 | QUESTION : Pascal's Triangle Pattern. 2 | 3 | 1 4 | 1 1 5 | 1 2 1 6 | 1 3 3 1 7 | 1 4 6 4 1 8 | 9 | CODE : 10 | 11 | #include 12 | int main() 13 | { 14 | int rows, cal = 1, space, i, j; 15 | 16 | printf("Enter number of rows: ");//enter number of rows for generating the pascal triangle 17 | scanf("%d",&rows); 18 | 19 | for(i=0; i1; j--) //inner loop for spaces 21 | { 22 | System.out.print(" "); //print space 23 | } 24 | for (int j=0; j<=i; j++ ) //inner loop for number of columns 25 | { 26 | System.out.print("* "); //print star 27 | } 28 | 29 | System.out.println(); //ending line after each row 30 | } 31 | } 32 | 33 | public static void main(String args[]) //driver function 34 | { 35 | int n = 5; 36 | pyramidPattern(n); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PATTERN/Sandglass_Star.c: -------------------------------------------------------------------------------- 1 | QUESTION : Sandglass Star Pattern 2 | 3 | * * * * * * 4 | * * * * * 5 | * * * * 6 | * * * 7 | * * 8 | * 9 | * * 10 | * * * 11 | * * * * 12 | * * * * * 13 | * * * * * * 14 | 15 | 16 | CODE : 17 | 18 | #include 19 | 20 | int main() 21 | { 22 | int i, j, k, rows; 23 | 24 | printf("Enter the no. of rows: "); 25 | scanf("%d", &rows); 26 | 27 | printf("Output: \n\n"); 28 | //upper half 29 | for (i = 1; i <= rows; i++) 30 | { 31 | for (k = 1; k < i; k++) 32 | printf(" "); 33 | 34 | for (j = i; j <= rows; j++) 35 | printf("* "); 36 | 37 | printf("\n"); 38 | } 39 | 40 | //lower half 41 | for (i = rows - 1; i >= 1; i--) 42 | { 43 | for (k = 1; k < i; k++) 44 | printf(" "); 45 | 46 | for (j = i; j <= rows; j++) 47 | printf("* "); 48 | 49 | printf("\n"); 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /PATTERN/Unique_Pyramid_of_Digits.py: -------------------------------------------------------------------------------- 1 | QUESTION : Unique Pyramid Pattern of Digits. 2 | 3 | 1 4 | 1 2 1 5 | 1 2 3 2 1 6 | 1 2 3 4 3 2 1 7 | 1 2 3 4 5 4 3 2 1 8 | 9 | CODE: 10 | 11 | rows = 6 12 | 13 | for i in range(1, rows + 1): 14 | 15 | for j in range(1, i - 1): 16 | 17 | print(j, end=' ') 18 | 19 | for j in range(i - 1, 0, -1): 20 | 21 | print(j, end=' ') 22 | 23 | print() 24 | -------------------------------------------------------------------------------- /PATTERN/diamond_inscribed_inside_rectangle.c: -------------------------------------------------------------------------------- 1 | QUESTION : Diamond Inscribed Inside Rectangle 2 | 3 | * * * * * * * * * * * * 4 | * * * * * * * * * * 5 | * * * * * * * * 6 | * * * * * * 7 | * * * * 8 | * * 9 | * * 10 | * * * * 11 | * * * * * * 12 | * * * * * * * * 13 | * * * * * * * * * * 14 | * * * * * * * * * * * * 15 | 16 | CODE : 17 | 18 | #include 19 | int main() 20 | { 21 | int i, j, n; 22 | scanf("%d", &n); 23 | // upper half of the pattern 24 | for(i = 0; i < n; i++) 25 | { 26 | for(j = 0; j < (2 * n); j++) 27 | { 28 | if(i + j <= n - 1) // upper left triangle 29 | printf("*"); 30 | else 31 | printf(" "); 32 | if((i + n) <= j) // upper right triangle 33 | printf("*"); 34 | else 35 | printf(" "); 36 | } 37 | printf("\n"); 38 | } 39 | // bottom half of the pattern 40 | for(i = 0; i < n; i++) 41 | { 42 | for(j = 0; j < (2 * n); j++) 43 | { 44 | if(i >= j) //bottom left triangle 45 | printf("*"); 46 | else 47 | printf(" "); 48 | if(i >= (2 * n - 1) - j) // bottom right triangle 49 | printf("*"); 50 | else 51 | printf(" "); 52 | } 53 | printf("\n"); 54 | } 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /PATTERN/half star pyramid: -------------------------------------------------------------------------------- 1 | ## Printing the half pyramid pattern 1 ## 2 | * 3 | * * 4 | * * * 5 | * * * * 6 | * * * * * 7 | package com.javainterviewpoint; 8 | 9 | public class star_Pattern 10 | { 11 | public static void main(String[] args) 12 | { 13 | int rows = 5; 14 | System.out.println("## Printing the pattern ##"); 15 | for (int i = 1; i <= rows; i++) 16 | { 17 | for (int j = rows; j > i; j--) 18 | { 19 | System.out.print(" "); 20 | } 21 | 22 | for (int k = 1; k <= i; k++) 23 | { 24 | System.out.print("* "); 25 | } 26 | System.out.println(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Pattern.py: -------------------------------------------------------------------------------- 1 | word="HACK" 2 | a=0 3 | x="" 4 | size=4 5 | m=2*size-2 6 | for i in range(0,size): 7 | for j in range(0,m): 8 | print(end=" ") 9 | m=m-1 10 | for j in range(0,i+1): 11 | q=word[a] 12 | print(q, end=" ") 13 | a+=1 14 | a=0 15 | print(" ") 16 | print() 17 | print() 18 | w="OCTOBER" 19 | s=7 20 | o=2*s-3 21 | for i in range(0,s): 22 | for j in range(0,o): 23 | print(end=" ") 24 | o-=1 25 | for j in range(0,i+1): 26 | q=w[a] 27 | print(q, end=" ") 28 | a+=1 29 | a=0 30 | print(" ") 31 | print() 32 | print() 33 | word="FEST" 34 | s=7 35 | o=2*s-3 36 | size=4 37 | m=2*size-2 38 | for i in range(0,size): 39 | for j in range(0,m): 40 | print(end=" ") 41 | m=m-1 42 | for j in range(0,i+1): 43 | q=word[a] 44 | print(q, end=" ") 45 | a+=1 46 | a=0 47 | print(" ") 48 | print("HACKTOBERFEST 2022!") 49 | -------------------------------------------------------------------------------- /Programs- Coder/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Programs- Coder/.gitkeep -------------------------------------------------------------------------------- /Programs- Coder/Bash/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Bash -------------------------------------------------------------------------------- /Programs- Coder/C#/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with " C++ " Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C#/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with " C++ " Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C#/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to C# -------------------------------------------------------------------------------- /Programs- Coder/C++/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C++/Fibonacci series/a.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Programs- Coder/C++/Fibonacci series/a.exe -------------------------------------------------------------------------------- /Programs- Coder/C++/Fibonacci series/fabinaccinum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int fibonacci(int n) 5 | { 6 | if (n <= 1) 7 | return n; /*Here we are printing the first three numbers of fibbonacci series 8 | if the entered number by user is either=1 (or) equals=0. */ 9 | 10 | return fibonacci(n - 1) + fibonacci(n - 2); /*printing the rest of the terms here.*/ 11 | 12 | /*Hope we all know the main logic of fibbonacci series,i.e is the sum 13 | of the two consecutive indices values is equal to next term 14 | Ex= 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233 ...*/ 15 | 16 | } 17 | 18 | int32_t main() 19 | { 20 | /*Example 1: 21 | 22 | Find the Fibonacci number when n=5, using recursive relation. 23 | 24 | Solution: 25 | 26 | The formula to calculate the Fibonacci Sequence is: Fn = Fn-1+Fn-2 27 | 28 | Take: F0=0 and F1=1 29 | 30 | Using the formula, we get 31 | 32 | F2 = F1+F0 = 1+0 = 1 33 | 34 | F3 = F2+F1 = 1+1 = 2 35 | 36 | F4 = F3+F2 = 2+1 = 3 37 | 38 | F5 = F4+F3 = 3+2 = 5 39 | 40 | Therefore, the fibonacci number is 5. 41 | 42 | */ 43 | int n; 44 | cin >> n; 45 | cout << fibonacci(n); 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Programs- Coder/C++/Fibonacci series/fibonacci_optimised.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int fibonacci_naive(int n) { 4 | if (n <= 1) 5 | return n; 6 | 7 | return fibonacci_naive(n - 1) + fibonacci_naive(n - 2); 8 | } 9 | 10 | int fibonacci_fast(int n) { 11 | int prev = 0, next = 1, ans; 12 | if(n==0) return prev; 13 | for(int i=2; i<=n ; i++){ 14 | ans = prev + next; 15 | prev = next; 16 | next = ans; 17 | } 18 | 19 | return next; 20 | } 21 | 22 | int main() { 23 | int n = 0; 24 | cin >> n; 25 | cout << fibonacci_fast(n) << '\n'; 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Programs- Coder/C++/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C++/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with " C++ " Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with " C++ " Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C/DSA/josephus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct node{ 4 | int data;struct node *next; 5 | }; 6 | void insert(struct node **Node,struct node **rear,int item) 7 | { 8 | 9 | struct node *ptr=(struct node*)malloc(sizeof(struct node)); 10 | ptr->data=item; 11 | if(*Node==NULL) 12 | { 13 | *Node=ptr; 14 | 15 | } 16 | else{ 17 | (*rear)->next=ptr; 18 | 19 | } 20 | ptr->next=NULL; 21 | *rear=ptr; 22 | } 23 | void traversal(struct node *head) 24 | { 25 | struct node *temp=head; 26 | 27 | printf("%d ",temp->data); 28 | temp=temp->next; 29 | while(temp!=head) 30 | { 31 | printf("%d ",temp->data); 32 | temp=temp->next; 33 | } 34 | } 35 | int calculate(struct node *head,int k) 36 | { 37 | struct node *temp=head; 38 | struct node *prev=head; 39 | int i; 40 | while(temp->next!=temp) 41 | { 42 | for(i=0;inext; 45 | } 46 | prev->next=temp->next; 47 | temp=prev->next; 48 | 49 | 50 | } 51 | return temp->data; 52 | } 53 | int main() 54 | { 55 | struct node *Node=NULL; 56 | struct node *rear=NULL; 57 | int option; 58 | while(1) 59 | { 60 | printf("Enter 0.Stop 1.Entry\n"); 61 | scanf("%d",&option); 62 | if(option==1) 63 | { 64 | int item; 65 | printf("Enter "); 66 | scanf("%d",&item); 67 | insert(&Node,&rear,item); 68 | 69 | 70 | } 71 | else 72 | { 73 | rear->next=Node; 74 | traversal(Node); 75 | int show=calculate(Node,3); 76 | printf("%d",show); 77 | break; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Programs- Coder/C/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with " C++ " Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/C/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to C -------------------------------------------------------------------------------- /Programs- Coder/Crystal/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Crystal -------------------------------------------------------------------------------- /Programs- Coder/Fibonacci Series/IterativeFibonacciSeries.java: -------------------------------------------------------------------------------- 1 | // fibonacci series using iteration 2 | 3 | import java.util.Scanner; 4 | 5 | public class IterativeFibonacciSeries { 6 | 7 | public static void fibonacci(int n) //here n is the number of terms in series 8 | { 9 | int num1 = 0, num2 = 1, m = 0; //m is the counter which starts from 0 10 | while (m < n) { 11 | System.out.print(num1 + " "); 12 | int num3; 13 | num3 = num2 + num1; 14 | num1 = num2; 15 | num2 = num3; 16 | m++; 17 | } 18 | } 19 | 20 | public static void main(String[] args) { 21 | Scanner sc=new Scanner(System.in); 22 | System.out.print("Enter the number of terms you want in series: "); 23 | int n=sc.nextInt(); 24 | 25 | System.out.print("The fibonacci series is - "); 26 | fibonacci(n); 27 | } 28 | 29 | } 30 | 31 | 32 | //Time Complexity :- O(n) -------------------------------------------------------------------------------- /Programs- Coder/Fibonacci Series/RecursiveFibonacciSeries.java: -------------------------------------------------------------------------------- 1 | // fibonacci series using recursion 2 | 3 | import java.util.Scanner; 4 | public class RecursiveFibonacciSeries { 5 | 6 | public static int fibonacci(int n) { //here n is the number of terms in series 7 | if ((n == 0) || (n == 1)) 8 | return n; 9 | else 10 | return fibonacci(n - 1) + fibonacci(n - 2); //recursive call to fibonacci function 11 | } 12 | 13 | public static void main(String[] args) { 14 | Scanner sc=new Scanner(System.in); 15 | System.out.print("Enter the number of terms you want in series: "); 16 | int n=sc.nextInt(); 17 | 18 | int m=0; 19 | System.out.print("The fibonacci series is - "); 20 | for(int i=1; i<=n; i++) { 21 | System.out.print(" " + fibonacci(m)); 22 | m++; 23 | } 24 | } 25 | 26 | } 27 | 28 | 29 | //Time Complexity:- O(2^n) 30 | 31 | -------------------------------------------------------------------------------- /Programs- Coder/Go/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Go/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Go/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Go -------------------------------------------------------------------------------- /Programs- Coder/Groovy/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Groovy -------------------------------------------------------------------------------- /Programs- Coder/JVM/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to JVM languages -------------------------------------------------------------------------------- /Programs- Coder/Java/DSA/MajorityELements.md: -------------------------------------------------------------------------------- 1 | # Program Eg: |Input: nums = [2,2,1,1,1,2,2] | --- |Output: 2| 2 | 3 | ## Question 4 | 5 | > Given an array nums of size n, return the majority element. 6 | > The majority element is the element that appears more than ⌊n / 2⌋ times. 7 | > You may assume that the majority element 8 | > always exists in the array. 9 | 10 | ## Solution 11 | 12 | > class Solution { 13 | > public int majorityElement(int[] nums) { 14 | > 15 | > //a simple solution can be using Hash maps but its not optimal 16 | > //it will be in TC of O(nlogn) and SC of O(n) 17 | > /*********************OPTIMAL APPROACH (Moore’s Voting Algorithm)************/ 18 | > int n=nums.length; 19 | > int vote =0,leader=0; 20 | > for(int i=0;i { 22 | > if(vote==0) leader=nums[i];//when we start the process we choose 0th element as leader 23 | > if(leader==nums[i]) vote++;//now when we see its appearance again in array we UPVOTE 24 | > else vote--;//if we see some othe element we DOWN VOTE 25 | > 26 | > //if current leader votes become 0 means its not the ans hence by help of first if 27 | > //we again put new element as leader, then carry on the process 28 | > } 29 | > return leader; 30 | > 31 | > } 32 | > } 33 | -------------------------------------------------------------------------------- /Programs- Coder/Java/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Java/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Java/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to java -------------------------------------------------------------------------------- /Programs- Coder/JavaScript/absoluteValue.js: -------------------------------------------------------------------------------- 1 | const absoluteValue = (num) => { 2 | const newNumber = num < 0 ? -num : num; 3 | console.log(`The absolute value of ${num} is ${newNumber}`); 4 | } 5 | -------------------------------------------------------------------------------- /Programs- Coder/JavaScript/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to TypeScript -------------------------------------------------------------------------------- /Programs- Coder/JavaScript/rock-paper-scissors.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | vs project 11 | 12 | 13 | 14 |

Welcome to the Rock , Paper, scissor game

15 |

Welcome "name"

16 |
17 |

computer

18 |

vs

19 |

you

20 |
21 |
22 | Rock 23 | paper 24 | scissors 25 | 28 | 29 |
30 |
31 |

symbol what the computer chose

32 |

symbol what the user chose

33 |
34 | 35 |
36 |

the winner is

37 |
38 | 39 | 40 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /Programs- Coder/Kotlin/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Kotlin/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Kotlin/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Kotlin -------------------------------------------------------------------------------- /Programs- Coder/Lua/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Lua -------------------------------------------------------------------------------- /Programs- Coder/Python/DSA/2_keys_keyboard.py: -------------------------------------------------------------------------------- 1 | #given number, you have to find out the minimum number of steps to form that string, by only using copy and paste method 2 | #ex INPUT-3 OUTPUT-3 3 | def minSteps(num): 4 | if (n == 0 or n==1): return 0 5 | ans = 0 6 | i = 2 7 | #for prime number the number of steps is equal to the number itself 8 | while (True): 9 | if (n % i == 0): 10 | #if the number is divisible by any number add that number to the ans, because the minimum number is going to be the prime number itself 11 | ans += i 12 | n /= i 13 | else: 14 | i += 1 15 | if (n == 1): 16 | break 17 | 18 | return (ans) 19 | 20 | num=int(input()) 21 | print(minSteps(num)) -------------------------------------------------------------------------------- /Programs- Coder/Python/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Python/DSA/caesarCipher.py: -------------------------------------------------------------------------------- 1 | #covert the given text to caesar cipher 2 | 3 | def encrypt(string,increase): 4 | 5 | new_str="" 6 | 7 | for i in range(len(string)): 8 | 9 | if(ord(string[i])+increase)>90: 10 | 11 | new_str+=chr((((ord(string[i])+increase)-65)%26)+65) 12 | 13 | else: 14 | new_str+=chr(ord(string[i])+increase) 15 | 16 | return new_str 17 | 18 | string=input() 19 | increase=int(input()) 20 | print(encrypt(string,increase)) -------------------------------------------------------------------------------- /Programs- Coder/Python/DSA/isSubsequence.py: -------------------------------------------------------------------------------- 1 | #given the 2 strings s and t , check whether that s is a subsequence of t 2 | #ex INPUT-cb caba OUTPUT-true 3 | def isSubsequence(s,t): 4 | 5 | j=0 6 | for i in range(len(t)): 7 | if(t[i]==s[j]):#for continuation 8 | j+=1 9 | 10 | if(j==len(s)): 11 | return"true" 12 | return"false" 13 | 14 | s,t=map(input().split(' ')) 15 | print(isSubsequence(s,t)) -------------------------------------------------------------------------------- /Programs- Coder/Python/DSA/unique_path.py: -------------------------------------------------------------------------------- 1 | #Find the number of unique possible paths for the robot to reach at the bottom-right corner of the matrix if he starts from [0,0] position 2 | #ex INPUT--row=3 colum=2 OUTPUT--POssible paths 3 3 | 4 | def unique_paths(matrix,row,column): 5 | 6 | for i in range(row):#initializing the first row to 1 7 | matrix[i][0]=1 8 | for i in range(column):#initializing the first column to 1 9 | matrix[0][i]=1 10 | 11 | for i in range(1,row):#calculating the sum of the top and left block 12 | for j in range(1,column): 13 | matrix[i][j]=matrix[i-1][j]+matrix[i][j-1] 14 | 15 | 16 | return(matrix[row-1][column-1])#the no. of paths is the present element of the [0,0] position 17 | 18 | row,column=map(int,input().split(' ')) 19 | matrix=[[0]*column for i in range(row)]#way to change every element of matrix to 0 20 | 21 | print(unique_paths(matrix,row,column)) -------------------------------------------------------------------------------- /Programs- Coder/Python/FC/FCFS.py: -------------------------------------------------------------------------------- 1 | 2 | ''' 3 | FCFS scheduler to calculate the average waiting time for each process. 4 | 5 | args: 6 | process_list: list of tuples representing each process. 7 | First value of the pair represents the arrival time of the process, while the second 8 | value represents the burst time, meaning the execution time of the process 9 | ''' 10 | class FCFS: 11 | 12 | def __init__(self, process_list): 13 | self.n_process = len(process_list) 14 | 15 | # Sort process list by the arrival times 16 | self.process_list = sorted(process_list, key=lambda process: process[0]) 17 | 18 | # Fetch arrival and burst time of each process at the same index 19 | self.arrival_time = [process[0] for process in self.process_list] 20 | self.burst_time = [process[1] for process in self.process_list] 21 | 22 | 23 | ''' 24 | Calculate waiting time for each process, assuming the waiting time for the initial process is 0. 25 | ''' 26 | def __calculate_waiting_times(self): 27 | 28 | # Initialize the waiting time list for each process with a 0 to aggregate later 29 | waiting_time = [0]*self.n_process 30 | 31 | # Skip the index 0, as the waiting time for the initial process at process_list[0] is assumed to be 0 32 | for idx in range(1,self.n_process): 33 | # Keep indexes of the previous and the current processes 34 | prev = idx-1 35 | curr = idx 36 | 37 | # Waiting time of the process with current idx will be from the arrival of the current process until the 38 | # end of the process 39 | end_of_previous_process = waiting_time[prev] + self.arrival_time[prev] + self.burst_time[prev] 40 | curr_waiting_time = end_of_previous_process - self.arrival_time[curr] 41 | 42 | # If waiting time is a positive number, meaning the process arrived while the previous process is still 43 | # running, assign value 44 | waiting_time[idx] = curr_waiting_time if curr_waiting_time > 0 else 0 45 | 46 | return waiting_time 47 | 48 | ''' 49 | Calculate average waiting time for the whole process queue 50 | ''' 51 | def calculate_average_waiting_time(self): 52 | 53 | # List of waiting times per each process 54 | waiting_times = self.__calculate_waiting_times() 55 | 56 | # Average waiting time 57 | return sum(waiting_times)/self.n_process 58 | 59 | 60 | if __name__ == '__main__': 61 | 62 | # Example: 63 | # 64 | # Here we are trying to solve the FCFS scheduling problem to find the average waiting time of 3 processes 65 | # Process Arrival time Burst Time 66 | # p1 1 3 67 | # p2 2 4 68 | # p3 5 1 69 | # 70 | # p1 will arrive at t=1 and end at t=1+3=4 71 | # p2 will arrive at t=2 and start at t=4 thus wait for t=2. It will end at t=4+4=8 72 | # p3 will arrive at t=5 and start at t=8, thus wait for t=3. 73 | # 74 | # The average waiting time is (3+2)/3=1.66 75 | 76 | processes =[(1,3),(2,4),(5,1)] 77 | 78 | fSolver = FCFS(processes) 79 | 80 | print(fSolver.calculate_average_waiting_time()) 81 | -------------------------------------------------------------------------------- /Programs- Coder/Python/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Python/NumPy Basic Tutorial Codes/NumPy_Basic_Tutorial.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "collapsed_sections": [], 8 | "toc_visible": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "source": [ 22 | "# **NumPy Basic Tutorial**\n" 23 | ], 24 | "metadata": { 25 | "id": "VHFbXaTY7aC8" 26 | } 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "source": [ 31 | "\n", 32 | "## Prerequisites\n", 33 | "- Basic Python knowledge.\n", 34 | "- Rudimentary understanding on the working of computers. \n", 35 | "- Fundamental linear algebra know-how" 36 | ], 37 | "metadata": { 38 | "id": "JyB0XijvHzeW" 39 | } 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "source": [ 44 | "## Introduction\n", 45 | "\n", 46 | "### **What is NumPy?**\n", 47 | "\n", 48 | "NumPy is short for \"Numerical Python\". It was created in 2005 by Travis Oliphant as an open source project to be used freely. The official documentation for NumPy defines NumPy as \"the fundamental package for scientific computing in Python.\"\n", 49 | "\n", 50 | "*So, NumPy is simply a Python library.*\n", 51 | "\n", 52 | "It's essential importance is highlighted by it's ability to provide an efficient and convenient method to work with arrays. It is a Python library that provides a multidimensional array object and various other derived objects along with a mixed bag of routines for quick operations on arrays such as mathematics, sorting, shape manipulation, basic linear algebra, basic statistical operations, random simulation to name a few.\n", 53 | "\n", 54 | "As w3schools puts it aptly,\n", 55 | "\n", 56 | "- NumPy is a Python library.\n", 57 | "- NumPy is used for working with arrays.\n", 58 | "- NumPy is short for \"Numerical Python\"." 59 | ], 60 | "metadata": { 61 | "id": "sB02vU9nHqf3" 62 | } 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "source": [ 67 | "### **Why NumPy?**\n", 68 | "\n", 69 | "A question that often crops up in the minds of novice implementers of this library is why do we opt to use NumPy when Python has already graced us with it's in-built implementation of arrays in the form of `lists`.\n", 70 | "\n", 71 | "NumPy aims to provide an array object which is **50 times faster than traditional Python lists**; not to mention the plethora of supporting functions that makes working with `ndarrays` (array objects in NumPy) so much more advantageous.\n", 72 | "\n", 73 | "#### **Why is NumPy just so quick in comparision to Lists?**\n", 74 | "\n", 75 | "NumPy arrays are stored at one continuous place in memory unlike lists, and it is this contiguous storage that allows efficient access and manipulation of arrays." 76 | ], 77 | "metadata": { 78 | "id": "kLr9hPDr_Mui" 79 | } 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "source": [ 84 | "### **Other notable differences between NumPy arrays and standard Python lists/sequences**\n", 85 | "\n", 86 | "- NumPy arrays have a fixed size at creation. Conversely, Python lists do not; opting for changing size by growing dynamically. Changing the size of an `ndarray` in turn, requires the creation of a new array and deleting the original.\n", 87 | "\n", 88 | "- The elements in a NumPy array are all required to be of the same data type, and thus take up exactly the same size in memory.\n", 89 | "\n", 90 | "- As mentioned earlier, NumPy arrays enables numerous operations on arrays always executed more efficiently and with less code than it's in-built Python counterpart.\n", 91 | "\n", 92 | "- A growing torrent of other scientific and mathematical Python-based packages/libraries use NumPy arrays. They often convert input to NumPy arrays prior to processing, often outputting NumPy arrays. Thus, cementing NumPy's place as an essential package in the Python community. " 93 | ], 94 | "metadata": { 95 | "id": "_NDfHhiTEJ4X" 96 | } 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "source": [ 101 | "## Installation\n", 102 | "\n", 103 | "Assumes that you have Python and PIP already installed on your systems.\n", 104 | "\n", 105 | "Install NumPy using the following command on your terminal:\n", 106 | "\n", 107 | "`pip install numpy`\n", 108 | "\n", 109 | "If the command fails, then use a python distribution that has NumPy pre-installed like Anaconda, Spyder, etc.\n", 110 | "\n", 111 | "Alternatively, you can also use online Jupyter Notebook Environments like Google Colab, Kaggle that have NumPy pre-installed. Such environments allow anyone to write and execute python code through the browser by running entirely in the cloud. " 112 | ], 113 | "metadata": { 114 | "id": "GWM2s7_mJdZY" 115 | } 116 | }, 117 | { 118 | "cell_type": "markdown", 119 | "source": [ 120 | "## Tutorial" 121 | ], 122 | "metadata": { 123 | "id": "tYUZ69AcICb6" 124 | } 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "source": [ 129 | "### **Importing NumPy**\n", 130 | "\n", 131 | "On successful installation, import NumPy in your projects by adding the `import` keyword." 132 | ], 133 | "metadata": { 134 | "id": "dhD1zG54LQ8s" 135 | } 136 | }, 137 | { 138 | "cell_type": "code", 139 | "source": [ 140 | "import numpy\n", 141 | "\n", 142 | "arr = numpy.array([1, 2, 3])\n", 143 | "print(arr)" 144 | ], 145 | "metadata": { 146 | "colab": { 147 | "base_uri": "https://localhost:8080/" 148 | }, 149 | "id": "4y_AxgZsEZKM", 150 | "outputId": "fe87b3e4-0c59-4218-877d-412ada443c68" 151 | }, 152 | "execution_count": 1, 153 | "outputs": [ 154 | { 155 | "output_type": "stream", 156 | "name": "stdout", 157 | "text": [ 158 | "[1 2 3]\n" 159 | ] 160 | } 161 | ] 162 | }, 163 | { 164 | "cell_type": "markdown", 165 | "source": [ 166 | "### **Importing NumPy as `np`**\n", 167 | "\n", 168 | "NumPy is generally imported under the alias `np`. An alias, for those unaware, works exactly like an alternate name. This alias has been universally accepted by the Python community and you are bound to find this alias being used almost every place where NumPy is being used. It also saves us the hastle of typing out the entire name while refering to the library. \n", 169 | "\n", 170 | "An alias is created by using the `as` keyword while importing:" 171 | ], 172 | "metadata": { 173 | "id": "3ZRGDOiuMQsz" 174 | } 175 | }, 176 | { 177 | "cell_type": "code", 178 | "source": [ 179 | "import numpy as np\n", 180 | "\n", 181 | "arr = np.array([1, 2, 3])\n", 182 | "print(arr)" 183 | ], 184 | "metadata": { 185 | "colab": { 186 | "base_uri": "https://localhost:8080/" 187 | }, 188 | "id": "0h3IiP0mNPy9", 189 | "outputId": "f703cbb8-a12b-46f8-9954-3b4b80cd4d9e" 190 | }, 191 | "execution_count": 2, 192 | "outputs": [ 193 | { 194 | "output_type": "stream", 195 | "name": "stdout", 196 | "text": [ 197 | "[1 2 3]\n" 198 | ] 199 | } 200 | ] 201 | }, 202 | { 203 | "cell_type": "markdown", 204 | "source": [ 205 | "### **Checking NumPy Version**" 206 | ], 207 | "metadata": { 208 | "id": "9zpdGPbcN-0T" 209 | } 210 | }, 211 | { 212 | "cell_type": "code", 213 | "source": [ 214 | "print(np.__version__)" 215 | ], 216 | "metadata": { 217 | "colab": { 218 | "base_uri": "https://localhost:8080/" 219 | }, 220 | "id": "Du2r8mjeOJIU", 221 | "outputId": "5b9c074a-61fc-4adb-f697-2c86f681204a" 222 | }, 223 | "execution_count": 3, 224 | "outputs": [ 225 | { 226 | "output_type": "stream", 227 | "name": "stdout", 228 | "text": [ 229 | "1.21.6\n" 230 | ] 231 | } 232 | ] 233 | }, 234 | { 235 | "cell_type": "markdown", 236 | "source": [ 237 | "### **Creating a NumPy `ndarray` Object**\n", 238 | "A few codeblocks ago, we created the `ndarray` by using the `array()` function. It accepts a `list`, `tuple` or any array-like object as a parameter and converts it into an `ndarray`. We can chefck the type of the object by using the built-in `type()` function." 239 | ], 240 | "metadata": { 241 | "id": "hfZ59QOKOO8r" 242 | } 243 | }, 244 | { 245 | "cell_type": "code", 246 | "source": [ 247 | "arr1 = np.array([1, 2, 3])\n", 248 | "arr2 = np.array((4, 5, 6))\n", 249 | "print(f\"arr1: {arr1}\")\n", 250 | "print(f\"arr2: {arr2}\")\n", 251 | "print(f\"arr1 type: {type(arr1)}\")\n", 252 | "print(f\"arr2 type: {type(arr2)}\")" 253 | ], 254 | "metadata": { 255 | "colab": { 256 | "base_uri": "https://localhost:8080/" 257 | }, 258 | "id": "ml6dvPr-PER3", 259 | "outputId": "8ceb7969-bf3d-42f0-8a2c-14859ba24b42" 260 | }, 261 | "execution_count": 4, 262 | "outputs": [ 263 | { 264 | "output_type": "stream", 265 | "name": "stdout", 266 | "text": [ 267 | "arr1: [1 2 3]\n", 268 | "arr2: [4 5 6]\n", 269 | "arr1 type: \n", 270 | "arr2 type: \n" 271 | ] 272 | } 273 | ] 274 | }, 275 | { 276 | "cell_type": "markdown", 277 | "source": [ 278 | "### **Dimensions in Arrays**\n", 279 | "Dimensions in arrays is implemented by using nested arrays, a.k.a., arrays that have arrays as their elements.\n", 280 | "\n", 281 | "Let's explore this in greater detail starting with:" 282 | ], 283 | "metadata": { 284 | "id": "fSgo1kWzP4vK" 285 | } 286 | }, 287 | { 288 | "cell_type": "markdown", 289 | "source": [ 290 | "#### **O-D Arrays**\n", 291 | "0-D arrays are nothing but scalars in mathematical terms. NumPy arrays provide the `ndim` attribute that returns an integer telling us how many dimensions the array have. " 292 | ], 293 | "metadata": { 294 | "id": "T1CL4tw1QX6C" 295 | } 296 | }, 297 | { 298 | "cell_type": "code", 299 | "source": [ 300 | "arr = np.array(8)\n", 301 | "print(f\"arr: {arr}\")\n", 302 | "print(f\"\\nNumber of Dimension/s: {arr.ndim}\")" 303 | ], 304 | "metadata": { 305 | "colab": { 306 | "base_uri": "https://localhost:8080/" 307 | }, 308 | "id": "DM3QrGInQtxJ", 309 | "outputId": "84b0117d-4c2a-4cd9-d414-8acc5582d875" 310 | }, 311 | "execution_count": 5, 312 | "outputs": [ 313 | { 314 | "output_type": "stream", 315 | "name": "stdout", 316 | "text": [ 317 | "arr: 8\n", 318 | "\n", 319 | "Number of Dimension/s: 0\n" 320 | ] 321 | } 322 | ] 323 | }, 324 | { 325 | "cell_type": "markdown", 326 | "source": [ 327 | "#### **1-D Arrays**\n", 328 | "\n", 329 | "1-D arrays are arrays that have 0-D arrays as it's elements. Also refered to as uni-dimensional arrays." 330 | ], 331 | "metadata": { 332 | "id": "bqf2DhhjQ9Wq" 333 | } 334 | }, 335 | { 336 | "cell_type": "code", 337 | "source": [ 338 | "arr = np.array([1, 2, 3])\n", 339 | "print(f\"arr: {arr}\")\n", 340 | "print(f\"\\nNumber of Dimension/s: {arr.ndim}\")" 341 | ], 342 | "metadata": { 343 | "colab": { 344 | "base_uri": "https://localhost:8080/" 345 | }, 346 | "id": "aRhpfrwRROM6", 347 | "outputId": "170ea875-dddd-4e6b-da0c-67f38c8703f7" 348 | }, 349 | "execution_count": 6, 350 | "outputs": [ 351 | { 352 | "output_type": "stream", 353 | "name": "stdout", 354 | "text": [ 355 | "arr: [1 2 3]\n", 356 | "\n", 357 | "Number of Dimension/s: 1\n" 358 | ] 359 | } 360 | ] 361 | }, 362 | { 363 | "cell_type": "markdown", 364 | "source": [ 365 | "#### **2-D Arrays**\n", 366 | "An array that has 1-D arrays as it's elements is a 2-D array. Often used to represent matrices or 2nd order tensors." 367 | ], 368 | "metadata": { 369 | "id": "-QazbKCxRZ5B" 370 | } 371 | }, 372 | { 373 | "cell_type": "code", 374 | "source": [ 375 | "arr = np.array([[1, 2, 3], [4, 5, 6]])\n", 376 | "print(f\"arr: {arr}\")\n", 377 | "print(f\"\\nNumber of Dimension/s: {arr.ndim}\")" 378 | ], 379 | "metadata": { 380 | "colab": { 381 | "base_uri": "https://localhost:8080/" 382 | }, 383 | "id": "-7ZlO8CCRpfC", 384 | "outputId": "efa2c2a8-f512-420a-cc99-f469acc1778d" 385 | }, 386 | "execution_count": 7, 387 | "outputs": [ 388 | { 389 | "output_type": "stream", 390 | "name": "stdout", 391 | "text": [ 392 | "arr: [[1 2 3]\n", 393 | " [4 5 6]]\n", 394 | "\n", 395 | "Number of Dimension/s: 2\n" 396 | ] 397 | } 398 | ] 399 | }, 400 | { 401 | "cell_type": "markdown", 402 | "source": [ 403 | "#### **3-D Arrays**\n", 404 | "An array that has 2-D arrays, i.e., matrices as it's elements is called a 3-D array. Used to represent 3rd order tensors." 405 | ], 406 | "metadata": { 407 | "id": "sa59FJfaUtwU" 408 | } 409 | }, 410 | { 411 | "cell_type": "code", 412 | "source": [ 413 | "arr = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])\n", 414 | "print(f\"arr: {arr}\")\n", 415 | "print(f\"\\nNumber of Dimension/s: {arr.ndim}\")" 416 | ], 417 | "metadata": { 418 | "colab": { 419 | "base_uri": "https://localhost:8080/" 420 | }, 421 | "id": "aRgr5kzAU-CG", 422 | "outputId": "3c5458b6-fba3-46f4-81bc-600d6ecc9810" 423 | }, 424 | "execution_count": 8, 425 | "outputs": [ 426 | { 427 | "output_type": "stream", 428 | "name": "stdout", 429 | "text": [ 430 | "arr: [[[1 2 3]\n", 431 | " [4 5 6]]\n", 432 | "\n", 433 | " [[1 2 3]\n", 434 | " [4 5 6]]]\n", 435 | "\n", 436 | "Number of Dimension/s: 3\n" 437 | ] 438 | } 439 | ] 440 | }, 441 | { 442 | "cell_type": "markdown", 443 | "source": [ 444 | "#### **Higher Dimensional Arrays**\n", 445 | "Arrays can obviously be n-dimensional, a fact highlighted by the name given to arrays in NumPy. This higher dimensionality can be explicitly stated to NumPy by using the `ndmin` argument." 446 | ], 447 | "metadata": { 448 | "id": "4LOtZevDVdLK" 449 | } 450 | }, 451 | { 452 | "cell_type": "code", 453 | "source": [ 454 | "arr = np.array([1, 2, 3], ndmin = 8)\n", 455 | "print(f\"arr: {arr}\")\n", 456 | "print(f\"\\nNumber of Dimension/s: {arr.ndim}\")" 457 | ], 458 | "metadata": { 459 | "colab": { 460 | "base_uri": "https://localhost:8080/" 461 | }, 462 | "id": "EsMQcJ8nVzsJ", 463 | "outputId": "298b7b44-47a4-4a51-d58f-16b44e14eced" 464 | }, 465 | "execution_count": 9, 466 | "outputs": [ 467 | { 468 | "output_type": "stream", 469 | "name": "stdout", 470 | "text": [ 471 | "arr: [[[[[[[[1 2 3]]]]]]]]\n", 472 | "\n", 473 | "Number of Dimension/s: 8\n" 474 | ] 475 | } 476 | ] 477 | }, 478 | { 479 | "cell_type": "markdown", 480 | "source": [ 481 | "### **NumPy Array Indexing**\n", 482 | "Array indexing, just like List indexing, is used to access an array element. The indexes in NumPy are also zero-indexed, i.e., the first element has index 0, and the second element has index 1, so on and so forth." 483 | ], 484 | "metadata": { 485 | "id": "fjTWlvsiWOap" 486 | } 487 | }, 488 | { 489 | "cell_type": "code", 490 | "source": [ 491 | "arr = np.array([1, 2, 3])\n", 492 | "print(f\"1-st element: {arr[0]}\")\n", 493 | "print(f\"2-nd element: {arr[1]}\")" 494 | ], 495 | "metadata": { 496 | "colab": { 497 | "base_uri": "https://localhost:8080/" 498 | }, 499 | "id": "p7TouZpzW6O5", 500 | "outputId": "cfa2a8e1-52da-443b-d0fb-0cad07e35025" 501 | }, 502 | "execution_count": 10, 503 | "outputs": [ 504 | { 505 | "output_type": "stream", 506 | "name": "stdout", 507 | "text": [ 508 | "1-st element: 1\n", 509 | "2-nd element: 2\n" 510 | ] 511 | } 512 | ] 513 | }, 514 | { 515 | "cell_type": "markdown", 516 | "source": [ 517 | "2-D and higher dimensional arrays are represented by using comma separated integers which represents the dimension and the index of the element. \n", 518 | "\n", 519 | "2-D arrays work like a table/matrice, the first dimension is the row and the index represents the column.\n", 520 | "\n", 521 | "It can also be indexed by first slicing the required dimension and slicing the element from that dimension. Slicing will be gone over in much greater detail coming up." 522 | ], 523 | "metadata": { 524 | "id": "WDHAMW4_XNfD" 525 | } 526 | }, 527 | { 528 | "cell_type": "code", 529 | "source": [ 530 | "arr1 = np.array([[1, 2, 3], [4, 5, 6]])\n", 531 | "print(f\"1-st element on 2-nd row of arr1: {arr1[1, 0]}\")\n", 532 | "print(f\"1-st element on 2-nd row of arr1 (By Slicing): {arr1[1][0]}\")" 533 | ], 534 | "metadata": { 535 | "colab": { 536 | "base_uri": "https://localhost:8080/" 537 | }, 538 | "id": "F5P5pCHgXM9C", 539 | "outputId": "6a9fa86c-7423-408d-f022-de05272a15a6" 540 | }, 541 | "execution_count": 11, 542 | "outputs": [ 543 | { 544 | "output_type": "stream", 545 | "name": "stdout", 546 | "text": [ 547 | "1-st element on 2-nd row of arr1: 4\n", 548 | "1-st element on 2-nd row of arr1 (By Slicing): 4\n" 549 | ] 550 | } 551 | ] 552 | }, 553 | { 554 | "cell_type": "markdown", 555 | "source": [ 556 | "Accessing 3-D Arrays has been explained in great detail by w3schools and it is as follows:" 557 | ], 558 | "metadata": { 559 | "id": "Lb_i9mRgYSrx" 560 | } 561 | }, 562 | { 563 | "cell_type": "code", 564 | "source": [ 565 | "arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])\n", 566 | "print(arr[0, 1, 2])" 567 | ], 568 | "metadata": { 569 | "colab": { 570 | "base_uri": "https://localhost:8080/" 571 | }, 572 | "id": "i6LC1pcmYboQ", 573 | "outputId": "a6eb6cf2-fe9b-4760-9348-3ad4af0deb77" 574 | }, 575 | "execution_count": 12, 576 | "outputs": [ 577 | { 578 | "output_type": "stream", 579 | "name": "stdout", 580 | "text": [ 581 | "6\n" 582 | ] 583 | } 584 | ] 585 | }, 586 | { 587 | "cell_type": "markdown", 588 | "source": [ 589 | "#### **Example Explained**\n", 590 | "`arr[0, 1, 2]` prints the value `6`.\n", 591 | "\n", 592 | "And this is why:\n", 593 | "\n", 594 | "The first number represents the first dimension, which contains two arrays:\n", 595 | "\n", 596 | "[[1, 2, 3], [4, 5, 6]]\n", 597 | "\n", 598 | "and:\n", 599 | "\n", 600 | "[[7, 8, 9], [10, 11, 12]]\n", 601 | "\n", 602 | "Since we selected `0`, we are left with the first array:\n", 603 | "\n", 604 | "[[1, 2, 3], [4, 5, 6]]\n", 605 | "\n", 606 | "The second number represents the second dimension, which also contains two arrays:\n", 607 | "\n", 608 | "[1, 2, 3]\n", 609 | "\n", 610 | "and:\n", 611 | "\n", 612 | "[4, 5, 6]\n", 613 | "\n", 614 | "Since we selected `1`, we are left with the second array:\n", 615 | "\n", 616 | "[4, 5, 6]\n", 617 | "\n", 618 | "The third number represents the third dimension, which contains three values:\n", 619 | "\n", 620 | "4\n", 621 | "\n", 622 | "5\n", 623 | "\n", 624 | "6\n", 625 | "\n", 626 | "Since we selected `2`, we end up with the third value:\n", 627 | "\n", 628 | "6" 629 | ], 630 | "metadata": { 631 | "id": "f7nMqQX8YenA" 632 | } 633 | }, 634 | { 635 | "cell_type": "markdown", 636 | "source": [ 637 | "#### **Negative Indexing**\n", 638 | "Used to access an array from it's ends." 639 | ], 640 | "metadata": { 641 | "id": "Qic1OLYVY9TZ" 642 | } 643 | }, 644 | { 645 | "cell_type": "code", 646 | "source": [ 647 | "arr = np.array([[1, 2, 3], [4, 5, 6]])\n", 648 | "print(f\"Last element of last row: {arr[-1, -1]}\")" 649 | ], 650 | "metadata": { 651 | "colab": { 652 | "base_uri": "https://localhost:8080/" 653 | }, 654 | "id": "1LKvhQOzZUXQ", 655 | "outputId": "81c87745-7169-4d62-ce51-d3bcb8aa3241" 656 | }, 657 | "execution_count": 13, 658 | "outputs": [ 659 | { 660 | "output_type": "stream", 661 | "name": "stdout", 662 | "text": [ 663 | "Last element of last row: 6\n" 664 | ] 665 | } 666 | ] 667 | }, 668 | { 669 | "cell_type": "markdown", 670 | "source": [ 671 | "### **NumPy Array Slicing**\n", 672 | "\n", 673 | "Similar to List slicing in it's definition.\n", 674 | "\n", 675 | "Takes the form `[start:end]`\n", 676 | "\n", 677 | "If step is to be included, the form is modified as `[start:end:step]`\n", 678 | "\n", 679 | "- If start is not passed, it is considered as 0. \n", 680 | "\n", 681 | "- If end is not passed, it is considered as the length of the array for that dimension.\n", 682 | "\n", 683 | "- The default value for step is 1.\n", 684 | "\n", 685 | "Negative slicing is also supported.\n", 686 | "\n", 687 | "**Point of great importance: The start index is included, i.e., the element at that index will a part of the output, while the end index is not included, i.e., the element at that index is not a part of the output.** " 688 | ], 689 | "metadata": { 690 | "id": "pG4lzmq6alSh" 691 | } 692 | }, 693 | { 694 | "cell_type": "code", 695 | "source": [ 696 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8])\n", 697 | "print(arr)\n", 698 | "print(f\"Elements from index-1 to index-5: {arr[1:5]}\")\n", 699 | "print(f\"Elements from index-5 to the end of the array: {arr[5:]}\")\n", 700 | "print(f\"Elements from the beginning to index-5 (not included): {arr[5:]}\")\n", 701 | "print(f\"Elements from index-5 from the end to index-1 from the end: {arr[-5:-1]}\")\n", 702 | "print(f\"Every other element from index-1 to index-5: {arr[1:5:2]}\")\n", 703 | "\n", 704 | "\n", 705 | "arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])\n", 706 | "print(\"\\n\", arr)\n", 707 | "print(f\"From the first row, elements from index-1 to index-5: {arr[0, 1:5]}\")\n", 708 | "print(f\"From both rows, elements from index-1 to index-3: {arr[0:, 1:3]}\")" 709 | ], 710 | "metadata": { 711 | "colab": { 712 | "base_uri": "https://localhost:8080/" 713 | }, 714 | "id": "5_LIXfv3bfsA", 715 | "outputId": "081d2003-fbbe-4d0c-bac0-ec3f0a024783" 716 | }, 717 | "execution_count": 14, 718 | "outputs": [ 719 | { 720 | "output_type": "stream", 721 | "name": "stdout", 722 | "text": [ 723 | "[1 2 3 4 5 6 7 8]\n", 724 | "Elements from index-1 to index-5: [2 3 4 5]\n", 725 | "Elements from index-5 to the end of the array: [6 7 8]\n", 726 | "Elements from the beginning to index-5 (not included): [6 7 8]\n", 727 | "Elements from index-5 from the end to index-1 from the end: [4 5 6 7]\n", 728 | "Every other element from index-1 to index-5: [2 4]\n", 729 | "\n", 730 | " [[ 1 2 3 4 5]\n", 731 | " [ 6 7 8 9 10]]\n", 732 | "From the first row, elements from index-1 to index-5: [2 3 4 5]\n", 733 | "From both rows, elements from index-1 to index-3: [[2 3]\n", 734 | " [7 8]]\n" 735 | ] 736 | } 737 | ] 738 | }, 739 | { 740 | "cell_type": "markdown", 741 | "source": [ 742 | "### **NumPy Array Iterating**\n", 743 | "\n", 744 | "Similar to iterating through Python lists/tuples.\n", 745 | "\n", 746 | "Iterating, to the unintiated, is going through each elements one by one. Implemented using the trusted `for` loop. Best understood by taking up multiple examples." 747 | ], 748 | "metadata": { 749 | "id": "wPN4qYb-f3UX" 750 | } 751 | }, 752 | { 753 | "cell_type": "code", 754 | "source": [ 755 | "arr = np.array([1, 2, 3])\n", 756 | "\n", 757 | "print(\"Iterating through a 1-D array (on the elements):\")\n", 758 | "for x in arr:\n", 759 | " print(x)\n" 760 | ], 761 | "metadata": { 762 | "colab": { 763 | "base_uri": "https://localhost:8080/" 764 | }, 765 | "id": "AMjcQO5agYNI", 766 | "outputId": "339d2694-3106-4717-c5ff-624b184530ce" 767 | }, 768 | "execution_count": 15, 769 | "outputs": [ 770 | { 771 | "output_type": "stream", 772 | "name": "stdout", 773 | "text": [ 774 | "Iterating through a 1-D array (on the elements):\n", 775 | "1\n", 776 | "2\n", 777 | "3\n" 778 | ] 779 | } 780 | ] 781 | }, 782 | { 783 | "cell_type": "code", 784 | "source": [ 785 | "arr = np.array([[1, 2, 3], [4, 5, 6]])\n", 786 | "print(\"Iterating through a 2-D array (on the elements):\")\n", 787 | "for x in arr:\n", 788 | " print(x)\n" 789 | ], 790 | "metadata": { 791 | "colab": { 792 | "base_uri": "https://localhost:8080/" 793 | }, 794 | "id": "wHl4RZqLhjC2", 795 | "outputId": "3fa3f5a3-66c2-4f97-b929-92aabe69a34d" 796 | }, 797 | "execution_count": 16, 798 | "outputs": [ 799 | { 800 | "output_type": "stream", 801 | "name": "stdout", 802 | "text": [ 803 | "Iterating through a 2-D array (on the elements):\n", 804 | "[1 2 3]\n", 805 | "[4 5 6]\n" 806 | ] 807 | } 808 | ] 809 | }, 810 | { 811 | "cell_type": "markdown", 812 | "source": [ 813 | "As seen, the loop iterates through each row instead of each scalar element. This is demonstrated by the loop printing the row entirely, instead of the scalars it contains individually. Therefore, if we iterate on a n-D array, it will go through n-1th dimension one by one. To return the actual values, i.e. scalars, follow the following piece of code." 814 | ], 815 | "metadata": { 816 | "id": "iniQEx9ohhCu" 817 | } 818 | }, 819 | { 820 | "cell_type": "code", 821 | "source": [ 822 | "arr = np.array([[1, 2, 3], [4, 5, 6]])\n", 823 | "\n", 824 | "for x in arr:\n", 825 | " for y in x:\n", 826 | " print(y)" 827 | ], 828 | "metadata": { 829 | "colab": { 830 | "base_uri": "https://localhost:8080/" 831 | }, 832 | "id": "5rJG26uIhsin", 833 | "outputId": "4160182b-7cbc-4926-869c-960787d5eb64" 834 | }, 835 | "execution_count": 17, 836 | "outputs": [ 837 | { 838 | "output_type": "stream", 839 | "name": "stdout", 840 | "text": [ 841 | "1\n", 842 | "2\n", 843 | "3\n", 844 | "4\n", 845 | "5\n", 846 | "6\n" 847 | ] 848 | } 849 | ] 850 | }, 851 | { 852 | "cell_type": "markdown", 853 | "source": [ 854 | "Same concept applies for 3-D and higher dimensional arrays." 855 | ], 856 | "metadata": { 857 | "id": "SPQ3j0gRiFaV" 858 | } 859 | }, 860 | { 861 | "cell_type": "code", 862 | "source": [ 863 | "arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])\n", 864 | "\n", 865 | "for x in arr:\n", 866 | " print(x)" 867 | ], 868 | "metadata": { 869 | "colab": { 870 | "base_uri": "https://localhost:8080/" 871 | }, 872 | "id": "EobZnMnFiKTe", 873 | "outputId": "56dbd54b-0afe-4043-f1e2-7f5454f814aa" 874 | }, 875 | "execution_count": 18, 876 | "outputs": [ 877 | { 878 | "output_type": "stream", 879 | "name": "stdout", 880 | "text": [ 881 | "[[1 2 3]\n", 882 | " [4 5 6]]\n", 883 | "[[ 7 8 9]\n", 884 | " [10 11 12]]\n" 885 | ] 886 | } 887 | ] 888 | }, 889 | { 890 | "cell_type": "code", 891 | "source": [ 892 | "arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])\n", 893 | "\n", 894 | "for x in arr:\n", 895 | " for y in x:\n", 896 | " for z in y:\n", 897 | " print(z)" 898 | ], 899 | "metadata": { 900 | "colab": { 901 | "base_uri": "https://localhost:8080/" 902 | }, 903 | "id": "BW6b7FqUiLEu", 904 | "outputId": "1f969da7-9440-48e5-aa93-5b7939eed3df" 905 | }, 906 | "execution_count": 19, 907 | "outputs": [ 908 | { 909 | "output_type": "stream", 910 | "name": "stdout", 911 | "text": [ 912 | "1\n", 913 | "2\n", 914 | "3\n", 915 | "4\n", 916 | "5\n", 917 | "6\n", 918 | "7\n", 919 | "8\n", 920 | "9\n", 921 | "10\n", 922 | "11\n", 923 | "12\n" 924 | ] 925 | } 926 | ] 927 | }, 928 | { 929 | "cell_type": "markdown", 930 | "source": [ 931 | "### **NumPy Array Shape**\n", 932 | "The shape of an array is the number of elements in each dimension.\n", 933 | "\n", 934 | "To know the shape of an `ndarray`, we can tap into it's shape attribute that returns a tuple with the index representing the corresponding dimension and the number at that index representing the number of corresponding elements in that respective dimension.\n" 935 | ], 936 | "metadata": { 937 | "id": "b6STBHnfipeF" 938 | } 939 | }, 940 | { 941 | "cell_type": "code", 942 | "source": [ 943 | "arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])\n", 944 | "print(f\"arr shape: {arr.shape}\")" 945 | ], 946 | "metadata": { 947 | "colab": { 948 | "base_uri": "https://localhost:8080/" 949 | }, 950 | "id": "Cfy0NTxejVDI", 951 | "outputId": "b7f5a9f4-f4de-4bc0-e3e6-1a741f0b6761" 952 | }, 953 | "execution_count": 20, 954 | "outputs": [ 955 | { 956 | "output_type": "stream", 957 | "name": "stdout", 958 | "text": [ 959 | "arr shape: (2, 5)\n" 960 | ] 961 | } 962 | ] 963 | }, 964 | { 965 | "cell_type": "markdown", 966 | "source": [ 967 | "(2, 5) demonstrates that the array has 2 dimensions (indicated by the number of elements in the tuple). The first dimension contains 2 elements (corresponding to the 2 rows in the above example) and the second has 5 (5 columns)." 968 | ], 969 | "metadata": { 970 | "id": "XxCvOJjVjpS1" 971 | } 972 | }, 973 | { 974 | "cell_type": "markdown", 975 | "source": [ 976 | "### **NumPy Array Copy and View**\n", 977 | "What are these 2 new elusive terms? By nomenclature, it is easy to gather that a copy of an array is simply a new array that is a copy of the original array while view is simply a view of the original array.\n", 978 | "\n", 979 | "- The copy owns the data and any changes made to the copy will not affect original array, and any changes made to the original array will not affect the copy.\n", 980 | "\n", 981 | "- The view does not own the data and any changes made to the view will affect the original array, and any changes made to the original array will affect the view.\n", 982 | "\n", 983 | "Difference b/w copy and view can be clearly explained through examples. Let us make an array, a copy of the array, change the original array and display the two of them.\n", 984 | "\n", 985 | "**The copy is not affected by the changes made to the original array.**" 986 | ], 987 | "metadata": { 988 | "id": "Dt7XzF9ckejO" 989 | } 990 | }, 991 | { 992 | "cell_type": "code", 993 | "source": [ 994 | "arr_original = np.array([1, 2, 3, 4, 5])\n", 995 | "arr_copy = arr_original.copy()\n", 996 | "arr_original[0] = 8\n", 997 | "print(f\"The original array is: {arr_original}\")\n", 998 | "print(f\"The copy of the array is: {arr_copy}\")" 999 | ], 1000 | "metadata": { 1001 | "colab": { 1002 | "base_uri": "https://localhost:8080/" 1003 | }, 1004 | "id": "bHyn3SNvu7mG", 1005 | "outputId": "1f210b6d-d3a3-4b8f-bc11-b973f60e5288" 1006 | }, 1007 | "execution_count": 21, 1008 | "outputs": [ 1009 | { 1010 | "output_type": "stream", 1011 | "name": "stdout", 1012 | "text": [ 1013 | "The original array is: [8 2 3 4 5]\n", 1014 | "The copy of the array is: [1 2 3 4 5]\n" 1015 | ] 1016 | } 1017 | ] 1018 | }, 1019 | { 1020 | "cell_type": "markdown", 1021 | "source": [ 1022 | "Let us replicate the same procedure but make a view of the array instead." 1023 | ], 1024 | "metadata": { 1025 | "id": "H0xjd_c1wOsK" 1026 | } 1027 | }, 1028 | { 1029 | "cell_type": "code", 1030 | "source": [ 1031 | "arr_original = np.array([1, 2, 3, 4, 5])\n", 1032 | "arr_view = arr_original.view()\n", 1033 | "arr_original[0] = 8\n", 1034 | "print(f\"The original array is: {arr_original}\")\n", 1035 | "print(f\"The view of the array is: {arr_view}\")" 1036 | ], 1037 | "metadata": { 1038 | "colab": { 1039 | "base_uri": "https://localhost:8080/" 1040 | }, 1041 | "id": "YqEA-Wmmw1t6", 1042 | "outputId": "44f2e36e-aed5-4881-c0cf-b2846fdc8708" 1043 | }, 1044 | "execution_count": 22, 1045 | "outputs": [ 1046 | { 1047 | "output_type": "stream", 1048 | "name": "stdout", 1049 | "text": [ 1050 | "The original array is: [8 2 3 4 5]\n", 1051 | "The view of the array is: [8 2 3 4 5]\n" 1052 | ] 1053 | } 1054 | ] 1055 | }, 1056 | { 1057 | "cell_type": "markdown", 1058 | "source": [ 1059 | "Thus, **the view is affected by the changes made to the original array.** \n", 1060 | "\n", 1061 | "Let us create an array, make a view, change the view and display both the arrays." 1062 | ], 1063 | "metadata": { 1064 | "id": "rG4uunhBwEiB" 1065 | } 1066 | }, 1067 | { 1068 | "cell_type": "code", 1069 | "source": [ 1070 | "arr_original = np.array([1, 2, 3, 4, 5])\n", 1071 | "arr_view = arr_original.view()\n", 1072 | "arr_view[0] = 8\n", 1073 | "print(f\"The original array is: {arr_original}\")\n", 1074 | "print(f\"The view of the array is: {arr_view}\")" 1075 | ], 1076 | "metadata": { 1077 | "colab": { 1078 | "base_uri": "https://localhost:8080/" 1079 | }, 1080 | "id": "kVoNiknuzlXx", 1081 | "outputId": "78c87ae3-1248-4d6c-ff02-44eb961851d7" 1082 | }, 1083 | "execution_count": 23, 1084 | "outputs": [ 1085 | { 1086 | "output_type": "stream", 1087 | "name": "stdout", 1088 | "text": [ 1089 | "The original array is: [8 2 3 4 5]\n", 1090 | "The view of the array is: [8 2 3 4 5]\n" 1091 | ] 1092 | } 1093 | ] 1094 | }, 1095 | { 1096 | "cell_type": "markdown", 1097 | "source": [ 1098 | "**The original array is affected by the changes made to the view.**" 1099 | ], 1100 | "metadata": { 1101 | "id": "tj-5v9o7zwES" 1102 | } 1103 | }, 1104 | { 1105 | "cell_type": "markdown", 1106 | "source": [ 1107 | "#### **Check if array is a copy or view through ownership**" 1108 | ], 1109 | "metadata": { 1110 | "id": "zMKILrzJ_CJc" 1111 | } 1112 | }, 1113 | { 1114 | "cell_type": "code", 1115 | "source": [ 1116 | "arr = np.array([1, 2, 3, 4, 5])\n", 1117 | "\n", 1118 | "x = arr.copy()\n", 1119 | "y = arr.view()\n", 1120 | "\n", 1121 | "print(x.base)\n", 1122 | "print(y.base)" 1123 | ], 1124 | "metadata": { 1125 | "colab": { 1126 | "base_uri": "https://localhost:8080/" 1127 | }, 1128 | "id": "fvrCrV82_AcL", 1129 | "outputId": "846b1ea0-98ca-4e77-b605-3a2da3801b82" 1130 | }, 1131 | "execution_count": 24, 1132 | "outputs": [ 1133 | { 1134 | "output_type": "stream", 1135 | "name": "stdout", 1136 | "text": [ 1137 | "None\n", 1138 | "[1 2 3 4 5]\n" 1139 | ] 1140 | } 1141 | ] 1142 | }, 1143 | { 1144 | "cell_type": "markdown", 1145 | "source": [ 1146 | "The copy returns `None` as there is no array that owns it. The view returns the original array as it has it's ownership." 1147 | ], 1148 | "metadata": { 1149 | "id": "UpyO4JZN-51M" 1150 | } 1151 | }, 1152 | { 1153 | "cell_type": "markdown", 1154 | "source": [ 1155 | "### **NumPy Array Reshaping**\n", 1156 | "Reshaping means changing the shape of an array. By reshaping, we can add or remove dimensions or change the number of elements in each dimension." 1157 | ], 1158 | "metadata": { 1159 | "id": "pt3UU8Es0pCJ" 1160 | } 1161 | }, 1162 | { 1163 | "cell_type": "code", 1164 | "source": [ 1165 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])\n", 1166 | "newarr = arr.reshape(4, 3)\n", 1167 | "\n", 1168 | "print(f\"The original array: {arr}\")\n", 1169 | "print(f\"The re-shaped array is: {newarr}\")" 1170 | ], 1171 | "metadata": { 1172 | "colab": { 1173 | "base_uri": "https://localhost:8080/" 1174 | }, 1175 | "id": "21PGSKRj4VQm", 1176 | "outputId": "f4d41c25-1aab-4445-db98-14241eb3e5cb" 1177 | }, 1178 | "execution_count": 25, 1179 | "outputs": [ 1180 | { 1181 | "output_type": "stream", 1182 | "name": "stdout", 1183 | "text": [ 1184 | "The original array: [ 1 2 3 4 5 6 7 8 9 10 11 12]\n", 1185 | "The re-shaped array is: [[ 1 2 3]\n", 1186 | " [ 4 5 6]\n", 1187 | " [ 7 8 9]\n", 1188 | " [10 11 12]]\n" 1189 | ] 1190 | } 1191 | ] 1192 | }, 1193 | { 1194 | "cell_type": "code", 1195 | "source": [ 1196 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])\n", 1197 | "newarr = arr.reshape(2, 3, 2)\n", 1198 | "\n", 1199 | "print(f\"The original array: {arr}\")\n", 1200 | "print(f\"The re-shaped array is: {newarr}\")" 1201 | ], 1202 | "metadata": { 1203 | "colab": { 1204 | "base_uri": "https://localhost:8080/" 1205 | }, 1206 | "id": "pQ8JdE4_7SxF", 1207 | "outputId": "9fceaa07-3330-41ab-968b-3652f79de119" 1208 | }, 1209 | "execution_count": 26, 1210 | "outputs": [ 1211 | { 1212 | "output_type": "stream", 1213 | "name": "stdout", 1214 | "text": [ 1215 | "The original array: [ 1 2 3 4 5 6 7 8 9 10 11 12]\n", 1216 | "The re-shaped array is: [[[ 1 2]\n", 1217 | " [ 3 4]\n", 1218 | " [ 5 6]]\n", 1219 | "\n", 1220 | " [[ 7 8]\n", 1221 | " [ 9 10]\n", 1222 | " [11 12]]]\n" 1223 | ] 1224 | } 1225 | ] 1226 | }, 1227 | { 1228 | "cell_type": "markdown", 1229 | "source": [ 1230 | "#### **Re-shape into any shape**\n", 1231 | "We can re-shape an array into any shape as long as there are required number of elements to shape the array. \n", 1232 | "\n", 1233 | "For example, an 1-D array with 8 elements can be shaped into a (4, 2) as a (4, 2) array contains 4 x 2 = 8 elements. However, it cannot be shapped into a (3, 3) because a (3, 3) would required 3 x 3 = 9 elements; one more element than what is supplied." 1234 | ], 1235 | "metadata": { 1236 | "id": "iS14gpEd8C-t" 1237 | } 1238 | }, 1239 | { 1240 | "cell_type": "code", 1241 | "source": [ 1242 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8])\n", 1243 | "newarr = arr.reshape(3, 3)\n", 1244 | "\n", 1245 | "print(f\"The re-shaped array is: {newarr}\")" 1246 | ], 1247 | "metadata": { 1248 | "colab": { 1249 | "base_uri": "https://localhost:8080/", 1250 | "height": 217 1251 | }, 1252 | "id": "Kbk-yicQ8w6D", 1253 | "outputId": "decd2b7b-b6b1-4309-c640-1f9b52829651" 1254 | }, 1255 | "execution_count": 27, 1256 | "outputs": [ 1257 | { 1258 | "output_type": "error", 1259 | "ename": "ValueError", 1260 | "evalue": "ignored", 1261 | "traceback": [ 1262 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 1263 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", 1264 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0marr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m7\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m8\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mnewarr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0marr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"The re-shaped array is: {newarr}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 1265 | "\u001b[0;31mValueError\u001b[0m: cannot reshape array of size 8 into shape (3,3)" 1266 | ] 1267 | } 1268 | ] 1269 | }, 1270 | { 1271 | "cell_type": "markdown", 1272 | "source": [ 1273 | "#### **Unknown Dimension**\n", 1274 | "You are allowed 1 unknown dimension. Pass -1 value and NumPy will calculate what that number should be accordingly." 1275 | ], 1276 | "metadata": { 1277 | "id": "yRE7XhsP7X5l" 1278 | } 1279 | }, 1280 | { 1281 | "cell_type": "code", 1282 | "source": [ 1283 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8])\n", 1284 | "newarr = arr.reshape(2, 2, -1)" 1285 | ], 1286 | "metadata": { 1287 | "id": "JfHsWhDR7XMP" 1288 | }, 1289 | "execution_count": 28, 1290 | "outputs": [] 1291 | }, 1292 | { 1293 | "cell_type": "markdown", 1294 | "source": [ 1295 | "### **NumPy Joining Array**\n", 1296 | "Joining is obviously putting contents of two or more arrays into a single array. Joining arrays is done by axes. \n", 1297 | "\n", 1298 | "The `concatenate()` function accepts arrays to be joined along with the axis. If the axis is not explicitly stated, it takes the default value of 0.\n", 1299 | "\n", 1300 | "Along axis-0:\n" 1301 | ], 1302 | "metadata": { 1303 | "id": "C_-159ZXDTfb" 1304 | } 1305 | }, 1306 | { 1307 | "cell_type": "code", 1308 | "source": [ 1309 | "arr1 = np.array([1, 2, 3])\n", 1310 | "arr2 = np.array([4, 5, 6])\n", 1311 | "arr = np.concatenate((arr1, arr2))\n", 1312 | "print(arr)" 1313 | ], 1314 | "metadata": { 1315 | "colab": { 1316 | "base_uri": "https://localhost:8080/" 1317 | }, 1318 | "id": "wclEyPplDSlb", 1319 | "outputId": "42d189ed-16b8-4d92-b8b0-b869b02c5032" 1320 | }, 1321 | "execution_count": 29, 1322 | "outputs": [ 1323 | { 1324 | "output_type": "stream", 1325 | "name": "stdout", 1326 | "text": [ 1327 | "[1 2 3 4 5 6]\n" 1328 | ] 1329 | } 1330 | ] 1331 | }, 1332 | { 1333 | "cell_type": "markdown", 1334 | "source": [ 1335 | "Along axis-1:" 1336 | ], 1337 | "metadata": { 1338 | "id": "7tGJi4A4FZiL" 1339 | } 1340 | }, 1341 | { 1342 | "cell_type": "code", 1343 | "source": [ 1344 | "arr1 = np.array([[1, 2], [3, 4]])\n", 1345 | "arr2 = np.array([[5, 6], [7, 8]])\n", 1346 | "arr = np.concatenate((arr1, arr2), axis=1)\n", 1347 | "print(arr)" 1348 | ], 1349 | "metadata": { 1350 | "colab": { 1351 | "base_uri": "https://localhost:8080/" 1352 | }, 1353 | "id": "SQQvadM0FcmS", 1354 | "outputId": "326e87a1-2385-4925-ba6f-38a5687e0fdc" 1355 | }, 1356 | "execution_count": 30, 1357 | "outputs": [ 1358 | { 1359 | "output_type": "stream", 1360 | "name": "stdout", 1361 | "text": [ 1362 | "[[1 2 5 6]\n", 1363 | " [3 4 7 8]]\n" 1364 | ] 1365 | } 1366 | ] 1367 | }, 1368 | { 1369 | "cell_type": "markdown", 1370 | "source": [ 1371 | "#### **Stacking**\n", 1372 | "Stacking is the same as concatenation, the only difference is stacking is done along a new axis. \n", 1373 | "\n", 1374 | "2 1-D arrays can be joined along the second axis, by putting them one over the other." 1375 | ], 1376 | "metadata": { 1377 | "id": "f81wt1OaFfca" 1378 | } 1379 | }, 1380 | { 1381 | "cell_type": "code", 1382 | "source": [ 1383 | "arr1 = np.array([1, 2, 3])\n", 1384 | "arr2 = np.array([4, 5, 6])\n", 1385 | "arr = np.stack((arr1, arr2), axis=1)\n", 1386 | "print(arr)" 1387 | ], 1388 | "metadata": { 1389 | "colab": { 1390 | "base_uri": "https://localhost:8080/" 1391 | }, 1392 | "id": "87m6FOQoGigK", 1393 | "outputId": "c452948f-47a1-465a-bd1f-5ce16dad0d3b" 1394 | }, 1395 | "execution_count": 31, 1396 | "outputs": [ 1397 | { 1398 | "output_type": "stream", 1399 | "name": "stdout", 1400 | "text": [ 1401 | "[[1 4]\n", 1402 | " [2 5]\n", 1403 | " [3 6]]\n" 1404 | ] 1405 | } 1406 | ] 1407 | }, 1408 | { 1409 | "cell_type": "markdown", 1410 | "source": [ 1411 | "To stack along rows, use `hstack()`." 1412 | ], 1413 | "metadata": { 1414 | "id": "5Oy3SNUAHCFa" 1415 | } 1416 | }, 1417 | { 1418 | "cell_type": "code", 1419 | "source": [ 1420 | "arr1 = np.array([1, 2, 3])\n", 1421 | "arr2 = np.array([4, 5, 6])\n", 1422 | "arr = np.hstack((arr1, arr2))\n", 1423 | "print(arr)" 1424 | ], 1425 | "metadata": { 1426 | "colab": { 1427 | "base_uri": "https://localhost:8080/" 1428 | }, 1429 | "id": "VHrG9ErfHIDh", 1430 | "outputId": "487f3eb8-550e-47be-930b-dd8b136d9780" 1431 | }, 1432 | "execution_count": 32, 1433 | "outputs": [ 1434 | { 1435 | "output_type": "stream", 1436 | "name": "stdout", 1437 | "text": [ 1438 | "[1 2 3 4 5 6]\n" 1439 | ] 1440 | } 1441 | ] 1442 | }, 1443 | { 1444 | "cell_type": "markdown", 1445 | "source": [ 1446 | "To stack along columns, use `vstack()`." 1447 | ], 1448 | "metadata": { 1449 | "id": "fpz9jAPXHKQZ" 1450 | } 1451 | }, 1452 | { 1453 | "cell_type": "code", 1454 | "source": [ 1455 | "arr1 = np.array([1, 2, 3])\n", 1456 | "arr2 = np.array([4, 5, 6])\n", 1457 | "arr = np.vstack((arr1, arr2))\n", 1458 | "print(arr)" 1459 | ], 1460 | "metadata": { 1461 | "colab": { 1462 | "base_uri": "https://localhost:8080/" 1463 | }, 1464 | "id": "zW4TKijQHPeh", 1465 | "outputId": "17c4ac42-ee87-4ab1-8e6c-fac85a58920e" 1466 | }, 1467 | "execution_count": 33, 1468 | "outputs": [ 1469 | { 1470 | "output_type": "stream", 1471 | "name": "stdout", 1472 | "text": [ 1473 | "[[1 2 3]\n", 1474 | " [4 5 6]]\n" 1475 | ] 1476 | } 1477 | ] 1478 | }, 1479 | { 1480 | "cell_type": "markdown", 1481 | "source": [ 1482 | "To stack along height, which is the same as depth, use `dstack()`." 1483 | ], 1484 | "metadata": { 1485 | "id": "aJR94qvsHshi" 1486 | } 1487 | }, 1488 | { 1489 | "cell_type": "code", 1490 | "source": [ 1491 | "arr1 = np.array([1, 2, 3])\n", 1492 | "arr2 = np.array([4, 5, 6])\n", 1493 | "arr = np.dstack((arr1, arr2))\n", 1494 | "print(arr)" 1495 | ], 1496 | "metadata": { 1497 | "colab": { 1498 | "base_uri": "https://localhost:8080/" 1499 | }, 1500 | "id": "HHu-3eG4HsAy", 1501 | "outputId": "626b6ad4-4cfc-4774-8fa5-7ba087ecdc02" 1502 | }, 1503 | "execution_count": 34, 1504 | "outputs": [ 1505 | { 1506 | "output_type": "stream", 1507 | "name": "stdout", 1508 | "text": [ 1509 | "[[[1 4]\n", 1510 | " [2 5]\n", 1511 | " [3 6]]]\n" 1512 | ] 1513 | } 1514 | ] 1515 | }, 1516 | { 1517 | "cell_type": "markdown", 1518 | "source": [ 1519 | "### **NumPy Splitting Array**\n", 1520 | "Splitting is the reverse of joining. Joining merges multiple arrays into 1, while splitting breaks 1 array into multiple.\n", 1521 | "\n", 1522 | "Implemented using the `array_split()` function." 1523 | ], 1524 | "metadata": { 1525 | "id": "4VQ7dBf7NOGQ" 1526 | } 1527 | }, 1528 | { 1529 | "cell_type": "code", 1530 | "source": [ 1531 | "arr = np.array([1, 2, 3, 4, 5, 6])\n", 1532 | "newarr = np.array_split(arr, 3)\n", 1533 | "print(f\"First array: {newarr[0]}\")\n", 1534 | "print(f\"Second array: {newarr[1]}\")\n", 1535 | "print(f\"Third array: {newarr[2]}\")" 1536 | ], 1537 | "metadata": { 1538 | "colab": { 1539 | "base_uri": "https://localhost:8080/" 1540 | }, 1541 | "id": "GweSJRmVNwAn", 1542 | "outputId": "7005a6fc-bfb0-447c-e8a0-c20702a1dc99" 1543 | }, 1544 | "execution_count": 35, 1545 | "outputs": [ 1546 | { 1547 | "output_type": "stream", 1548 | "name": "stdout", 1549 | "text": [ 1550 | "First array: [1 2]\n", 1551 | "Second array: [3 4]\n", 1552 | "Third array: [5 6]\n" 1553 | ] 1554 | } 1555 | ] 1556 | }, 1557 | { 1558 | "cell_type": "markdown", 1559 | "source": [ 1560 | "If the array has less elements than required, it will adjust accordingly.\n", 1561 | "A `split()` method also exists but it doesnt not adjust the elements when the elements are less in the source array." 1562 | ], 1563 | "metadata": { 1564 | "id": "Bts0zYB6N9-i" 1565 | } 1566 | }, 1567 | { 1568 | "cell_type": "code", 1569 | "source": [ 1570 | "arr = np.array([1, 2, 3, 4, 5, 6])\n", 1571 | "newarr = np.array_split(arr, 4)\n", 1572 | "print(newarr)" 1573 | ], 1574 | "metadata": { 1575 | "colab": { 1576 | "base_uri": "https://localhost:8080/" 1577 | }, 1578 | "id": "c-OEJy8BOQ2Y", 1579 | "outputId": "c0d254da-3579-4ab9-dfaa-458986024954" 1580 | }, 1581 | "execution_count": 36, 1582 | "outputs": [ 1583 | { 1584 | "output_type": "stream", 1585 | "name": "stdout", 1586 | "text": [ 1587 | "[array([1, 2]), array([3, 4]), array([5]), array([6])]\n" 1588 | ] 1589 | } 1590 | ] 1591 | }, 1592 | { 1593 | "cell_type": "markdown", 1594 | "source": [ 1595 | "Same syntax used while splitting 2-D arrays." 1596 | ], 1597 | "metadata": { 1598 | "id": "fML2z2CsOzlX" 1599 | } 1600 | }, 1601 | { 1602 | "cell_type": "code", 1603 | "source": [ 1604 | "arr = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]])\n", 1605 | "newarr = np.array_split(arr, 3)\n", 1606 | "print(newarr)" 1607 | ], 1608 | "metadata": { 1609 | "colab": { 1610 | "base_uri": "https://localhost:8080/" 1611 | }, 1612 | "id": "lUUu00DTO-EG", 1613 | "outputId": "7ebb05f6-4ad5-43a1-dbe5-5527a6ecf5fd" 1614 | }, 1615 | "execution_count": 37, 1616 | "outputs": [ 1617 | { 1618 | "output_type": "stream", 1619 | "name": "stdout", 1620 | "text": [ 1621 | "[array([[1, 2],\n", 1622 | " [3, 4]]), array([[5, 6],\n", 1623 | " [7, 8]]), array([[ 9, 10],\n", 1624 | " [11, 12]])]\n" 1625 | ] 1626 | } 1627 | ] 1628 | }, 1629 | { 1630 | "cell_type": "markdown", 1631 | "source": [ 1632 | "You can also specify the axis along which the split is to be performed." 1633 | ], 1634 | "metadata": { 1635 | "id": "zlP-kwNUO_BH" 1636 | } 1637 | }, 1638 | { 1639 | "cell_type": "code", 1640 | "source": [ 1641 | "arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]])\n", 1642 | "newarr = np.array_split(arr, 3, axis=1)\n", 1643 | "print(newarr)" 1644 | ], 1645 | "metadata": { 1646 | "colab": { 1647 | "base_uri": "https://localhost:8080/" 1648 | }, 1649 | "id": "YHER4GSrPHsn", 1650 | "outputId": "48947784-9046-4641-e503-f392504b6db4" 1651 | }, 1652 | "execution_count": 38, 1653 | "outputs": [ 1654 | { 1655 | "output_type": "stream", 1656 | "name": "stdout", 1657 | "text": [ 1658 | "[array([[ 1],\n", 1659 | " [ 4],\n", 1660 | " [ 7],\n", 1661 | " [10],\n", 1662 | " [13],\n", 1663 | " [16]]), array([[ 2],\n", 1664 | " [ 5],\n", 1665 | " [ 8],\n", 1666 | " [11],\n", 1667 | " [14],\n", 1668 | " [17]]), array([[ 3],\n", 1669 | " [ 6],\n", 1670 | " [ 9],\n", 1671 | " [12],\n", 1672 | " [15],\n", 1673 | " [18]])]\n" 1674 | ] 1675 | } 1676 | ] 1677 | }, 1678 | { 1679 | "cell_type": "markdown", 1680 | "source": [ 1681 | "### **NumPy Searching Arrays**\n", 1682 | "To search an array, we use the `where()` method. Returns indices of numbers which fulfill the given condition." 1683 | ], 1684 | "metadata": { 1685 | "id": "IAHD1hd4QFq3" 1686 | } 1687 | }, 1688 | { 1689 | "cell_type": "code", 1690 | "source": [ 1691 | "arr = np.array([1, 2, 3, 4, 5, 4, 4])\n", 1692 | "print(np.where(arr == 4))" 1693 | ], 1694 | "metadata": { 1695 | "colab": { 1696 | "base_uri": "https://localhost:8080/" 1697 | }, 1698 | "id": "YlneBtOvQgiu", 1699 | "outputId": "b309c73b-54c8-445e-c5a9-9e1fbc5c9f2b" 1700 | }, 1701 | "execution_count": 39, 1702 | "outputs": [ 1703 | { 1704 | "output_type": "stream", 1705 | "name": "stdout", 1706 | "text": [ 1707 | "(array([3, 5, 6]),)\n" 1708 | ] 1709 | } 1710 | ] 1711 | }, 1712 | { 1713 | "cell_type": "markdown", 1714 | "source": [ 1715 | "Can pass functions like find numbers divisible by 2, i.e., even numbers." 1716 | ], 1717 | "metadata": { 1718 | "id": "lhpfOBlVQo1v" 1719 | } 1720 | }, 1721 | { 1722 | "cell_type": "code", 1723 | "source": [ 1724 | "arr = np.array([1, 2, 3, 4, 5, 6, 7, 8])\n", 1725 | "print(np.where(arr%2 == 0))" 1726 | ], 1727 | "metadata": { 1728 | "colab": { 1729 | "base_uri": "https://localhost:8080/" 1730 | }, 1731 | "id": "PUnPgdmiQz7v", 1732 | "outputId": "25c095e8-e4ef-4f86-b77d-258c8d28dcc3" 1733 | }, 1734 | "execution_count": 40, 1735 | "outputs": [ 1736 | { 1737 | "output_type": "stream", 1738 | "name": "stdout", 1739 | "text": [ 1740 | "(array([1, 3, 5, 7]),)\n" 1741 | ] 1742 | } 1743 | ] 1744 | }, 1745 | { 1746 | "cell_type": "markdown", 1747 | "source": [ 1748 | "### **Data Types in NumPy**\n", 1749 | "NumPy comes with it's own fair share of datatypes, along with the default 5 python data types.\n", 1750 | "\n", 1751 | "- i - integer\n", 1752 | "- b - boolean\n", 1753 | "- u - unsigned integer\n", 1754 | "- f - float\n", 1755 | "- c - complex float\n", 1756 | "- m - timedelta\n", 1757 | "- M - datetime\n", 1758 | "- O - object\n", 1759 | "- S - string\n", 1760 | "- U - unicode string\n", 1761 | "- V - fixed chunk of memory for other type (void)" 1762 | ], 1763 | "metadata": { 1764 | "id": "Q73WHHmNewiP" 1765 | } 1766 | }, 1767 | { 1768 | "cell_type": "markdown", 1769 | "source": [ 1770 | "#### **Checking Data Type of Array**\n", 1771 | "`dtype` attribute returns the data type of the array." 1772 | ], 1773 | "metadata": { 1774 | "id": "AUgmr0qlS5Xl" 1775 | } 1776 | }, 1777 | { 1778 | "cell_type": "code", 1779 | "source": [ 1780 | "arr = np.array([1, 2, 3])\n", 1781 | "print(f\"Data Type of array: {arr.dtype}\")" 1782 | ], 1783 | "metadata": { 1784 | "colab": { 1785 | "base_uri": "https://localhost:8080/" 1786 | }, 1787 | "id": "034fj934S1qW", 1788 | "outputId": "b731714e-9583-4f56-dd48-28c9b028b5a2" 1789 | }, 1790 | "execution_count": 41, 1791 | "outputs": [ 1792 | { 1793 | "output_type": "stream", 1794 | "name": "stdout", 1795 | "text": [ 1796 | "Data Type of array: int64\n" 1797 | ] 1798 | } 1799 | ] 1800 | }, 1801 | { 1802 | "cell_type": "markdown", 1803 | "source": [ 1804 | "The `array()` function also accepts `dtype` that allows us to define what the expected data type of the array elements must be. We can also define the size for `i`, `u`, `f`, `S`, and `U`." 1805 | ], 1806 | "metadata": { 1807 | "id": "O57mlZdbTY1m" 1808 | } 1809 | }, 1810 | { 1811 | "cell_type": "code", 1812 | "source": [ 1813 | "arr = np.array([1, 2, 3], dtype='S')\n", 1814 | "print(f\"arr: {arr}\")\n", 1815 | "print(f\"Data Type of array: {arr.dtype}\")\n", 1816 | "\n", 1817 | "arr = np.array([1, 2, 3, 4], dtype='i4')\n", 1818 | "print(f\"arr: {arr}\")\n", 1819 | "print(f\"Data Type of array: {arr.dtype}\")" 1820 | ], 1821 | "metadata": { 1822 | "colab": { 1823 | "base_uri": "https://localhost:8080/" 1824 | }, 1825 | "id": "jzUwVew9Tx2G", 1826 | "outputId": "422950d0-c2ad-4cf8-89aa-4b61f57f87ce" 1827 | }, 1828 | "execution_count": 42, 1829 | "outputs": [ 1830 | { 1831 | "output_type": "stream", 1832 | "name": "stdout", 1833 | "text": [ 1834 | "arr: [b'1' b'2' b'3']\n", 1835 | "Data Type of array: |S1\n", 1836 | "arr: [1 2 3 4]\n", 1837 | "Data Type of array: int32\n" 1838 | ] 1839 | } 1840 | ] 1841 | }, 1842 | { 1843 | "cell_type": "markdown", 1844 | "source": [ 1845 | "#### **If a Value cannot be converted**\n", 1846 | "NumPy will raise a ValueError." 1847 | ], 1848 | "metadata": { 1849 | "id": "RV4-AV4_T_4X" 1850 | } 1851 | }, 1852 | { 1853 | "cell_type": "code", 1854 | "source": [ 1855 | "arr = np.array(['a', '1', '2', '3'], dtype='i')" 1856 | ], 1857 | "metadata": { 1858 | "colab": { 1859 | "base_uri": "https://localhost:8080/", 1860 | "height": 165 1861 | }, 1862 | "id": "0L97TCEUUJ3f", 1863 | "outputId": "9f498ff7-9b1c-4910-b702-7e573cc227ff" 1864 | }, 1865 | "execution_count": 43, 1866 | "outputs": [ 1867 | { 1868 | "output_type": "error", 1869 | "ename": "ValueError", 1870 | "evalue": "ignored", 1871 | "traceback": [ 1872 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 1873 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", 1874 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0marr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'a'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'1'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'2'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'3'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'i'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 1875 | "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: 'a'" 1876 | ] 1877 | } 1878 | ] 1879 | }, 1880 | { 1881 | "cell_type": "markdown", 1882 | "source": [ 1883 | "#### **Converting datatype of existing arrays**\n", 1884 | "\n", 1885 | "The astype() function creates a copy of the array, and allows you to specify the data type as a parameter." 1886 | ], 1887 | "metadata": { 1888 | "id": "9DCAt-6dUOdG" 1889 | } 1890 | }, 1891 | { 1892 | "cell_type": "code", 1893 | "source": [ 1894 | "arr = np.array([1.1, 2.1, 3.1])\n", 1895 | "newarr = arr.astype('i')\n", 1896 | "print(f\"arr: {newarr}\")\n", 1897 | "print(f\"Data Type of array: {newarr.dtype}\")" 1898 | ], 1899 | "metadata": { 1900 | "colab": { 1901 | "base_uri": "https://localhost:8080/" 1902 | }, 1903 | "id": "Ivc7ayFEUZzO", 1904 | "outputId": "e1ec5f74-6a40-4f20-a347-5e138f93485a" 1905 | }, 1906 | "execution_count": 44, 1907 | "outputs": [ 1908 | { 1909 | "output_type": "stream", 1910 | "name": "stdout", 1911 | "text": [ 1912 | "arr: [1 2 3]\n", 1913 | "Data Type of array: int32\n" 1914 | ] 1915 | } 1916 | ] 1917 | }, 1918 | { 1919 | "cell_type": "markdown", 1920 | "source": [ 1921 | "### **NumPy Sorting Arrays**\n", 1922 | "Orders elements according to a sequence. Implemented using the `sort()` function. String arrays are sorted alphabetically, numeric arrays are sorted in an ascending order, boolean are also sorted in an ascending order taking into consideration False is 0 and True is 1 and multidimensional arrays are sorted within it's dimensions." 1923 | ], 1924 | "metadata": { 1925 | "id": "CgU3icqxRD5f" 1926 | } 1927 | }, 1928 | { 1929 | "cell_type": "code", 1930 | "source": [ 1931 | "arr = np.array([3, 2, 0, 1])\n", 1932 | "print(f\"1-D integer array: {np.sort(arr)}\")\n", 1933 | "\n", 1934 | "arr = np.array(['banana', 'cherry', 'apple'])\n", 1935 | "print(f\"1-D strings array: {np.sort(arr)}\")\n", 1936 | "\n", 1937 | "arr = np.array([True, False, True])\n", 1938 | "print(f\"1-D boolean array: {np.sort(arr)}\")\n", 1939 | "\n", 1940 | "arr = np.array([[3, 2, 4], [5, 0, 1]])\n", 1941 | "print(f\"2-D integer array: {np.sort(arr)}\")" 1942 | ], 1943 | "metadata": { 1944 | "colab": { 1945 | "base_uri": "https://localhost:8080/" 1946 | }, 1947 | "id": "Mp7ToQrERCWn", 1948 | "outputId": "42939094-b1af-4b18-d352-191caba1d185" 1949 | }, 1950 | "execution_count": 45, 1951 | "outputs": [ 1952 | { 1953 | "output_type": "stream", 1954 | "name": "stdout", 1955 | "text": [ 1956 | "1-D integer array: [0 1 2 3]\n", 1957 | "1-D strings array: ['apple' 'banana' 'cherry']\n", 1958 | "1-D boolean array: [False True True]\n", 1959 | "2-D integer array: [[2 3 4]\n", 1960 | " [0 1 5]]\n" 1961 | ] 1962 | } 1963 | ] 1964 | } 1965 | ] 1966 | } -------------------------------------------------------------------------------- /Programs- Coder/Python/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print Hello World ? 5 | 6 | ## Solution 7 | > Print("Hello World") 8 | 9 | **NOTE: Please Drop all file with ' Python ' & ' Artificial Intelligence ' Tag** 10 | -------------------------------------------------------------------------------- /Programs- Coder/Python/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Python -------------------------------------------------------------------------------- /Programs- Coder/README.md: -------------------------------------------------------------------------------- 1 | # Program Format 2 | 3 | ## Question 4 | > Question 5 | 6 | ## Solution 7 | > Solution 8 | 9 | 10 | **NOTE: Please Put Files According To Their Tags** 11 | -------------------------------------------------------------------------------- /Programs- Coder/Ruby/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Ruby/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Ruby/caesar_cypher.rb: -------------------------------------------------------------------------------- 1 | class CaesarCipher 2 | def cipher(message, shift, result = '') 3 | message.each_char do |char| 4 | base = char.ord < 91 ? 65 : 97 5 | if char.ord.between?(65, 90) ||char.ord.between?(97, 112) 6 | rotation = (((char.ord - base) + shift) % 26) + base 7 | result += rotation.chr 8 | else 9 | result += char 10 | end 11 | end 12 | result 13 | end 14 | end 15 | 16 | cc = CaesarCipher.new 17 | # This would output: "Bmfy f xywnsl!" 18 | cc.cipher(("What a string!", 5) 19 | -------------------------------------------------------------------------------- /Programs- Coder/Rust/DSA/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Rust/Graph/README.md: -------------------------------------------------------------------------------- 1 | # Program Eg: 2 | 3 | ## Question 4 | > WAP To Print "Hello World" ? 5 | 6 | ## Solution 7 | > #include iostream 8 | > 9 | > using namespace std; 10 | > 11 | > int main() 12 | > 13 | > { 14 | > 15 | > cout<<"Hello world"; 16 | > 17 | > return 0; 18 | > 19 | > } 20 | 21 | **NOTE: Please Drop all file with respected Tag** 22 | **NOTE: Graph problem in graph folder and DSA in DSA folder** -------------------------------------------------------------------------------- /Programs- Coder/Rust/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Rust -------------------------------------------------------------------------------- /Programs- Coder/Scala/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Scala -------------------------------------------------------------------------------- /Programs- Coder/Swift/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Swift -------------------------------------------------------------------------------- /Programs- Coder/TypeScript/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to TypeScript -------------------------------------------------------------------------------- /Programs- Coder/Zig/disclaimer.txt: -------------------------------------------------------------------------------- 1 | Files related to Zig -------------------------------------------------------------------------------- /Programs/C++/Find_the_longest_path_in_a_matrix_with_given_constraints.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to find the longest path in a matrix 2 | 3 | #include 4 | #define n 3 5 | using namespace std; 6 | 7 | 8 | int findLongestFromACell(int i, int j, int mat[n][n], 9 | int dp[n][n]) 10 | { 11 | if (i < 0 || i >= n || j < 0 || j >= n) 12 | return 0; 13 | 14 | 15 | if (dp[i][j] != -1) 16 | return dp[i][j]; 17 | 18 | int x = INT_MIN, y = INT_MIN, z = INT_MIN, w = INT_MIN; 19 | 20 | if (j < n - 1 && ((mat[i][j] + 1) == mat[i][j + 1])) 21 | x = 1 + findLongestFromACell(i, j + 1, mat, dp); 22 | 23 | if (j > 0 && (mat[i][j] + 1 == mat[i][j - 1])) 24 | y = 1 + findLongestFromACell(i, j - 1, mat, dp); 25 | 26 | if (i > 0 && (mat[i][j] + 1 == mat[i - 1][j])) 27 | z = 1 + findLongestFromACell(i - 1, j, mat, dp); 28 | 29 | if (i < n - 1 && (mat[i][j] + 1 == mat[i + 1][j])) 30 | w = 1 + findLongestFromACell(i + 1, j, mat, dp); 31 | 32 | return dp[i][j] = max({x, y, z, w, 1}); 33 | } 34 | 35 | 36 | int finLongestOverAll(int mat[n][n]) 37 | { 38 | int result = 1; // Initialize result 39 | 40 | 41 | int dp[n][n]; 42 | memset(dp, -1, sizeof dp); 43 | 44 | for (int i = 0; i < n; i++) { 45 | for (int j = 0; j < n; j++) { 46 | if (dp[i][j] == -1) 47 | findLongestFromACell(i, j, mat, dp); 48 | 49 | // Update result if needed 50 | result = max(result, dp[i][j]); 51 | } 52 | } 53 | 54 | return result; 55 | } 56 | 57 | 58 | int main() 59 | { 60 | int mat[n][n] 61 | = { { 1, 2, 9 }, { 5, 3, 8 }, { 4, 6, 7 } }; 62 | cout << "Length of the longest path is " 63 | << finLongestOverAll(mat); 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /Programs/C++/TowerOfHanoi.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Rules of Tower of Hanoi: 3 | // 1. Only one disc can be moved at a time. 4 | // 2. Only the top disc on any peg can be moved to any other peg. 5 | // 3. A larger disc can’t be placed on a smaller peg. 6 | #include 7 | using namespace std; 8 | 9 | int binarySearch(int arr[], int find, int first, int end){ //this method is commom for all Binary Search examples. 10 | if(first>end){ //if first element is greater then last(end) element then it will return -1.(base condition) 11 | return -1; 12 | } 13 | int middle=(first+end)/2;{ //find middle of the binarySearch so we can easily Travers from its left and right side 14 | if(arr[middle]==find){ //if find(target) element is equal to middle then it will return that value of middle 15 | return middle; 16 | }else if(arr[middle]>find){ 17 | return binarySearch(arr,find,first,middle-1); 18 | } 19 | else{ 20 | return binarySearch(arr,find,middle+1,end); //if middle is smaller then target 21 | } 22 | } 23 | } 24 | void towerOfHanoi(int start,int finish,char source,char aux,char destination){ //start -> (first disc) and finish -> (last disc), Source(peg1) where the all discs are present initially, aux(peg2) middle one and destination(peg3) where all the discs to be moved here. 25 | if(start>finish){ //base condition 26 | return;//return the function 27 | } 28 | //recursion(n-1) 29 | towerOfHanoi(start,finish-1,source,destination,aux); 30 | cout<<"move disc"<< finish <<" from "< 2 | using namespace std; 3 | struct node { 4 | int u; 5 | int v; 6 | int wt; 7 | node(int first, int second, int weight) { 8 | u = first; 9 | v = second; 10 | wt = weight; 11 | } 12 | }; 13 | 14 | int main(){ 15 | int N=6,m=7; 16 | vector edges; 17 | edges.push_back(node(0,1,5)); 18 | edges.push_back(node(1,2,-2)); 19 | edges.push_back(node(1,5,-3)); 20 | edges.push_back(node(2,4,3)); 21 | edges.push_back(node(3,2,6)); 22 | edges.push_back(node(3,4,-2)); 23 | edges.push_back(node(5,3,1)); 24 | int src=0; 25 | int inf = 10000000; 26 | vector dist(N, inf); 27 | dist[src] = 0; 28 | for(int i = 1;i<=N-1;i++) { 29 | for(auto it: edges) { 30 | if(dist[it.u] + it.wt < dist[it.v]) { 31 | dist[it.v] = dist[it.u] + it.wt; 32 | } 33 | } 34 | } 35 | 36 | int fl = 0; 37 | for(auto it: edges) { 38 | if(dist[it.u] + it.wt < dist[it.v]) { 39 | cout << -1; 40 | fl = 1; 41 | break; 42 | } 43 | } 44 | 45 | if(!fl) { 46 | for(int i = 0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a[]={4,5,3,2,3,5,6,6,5,4,3,5,2,2,1,3,4,5,6,7}; 8 | int n=sizeof(a)/sizeof(a[0]); 9 | sort(a,a+n); 10 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | const int MAX = 1e6-1; 6 | 7 | int parent[MAX]; 8 | 9 | int find(int a) 10 | { 11 | 12 | while(parent[a]!=a){ 13 | 14 | parent[a] = parent[parent[a]]; 15 | 16 | a = parent[a]; 17 | 18 | } 19 | 20 | return a; 21 | 22 | } 23 | 24 | void union_(int a,int b) 25 | { 26 | 27 | int d = find(a); 28 | 29 | int e = find(b); 30 | 31 | parent[d] = parent[e]; 32 | } 33 | 34 | int main(){ 35 | 36 | int vertices; 37 | 38 | cin>>vertices; 39 | 40 | int edges; 41 | 42 | cin>>edges; 43 | 44 | vector>>adj; 45 | 46 | for(int i=0;i>weight>>src>>destination; 53 | 54 | adj.push_back({weight,{src,destination}}); 55 | 56 | } 57 | 58 | sort(adj.begin(),adj.end()); 59 | 60 | for(int i = 0;i>tree_edges; 67 | 68 | int totalweight = 0; 69 | 70 | for(auto x:adj) 71 | { 72 | 73 | int a = x.second.first; 74 | 75 | int b = x.second.second; 76 | 77 | int cost = x.first; 78 | 79 | if(find(a)!=find(b)){ 80 | totalweight+=cost; 81 | 82 | union_(a,b); 83 | 84 | tree_edges.push_back({a,b}); 85 | 86 | } 87 | 88 | } 89 | 90 | cout<<"Edges are : "<Note : Add Android project in the android folder only. Same fro web projects 2 | >Note : You can make sub folders in these folders 3 | >Note : Also provide screen shots of project as a proof inside the folder 4 | # Good Day -------------------------------------------------------------------------------- /Project/README.md: -------------------------------------------------------------------------------- 1 | >Note : Add Android project in the android folder only. Same fro web projects 2 | >Note : You can make sub folders in these folders 3 | >Note : Also provide screen shots of project as a proof inside the folder 4 | # Good Day -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/Screenshots/1.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/Maze Game/Screenshots/1.JPG -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/Screenshots/2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/Maze Game/Screenshots/2.JPG -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/Screenshots/3.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/Maze Game/Screenshots/3.JPG -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/Screenshots/4.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/Maze Game/Screenshots/4.JPG -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Title 10 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Project/Web project ADD here/Maze Game/index.js: -------------------------------------------------------------------------------- 1 | const { Engine, Render, Runner, World, Bodies, Body, Events } = Matter 2 | 3 | const WIDTH = window.innerWidth - 3.5 4 | const HEIGHT = window.innerHeight - 3.5 5 | const M = 3, N = 3 6 | const UNIT_LENGTH_X = WIDTH / M 7 | const UNIT_LENGTH_Y = HEIGHT / N 8 | 9 | const engine = Engine.create() 10 | engine.world.gravity.y = 0 11 | const { world } = engine 12 | const render = Render.create({ 13 | element: document.body, 14 | engine: engine, 15 | options: { 16 | wireframes: false, 17 | width: WIDTH, 18 | height: HEIGHT 19 | } 20 | }) 21 | Render.run(render) 22 | Runner.run(Runner.create(), engine) 23 | 24 | // walls 25 | const walls = [ 26 | Bodies.rectangle(WIDTH/2, 0, WIDTH, 2, { 27 | isStatic: true 28 | }), 29 | Bodies.rectangle(WIDTH/2, HEIGHT, WIDTH, 2, { 30 | isStatic: true 31 | }), 32 | Bodies.rectangle(0, HEIGHT/2, 2, HEIGHT, { 33 | isStatic: true 34 | }), 35 | Bodies.rectangle(WIDTH, HEIGHT/2, 2, HEIGHT, { 36 | isStatic: true 37 | }) 38 | ] 39 | World.add(world, walls) 40 | 41 | 42 | const grid = Array(M).fill(null).map(() => Array(N).fill(false)) 43 | // console.log(grid) 44 | 45 | const verticals = Array(M).fill(null).map(() => Array(N-1).fill(false)) 46 | // console.log(verticals) 47 | 48 | const horizontals = Array(N-1).fill(null).map(() => Array(M).fill(false)) 49 | // console.log(horizontals) 50 | 51 | const shuffle = (arr) => { 52 | let counter = arr.length 53 | 54 | while (counter > 0) { 55 | const i = Math.floor(Math.random()*counter) 56 | 57 | counter-- 58 | 59 | const temp = arr[counter] 60 | arr[counter] = arr[i] 61 | arr[i] = temp 62 | } 63 | 64 | return arr 65 | } 66 | 67 | const recurse = (row, column) => { 68 | if (grid[row][column]) 69 | return 70 | 71 | grid[row][column] = true // is visited 72 | 73 | const neighbours = shuffle([ 74 | [row-1, column, 'up'], 75 | [row, column+1, 'right'], 76 | [row+1, column, 'down'], 77 | [row, column-1, 'left'] 78 | ]) 79 | 80 | neighbours.forEach(neighbour => { 81 | const [nextRow, nextColumn, direction] = neighbour 82 | 83 | if (nextRow<0 || nextRow>=M || nextColumn<0 || nextColumn>=N) 84 | return // same as continue clause 85 | 86 | if (grid[nextRow][nextColumn]) // is visited 87 | return 88 | 89 | if (direction === 'left') 90 | verticals[row][column-1] = true 91 | else if (direction === 'right') 92 | verticals[row][column] = true 93 | else if (direction === 'up') 94 | horizontals[row-1][column] = true 95 | else // down 96 | horizontals[row][column] = true 97 | 98 | recurse(nextRow, nextColumn) 99 | }) 100 | 101 | } 102 | 103 | const startRow = Math.floor(Math.random()*M) 104 | const startColumn = Math.floor(Math.random()*N) 105 | recurse(startRow, startColumn) 106 | 107 | horizontals.forEach((row, rowIndex) => { 108 | row.forEach((open, columnIndex) => { 109 | if (open) 110 | return 111 | 112 | const wall = Bodies.rectangle( 113 | columnIndex*UNIT_LENGTH_X + UNIT_LENGTH_X/2, 114 | rowIndex*UNIT_LENGTH_Y + UNIT_LENGTH_Y, 115 | UNIT_LENGTH_X, 116 | 5, 117 | { 118 | isStatic: true, 119 | label: 'wall', 120 | render: { 121 | fillStyle: 'red' 122 | } 123 | } 124 | ) 125 | 126 | World.add(world, wall) 127 | }) 128 | }) 129 | 130 | verticals.forEach((row, rowIndex) => { 131 | row.forEach((open, columnIndex) => { 132 | if (open) 133 | return 134 | 135 | const wall = Bodies.rectangle( 136 | columnIndex*UNIT_LENGTH_X + UNIT_LENGTH_X, 137 | rowIndex*UNIT_LENGTH_Y + UNIT_LENGTH_Y/2, 138 | 5, 139 | UNIT_LENGTH_Y, 140 | { 141 | isStatic: true, 142 | label: 'wall', 143 | render: { 144 | fillStyle: 'red' 145 | } 146 | } 147 | ) 148 | 149 | World.add(world, wall) 150 | }) 151 | }) 152 | 153 | // object to be taken to the goal 154 | const object = Bodies.circle( 155 | UNIT_LENGTH_X/2, 156 | UNIT_LENGTH_Y/2, 157 | Math.min(UNIT_LENGTH_X, UNIT_LENGTH_Y)/4, // ball radius 158 | { 159 | label: 'object', 160 | render: { 161 | fillStyle: 'blue' 162 | } 163 | } 164 | ) 165 | World.add(world, object) 166 | 167 | // goal 168 | const goal = Bodies.rectangle( 169 | WIDTH - UNIT_LENGTH_X/2, 170 | HEIGHT - UNIT_LENGTH_Y/2, 171 | UNIT_LENGTH_X/2, 172 | UNIT_LENGTH_Y/2, 173 | { 174 | isStatic: true, 175 | label: 'goal', 176 | render: { 177 | fillStyle: 'green' 178 | } 179 | } 180 | ) 181 | World.add(world, goal) 182 | 183 | // detecting keypresses for movement 184 | document.addEventListener('keydown', (event) => { 185 | const {x, y} = object.velocity 186 | if (event.key === 'w' || event.key === 'ArrowUp'){ 187 | Body.setVelocity(object, {x: x, y:y-5}) 188 | } 189 | else if (event.key === 'd' || event.key === 'ArrowRight'){ 190 | Body.setVelocity(object, {x: x+5, y: y}) 191 | } 192 | else if (event.key === 's' || event.key === 'ArrowDown'){ 193 | Body.setVelocity(object, {x: x, y: y+5}) 194 | 195 | } 196 | else if (event.key === 'a' || event.key === 'ArrowLeft'){ 197 | Body.setVelocity(object, {x: x-5, y: y}) 198 | } 199 | }) 200 | // document.addEventListener('keyup', event =>{ 201 | // const {x, y} = object.velocity 202 | // if (event.key === 'w' || event.key === 'ArrowUp'){ 203 | // Body.setVelocity(object, {x: x, y:0}) 204 | // } 205 | // else if (event.key === 'd' || event.key === 'ArrowRight'){ 206 | // Body.setVelocity(object, {x: 0, y: y}) 207 | // } 208 | // else if (event.key === 's' || event.key === 'ArrowDown'){ 209 | // Body.setVelocity(object, {x: x, y:0}) 210 | 211 | // } 212 | // else if (event.key === 'a' || event.key === 'ArrowLeft'){ 213 | // Body.setVelocity(object, {x: 0, y: y}) 214 | // } 215 | // }) 216 | 217 | // win condition (collision of object with goal) 218 | Events.on(engine, 'collisionStart', (event) => { 219 | event.pairs.forEach(collision => { 220 | const labels = ['object', 'goal'] 221 | 222 | if (labels.includes(collision.bodyA.label) && labels.includes(collision.bodyA.label)) { 223 | console.log('Won!!') 224 | 225 | world.gravity.y = 1 226 | 227 | world.bodies.forEach(body => { 228 | if (body.label === 'wall') { 229 | // walls are no longer static 230 | Body.setStatic(body, false) 231 | } 232 | }) 233 | 234 | document.querySelector('.winner').classList.remove('hidden') 235 | } 236 | }) 237 | }) -------------------------------------------------------------------------------- /Project/Web project ADD here/ProjectHotelManagement.py: -------------------------------------------------------------------------------- 1 | import random 2 | import datetime 3 | 4 | # Global List Declaration 5 | name = [] 6 | phno = [] 7 | add = [] 8 | checkin = [] 9 | checkout = [] 10 | room = [] 11 | price = [] 12 | rc = [] 13 | p = [] 14 | roomno = [] 15 | custid = [] 16 | day = [] 17 | 18 | # Global Variable Declaration 19 | 20 | i = 0 21 | 22 | # Home Function 23 | 24 | def Home(): 25 | 26 | print("\t\t\t\t\t\t WELCOME TO THE BAY CLUB\n") 27 | print("\t\t\t 1 Booking\n") 28 | print("\t\t\t 2 Rooms Info\n") 29 | print("\t\t\t 3 Room Service(Menu Card)\n") 30 | print("\t\t\t 4 Payment\n") 31 | print("\t\t\t 5 Record\n") 32 | print("\t\t\t 0 Exit\n") 33 | 34 | ch=int(input("->")) 35 | 36 | if ch == 1: 37 | print(" ") 38 | Booking() 39 | 40 | elif ch == 2: 41 | print(" ") 42 | Rooms_Info() 43 | 44 | elif ch == 3: 45 | print(" ") 46 | restaurant() 47 | 48 | elif ch == 4: 49 | print(" ") 50 | Payment() 51 | 52 | elif ch == 5: 53 | print(" ") 54 | Record() 55 | 56 | else: 57 | exit() 58 | 59 | # Function used in booking 60 | 61 | def date(c): 62 | 63 | if c[2] >= 2020 and c[2] <= 2021: 64 | 65 | if c[1] != 0 and c[1] <= 12: 66 | 67 | if c[1] == 2 and c[0] != 0 and c[0] <= 31: 68 | 69 | if c[2]%4 == 0 and c[0] <= 29: 70 | pass 71 | 72 | elif c[0]<29: 73 | pass 74 | 75 | else: 76 | print("Invalid date\n") 77 | name.pop(i) 78 | phno.pop(i) 79 | add.pop(i) 80 | checkin.pop(i) 81 | checkout.pop(i) 82 | Booking() 83 | 84 | 85 | # if month is odd & less than equal 86 | # to 7th month 87 | elif c[1] <= 7 and c[1]%2 != 0 and c[0] <= 31: 88 | pass 89 | 90 | # if month is even & less than equal to 7th 91 | # month and not 2nd month 92 | elif c[1] <= 7 and c[1]%2 == 0 and c[0] <= 30 and c[1] != 2: 93 | pass 94 | 95 | # if month is even & greater than equal 96 | # to 8th month 97 | elif c[1] >= 8 and c[1]%2 == 0 and c[0] <= 31: 98 | pass 99 | 100 | # if month is odd & greater than equal 101 | # to 8th month 102 | elif c[1]>=8 and c[1]%2!=0 and c[0]<=30: 103 | pass 104 | 105 | else: 106 | print("Invalid date\n") 107 | name.pop(i) 108 | phno.pop(i) 109 | add.pop(i) 110 | checkin.pop(i) 111 | checkout.pop(i) 112 | Booking() 113 | 114 | else: 115 | print("Invalid date\n") 116 | name.pop(i) 117 | phno.pop(i) 118 | add.pop(i) 119 | checkin.pop(i) 120 | checkout.pop(i) 121 | Booking() 122 | 123 | else: 124 | print("Invalid date\n") 125 | name.pop(i) 126 | phno.pop(i) 127 | add.pop(i) 128 | checkin.pop(i) 129 | checkout.pop(i) 130 | Booking() 131 | 132 | 133 | # Booking function 134 | 135 | def Booking(): 136 | 137 | # used global keyword to 138 | # use global variable 'i' 139 | global i 140 | print(" BOOKING ROOMS") 141 | print(" ") 142 | 143 | while 1: 144 | n = str(input("Name: ")) 145 | p1 = str(input("Phone No.: ")) 146 | a = str(input("Address: ")) 147 | 148 | # checks if any field is not empty 149 | if n!="" and p1!="" and a!="": 150 | name.append(n) 151 | add.append(a) 152 | break 153 | 154 | else: 155 | print("\tName, Phone no. & Address cannot be empty..!!") 156 | 157 | cii=str(input("Check-In: ")) 158 | checkin.append(cii) 159 | cii=cii.split('/') 160 | ci=cii 161 | ci[0]=int(ci[0]) 162 | ci[1]=int(ci[1]) 163 | ci[2]=int(ci[2]) 164 | date(ci) 165 | 166 | coo=str(input("Check-Out: ")) 167 | checkout.append(coo) 168 | coo=coo.split('/') 169 | co=coo 170 | co[0]=int(co[0]) 171 | co[1]=int(co[1]) 172 | co[2]=int(co[2]) 173 | 174 | # checks if check-out date falls after 175 | # check-in date 176 | if co[1]=ci[2] and co[0]<=ci[0]: 185 | 186 | print("\n\tErr..!!\n\tCheck-Out date must fall after Check-In\n") 187 | name.pop(i) 188 | add.pop(i) 189 | checkin.pop(i) 190 | checkout.pop(i) 191 | Booking() 192 | else: 193 | pass 194 | 195 | date(co) 196 | d1 = datetime.datetime(ci[2],ci[1],ci[0]) 197 | d2 = datetime.datetime(co[2],co[1],co[0]) 198 | d = (d2-d1).days 199 | day.append(d) 200 | 201 | print("----SELECT ROOM TYPE----") 202 | print(" 1. Standard Non-AC") 203 | print(" 2. Standard AC") 204 | print(" 3. 3-Bed Non-AC") 205 | print(" 4. 3-Bed AC") 206 | print(("\t\tPress 0 for Room Prices")) 207 | 208 | ch=int(input("->")) 209 | 210 | # if-conditions to display alloted room 211 | # type and it's price 212 | if ch==0: 213 | print(" 1. Standard Non-AC - Rs. 3500") 214 | print(" 2. Standard AC - Rs. 4000") 215 | print(" 3. 3-Bed Non-AC - Rs. 4500") 216 | print(" 4. 3-Bed AC - Rs. 5000") 217 | ch=int(input("->")) 218 | if ch==1: 219 | room.append('Standard Non-AC') 220 | print("Room Type- Standard Non-AC") 221 | price.append(3500) 222 | print("Price- 3500") 223 | elif ch==2: 224 | room.append('Standard AC') 225 | print("Room Type- Standard AC") 226 | price.append(4000) 227 | print("Price- 4000") 228 | elif ch==3: 229 | room.append('3-Bed Non-AC') 230 | print("Room Type- 3-Bed Non-AC") 231 | price.append(4500) 232 | print("Price- 4500") 233 | elif ch==4: 234 | room.append('3-Bed AC') 235 | print("Room Type- 3-Bed AC") 236 | price.append(5000) 237 | print("Price- 5000") 238 | else: 239 | print(" Wrong choice..!!") 240 | 241 | 242 | # randomly generating room no. and customer 243 | # id for customer 244 | rn = random.randrange(40)+300 245 | cid = random.randrange(40)+10 246 | 247 | 248 | # checks if alloted room no. & customer 249 | # id already not alloted 250 | while rn in roomno or cid in custid: 251 | rn = random.randrange(60)+300 252 | cid = random.randrange(60)+10 253 | 254 | rc.append(0) 255 | p.append(0) 256 | 257 | if p1 not in phno: 258 | phno.append(p1) 259 | elif p1 in phno: 260 | for n in range(0,i): 261 | if p1== phno[n]: 262 | if p[n]==1: 263 | phno.append(p1) 264 | elif p1 in phno: 265 | for n in range(0,i): 266 | if p1== phno[n]: 267 | if p[n]==0: 268 | print("\tPhone no. already exists and payment yet not done..!!") 269 | name.pop(i) 270 | add.pop(i) 271 | checkin.pop(i) 272 | checkout.pop(i) 273 | Booking() 274 | print("") 275 | print("\t\t\t***ROOM BOOKED SUCCESSFULLY***\n") 276 | print("Room No. - ",rn) 277 | print("Customer Id - ",cid) 278 | roomno.append(rn) 279 | custid.append(cid) 280 | i=i+1 281 | n=int(input("0-BACK\n ->")) 282 | if n==0: 283 | Home() 284 | else: 285 | exit() 286 | 287 | # ROOMS INFO 288 | def Rooms_Info(): 289 | print(" ------ HOTEL ROOMS INFO ------") 290 | print("") 291 | print("STANDARD NON-AC") 292 | print("---------------------------------------------------------------") 293 | print("Room amenities include: 1 Double Bed, Television, Telephone,") 294 | print("Double-Door Cupboard, 1 Coffee table with 2 sofa, Balcony and") 295 | print("an attached washroom with hot/cold water.\n") 296 | print("STANDARD NON-AC") 297 | print("---------------------------------------------------------------") 298 | print("Room amenities include: 1 Double Bed, Television, Telephone,") 299 | print("Double-Door Cupboard, 1 Coffee table with 2 sofa, Balcony and") 300 | print("an attached washroom with hot/cold water + Window/Split AC.\n") 301 | print("3-Bed NON-AC") 302 | print("---------------------------------------------------------------") 303 | print("Room amenities include: 1 Double Bed + 1 Single Bed, Television,") 304 | print("Telephone, a Triple-Door Cupboard, 1 Coffee table with 2 sofa, 1") 305 | print("Side table, Balcony with an Accent table with 2 Chair and an") 306 | print("attached washroom with hot/cold water.\n") 307 | print("3-Bed AC") 308 | print("---------------------------------------------------------------") 309 | print("Room amenities include: 1 Double Bed + 1 Single Bed, Television,") 310 | print("Telephone, a Triple-Door Cupboard, 1 Coffee table with 2 sofa, ") 311 | print("1 Side table, Balcony with an Accent table with 2 Chair and an") 312 | print("attached washroom with hot/cold water + Window/Split AC.\n\n") 313 | print() 314 | n=int(input("0-BACK\n ->")) 315 | if n==0: 316 | Home() 317 | else: 318 | exit() 319 | 320 | # RESTAURANT FUNCTION 321 | def restaurant(): 322 | ph=int(input("Customer Id: ")) 323 | global i 324 | f=0 325 | r=0 326 | for n in range(0,i): 327 | if custid[n]==ph and p[n]==0: 328 | f=1 329 | print("-------------------------------------------------------------------------") 330 | print(" The BayClub") 331 | print("-------------------------------------------------------------------------") 332 | print(" Menu Card") 333 | print("-------------------------------------------------------------------------") 334 | print("\n BEVARAGES 26 Dal Fry................ 140.00") 335 | print("---------------------------------- 27 Dal Makhani............ 150.00") 336 | print(" 1 Regular Tea............. 20.00 28 Dal Tadka.............. 150.00") 337 | print(" 2 Masala Tea.............. 25.00") 338 | print(" 3 Coffee.................. 25.00 ROTI") 339 | print(" 4 Cold Drink.............. 25.00 ----------------------------------") 340 | print(" 5 Bread Butter............ 30.00 29 Plain Roti.............. 15.00") 341 | print(" 6 Bread Jam............... 30.00 30 Butter Roti............. 15.00") 342 | print(" 7 Veg. Sandwich........... 50.00 31 Tandoori Roti........... 20.00") 343 | print(" 8 Veg. Toast Sandwich..... 50.00 32 Butter Naan............. 20.00") 344 | print(" 9 Cheese Toast Sandwich... 70.00") 345 | print(" 10 Grilled Sandwich........ 70.00 RICE") 346 | print(" ----------------------------------") 347 | print(" SOUPS 33 Plain Rice.............. 90.00") 348 | print("---------------------------------- 34 Jeera Rice.............. 90.00") 349 | print(" 11 Tomato Soup............ 110.00 35 Veg Pulao.............. 110.00") 350 | print(" 12 Hot & Sour............. 110.00 36 Peas Pulao............. 110.00") 351 | print(" 13 Veg. Noodle Soup....... 110.00") 352 | print(" 14 Sweet Corn............. 110.00 SOUTH INDIAN") 353 | print(" 15 Veg. Munchow........... 110.00 ----------------------------------") 354 | print(" 37 Plain Dosa............. 100.00") 355 | print(" MAIN COURSE 38 Onion Dosa............. 110.00") 356 | print("---------------------------------- 39 Masala Dosa............ 130.00") 357 | print(" 16 Shahi Paneer........... 110.00 40 Paneer Dosa............ 130.00") 358 | print(" 17 Kadai Paneer........... 110.00 41 Rice Idli.............. 130.00") 359 | print(" 18 Handi Paneer........... 120.00 42 Sambhar Vada........... 140.00") 360 | print(" 19 Palak Paneer........... 120.00") 361 | print(" 20 Chilli Paneer.......... 140.00 ICE CREAM") 362 | print(" 21 Matar Mushroom......... 140.00 ----------------------------------") 363 | print(" 22 Mix Veg................ 140.00 43 Vanilla................. 60.00") 364 | print(" 23 Jeera Aloo............. 140.00 44 Strawberry.............. 60.00") 365 | print(" 24 Malai Kofta............ 140.00 45 Pineapple............... 60.00") 366 | print(" 25 Aloo Matar............. 140.00 46 Butter Scotch........... 60.00") 367 | print("Press 0 -to end ") 368 | ch=1 369 | while(ch!=0): 370 | 371 | ch=int(input(" -> ")) 372 | 373 | # if-elif-conditions to assign item 374 | # prices listed in menu card 375 | if ch==1 or ch==31 or ch==32: 376 | rs=20 377 | r=r+rs 378 | elif ch<=4 and ch>=2: 379 | rs=25 380 | r=r+rs 381 | elif ch<=6 and ch>=5: 382 | rs=30 383 | r=r+rs 384 | elif ch<=8 and ch>=7: 385 | rs=50 386 | r=r+rs 387 | elif ch<=10 and ch>=9: 388 | rs=70 389 | r=r+rs 390 | elif (ch<=17 and ch>=11) or ch==35 or ch==36 or ch==38: 391 | rs=110 392 | r=r+rs 393 | elif ch<=19 and ch>=18: 394 | rs=120 395 | r=r+rs 396 | elif (ch<=26 and ch>=20) or ch==42: 397 | rs=140 398 | r=r+rs 399 | elif ch<=28 and ch>=27: 400 | rs=150 401 | r=r+rs 402 | elif ch<=30 and ch>=29: 403 | rs=15 404 | r=r+rs 405 | elif ch==33 or ch==34: 406 | rs=90 407 | r=r+rs 408 | elif ch==37: 409 | rs=100 410 | r=r+rs 411 | elif ch<=41 and ch>=39: 412 | rs=130 413 | r=r+rs 414 | elif ch<=46 and ch>=43: 415 | rs=60 416 | r=r+rs 417 | elif ch==0: 418 | pass 419 | else: 420 | print("Wrong Choice..!!") 421 | print("Total Bill: ",r) 422 | 423 | # updates restaurant charges and then 424 | # appends in 'rc' list 425 | r=r+rc.pop(n) 426 | rc.append(r) 427 | else: 428 | pass 429 | if f == 0: 430 | print("Invalid Customer Id") 431 | n=int(input("0-BACK\n ->")) 432 | if n==0: 433 | Home() 434 | else: 435 | exit() 436 | 437 | 438 | # PAYMENT FUNCTION 439 | def Payment(): 440 | 441 | ph=str(input("Phone Number: ")) 442 | global i 443 | f=0 444 | 445 | for n in range(0,i): 446 | if ph==phno[n] : 447 | 448 | # checks if payment is 449 | # not already done 450 | if p[n]==0: 451 | f=1 452 | print(" Payment") 453 | print(" --------------------------------") 454 | print(" MODE OF PAYMENT") 455 | 456 | print(" 1- Credit/Debit Card") 457 | print(" 2- Paytm/PhonePe") 458 | print(" 3- Using UPI") 459 | print(" 4- Cash") 460 | x=int(input("-> ")) 461 | print("\n Amount: ",(price[n]*day[n])+rc[n]) 462 | print("\n Pay For BayClub") 463 | print(" (y/n)") 464 | ch=str(input("->")) 465 | 466 | if ch=='y' or ch=='Y': 467 | print("\n\n --------------------------------") 468 | print(" The BayClub") 469 | print(" --------------------------------") 470 | print(" Bill") 471 | print(" --------------------------------") 472 | print(" Name: ",name[n],"\t\n Phone No.: ",phno[n],"\t\n Address: ",add[n],"\t") 473 | print("\n Check-In: ",checkin[n],"\t\n Check-Out: ",checkout[n],"\t") 474 | print("\n Room Type: ",room[n],"\t\n Room Charges: ",price[n]*day[n],"\t") 475 | print(" Restaurant Charges: \t",rc[n]) 476 | print(" --------------------------------") 477 | print("\n Total Amount: ",(price[n]*day[n])+rc[n],"\t") 478 | print(" --------------------------------") 479 | print(" Thank You") 480 | print(" Visit Again :)") 481 | print(" --------------------------------\n") 482 | p.pop(n) 483 | p.insert(n,1) 484 | 485 | # pops room no. and customer id from list and 486 | # later assigns zero at same position 487 | roomno.pop(n) 488 | custid.pop(n) 489 | roomno.insert(n,0) 490 | custid.insert(n,0) 491 | 492 | else: 493 | 494 | for j in range(n+1,i): 495 | if ph==phno[j] : 496 | if p[j]==0: 497 | pass 498 | 499 | else: 500 | f=1 501 | print("\n\tPayment has been Made :)\n\n") 502 | if f==0: 503 | print("Invalid Customer Id") 504 | 505 | n = int(input("0-BACK\n ->")) 506 | if n == 0: 507 | Home() 508 | else: 509 | exit() 510 | 511 | # RECORD FUNCTION 512 | def Record(): 513 | 514 | # checks if any record exists or not 515 | if phno!=[]: 516 | print(" *** HOTEL RECORD ***\n") 517 | print("| Name | Phone No. | Address | Check-In | Check-Out | Room Type | Price |") 518 | print("----------------------------------------------------------------------------------------------------------------------") 519 | 520 | for n in range(0,i): 521 | print("|",name[n],"\t |",phno[n],"\t|",add[n],"\t|",checkin[n],"\t|",checkout[n],"\t|",room[n],"\t|",price[n]) 522 | 523 | print("----------------------------------------------------------------------------------------------------------------------") 524 | 525 | else: 526 | print("No Records Found") 527 | n = int(input("0-BACK\n ->")) 528 | if n == 0: 529 | Home() 530 | 531 | else: 532 | exit() 533 | 534 | # Driver Code 535 | Home() 536 | -------------------------------------------------------------------------------- /Project/Web project ADD here/README.md: -------------------------------------------------------------------------------- 1 | >Note : Add Android project in the android folder only. Same fro web projects 2 | >Note : You can make sub folders in these folders 3 | >Note : Also provide screen shots of project as a proof inside the folder 4 | # Good Day -------------------------------------------------------------------------------- /Project/Web project ADD here/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Express VPN 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 |
23 |
24 |
25 |
26 |

The VPN that just works

27 |
GO further with #1 trusted leadedin VPN
28 | Get Express VPN → 29 |
30 Day Money Back Gurantee
30 |
31 |
32 |
33 | 34 |
35 |
36 |
37 |
38 | 39 |
40 |
41 |

Secures access worldwide

42 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Iste numquam neque, consectetur repellat 43 | animi corporis doloremque recusandae tenetur dolores iure.

44 | Get Express VPN → 45 |
46 |
47 |
48 | 49 |
50 |

One Click to Safer Internet

51 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Iste numquam neque, consectetur repellat 52 | animi corporis doloremque recusandae tenetur dolores iure.

53 | Get Express VPN → 54 |
55 |
56 | 57 |
58 |
59 |
60 |
61 | 62 |
63 |
64 |

Use ExpressVPN on every device

65 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Iste numquam neque, consectetur repellat 66 | animi corporis doloremque recusandae tenetur dolores iure.

67 | Get Express VPN → 68 |
69 |
70 |
71 |
72 | 73 | 74 |
75 |
76 |

Benefits with using our VPN

77 |
78 |
79 |
80 | 81 |
82 |
83 | 84 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque magnam a facere natus, ea eum. 85 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Quibusdam voluptas tenetur laudantium, 86 | aut reprehenderit nostrum. 87 |
88 |
89 |
90 |
91 | 92 |
93 |
94 | 95 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque magnam a facere natus, ea eum. 96 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Quibusdam voluptas tenetur laudantium, 97 | aut reprehenderit nostrum. 98 |
99 |
100 |
101 |
102 | 103 |
104 |
105 | 106 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque magnam a facere natus, ea eum. 107 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Quibusdam voluptas tenetur laudantium, 108 | aut reprehenderit nostrum. 109 |
110 |
111 |
112 |
113 |
114 | 115 | 116 |
117 | 132 | 133 |
134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /Project/Web project ADD here/newImage.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/newImage.jpeg -------------------------------------------------------------------------------- /Project/Web project ADD here/solid_security2-removebg-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Meghwantsingh/Hacktoberfest2023/d603dd910d617a770aacc4c998c9bbe2880dbc13/Project/Web project ADD here/solid_security2-removebg-preview.png -------------------------------------------------------------------------------- /Project/Web project ADD here/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;500&display=swap'); 2 | 3 | * { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | transition: 0.5s ease; 8 | font-family: 'Poppins', sans-serif; 9 | margin: auto; 10 | max-width: 120rem; 11 | font-style: normal; 12 | cursor:default; 13 | } 14 | 15 | body{ 16 | background-color: #f0bda24f; 17 | } 18 | 19 | nav ul{ 20 | display: flex; 21 | justify-content: space-evenly; 22 | align-items: center; 23 | z-index: 111; 24 | margin-top: 1rem; 25 | } 26 | 27 | li{ 28 | list-style: none; 29 | } 30 | 31 | 32 | .logo{ 33 | font-size: 2rem; 34 | font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; 35 | } 36 | 37 | 38 | .VPNcontainer{ 39 | background: #f0bda24f url(newImage.jpeg); 40 | background-size: cover; 41 | min-height: 100vh; 42 | background-attachment: fixed; 43 | position: relative; 44 | background-blend-mode: multiply; 45 | width: 100%; 46 | height: 100%; 47 | vertical-align: middle; 48 | padding-bottom: 15.6rem; 49 | position: relative; 50 | overflow: hidden; 51 | width: 100%; 52 | margin-top: -4rem; 53 | display: flex; 54 | justify-content: center; 55 | align-items: center; 56 | text-align: center; 57 | z-index: -1; 58 | } 59 | 60 | .VPNcontent{ 61 | margin-top: 17%; 62 | } 63 | 64 | .VPNcontent h1{ 65 | font-size: 5rem; 66 | } 67 | 68 | .VPNcontent h5{ 69 | font-size: 1rem; 70 | margin-bottom: 2rem; 71 | 72 | } 73 | 74 | .btn{ 75 | background: #f0bda2; 76 | padding: 15px 20px; 77 | text-decoration: none; 78 | color: black; 79 | font-weight: 1000; 80 | cursor: pointer !important; 81 | } 82 | 83 | .VPNcontent h6{ 84 | margin-top: 2rem; 85 | 86 | } 87 | 88 | .VPNfeatureContainer1{ 89 | height: 100%; 90 | } 91 | 92 | .VPNfeature1{ 93 | display: flex; 94 | justify-content: center; 95 | align-items: center; 96 | background-color: #fff; 97 | width: 80%; 98 | border-radius: 20px; 99 | margin-top: 4rem; 100 | padding: 60px 20px !important; 101 | box-shadow: 102 | 2.8px 2.8px 2.2px rgba(0, 0, 0, 0.02), 103 | 6.7px 6.7px 5.3px rgba(0, 0, 0, 0.028), 104 | 12.5px 12.5px 10px rgba(0, 0, 0, 0.035), 105 | 22.3px 22.3px 17.9px rgba(0, 0, 0, 0.042), 106 | 41.8px 41.8px 33.4px rgba(0, 0, 0, 0.05), 107 | 100px 100px 80px rgba(0, 0, 0, 0.07); 108 | } 109 | 110 | .VPNimage1{ 111 | width: 200px; 112 | } 113 | 114 | .VPNimage1 img{ 115 | width: 100%; 116 | height: 100%; 117 | filter: grayscale(5); 118 | } 119 | 120 | .VPNfeature1{ 121 | padding: 20px; 122 | } 123 | 124 | .VPNfeature1 .VPNcontent1{ 125 | width: 50vh; 126 | } 127 | 128 | .VPNcontent1 p{ 129 | margin-bottom: 2rem; 130 | } 131 | 132 | 133 | .VPNCardsContainer{ 134 | height: 100vh; 135 | padding-top: 7rem; 136 | } 137 | 138 | 139 | 140 | .VPNCards{ 141 | display: flex; 142 | justify-content: center; 143 | align-items: center; 144 | flex-wrap: wrap; 145 | margin: 5rem 1rem; 146 | } 147 | 148 | .VPNCardsContainer h1{ 149 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 150 | text-align: center; 151 | font-size: 3rem; 152 | } 153 | 154 | .VPNimage{ 155 | width: 200px; 156 | height: 200px; 157 | } 158 | 159 | 160 | 161 | .VPNimage img{ 162 | width: 100%; 163 | height: 100%; 164 | } 165 | 166 | .VPNcard{ 167 | width: 400px; 168 | height: 400px; 169 | background-color: #fff; 170 | box-shadow: 171 | 2.8px 2.8px 2.2px rgba(0, 0, 0, 0.02), 172 | 6.7px 6.7px 5.3px rgba(0, 0, 0, 0.028), 173 | 12.5px 12.5px 10px rgba(0, 0, 0, 0.035), 174 | 22.3px 22.3px 17.9px rgba(0, 0, 0, 0.042), 175 | 41.8px 41.8px 33.4px rgba(0, 0, 0, 0.05), 176 | 100px 100px 80px rgba(0, 0, 0, 0.07); 177 | padding: 15px; 178 | border-radius: 15px; 179 | text-align: center; 180 | margin: 1rem; 181 | color: rgb(160, 158, 158); 182 | } 183 | 184 | .VPNcard:hover{ 185 | color: #000; 186 | 187 | } 188 | 189 | .VPNcardContent{ 190 | padding-top: 7px; 191 | } 192 | 193 | 194 | footer { 195 | background: rgb(30 30 30); 196 | text-align: center; 197 | color: #666; 198 | 199 | } 200 | 201 | .footer_btn { 202 | background-color: #555 !important; 203 | color: rgb(175, 174, 174) !important; 204 | } 205 | 206 | .footer_btn:hover { 207 | background-color: rgb(126, 126, 126) !important; 208 | color: #fff !important; 209 | } 210 | 211 | .footer_name h1 { 212 | font-size: 19px; 213 | color: #f0bda2; 214 | font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; 215 | } 216 | 217 | .footer_image { 218 | width: 200px; 219 | height: 200px; 220 | display: none; 221 | } 222 | 223 | .footer_image img { 224 | width: 100%; 225 | height: 100%; 226 | border-radius: 50%; 227 | margin-top: -3rem; 228 | display: none; 229 | } 230 | 231 | .footer_name { 232 | margin-bottom: 1rem; 233 | padding-top: 49px; 234 | } 235 | 236 | .footer_social_cards { 237 | display: flex; 238 | justify-content: space-evenly; 239 | align-items: center; 240 | flex-wrap: wrap; 241 | } 242 | 243 | .social_image { 244 | width: 100px; 245 | height: 100px; 246 | margin-bottom: 1rem; 247 | margin-left: 2rem; 248 | } 249 | 250 | .social_image img { 251 | width: 100%; 252 | height: 100%; 253 | border-radius: 50%; 254 | } 255 | 256 | .avez_small_btn { 257 | background: linear-gradient(90deg, #ffa84c, #fe8f16); 258 | display: inline-block; 259 | padding: 7px 15px; 260 | border-radius: 5px; 261 | font-weight: bold; 262 | color: #000; 263 | } 264 | 265 | .avez_small_btn:hover { 266 | background: linear-gradient(90deg, #ff8400, #fe8f16); 267 | cursor: pointer; 268 | transform: scaleY(1.1); 269 | font-size: bolder; 270 | 271 | 272 | } 273 | 274 | .avez_social_name { 275 | letter-spacing: 1px; 276 | } 277 | 278 | .avez_rights { 279 | padding: 2rem; 280 | } 281 | 282 | .footer_avez_content { 283 | line-height: 2rem; 284 | font-weight: bold; 285 | } 286 | 287 | .address { 288 | padding-bottom: 1rem; 289 | } 290 | 291 | ::-webkit-scrollbar{ 292 | width: 10px; 293 | background-color: #ffede3; 294 | 295 | } 296 | 297 | ::-webkit-scrollbar-thumb{ 298 | background-color: #ffbf9d; 299 | border-radius: 10px; 300 | } 301 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | >Note : Any one can contribute i am busy so contribute I will check later ( those who are doing projects ) 2 |

3 | 4 | 5 | 6 |

7 | 8 |

Hacktoberfest 2023 🎉

9 | 10 |
11 | 12 | 13 | Participate in Hacktoberfest by contributing to any Open Source project on GitHub! 14 | Any kind of Contributions are welcome! 15 | 16 |
17 | 18 | ## What is Hacktoberfest? 19 | A month-long celebration from October 1st - 31st sponsored by [Digital Ocean](https://hacktoberfest.digitalocean.com/) and [GitHub](https://github.blog/2021-10-07-githubs-guide-hacktoberfest-2021/) to get people involved in [Open Source](https://github.com/open-source). Create your very first pull request to any public repository on GitHub and contribute to the open source developer community. 20 | 21 | [https://hacktoberfest.digitalocean.com/](https://hacktoberfest.digitalocean.com/) 22 | > Note : Add Code in Program Folder and Project in Project Folder 23 | 24 | ## How to contribute to this project 25 | Here are 3 quick and painless ways to contribute to this project: 26 | - Find the suitable issue from Issues Section 27 | - Request for work on that issue till don't work 28 | - Fork-Work-Pull and Also star the repo 29 | - Add your name to the `CONTRIBUTORS.md` file 30 | - Put issue number in pull request so that we can get it quickly 31 | - Join our Youtube Channel [MyChannel](https://youtube.com/shorts/o5rAIdtxUYA?feature=share) 32 | - Follows us 33 | 34 | 35 | > Note : Don't Contribute Until Assigned ( Any one can contribute i am busy so contribute I will check later) 36 |
37 | 38 | ## New Stuff 39 | 40 | 41 | 42 |
43 | 44 | ## Getting started 45 | 46 | * Fork this repository (Click the Fork button in the top right of this page, click your Profile Image) 47 | * Clone your fork down to your local machine 48 | 49 | ```markdown 50 | git clone [https://github.com/your-username/hacktoberfest.git](https://github.com/MadJokkerr/Hacktoberfest-2022.git) 51 | ``` 52 | 53 | * Create a branch 54 | 55 | ```markdown 56 | git checkout -b branch-name 57 | ``` 58 | 59 | * Make your changes (choose from any task below) 60 | * Commit and push 61 | 62 | ```markdown 63 | git add . 64 | git commit -m 'Commit message' 65 | git push origin branch-name 66 | ``` 67 | 68 | * Create a new pull request from your forked repository (Click the `New Pull Request` button located at the top of your repo) 69 | * Wait for your PR review and merge approval! 70 | * __Star this repository__ if you had fun! 71 | 72 | ## Github Contribution Rules 73 | - Have 4 pull/merge requests accepted between October 1 and October 31 to complete Hacktoberfest 74 | - The first 40,000 participants (maintainers and contributors) who complete Hacktoberfest can elect to receive one of two prizes: a tree planted in their name, or the Hacktoberfest 2022 t-shirt. 75 | - Pull requests can be submitted to any opted-in repository on GitHub or GitLab. 76 | - The pull request must contain commits you made yourself. 77 | - If a maintainer reports your pull request as spam, it will not be counted toward your participation in Hacktoberfest. 78 | - If a maintainer reports behavior that’s not in line with the project’s code of conduct, you will be ineligible to participate. 79 | 80 | --- 81 | 82 | ## 83 | 84 | 85 | ## Watch below both the video if you are a beginner 86 |

87 | 88 | 89 | 90 |

91 |

92 | 93 | 94 | 95 |

96 | 97 | - In the video you will learn to research which challenge suits your knowledge. 98 | - Good event and have fun :) 99 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 |

Hi 👋, I'm MEGHWANT SINGH

2 |

A passionate in cloud computing

3 | 4 | coding 5 | 6 |

simplified_learner

7 | - 🔭 I’m currently working on ... 8 |
9 | - 🌱 I’m currently learning web development , Android development and machine learning. 10 |
11 | - 👯 I’m looking to collaborate on ... 12 |
13 | - 🤔 I’m looking for help with ... 14 |
15 | - 💬 Ask me about ... 16 |
17 | - 😄 Pronouns: ... 18 |
19 | - ⚡ Fun fact: ... 20 |
21 | 22 |

Connect with me:

23 |

24 | simplified_learner 25 | simplified_learner 26 |

27 | 28 |

Languages and Tools:

29 |

css3 html5 java python" 30 | 31 |

simplified_learner

32 | 33 |

 simplified_learner

34 | 35 |

simplified_learner

36 | -------------------------------------------------------------------------------- /RecursionPython/Even.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Even 4 | { 5 | static void calEven(int n)//static method so no need to make object 6 | { 7 | 8 | if(n>2) 9 | calEven(n-2);//recursive call till n>2. 10 | 11 | System.out.print(n+" ");//printing after the condition n>2 becomes false. 12 | 13 | } 14 | 15 | public static void main(String args[]) 16 | { 17 | 18 | Scanner sc = new Scanner(System.in);//for the user input 19 | 20 | System.out.println("Enter any number : "); 21 | 22 | int num = sc.nextInt();//input of number from the user 23 | 24 | //calEven is a static method so no need to make the object. 25 | 26 | System.out.println("The Even Numbers : "+calEven(num*2));//function call from the user 27 | 28 | sc.close();//closing the scanner object to prevent leaking 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /RecursionPython/Fabonacci.py: -------------------------------------------------------------------------------- 1 | def fib(n) : 2 | if n==0: 3 | return 0 4 | elif n ==1 : 5 | return 1 6 | else : 7 | return fib(n-1) +fib(n-2) 8 | num = int(input("Enter a number: ")) 9 | print("The {num} element of fibonacci series is: ".format(num), fib(7)) -------------------------------------------------------------------------------- /RecursionPython/MergeSort.py: -------------------------------------------------------------------------------- 1 | def merge_sort(list1): 2 | length = len(list1) 3 | if length > 1: 4 | middle = length // 2 5 | left_arr = list1[:middle] 6 | right_arr = list1[middle:] 7 | 8 | merge_sort(left_arr) 9 | merge_sort(right_arr) 10 | 11 | p = 0 12 | q = 0 13 | r = 0 14 | 15 | left_length = len(left_arr) 16 | right_length = len(right_arr) 17 | while p < left_length and q < right_length: 18 | if left_arr[p] < right_arr[q]: 19 | list1[r] = left_arr[p] 20 | p += 1 21 | else: 22 | list1[r] = right_arr[q] 23 | q += 1 24 | 25 | r += 1 26 | 27 | while p < left_length: 28 | list1[r] = left_arr[p] 29 | p += 1 30 | r += 1 31 | 32 | while q < right_length: 33 | list1[r] = right_arr[q] 34 | q += 1 35 | r += 1 36 | 37 | list1 = [24, 11, 50, 27, 16, 36, 60, 91] 38 | print("Input Array: ") 39 | print(list1) 40 | merge_sort(list1) 41 | print("Sorted Array :") 42 | print(list1) -------------------------------------------------------------------------------- /RecursionPython/PascalTriangle.py: -------------------------------------------------------------------------------- 1 | def pascal(n): 2 | if n == 1: 3 | return [1] 4 | else: 5 | line = [1] 6 | previous_line = pascal(n-1) 7 | for i in range(len(previous_line)-1): 8 | line.append(previous_line[i] + previous_line[i+1]) 9 | line += [1] 10 | return line 11 | num = int(input("Enter a number: ")) 12 | print(pascal(num)) -------------------------------------------------------------------------------- /RecursionPython/SumOfDigits.py: -------------------------------------------------------------------------------- 1 | def sumDigits(no): 2 | if no == 0: 3 | return 0 4 | else : 5 | return int(no % 10) + sumDigits(int(no / 10)) 6 | nums = int(input("Enter a number: ")) 7 | print("The sum is:", sumDigits(nums)) -------------------------------------------------------------------------------- /RecursionPython/factorial.py: -------------------------------------------------------------------------------- 1 | def factorial(n): 2 | if n==0: 3 | return 1 4 | else: 5 | return n*factorial(n-1) 6 | 7 | num = int(input("Enter a number: ")) 8 | print("The factorial of a {0} is: ".format(num), factorial(num)) -------------------------------------------------------------------------------- /RecursionPython/powerOfNum.py: -------------------------------------------------------------------------------- 1 | def power_of_num(num, topwr): 2 | if topwr == 0: 3 | return 1 4 | else: 5 | return num * power_of_num(num, topwr - 1) 6 | 7 | print('{} to the power of {} is: {} '.format(4, 7, power_of_num(3, 7))) 8 | print('{} to the power of {} is: {} '.format(2, 8, power_of_num(4, 3))) -------------------------------------------------------------------------------- /RecursionPython/towerOfHanoi.py: -------------------------------------------------------------------------------- 1 | def tower_of_hanoi(disks, source, auxiliary, target): 2 | if(disks == 1): 3 | print('Move disk 1 from rod {} to rod {}.'.format(source, target)) 4 | return 5 | tower_of_hanoi(disks - 1, source, target, auxiliary) 6 | print('Move disk {} from rod {} to rod {}.'.format(disks, source, target)) 7 | tower_of_hanoi(disks - 1, auxiliary, source, target) 8 | 9 | 10 | disks = int(input('Enter the number of disks: ')) 11 | tower_of_hanoi(disks, 'A', 'B', 'C') -------------------------------------------------------------------------------- /Video- Non Coder/README.md: -------------------------------------------------------------------------------- 1 | >Note : Add Animation in this folder. 2 | # Good Day 3 |
4 | Provide your name and video link.
5 | >Note : This format follow
6 | Name : MEHAK BASRANI
7 | Video link : https://linksharing.samsungcloud.com/s4migGzOoEED 8 | -------------------------------------------------------------------------------- /fibbonacci.py: -------------------------------------------------------------------------------- 1 | def fib(n): 2 | #creating function fib and assigning variables to it 3 | a, b = 0, 1 #assinging values to variables 4 | i=0 5 | while i 9 | 10 | using namespace std; 11 | 12 | //class to define a node 13 | class SinglyLinkedListNode 14 | { 15 | public: 16 | int data; 17 | SinglyLinkedListNode *next; 18 | 19 | SinglyLinkedListNode (int node_data) 20 | { 21 | this->data = node_data; 22 | this->next = nullptr; 23 | } 24 | }; 25 | 26 | //class to define linkedlist 27 | class SinglyLinkedList 28 | { 29 | public: 30 | SinglyLinkedListNode * head; 31 | SinglyLinkedListNode *tail; 32 | 33 | SinglyLinkedList () 34 | { 35 | this->head = nullptr; 36 | this->tail = nullptr; 37 | } 38 | 39 | //function to insert a node 40 | void insert_node (int node_data) 41 | { 42 | SinglyLinkedListNode *node = new SinglyLinkedListNode (node_data); 43 | if (!this->head) 44 | { 45 | this->head = node; 46 | } 47 | else 48 | { 49 | this->tail->next = node; 50 | } 51 | this->tail = node; 52 | } 53 | }; 54 | 55 | //function to print linkedlist 56 | void 57 | print_singly_linked_list (SinglyLinkedListNode * node, string sep, 58 | ofstream & fout) 59 | { 60 | while (node) 61 | { 62 | fout << node->data; 63 | node = node->next; 64 | if (node) 65 | { 66 | fout << sep; 67 | } 68 | } 69 | } 70 | 71 | void 72 | free_singly_linked_list (SinglyLinkedListNode * node) 73 | { 74 | while (node) 75 | { 76 | SinglyLinkedListNode *temp = node; 77 | node = node->next; 78 | free (temp); 79 | } 80 | } 81 | 82 | //function to detect cycle in linkedlist 83 | bool 84 | has_cycle (SinglyLinkedListNode * head) 85 | { 86 | SinglyLinkedListNode *cur = head; 87 | SinglyLinkedListNode *cur1 = head; 88 | while (cur1 != NULL && cur1->next != NULL) 89 | { 90 | cur = cur->next; 91 | cur1 = cur1->next->next; 92 | if (cur == cur1) 93 | return true; 94 | } 95 | return false; 96 | } 97 | 98 | int 99 | main () 100 | { 101 | ofstream fout (getenv ("OUTPUT_PATH")); 102 | int tests; 103 | cin >> tests; 104 | cin.ignore (numeric_limits < streamsize >::max (), '\n'); 105 | for (int tests_itr = 0; tests_itr < tests; tests_itr++) 106 | { 107 | int index; 108 | cin >> index; 109 | cin.ignore (numeric_limits < streamsize >::max (), '\n'); 110 | SinglyLinkedList *llist = new SinglyLinkedList (); 111 | int llist_count; 112 | cin >> llist_count; 113 | cin.ignore (numeric_limits < streamsize >::max (), '\n'); 114 | for (int i = 0; i < llist_count; i++) 115 | { 116 | int llist_item; 117 | cin >> llist_item; 118 | cin.ignore (numeric_limits < streamsize >::max (), '\n'); 119 | llist->insert_node (llist_item); 120 | } 121 | SinglyLinkedListNode *extra = new SinglyLinkedListNode (-1); 122 | SinglyLinkedListNode *temp = llist->head; 123 | for (int i = 0; i < llist_count; i++) 124 | { 125 | if (i == index) 126 | { 127 | extra = temp; 128 | } 129 | if (i != llist_count - 1) 130 | { 131 | temp = temp->next; 132 | } 133 | } 134 | temp->next = extra; 135 | bool result = has_cycle (llist->head); 136 | fout << result << "\n"; 137 | } 138 | fout.close (); 139 | return 0; 140 | } 141 | -------------------------------------------------------------------------------- /temperature converter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Converter 7 | 8 | 9 | 10 |
11 |
12 |

Temperature Converter

13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /temperature converter/script.js: -------------------------------------------------------------------------------- 1 | const celciusInput = document.getElementById("celcius"); 2 | const fahrenheitInput = document.getElementById("fahrenheit"); 3 | const kelvinInput = document.getElementById("kelvin"); 4 | 5 | const inputs = document.getElementsByClassName("input"); 6 | 7 | for (let i = 0; i < inputs.length; i++) { 8 | let input = inputs[i]; 9 | 10 | input.addEventListener("input", function (e) { 11 | let value = parseFloat(e.target.value); 12 | 13 | switch (e.target.name) { 14 | case "celcius": 15 | fahrenheitInput.value = (value * 1.8) + 32; 16 | kelvinInput.value = value + 273.15; 17 | break; 18 | case "fahrenheit": 19 | celciusInput.value = (value - 32) / 1.8; 20 | kelvinInput.value = ((value - 32) / 1.8) + 273.15; 21 | break; 22 | case "kelvin": 23 | celciusInput.value = value - 273.15; 24 | fahrenheitInput.value = ((value - 273.15) * 1.8) + 32; 25 | break; 26 | } 27 | }); 28 | } -------------------------------------------------------------------------------- /temperature converter/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | 7 | main { 8 | width: 100%; 9 | height: 100vh; 10 | background-image: linear-gradient(to bottom, #FFCE00, #b9f700); 11 | } 12 | 13 | header { 14 | display: flex; 15 | justify-content: center; 16 | padding-top: 200px; 17 | } 18 | 19 | h1 { 20 | margin-bottom: 30px; 21 | color: black; 22 | } 23 | 24 | .inputs { 25 | display: flex; 26 | flex-wrap: wrap; 27 | justify-content: center; 28 | align-items: center; 29 | max-width: 768px; 30 | margin: 0 auto; 31 | } 32 | 33 | .input { 34 | flex: 1 1 40%; 35 | margin: 15px; 36 | appearance: none; 37 | background: none; 38 | background-color: #FFF; 39 | border-radius: 8px; 40 | padding: 15px; 41 | border: none; 42 | outline: none; 43 | transition: 0.4s; 44 | } 45 | 46 | .input:focus { 47 | box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2); 48 | } --------------------------------------------------------------------------------