├── Program's_Contributed_By_Contributors ├── Python_Programs │ ├── n-queens.py │ ├── Tables.py │ ├── Triangle.py │ ├── Video-audio_extractor.py │ ├── Exponential Sum.py │ ├── hello_world.py │ ├── Person class file.py │ ├── python.py │ ├── RainbowBenzene.py │ ├── qr.py │ ├── Modified_Bubble_Sort.py │ ├── calender.py │ ├── DisplayCalendar.py │ ├── phone number mapping.py │ ├── maxslidingwindow.py │ ├── leap year.py │ ├── guess.py │ ├── findMissingNumber.py │ ├── lyrics_scrapper.py │ ├── MinMaxNorm.py │ ├── spirograph.py │ ├── Selection Sort.py │ ├── wifipass.py │ ├── password_checker.py │ ├── insertion Sort.py │ ├── Bubble Sort.py │ ├── Treasure Hunt.py │ ├── pdf_password_remover.py │ ├── organize_files.py │ ├── Breadth-First Search (BFS).py │ ├── Guessing_No.py │ ├── Merge_Sort.py │ ├── send_email.py │ ├── Depth First Search(Weighted Graph).py │ ├── reversalAlgorithm.py │ ├── moveAllZerosToEnd.py │ ├── Random_Walk_in_1D │ ├── scanner.py │ ├── RadixSort.py │ ├── number_guessing_game.py │ ├── coffee shop program.py │ ├── DiceRollSimulator.py │ ├── car game.py │ ├── Guessing Game Challenge.py │ ├── particleEffect.py │ ├── QuickSort.py │ ├── Password_Strong_weak.py │ ├── YouTube_Video_Downloader.py │ ├── Level_order_traversal_binary_tree.py │ ├── Raspberrypi_LED.py │ ├── flappy.py │ ├── Guessthenumber.py │ ├── port_scanner.py │ ├── BMI Calculator.py │ ├── djikstra.py │ ├── Rock_Paper_Scissors.py │ ├── weight_convertor_gui.py │ ├── Image_Resizer.py │ ├── Zoom_automation.py │ ├── heapheapsort.py │ ├── voice_activated_calculator.py │ ├── Color_Detection.py │ ├── pattern.py │ ├── Alarm Clock In Python │ └── alarm_clock.py ├── Java_Programs │ ├── Misc │ │ ├── SpiralMatrix.java │ │ ├── runnableInterface.java │ │ ├── SuperClass.java │ │ ├── IPFinder.java │ │ ├── RainWaterTrapping.java │ │ ├── URLconn.java │ │ ├── HierarchialInheritance.java │ │ ├── BinaryPow.java │ │ ├── BestTimeToBuyAndSellStockOne.java │ │ ├── Threadmethods.java │ │ ├── Toggle_Bulbs.java │ │ ├── gui.java │ │ ├── FizzBuzzSetImplementation.java │ │ └── majority_Element.java │ ├── Main.class │ ├── Test.class │ ├── max3.class │ ├── prime.class │ ├── sum.class │ ├── Complex.class │ ├── NQueens.class │ ├── Reverse.class │ ├── inputs.class │ ├── isPrime.class │ ├── Armstrong.class │ ├── Calculator.class │ ├── CountNums.class │ ├── Switch_case.class │ ├── Sum_of_Fibonacci.class │ ├── UpperORLowercase.class │ ├── Complex$ComplexNumber.class │ ├── Addition without arithmetic operation │ ├── Data_structure │ │ ├── Addition without arithmetic operation │ │ ├── BinarySearch.java │ │ ├── Binary_Palindrome.java │ │ ├── ChocolaProblem.java │ │ ├── BinaryNode.java │ │ ├── TrappingRainWater_problem.java │ │ ├── RevLinkList.java │ │ ├── InfiniteSortedArray.java │ │ ├── DetectCycle.java │ │ ├── Reverse_Linked_List.java │ │ ├── Edge.java │ │ ├── AnagramTechniques.java │ │ ├── Greatestelement.java │ │ ├── Balancedbrackets.java │ │ └── GraphMA.java │ ├── java │ │ ├── queue │ │ │ ├── Queue.java │ │ │ ├── ArrayQueue.java │ │ │ └── LinkedQueue.java │ │ └── stack │ │ │ ├── Stack.java │ │ │ └── RPN.java │ ├── Prime_Number_In_given.class │ ├── CommonElement.java │ ├── Josephus.class │ ├── Sorting │ │ └── QuickSort.java │ │ │ └── QuickSort │ ├── Maximize_Power.java │ └── Hollow Rhombus Pattern.java ├── Implementation_of_DS │ ├── LinkedlistOperations.c │ ├── BSTsort.c │ └── circluar_linkedList.c ├── C++ Programs │ ├── greedy │ │ ├── a.out │ │ ├── minplatform.cpp │ │ ├── nmeetings.cpp │ │ └── jobsequence.cpp │ ├── 2pointer │ │ ├── a.out │ │ ├── removeduplicate.cpp │ │ ├── 3sum.cpp │ │ └── traprainwater.cpp │ ├── hashing │ │ ├── a.out │ │ ├── longestsubnorepeat.cpp │ │ ├── largestsubarrayzero.cpp │ │ ├── countgivenxor.cpp │ │ ├── longestconsecutiveseq.cpp │ │ ├── 2sum.cpp │ │ └── 4sum.cpp │ ├── linkedlist │ │ ├── a.out │ │ ├── middlelist.cpp │ │ ├── Delete Node From Linked List │ │ ├── reverselist.cpp │ │ ├── removefromend.cpp │ │ ├── intersectlist.cpp │ │ ├── merge2list.cpp │ │ ├── listCycle.cpp │ │ └── add2num.cpp │ ├── Array │ │ ├── gridpath.cpp │ │ ├── buyandsell.cpp │ │ ├── repeatandmissing.cpp │ │ ├── majorelement.cpp │ │ ├── maxsumsubarray.cpp │ │ ├── power.cpp │ │ ├── searchmatrix.cpp │ │ ├── TargetSum.cpp │ │ ├── rotmatrix.cpp │ │ ├── Union_of_two_array.cpp │ │ ├── pascal.cpp │ │ ├── swap_numbers.cpp │ │ ├── mergeinterval.cpp │ │ ├── equilibriumpoint.cpp │ │ ├── sort012.cpp │ │ ├── mergesortedarray.cpp │ │ ├── reversepair.cpp │ │ ├── countinversion.cpp │ │ ├── major3.cpp │ │ ├── SquareOfSortedArray.cpp │ │ └── setmatrixzero.cpp │ └── Stacks │ │ ├── Reversing_the_String.cpp │ │ └── postfix_to_infix.cpp ├── Golang Programs │ ├── go_while_loop.go │ ├── helloworld.go │ ├── addition.go │ ├── fizzbuzz.go │ ├── areaFigure.go │ └── countdown_timer.go ├── Rust_Programs │ └── fizzbuzz.rs ├── BrainFuck_Programs │ └── FizzBuzz.bf ├── checkPalindrome.js ├── checkPrime.js └── LogIn │ ├── index.html │ └── style.css ├── scripts ├── README.md ├── Event_Completed_.png └── scroll.js ├── .gitignore ├── css ├── hacktoberfest.ico ├── Style.css ├── style.css └── navbar.css ├── pull_request_template.md ├── .github ├── ISSUE_TEMPLATE │ └── feature_request.md └── workflows │ ├── auto-merge.yml │ └── auto-comment.yml ├── CONTRIBUTING.md ├── tic-tac-toe board.java ├── tree.cpp └── logo.html /Program's_Contributed_By_Contributors/Python_Programs/n-queens.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | This repository contains JS files for the project 2 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/SpiralMatrix.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Implementation_of_DS/LinkedlistOperations.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .git/objects/ 3 | .DS_Store 4 | *.idea* 5 | .github 6 | *.github/ 7 | /.vs 8 | -------------------------------------------------------------------------------- /css/hacktoberfest.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/css/hacktoberfest.ico -------------------------------------------------------------------------------- /scripts/Event_Completed_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/scripts/Event_Completed_.png -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/greedy/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/C++ Programs/greedy/a.out -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Main.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Test.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/max3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/max3.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/prime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/prime.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/sum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/sum.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/2pointer/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/C++ Programs/2pointer/a.out -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/hashing/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/C++ Programs/hashing/a.out -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Complex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Complex.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/NQueens.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/NQueens.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Reverse.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Reverse.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/inputs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/inputs.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/isPrime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/isPrime.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/linkedlist/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/C++ Programs/linkedlist/a.out -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Armstrong.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Armstrong.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Calculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Calculator.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/CountNums.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/CountNums.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Tables.py: -------------------------------------------------------------------------------- 1 | a=float(input('Enter a Number: ')) 2 | m=int(input('Enter the last Multiple: ')) 3 | for i in range(1,m+1): 4 | print(a,' * ', i, ' = ',a*i,) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Switch_case.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Switch_case.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Sum_of_Fibonacci.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Sum_of_Fibonacci.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/UpperORLowercase.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/UpperORLowercase.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Complex$ComplexNumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubham-Bhoite/Hacktoberfest2023-2/master/Program's_Contributed_By_Contributors/Java_Programs/Complex$ComplexNumber.class -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Golang Programs/go_while_loop.go: -------------------------------------------------------------------------------- 1 | package main 2 | import ("fmt") 3 | 4 | func main() { 5 | number := 1 6 | 7 | for number <= 5 { 8 | fmt.Println(number) 9 | number++ 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Triangle.py: -------------------------------------------------------------------------------- 1 | x=str(input('Enter a symbol: ')) 2 | l=int(input('Enter no. of layers: ')) 3 | for i in range(1,l+1): 4 | for a in range(1,i+1): 5 | print(x,end='') 6 | print() 7 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Golang Programs/helloworld.go: -------------------------------------------------------------------------------- 1 | // First Go program 2 | package main 3 | 4 | import "fmt" 5 | 6 | // Main function 7 | func main() { 8 | 9 | fmt.Println("!... Hello World ...!") 10 | } -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Problem 4 | - 5 | # Solution 6 | - 7 | 8 | ## Changes proposed in this Pull Request : 9 | - `1.` 10 | - `..` 11 | 12 | ## Other changes 13 | - 14 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Video-audio_extractor.py: -------------------------------------------------------------------------------- 1 | import moviepy.editor 2 | 3 | 4 | # Video path 5 | video = moviepy.editor.VideoFileClip('file.mp4') 6 | 7 | 8 | #audio conversion 9 | audio = video.audio 10 | 11 | audio.write_audiofile('file.mp3') 12 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Exponential Sum.py: -------------------------------------------------------------------------------- 1 | s=0 2 | a=int(input('Enter the base Number: ')) 3 | e=int(input('Enter the Exponent: ')) 4 | for i in range(1,e+1): 5 | t=a**i 6 | print(a,'raised to index',i,' = ',t) 7 | s+=t 8 | print('Sum of this Progression is: ',s) 9 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Golang Programs/addition.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // Function accepting arguments 6 | func add(x int, y int) { 7 | total := 0 8 | total = x + y 9 | fmt.Println(total) 10 | } 11 | 12 | func main() { 13 | // Passing arguments 14 | add(20, 30) 15 | } 16 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/hello_world.py: -------------------------------------------------------------------------------- 1 | #Create a function to print hello github 2 | def hello_world(): 3 | print("Hello Github!") 4 | 5 | #function to check whether module (or script) runs directly and returns back the previous function 6 | if __name__ == "__main__": 7 | hello_world() 8 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Person class file.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, name): 3 | self.name = name 4 | 5 | def talk(self): 6 | print(f"Hi, I am {self.name}") 7 | 8 | 9 | john = Person("John") 10 | john.talk() 11 | 12 | bob = Person("Bob") 13 | bob.talk() -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/python.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | test_list = ['black', 'white', 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple', 'violet', 'pink', 'silver', 'gold', 'brown', 'gray'] 4 | random_index = random.randrange(len(test_list)) 5 | 6 | print(test_list[random_index]) 7 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/RainbowBenzene.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow'] 3 | t = turtle.Pen() 4 | turtle.bgcolor('black') 5 | for x in range(360): 6 | t.pencolor(colors[x%6]) 7 | t.width(x/100 + 1) 8 | t.forward(x) 9 | t.left(59) 10 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/qr.py: -------------------------------------------------------------------------------- 1 | import pyqrcode 2 | from pyqrcode import QRCode 3 | 4 | # String which represent the QR code 5 | s = "https://fueler.io/arjun_ms" 6 | 7 | # Generate QR code 8 | url = pyqrcode.create(s) 9 | 10 | # Create and save the png file naming "myqr.png" 11 | url.svg("myyoutube.svg", scale = 8) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Modified_Bubble_Sort.py: -------------------------------------------------------------------------------- 1 | num = [40,32,55,21,90,33,15,31] #input your number here 2 | 3 | i = 0 4 | while (i num[i+1]: 6 | temp = num[i] 7 | num[i] = num[i+1] 8 | num[i+1] = temp 9 | i=0 10 | else: 11 | i = i+1 12 | print (num) 13 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/gridpath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int m = 5; 7 | int n = 4; 8 | int N = m+n-2; 9 | int r = m-1; 10 | int res = 1; 11 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector price = {7,1,5,3,6,4}; 7 | int mn =INT_MAX; 8 | int profit = 0; 9 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector A = {1,2,3,4,4,5,7,8}; 8 | int s1=0,s2=0; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector vals = {7,7,5,1,7,7,5,1,1,5,5,5,5,5,5,1}; 7 | int count = 0; 8 | int el; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums = {1,1,1,2,3,4,4,4,4,5}; 7 | int i = 0, j = 1; 8 | while(j 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums= {-2,1,4,-3,2,-5,-1,6,-4,3,5}; 7 | int local_sum=0,global_sum=0; 8 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string s = "abcaabcda"; 7 | vector vals(256,-1); 8 | int l = 0, r = 0; 9 | int n = s.length(); 10 | int len = 0; 11 | while(r 3: 12 | q.pop(0) 13 | 14 | if len(q) == 3: 15 | out.append(max( q )) 16 | 17 | return out 18 | 19 | 20 | 21 | nums = [1, 3, -1, -3, 5, 3, 6, 7] 22 | k = 3 23 | 24 | print (maxSlidingWindow(nums, k)) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/hashing/largestsubarrayzero.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums={1,-1,3,2,-2,-8,1,7,2,6,10}; 7 | map mp; 8 | int sum = 0; 9 | int len = 0; 10 | for(int i=0;i target: 13 | print("Try a Lower Number!") 14 | continue 15 | 16 | else: 17 | print('Try a Higher Number!') 18 | continue -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/power.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int help(int base, int pow) 5 | { 6 | if(pow==0) 7 | return 1; 8 | if(pow==1) 9 | return base; 10 | if(pow%2) 11 | return base*help(base*2,(pow-1)/2); 12 | else 13 | return help(base*2,pow/2); 14 | } 15 | 16 | int main() 17 | { 18 | int base = 4; 19 | int pow = -2; 20 | if(pow<0) 21 | cout<<1.0/help(base,-pow)< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | vector nums = {4,2,2,6,4}; 8 | int target = 6; 9 | map mp; 10 | int count = 0; 11 | int xorr = 0; 12 | for(auto x:nums) 13 | { 14 | xorr = xorr ^ x; 15 | if(xorr==target) 16 | count++; 17 | if(mp.find(xorr^target)!=mp.end()) 18 | { 19 | count+=mp[xorr^target]; 20 | } 21 | mp[xorr]+=1; 22 | } 23 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums = {2,4,100,3,102,101,1}; 7 | set st; 8 | for(auto x:nums) 9 | st.insert(x); 10 | int len = 0; 11 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums = {2,6,3,8,1,5,4}; 7 | int target = 9; 8 | map mp; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector> mat = {{10,20,30,40},{11,21,36,43},{25,29,39,50},{50,60,70,80}}; 7 | 8 | int row = 0, col = mat[0].size()-1; 9 | int target = 42; 10 | while(row<=mat.size() and col>=0) 11 | { 12 | if(mat[row][col]==target) 13 | { 14 | cout<<"Found"<target) 18 | { 19 | col--; 20 | } 21 | else 22 | { 23 | row++; 24 | } 25 | } 26 | cout<<"Not Found"< 2 | #include 3 | using namespace std; 4 | int findTotalWays(vector arr, int i, int s, int target) 5 | { 6 | if (s == target && i == arr.size()) 7 | return 1; 8 | if (i >= arr.size()) 9 | return 0; 10 | return findTotalWays(arr, i + 1, s + arr[i], target) 11 | + findTotalWays(arr, i + 1, s - arr[i], target); 12 | } 13 | 14 | 15 | int main() 16 | { 17 | vector arr = { 1, 1, 1, 1, 1 }; 18 | 19 | 20 | int target = 3; 21 | 22 | cout << findTotalWays(arr, 0, 0, target) << endl; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/MinMaxNorm.py: -------------------------------------------------------------------------------- 1 | # Min Max Normalization method 2 | class MinMaxNorm: 3 | def __init__(self, data): 4 | self.data = data 5 | def calculate(self): 6 | data_norm = self.data.copy() 7 | for i, da in enumerate(data_norm): 8 | maxi = max(da) 9 | mini = min(da) 10 | for j, d in enumerate(da): 11 | data_norm[i][j] = (d-mini)/(maxi-mini) 12 | return data_norm 13 | 14 | sample_data = [[1,2,3], [5,6,7]] 15 | data_norm = MinMaxNorm(sample_data).calculate() 16 | print(data_norm) #output: [[0.0, 0.5, 1.0], [0.0, 0.5, 1.0]] -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Prime_Number_In_given.class: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Prime_Number_In_given { 3 | public static void main(String[] args){ 4 | int M = 1,N=10; 5 | ArrayList a = new ArrayList(); 6 | boolean isPrime = true; 7 | for(int i=M; i<=N;i++){ 8 | for(int j=2; j*j<=i; j++){ 9 | if(i%j==0){ 10 | isPrime = false; 11 | } 12 | } 13 | if(isPrime && i!=1){ 14 | a.add(i); 15 | } 16 | 17 | } 18 | System.out.println(a); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/spirograph.py: -------------------------------------------------------------------------------- 1 | import turtle as t 2 | import random 3 | 4 | tim = t.Turtle() 5 | s = t.Screen() 6 | 7 | colors = ["#0F3460", "#533483", "#E94560", "#59CE8F", "#66BFBF", "#FF0063", "#4C3A51", "#774360", "#B25068"] 8 | 9 | 10 | def color_gen(): 11 | rand_color = random.choice(colors) 12 | return rand_color 13 | 14 | tim.speed("fastest") 15 | tim.hideturtle() 16 | 17 | 18 | def draw_spirograph(gap): 19 | for _ in range(360 // gap): 20 | tim.color(color_gen()) 21 | tim.circle(100) 22 | tim.setheading(tim.heading() + gap) 23 | 24 | 25 | draw_spirograph(5) 26 | s.exitonclick() 27 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Selection Sort.py: -------------------------------------------------------------------------------- 1 | # Selection Sort algorithm in Python 2 | def selectionSort(array, size): 3 | 4 | for s in range(size): 5 | min_idx = s 6 | 7 | for i in range(s + 1, size): 8 | 9 | # For sorting in descending order 10 | # for minimum element in each loop 11 | if array[i] < array[min_idx]: 12 | min_idx = i 13 | 14 | # Arranging min at the correct position 15 | (array[s], array[min_idx]) = (array[min_idx], array[s]) 16 | 17 | # Driver code 18 | data = [ 7, 2, 1, 6 ] 19 | size = len(data) 20 | selectionSort(data, size) 21 | 22 | print('Sorted Array in Ascending Order is :') 23 | print(data) 24 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/wifipass.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n') 4 | 5 | profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i] 6 | 7 | for i in profiles: 8 | results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 9 | 'key=clear']).decode('utf-8').split('\n') 10 | results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b] 11 | try: 12 | print ("{:<30}| {:<}".format(i, results[0])) 13 | except IndexError: 14 | print ("{:<30}| {:<}".format(i, "")) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/SuperClass.java: -------------------------------------------------------------------------------- 1 | //Demonstration of super class 2 | 3 | class Super 4 | { 5 | int x; 6 | Super(int x) 7 | { 8 | this.x = x; 9 | } 10 | void display() 11 | { 12 | System.out.println("Super x =" +x); //print super object 13 | } 14 | } 15 | Class Sub extends Super 16 | { 17 | int y; 18 | sub (int x, int y) 19 | { 20 | super (x); 21 | this.y=y; 22 | } 23 | void display() 24 | { 25 | System.out.println("Super x =" +x); 26 | System.out.println("Sub y =" +y); 27 | } 28 | } 29 | class OverrideTest 30 | { 31 | public static void main(String args[]) 32 | { 33 | Sub sl = new Sub(100,200); 34 | sl.display(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/rotmatrix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector> matrix = {{1,2,3},{4,5,6},{7,8,9}}; 7 | for(int i =0;i= 8): 4 | for i in s: 5 | 6 | # counting lowercase alphabets in the given password 7 | if (i.islower()): 8 | l+=1 9 | 10 | # counting uppercase alphabets in the given password 11 | if (i.isupper()): 12 | u+=1 13 | 14 | # counting digits in the given password 15 | if (i.isdigit()): 16 | d+=1 17 | 18 | # counting the mentioned special characters 19 | if(i=='@'or i=='$' or i=='_'): 20 | p+=1 21 | if (l>=1 and u>=1 and p>=1 and d>=1 and l+p+u+d==len(s)): 22 | print("Valid Password!") 23 | else: 24 | print("Invalid Password") 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/2pointer/3sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector vals={2,6,3,11,7,4,9,7,10,6}; 7 | int target = 20; 8 | 9 | sort(vals.begin(),vals.end()); 10 | for(int i=0;itarget) 23 | { 24 | r--; 25 | } 26 | else 27 | { 28 | l++; 29 | } 30 | } 31 | } 32 | 33 | cout<<"No triplet"< 3 | 4 | using namespace std; 5 | void getUnion(int a[], int n, int b[], int m) 6 | { 7 | set s; 8 | for (int i = 0; i < n; i++) 9 | s.insert(a[i]); 10 | 11 | for (int i = 0; i < m; i++) 12 | s.insert(b[i]); 13 | cout << "Number of elements after union operation: " << s.size() << endl; 14 | cout << "The union set of both arrays is :" << endl; 15 | for (auto itr = s.begin(); itr != s.end(); itr++) 16 | cout << *itr 17 | << " "; 18 | } 19 | 20 | int main() 21 | { 22 | int a[9] = { 1, 2, 5, 6, 2, 3, 5, 7, 3 }; 23 | int b[10] = { 2, 4, 5, 6, 8, 9, 4, 6, 5, 4 }; 24 | 25 | getUnion(a, 9, b, 10); 26 | } 27 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/insertion Sort.py: -------------------------------------------------------------------------------- 1 | # Creating a function for insertion sort algorithm 2 | def insertion_sort(list1): 3 | 4 | # Outer loop to traverse on len(list1) 5 | for i in range(1, len(list1)): 6 | 7 | a = list1[i] 8 | 9 | # Move elements of list1[0 to i-1], 10 | # which are greater to one position 11 | # ahead of their current position 12 | j = i - 1 13 | 14 | while j >= 0 and a < list1[j]: 15 | list1[j + 1] = list1[j] 16 | j -= 1 17 | 18 | list1[j + 1] = a 19 | 20 | return list1 21 | 22 | # Driver code 23 | list1 = [ 7, 2, 1, 6 ] 24 | print("The unsorted list is:", list1) 25 | print("The sorted new list is:", insertion_sort(list1)) 26 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Bubble Sort.py: -------------------------------------------------------------------------------- 1 | # Python3 program for Bubble Sort Algorithm Implementation 2 | def bubbleSort(arr): 3 | 4 | n = len(arr) 5 | 6 | # For loop to traverse through all 7 | # element in an array 8 | for i in range(n): 9 | for j in range(0, n - i - 1): 10 | 11 | # Range of the array is from 0 to n-i-1 12 | # Swap the elements if the element found 13 | #is greater than the adjacent element 14 | if arr[j] > arr[j + 1]: 15 | arr[j], arr[j + 1] = arr[j + 1], arr[j] 16 | 17 | # Driver code 18 | 19 | # Example to test the above code 20 | arr = [ 2, 1, 10, 23 ] 21 | 22 | bubbleSort(arr) 23 | 24 | print("Sorted array is:") 25 | for i in range(len(arr)): 26 | print("%d" % arr[i]) 27 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Treasure Hunt.py: -------------------------------------------------------------------------------- 1 | 2 | row1 = ["⬜️","⬜️","⬜️"] 3 | row2 = ["⬜️","⬜️","⬜️"] 4 | row3 = ["⬜️","⬜️","⬜️"] 5 | map = [row1, row2, row3] 6 | print(f"{row1}\n{row2}\n{row3}") 7 | position = input("Where do you want to put the treasure? ") 8 | 9 | 10 | position=int(position) 11 | if position==11: 12 | row1[0]="X" 13 | elif position==12: 14 | row1[1]="X" 15 | elif position==13: 16 | row1[2]="X" 17 | elif position==21: 18 | row2[0]="X" 19 | elif position==22: 20 | row2[1]="X" 21 | elif position==23: 22 | row2[2]="X" 23 | elif position==31: 24 | row3[0]="X" 25 | elif position==32: 26 | row3[1]="X" 27 | elif position==33: 28 | row3[2]="X" 29 | 30 | print(f"{row1}\n{row2}\n{row3}") 31 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/2pointer/traprainwater.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector rain = {0,1,0,2,1,0,1,3,2,1,2,1}; 7 | int l = 0; 8 | int r = rain.size() -1; 9 | int leftmax = 0; 10 | int rightmax = 0; 11 | int res = 0; 12 | while(l<=r) 13 | { 14 | if(rain[l]<=rain[r]) 15 | { 16 | if(rain[l]>=leftmax) 17 | { 18 | leftmax = rain[l]; 19 | } 20 | else 21 | { 22 | res+= leftmax - rain[l]; 23 | } 24 | l++; 25 | } 26 | else 27 | { 28 | if(rain[r]>=rightmax) 29 | { 30 | rightmax = rain[r]; 31 | } 32 | else 33 | { 34 | res+=rightmax - rain[r]; 35 | } 36 | r--; 37 | } 38 | } 39 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector arr = {120,200,50,700,850,550}; 7 | vector dep = {550,600,500,900,1000,700}; 8 | for(auto x:arr) 9 | cout<dep[j]) 30 | { 31 | curr--; 32 | j++; 33 | } 34 | mx = max(mx,curr); 35 | } 36 | cout<100 or userGuess<1: 10 | print("Enter Valid Number") 11 | guesses+=1 12 | if(userGuess == randNumber): 13 | print("You Guessed it right!!") 14 | else: 15 | if(userGuess>randNumber): 16 | print("You Guessed it worng!! Enter a smaller number") 17 | else: 18 | print("You Guessed it wrong!! Enter a larger number") 19 | 20 | print(f"You Guessed the number in {guesses} Guesses") 21 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Merge_Sort.py: -------------------------------------------------------------------------------- 1 | def merge(left, right): 2 | if len(left) == 0: 3 | return right 4 | 5 | if len(right) == 0: 6 | return left 7 | 8 | result = [] 9 | index_left = index_right = 0 10 | 11 | while len(result) < len(left) + len(right): 12 | if left[index_left] <= right[index_right]: 13 | result.append(left[index_left]) 14 | index_left += 1 15 | else: 16 | result.append(right[index_right]) 17 | index_right += 1 18 | 19 | if index_right == len(right): 20 | result += left[index_left:] 21 | break 22 | 23 | if index_left == len(left): 24 | result += right[index_right:] 25 | break 26 | 27 | return result 28 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/CommonElement.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class CommonElement { 3 | public static void main(String[] args) { 4 | int a1[] = {1, 5, 10, 20, 40, 80}; 5 | int a2[] = {6, 7, 20, 80, 100}; 6 | int a3[] = {3, 4, 15, 20, 30, 70, 80, 120}; 7 | ArrayList a = new ArrayList(); 8 | Sets =new HashSet(); 9 | Sets2 =new HashSet(); 10 | for(int se: a2){ 11 | s.add(se); 12 | } 13 | Sets1 =new HashSet(); 14 | for(int se: a3){ 15 | s1.add(se); 16 | } 17 | for(int i=0; i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int num_rows = 6; 7 | vector> triangle(num_rows); 8 | for(int i=0;i res(7); 28 | int res = 1; 29 | cout<<1<<" "; 30 | for(int i=0;i<5;i++) 31 | { 32 | res*=(5-i); 33 | res/=(i+1); 34 | 35 | cout< 2 | using namespace std; 3 | 4 | void cyclicSwap(int *a, int *b, int *c); 5 | 6 | int main() 7 | { 8 | int a, b, c; 9 | 10 | cout << "Enter value of a, b and c respectively: "; 11 | cin >> a >> b >> c; 12 | 13 | cout << "Value before swapping: " << endl; 14 | cout << "a, b and c respectively are: " << a << ", " << b << ", " << c << endl; 15 | 16 | cyclicSwap(&a, &b, &c); 17 | 18 | cout << "Value after swapping numbers in cycle: " << endl; 19 | cout << "a, b and c respectively are: " << a << ", " << b << ", " << c << endl; 20 | 21 | return 0; 22 | } 23 | 24 | void cyclicSwap(int *a, int *b, int *c) 25 | { 26 | int temp; 27 | temp = *b; 28 | *b = *a; 29 | *a = *c; 30 | *c = temp; 31 | } 32 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/BinarySearch.java: -------------------------------------------------------------------------------- 1 | public class BinarySearch { 2 | public static void main(String[] args) 3 | { 4 | static int Binary(int[] arr, int target , int start, int end) 5 | { 6 | int start=0; 7 | int end=arr.length-1; 8 | while(start<=end) 9 | { 10 | int mid= start+(end-start)/2; 11 | if(targetarr[mid]) 16 | { 17 | start=mid+1; 18 | } 19 | else{ 20 | return mid; 21 | } 22 | } 23 | return -1; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Auto-Merge PRs 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - synchronize 8 | 9 | jobs: 10 | auto_merge: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Check PR status 15 | run: | 16 | PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH") 17 | PR_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" 18 | PR_STATE=$(curl -s -H "Authorization: token ${{ secrets.AUTOMERGE_TOKEN }}" $PR_URL | jq -r .state) 19 | 20 | if [ "$PR_STATE" = "open" ]; then 21 | echo "PR is still open. Merging..." 22 | curl -s -X PUT -H "Authorization: token ${{ secrets.AUTOMERGE_TOKEN }}" $PR_URL/merge 23 | fi 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} 26 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/BrainFuck_Programs/FizzBuzz.bf: -------------------------------------------------------------------------------- 1 | BrainFuck implementation of FizzBuzz 2 | Author: @muhazafasa 3 | ++++++++++[>++++++++++<-]>>++++++++++>->>>>>>>>>>>>>>>>-->+++++++[->++ 4 | ++++++++<]>[->+>+>+>+<<<<]+++>>+++>>>++++++++[-<++++<++++<++++>>>]++++ 5 | +[-<++++<++++>>]>>-->++++++[->+++++++++++<]>[->+>+>+>+<<<<]+++++>>+>++ 6 | ++++>++++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>>--> 7 | ---+[-<+]-<[+[->+]-<<->>>+>[-]++[-->++]-->+++[---++[--<++]---->>-<+>[+ 8 | +++[----<++++]--[>]++[-->++]--<]>++[--+[-<+]->>[-]+++++[---->++++]-->[ 9 | ->+<]>>[.>]++[-->++]]-->+++]---+[-<+]->>-[+>>>+[-<+]->>>++++++++++<<[- 10 | >+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]> 11 | +>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->+++ 12 | +++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]+[-<+]->>]+[-]<<<.>>>+[ 13 | -<+]-<<] -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/Binary_Palindrome.java: -------------------------------------------------------------------------------- 1 | // Binary Plaindrom in JAVA 2 | // Write a program to check if the binary representation of a number is palindrome or not. 3 | 4 | import java.util.*; 5 | public class Main 6 | { 7 | public static void main(String[] args) 8 | { 9 | Scanner sc = new Scanner(System.in); 10 | int n = sc.nextInt(); 11 | int m = n; 12 | int rev =0; 13 | while(m>0) 14 | { 15 | rev<<= 1; 16 | if((m & 1) == 1) 17 | { 18 | rev^= 1; 19 | } 20 | m >>= 1; 21 | } 22 | if(n == rev) 23 | { 24 | System.out.println("Binary representation of " + n + " is palindrome"); 25 | } 26 | else{ 27 | System.out.println("Binary representation of " + n + " is not palindrome"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/mergeinterval.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector> intervals = {{1,2},{2,6},{4,8},{9,11},{11,15},{18,20}}; 7 | sort(intervals.begin(),intervals.end()); 8 | int curr_start = intervals[0][0]; 9 | int curr_end = intervals[0][1]; 10 | for(int i=1;icurr_end) 13 | { 14 | cout< 5 | using namespace std; 6 | #define eff ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 7 | #define vi vector 8 | 9 | signed main(){ 10 | eff; 11 | int n; 12 | cin>>n; 13 | vi v(n); 14 | for(int i = 0; i < n; i++) 15 | cin>>v[i]; 16 | 17 | int sum = accumulate(v.begin(), v.end(), 0); 18 | int left = 0; 19 | for(int i = 0; i < n; i++) 20 | { 21 | if(left == sum - v[i]) 22 | { 23 | cout<>""" 11 | message = MIMEMultipart() 12 | message["From"] = email 13 | message["To"] = to 14 | message["Subject"] = "HacktoberFest 2019" 15 | message.attach(MIMEText(msg, "plain")) 16 | context = ssl.create_default_context() 17 | server = smtplib.SMTP("smtp.gmail.com") 18 | server.starttls() 19 | server.ehlo() 20 | server.login(email, password) 21 | server.sendmail(email, to, message.as_string()) 22 | print('Email have been successfully send') 23 | 24 | except Exception as ex: 25 | print(ex) 26 | 27 | finally: 28 | server.quit() -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/sort012.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void sortColors(vector& nums) { 5 | int low = 0; 6 | int mid = 0; 7 | int high = nums.size()-1; 8 | while(mid<=high) 9 | { 10 | if(nums[mid]==0) 11 | { 12 | swap(nums[mid],nums[low]); 13 | low++; 14 | mid++; 15 | } 16 | else if(nums[mid]==1) 17 | { 18 | mid++; 19 | } 20 | else if(nums[mid]==2) 21 | { 22 | swap(nums[mid],nums[high]); 23 | high--; 24 | } 25 | } 26 | } 27 | int main() 28 | { 29 | vector nums = {1,2,0,2,0,1,1,2,0}; 30 | sortColors(nums); 31 | for(auto x: nums) 32 | cout< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | string reverseString(string inputString) { 8 | stack charStack; // Create a stack of characters 9 | string reversedString = ""; 10 | 11 | // Push each character of the input string onto the stack 12 | for (char c : inputString) { 13 | charStack.push(c); 14 | } 15 | 16 | // Pop characters from the stack to construct the reversed string 17 | while (!charStack.empty()) { 18 | reversedString += charStack.top(); // Get the top character 19 | charStack.pop(); // Pop the top character 20 | } 21 | 22 | return reversedString; 23 | } 24 | 25 | int main() { 26 | string inputString = "Hello, World!"; 27 | string reversedResult = reverseString(inputString); 28 | cout << reversedResult << endl; // Print the reversed string 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Depth First Search(Weighted Graph).py: -------------------------------------------------------------------------------- 1 | # Using a Python dictionary to act as an adjacency list 2 | graph = { 3 | 'A' : [[8,'B'],[5,'E']], 4 | 'B' : [[2,'D'],[1,'C']], 5 | 'E' : [[1,'G']], 6 | 'G' : [], 7 | 'C' : [[3,'F']], 8 | 'F' : [[4,'G']], 9 | 'D' : [[3,'E']] 10 | 11 | } 12 | print("The Path Is = ",end = " ") 13 | found=0 14 | visited = set() 15 | def dfs(visited, graph, node,goal): 16 | global found 17 | if found==1: 18 | return 19 | elif node not in visited: 20 | print(node,end=" ") 21 | if node ==goal: 22 | print ("\n***Goal Found***") 23 | found=1 24 | return 25 | visited.add(node) 26 | templist=graph[node] 27 | templist.sort() 28 | for neighbour in templist: 29 | if len(neighbour)>0: 30 | dfs(visited, graph,neighbour[1],'G') 31 | dfs(visited, graph, 'A','G') -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/reversalAlgorithm.py: -------------------------------------------------------------------------------- 1 | 2 | def reverseArray(arr, start, end): 3 | while (start < end): 4 | temp = arr[start] 5 | arr[start] = arr[end] 6 | arr[end] = temp 7 | start += 1 8 | end = end-1 9 | 10 | # Function to left rotate arr[] of size n by d 11 | 12 | 13 | def leftRotate(arr, d): 14 | 15 | if d == 0: 16 | return 17 | n = len(arr) 18 | # in case the rotating factor is 19 | # greater than array length 20 | d = d % n 21 | reverseArray(arr, 0, d-1) 22 | reverseArray(arr, d, n-1) 23 | reverseArray(arr, 0, n-1) 24 | 25 | # Function to print an array 26 | 27 | 28 | def printArray(arr): 29 | for i in range(0, len(arr)): 30 | print (arr[i],end=' ') 31 | 32 | 33 | # Driver function to test above functions 34 | arr = [1, 2, 3, 4, 5, 6, 7] 35 | n = len(arr) 36 | d = 2 37 | 38 | leftRotate(arr, d) # Rotate array by 2 39 | printArray(arr) 40 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/moveAllZerosToEnd.py: -------------------------------------------------------------------------------- 1 | # Function which pushes all 2 | # zeros to end of an array. 3 | def pushZerosToEnd(arr, n): 4 | count = 0 # Count of non-zero elements 5 | 6 | # Traverse the array. If element 7 | # encountered is non-zero, then 8 | # replace the element at index 9 | # 'count' with this element 10 | for i in range(n): 11 | if arr[i] != 0: 12 | 13 | # here count is incremented 14 | arr[count] = arr[i] 15 | count+=1 16 | 17 | # Now all non-zero elements have been 18 | # shifted to front and 'count' is set 19 | # as index of first 0. Make all 20 | # elements 0 from count to end. 21 | while count < n: 22 | arr[count] = 0 23 | count += 1 24 | 25 | # Driver code 26 | arr = [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0, 9] 27 | n = len(arr) 28 | pushZerosToEnd(arr, n) 29 | print("Array after pushing all zeros to end of array:") 30 | print(arr) 31 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/checkPalindrome.js: -------------------------------------------------------------------------------- 1 | // Palindrome 2 | 3 | // A string is a palindrome if it is read the same from forward or backward. 4 | // For example, dad reads the same either from forward or backward. 5 | // So the word dad is a palindrome. Similarly, madam is also a palindrome. 6 | 7 | 8 | 9 | // program to check if the string is palindrome or not 10 | 11 | function checkPalindrome(string) { 12 | 13 | // find the length of a string 14 | const len = string.length; 15 | 16 | // loop through half of the string 17 | for (let i = 0; i < len / 2; i++) { 18 | 19 | // check if first and last string are same 20 | if (string[i] !== string[len - 1 - i]) { 21 | return 'It is not a palindrome'; 22 | } 23 | } 24 | return 'It is a palindrome'; 25 | } 26 | 27 | // take input 28 | const string = prompt('Enter a string: '); 29 | 30 | // call the function 31 | const value = checkPalindrome(string); 32 | 33 | console.log(value); 34 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/greedy/nmeetings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | static bool comp(vector a, vector b) 5 | { 6 | return a[1] st = {1,0,3,8,5,8}; 11 | vector fin = {2,6,4,9,7,9}; 12 | for(auto x:st) 13 | cout<> dummy; 21 | for(int i=0;i temp; 24 | temp.push_back(st[i]); 25 | temp.push_back(fin[i]); 26 | temp.push_back(i+1); 27 | dummy.push_back(temp); 28 | } 29 | sort(dummy.begin(), dummy.end(), comp); 30 | vector ans; 31 | int end = dummy[0][1]; 32 | ans.push_back(dummy[0][2]); 33 | for(int i=1;iend) 36 | { 37 | ans.push_back(dummy[i][2]); 38 | end = dummy[i][1]; 39 | } 40 | } 41 | for(auto x:ans) 42 | cout<"; 31 | temp = temp->next; 32 | } 33 | cout<<"NULL"<next) 39 | { 40 | slow = slow->next; 41 | fast = fast->next->next; 42 | } 43 | cout<val< list = new ArrayList(); 7 | Scanner in = new Scanner(System.in); 8 | 9 | 10 | System.out.print("Enter the number of soldiers: "); 11 | numPeople = in.nextInt(); 12 | in.nextLine(); 13 | 14 | 15 | System.out.print("Enter the number of soldiers to skip: "); 16 | skip = in.nextInt(); 17 | 18 | 19 | for (int count = 1; count <= numPeople; count++) 20 | { 21 | list.add("Soldier " + count); 22 | } 23 | 24 | targetIndex = skip; 25 | System.out.println("The order is: "); 26 | 27 | while (!list.isEmpty()) 28 | { 29 | System.out.println(list.remove(targetIndex)); 30 | if (list.size() > 0) 31 | targetIndex = (targetIndex + skip) % list.size(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/linkedlist/Delete Node From Linked List: -------------------------------------------------------------------------------- 1 | 2 | Node* deleteNode(Node *head, int pos) 3 | { 4 | 5 | if(pos == 1){ 6 | Node* temp = head; 7 | head = head->next; 8 | 9 | delete temp; 10 | 11 | return head; 12 | } 13 | 14 | Node* temp= head; 15 | pos = pos-1; 16 | 17 | 18 | while(pos--){ 19 | temp = temp->next; 20 | } 21 | 22 | 23 | if(temp->next == NULL){ 24 | Node* copy = temp; 25 | temp->prev->next = NULL; 26 | delete copy; 27 | 28 | return head; 29 | } 30 | 31 | 32 | Node* copy = temp; 33 | 34 | temp->next->prev = temp->prev; 35 | temp->prev->next = temp->next; 36 | 37 | delete copy; 38 | 39 | return head; 40 | 41 | 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/scanner.py: -------------------------------------------------------------------------------- 1 | #! bin/python3 2 | 3 | 4 | import socket 5 | import sys 6 | from datetime import datetime 7 | 8 | #define our target 9 | if len(sys.argv) == 2: 10 | target = socket.gethostbyname(sys.argv[1]) #Transulate hostname to IPv4 11 | else: 12 | print("Invaid Argument") 13 | 14 | # add a pretty banner 15 | 16 | print("-" *50) 17 | print("Scanning target "+ target) 18 | print("Time started : " +str(datetime.now())) 19 | print("-"*50) 20 | 21 | try: 22 | for port in range(1,65535): 23 | s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) 24 | socket.setdefaulttimeout(1) 25 | result = s.connect_ex((target,port)) #returns an Error Indicator 26 | print("Checking port{}" .format(port)) 27 | if result == 0: 28 | print("Port {} is open" .format(port)) 29 | s.close() 30 | except KeyboardInterrupt: 31 | print("\n Exiting Program") 32 | sys.exit() 33 | except socket.gaierror: 34 | print("hostname could not be resolved") 35 | sys.exit() 36 | 37 | except socket.error: 38 | print("couldn't connect to server") 39 | sys.exit() 40 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/greedy/jobsequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | bool comp(vector a, vector b) 5 | { 6 | return a[0]>b[0]; 7 | } 8 | 9 | int main() 10 | { 11 | vector profit = {25,20,10,65,60,80,22,70}; 12 | vector deadline = {4,4,2,6,5,2,2,6}; 13 | 14 | vector> job; 15 | for(int i=0;i temp; 18 | temp.push_back(profit[i]); 19 | temp.push_back(deadline[i]); 20 | temp.push_back(i+1); 21 | job.push_back(temp); 22 | } 23 | sort(job.begin(),job.end(),comp); 24 | vector sequence(7,-1); 25 | int prof = 0; 26 | for(int i=0;i0) 30 | { 31 | if(sequence[j]==-1) 32 | { 33 | sequence[j] = job[i][2]; 34 | prof += job[i][0]; 35 | break; 36 | } 37 | j--; 38 | } 39 | } 40 | cout<<"profit: "< 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | bool isOperator(char c) { 8 | return (c == '+' || c == '-' || c == '*' || c == '/'); 9 | } 10 | 11 | string postfixToInfix(string postfix) { 12 | stack st; 13 | 14 | for (char c : postfix) { 15 | if (!isOperator(c)) { 16 | st.push(string(1, c)); 17 | } else { 18 | string operand2 = st.top(); 19 | st.pop(); 20 | string operand1 = st.top(); 21 | st.pop(); 22 | 23 | string newExpr = "(" + operand1 + " " + c + " " + operand2 + ")"; 24 | st.push(newExpr); 25 | } 26 | } 27 | 28 | return st.top(); 29 | } 30 | 31 | int main() { 32 | string postfixExpression; 33 | cout << "Enter a postfix expression: "; 34 | cin >> postfixExpression; 35 | 36 | string infixExpression = postfixToInfix(postfixExpression); 37 | 38 | cout << "Infix expression: " << infixExpression << endl; 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/checkPrime.js: -------------------------------------------------------------------------------- 1 | // Prime Number 2 | // A prime number is a positive integer that is only divisible by 1 and itself. For example, 2, 3, 5, 7, 11 are the first few prime numbers. 3 | 4 | 5 | // program to check if a number is prime or not 6 | 7 | // take input from the user 8 | const number = parseInt(prompt("Enter a positive number: ")); 9 | let isPrime = true; 10 | 11 | // check if number is equal to 1 12 | if (number === 1) { 13 | console.log("1 is neither prime nor composite number."); 14 | } 15 | 16 | // check if number is greater than 1 17 | else if (number > 1) { 18 | 19 | // looping through 2 to number-1 20 | for (let i = 2; i < number; i++) { 21 | if (number % i == 0) { 22 | isPrime = false; 23 | break; 24 | } 25 | } 26 | 27 | if (isPrime) { 28 | console.log(`${number} is a prime number`); 29 | } else { 30 | console.log(`${number} is a not prime number`); 31 | } 32 | } 33 | 34 | // check if number is less than 1 35 | else { 36 | console.log("The number is not a prime number."); 37 | } 38 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/RainWaterTrapping.java: -------------------------------------------------------------------------------- 1 | // Java implementation of the Rainwater Trapping problem using Two pointer apporach 2 | class RainWaterTrapping { 3 | public static int maxWater(int arr[], int n) 4 | { 5 | int size = n - 1; 6 | 7 | int prev = arr[0]; 8 | 9 | int prev_index = 0; 10 | int water = 0; 11 | int temp = 0; 12 | for (int i = 1; i <= size; i++) { 13 | 14 | if (arr[i] >= prev) { 15 | prev = arr[i]; 16 | prev_index = i; 17 | temp = 0; 18 | } 19 | else { 20 | water += prev - arr[i]; 21 | temp += prev - arr[i]; 22 | } 23 | } 24 | if (prev_index < size) { 25 | water -= temp; 26 | prev = arr[size]; 27 | for (int i = size; i >= prev_index; i--) { 28 | if (arr[i] >= prev) { 29 | prev = arr[i]; 30 | } 31 | else { 32 | water += prev - arr[i]; 33 | } 34 | } 35 | } 36 | return water; 37 | } 38 | public static void main(String[] args) 39 | { 40 | int arr[] = { 0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1, 7, 2, 5 }; 41 | int N = arr.length; 42 | System.out.print(maxWater(arr, N)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/LogIn/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LogIn 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 21 | 22 | 30 |
31 | 32 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/linkedlist/reverselist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | Node* reverse(Node* head) 11 | { 12 | Node* dummy = NULL; 13 | while(head!=NULL) 14 | { 15 | Node* temp = head->next; 16 | head->next = dummy; 17 | dummy = head; 18 | head = temp; 19 | } 20 | return dummy; 21 | } 22 | 23 | int main() 24 | { 25 | Node* head = new Node(); 26 | Node* one = new Node(); 27 | Node* two = new Node(); 28 | Node* three = new Node(); 29 | Node* four = new Node(); 30 | head->val = 5; 31 | one->val = 2; 32 | two->val = 3; 33 | three->val = 1; 34 | four->val = 4; 35 | head->next = one; 36 | one->next = two; 37 | two->next = three; 38 | three->next = four; 39 | four->next = NULL; 40 | Node* temp = head; 41 | while(temp) 42 | { 43 | cout<val<<"->"; 44 | temp = temp->next; 45 | } 46 | cout<<"NULL"<val<<"->"; 51 | newHead = newHead->next; 52 | } 53 | cout<<"NULL"< { 3 | 4 | private T content; 5 | private BinaryTree left; 6 | private BinaryTree right; 7 | 8 | public BinaryNode() { 9 | this(null, null, null); 10 | } 11 | 12 | public BinaryNode(T content) { 13 | this(content, null, null); 14 | } 15 | 16 | public BinaryNode(T content, BinaryTree left, BinaryTree right) { 17 | this.content = content; 18 | this.left = left; 19 | this.right = right; 20 | } 21 | 22 | public T getContent() { 23 | return content; 24 | } 25 | 26 | public void setContent(T content) { 27 | this.content = content; 28 | } 29 | 30 | public BinaryTree getLeft() { 31 | return left; 32 | } 33 | 34 | public void setLeft(BinaryTree left) { 35 | this.left = left; 36 | } 37 | 38 | public BinaryTree getRight() { 39 | return right; 40 | } 41 | 42 | public void setRight(BinaryTree right) { 43 | this.right = right; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/TrappingRainWater_problem.java: -------------------------------------------------------------------------------- 1 | // java program for trapped rain water 2 | 3 | public class TrappedRain { 4 | public static int tappedrain(int height[]) { 5 | int n = height.length; 6 | 7 | 8 | //calculate leftMax boundary -array 9 | int leftmax[] = new int[n]; 10 | leftmax[0] = height[0]; 11 | for(int i=1; i=0 ;i--) { 20 | rightmax[i] = Math.max(height[i], rightmax[i+1]); 21 | } 22 | int trappedwater = 0; 23 | for(int i=0; i= 0: 18 | index = array[i] // place 19 | output[count[index % 10] - 1] = array[i] 20 | count[index % 10] -= 1 21 | i -= 1 22 | 23 | for i in range(0, size): 24 | array[i] = output[i] 25 | 26 | 27 | # Main function to implement radix sort 28 | def radixSort(array): 29 | # Get maximum element 30 | max_element = max(array) 31 | 32 | # Apply counting sort to sort elements based on place value. 33 | place = 1 34 | while max_element // place > 0: 35 | countingSort(array, place) 36 | place *= 10 37 | 38 | 39 | data = [121, 432, 564, 23, 1, 45, 788] 40 | radixSort(data) 41 | print(data) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/URLconn.java: -------------------------------------------------------------------------------- 1 | import java.sql.Connection; 2 | import java.sql.DriverManager; 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.sql.Statement; 6 | 7 | public class ConnectURL { 8 | public static void main(String[] args) { 9 | 10 | // Create a variable for the connection string. 11 | String connectionUrl = "jdbc:sqlserver://:;databaseName=AdventureWorks;user=;password="; 12 | 13 | try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement();) { 14 | String SQL = "SELECT TOP 10 * FROM Person.Contact"; 15 | ResultSet rs = stmt.executeQuery(SQL); 16 | 17 | // Iterate through the data in the result set and display it. 18 | while (rs.next()) { 19 | System.out.println(rs.getString("FirstName") + " " + rs.getString("LastName")); 20 | } 21 | } 22 | // Handle any errors that may have occurred. 23 | catch (SQLException e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/mergesortedarray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector arr1 = {1,4,8,9,11}; 7 | vector arr2 = {2,3,6,7}; 8 | 9 | int size = arr1.size() + arr2.size(); 10 | int gap; 11 | gap = (size + 1)/2; 12 | //int flag = 0; 13 | while(gap>=1) 14 | { 15 | int low = 0; 16 | int high = gap; 17 | while(higharr1[high]) 22 | swap(arr1[low],arr1[high]); 23 | } 24 | else if(low=arr1.size()) 25 | { 26 | if(arr1[low] > arr2[high-arr1.size()]) 27 | { 28 | swap(arr1[low],arr2[high-arr1.size()]); 29 | } 30 | } 31 | else 32 | { 33 | if(arr2[low-arr1.size()]>arr2[high-arr1.size()]) 34 | { 35 | swap(arr2[low-arr1.size()],arr2[high-arr1.size()]); 36 | } 37 | } 38 | low++; 39 | high++; 40 | } 41 | if(gap==1) 42 | break; 43 | gap = (gap+1)/2; 44 | } 45 | for(auto x: arr1) 46 | { 47 | cout< dev-32 3 | import random as r 4 | 5 | EASY = 10 6 | HARD = 5 7 | 8 | 9 | def check_ans(guess, ans): 10 | if guess > ans: 11 | print("Too high.") 12 | elif guess < ans: 13 | print("Too low.") 14 | else: 15 | print("Boom !! your answer is correct.") 16 | 17 | 18 | def difficulty(): 19 | diff = input("Choose a difficulty.Type 'easy' or 'hard': ") 20 | if diff == "easy": 21 | return EASY 22 | else: 23 | return HARD 24 | 25 | 26 | print("WELCOME TO THE GUESSING GAME!!") 27 | print("Think of a number between 1 and 100.") 28 | ans = r.randint(1, 100) 29 | 30 | # print(f"The correct answer is :{ans}") 31 | turns = difficulty() 32 | status = 0 33 | while turns: 34 | print(f"You have {turns} attempts remaining to guess the number!!") 35 | guess = int(input("Make a guess: ")) 36 | 37 | if (guess == ans): 38 | print("Congrats!! you won.") 39 | status = 1 40 | break 41 | else: 42 | check_ans(guess, ans) 43 | turns -= 1 44 | 45 | if status == 0: 46 | print("Sorry!! you lost the game.") 47 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/coffee shop program.py: -------------------------------------------------------------------------------- 1 | class Coffee: 2 | # Constructor 3 | def __init__(self, name, price): 4 | self.name = name 5 | self.price = float(price) 6 | def check_budget(self, budget): 7 | # Check if the budget is valid 8 | if not isinstance(budget, (int, float)): 9 | print('Enter float or int') 10 | exit() 11 | if budget < 0: 12 | print('Sorry you don\'t have money') 13 | exit() 14 | def get_change(self, budget): 15 | return budget - self.price 16 | 17 | def sell(self, budget): 18 | self.check_budget(budget) 19 | if budget >= self.price: 20 | print(f'You can buy the {self.name} coffee') 21 | if budget == self.price: 22 | print('It\'s complete') 23 | else: 24 | print(f'Here is your change {self.get_change(budget)}$') 25 | 26 | exit('Thanks for your transaction') 27 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/reversepair.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | int merge(vector& nums, int low, int mid, int high) 6 | { 7 | int count = 0; 8 | int j = mid + 1; 9 | for(int i=low;i<=mid;i++) 10 | { 11 | while(j<=high and nums[i]> 2*nums[j]) 12 | { 13 | j++; 14 | } 15 | count+=(j-(mid+1)); 16 | } 17 | vector temp; 18 | int i = low; 19 | int k = mid+1; 20 | while(i<=mid and k<=high) 21 | { 22 | if(nums[i]<=nums[k]) 23 | temp.push_back(nums[i++]); 24 | else 25 | temp.push_back(nums[k++]); 26 | } 27 | while(i<=mid) 28 | temp.push_back(nums[i++]); 29 | while(k<=high) 30 | temp.push_back(nums[k++]); 31 | for(int i=low;i<=high;i++) 32 | nums[i]=temp[i-low]; 33 | return count; 34 | } 35 | 36 | int mergesort(vector& nums, int low, int high) 37 | { 38 | if(low>=high) 39 | return 0; 40 | int mid = (low+high)/2; 41 | int count = 0; 42 | count+=mergesort(nums,low,mid); 43 | count+=mergesort(nums,mid+1,high); 44 | count+=merge(nums,low,mid,high); 45 | return count; 46 | } 47 | int main() 48 | { 49 | vector nums = {40,25,19,12,9,6,2}; 50 | cout< 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | int main() 11 | { 12 | Node* head = new Node(); 13 | Node* one = new Node(); 14 | Node* two = new Node(); 15 | Node* three = new Node(); 16 | Node* four = new Node(); 17 | int n = 5; 18 | head->val = 5; 19 | one->val = 2; 20 | two->val = 3; 21 | three->val = 1; 22 | four->val = 4; 23 | head->next = one; 24 | one->next = two; 25 | two->next = three; 26 | three->next = four; 27 | four->next = NULL; 28 | Node* temp = head; 29 | while(temp) 30 | { 31 | cout<val<<"->"; 32 | temp = temp->next; 33 | } 34 | cout<<"NULL"<val = -1; 37 | dummy->next = head; 38 | Node* slow = dummy; 39 | Node* fast = dummy; 40 | for(int i=0;inext; 43 | } 44 | while(fast->next!=NULL) 45 | { 46 | slow = slow->next; 47 | fast = fast->next; 48 | } 49 | slow->next = slow->next->next; 50 | dummy = dummy->next; 51 | while(dummy) 52 | { 53 | cout<val<<"->"; 54 | dummy = dummy->next; 55 | } 56 | cout<<"NULL"< 2 | using namespace std; 3 | 4 | int merge(vector& nums, vector& temp, int low, int mid, int high) 5 | { 6 | int i,j,k; 7 | int count = 0; 8 | i = low; 9 | j = mid; 10 | k = low; 11 | while(i<=mid-1 and j<=high) 12 | { 13 | if(nums[i]<=nums[j]) 14 | { 15 | temp[k++] = nums[i++]; 16 | } 17 | else 18 | { 19 | temp[k++] = nums[j++]; 20 | count+= mid-i; 21 | } 22 | 23 | } 24 | while(i& nums, vector& temp, int low, int high) 38 | { 39 | int mid, count=0; 40 | 41 | if(high>low) 42 | { 43 | mid = (low+high)/2; 44 | count+=mergesort(nums, temp, low, mid); 45 | count+=mergesort(nums, temp, mid+1, high); 46 | count+=merge(nums, temp, low, mid+1, high); 47 | } 48 | return count; 49 | } 50 | int main() 51 | { 52 | vector nums = {5,2,3,4,1}; 53 | vector temp(nums.size()); 54 | int ans = mergesort(nums, temp, 0, nums.size()-1); 55 | cout< 0) { 15 | if ((p & 1) == 1) { 16 | res = res * a; 17 | } 18 | a = a * a; 19 | p >>>= 1; 20 | } 21 | return res; 22 | } 23 | 24 | /** 25 | * Function for testing binary exponentiation 26 | * 27 | * @param a the base 28 | * @param p the exponent 29 | */ 30 | public static void test(int a, int p) { 31 | int res = binPow(a, p); 32 | assert res == (int) Math.pow(a, p) : "Incorrect Implementation"; 33 | System.out.println(a + "^" + p + ": " + res); 34 | } 35 | 36 | /** 37 | * Main Function to call tests 38 | * 39 | * @param args System Line Arguments 40 | */ 41 | public static void main(String[] args) { 42 | // prints 2^15: 32768 43 | test(2, 15); 44 | 45 | // prints 3^9: 19683 46 | test(3, 9); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/DiceRollSimulator.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | import random 3 | 4 | dice = ['\u2680', '\u2681','\u2682','\u2683','\u2684','\u2685',] 5 | 6 | 7 | 8 | 9 | root = tkinter.Tk() 10 | canvas = tkinter.Canvas() 11 | root.title('Dice Roll Simulator') 12 | root.geometry('400x400') 13 | 14 | frame = tkinter.Frame() 15 | frame.pack(pady=20) 16 | 17 | 18 | dice_label = tkinter.Label(frame, text='', font=("Helvetica", 100), fg="black") 19 | dice_label.grid(row=0, column=0, padx=5) 20 | sub_dice_label = tkinter.Label(frame,text="",font=("Helvetica", 20)) 21 | sub_dice_label.grid(row=1,column=0) 22 | 23 | 24 | 25 | def roll(): 26 | def get_number(x): 27 | if x == '\u2680': 28 | return(1) 29 | elif x == '\u2681': 30 | return(2) 31 | elif x == '\u2682': 32 | return(3) 33 | elif x == '\u2683': 34 | return(4) 35 | elif x == '\u2684': 36 | return(5) 37 | elif x == '\u2685': 38 | return(6) 39 | d = random.choice(dice) 40 | sub_d = get_number(d) 41 | dice_label.config(text=d) 42 | sub_dice_label.config(text=sub_d) 43 | 44 | btn = tkinter.Button(root,text="Roll",command=roll,font=("Helvetica",25)) 45 | btn.pack(pady=20) 46 | root.mainloop() -------------------------------------------------------------------------------- /.github/workflows/auto-comment.yml: -------------------------------------------------------------------------------- 1 | name: Auto Comment 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | pull_request: 8 | types: 9 | - opened 10 | 11 | jobs: 12 | run: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Check if it's an issue or pull request 16 | run: | 17 | if [[ ${{ github.event_name }} == 'issues' ]]; then 18 | echo "COMMENT_BODY=@${{ github.event.issue.user.login }} Please Star ⭐️ the repo to earn '**_hacktober-accepted_**' label for the event.\nMeanwhile, if you want to work on this issue, please raise a PR, and we will review and merge it." >> $GITHUB_ENV 19 | else 20 | echo "COMMENT_BODY=@${{ github.event.pull_request.user.login }} Please Star ⭐️ the repo to earn '**_hacktober-accepted_**' label for the event." >> $GITHUB_ENV 21 | fi 22 | shell: bash 23 | 24 | - name: Comment on issue/PR 25 | run: | 26 | echo "Commenting on issue/PR..." 27 | comment_body="${{ env.COMMENT_BODY }}" 28 | echo "$comment_body" | gh issue comment ${{ github.event.issue.number }} --body - 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} 31 | if: ${{ github.event_name == 'issues' || github.event_name == 'pull_request' }} 32 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/Array/major3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | vector nums = {1,1,1,2,3,2,3,2}; 8 | int num1 = INT_MIN; 9 | int num2 = INT_MIN; 10 | int count1=0,count2=0; 11 | for(auto x: nums) 12 | { 13 | if(x==num1) 14 | count1++; 15 | else if(x==num2) 16 | count2++; 17 | else if(count1==0) 18 | { 19 | num1=x; 20 | count1=1; 21 | } 22 | else if(count2==0) 23 | { 24 | num2=x; 25 | count2=1; 26 | } 27 | else 28 | { 29 | count1--; 30 | count2--; 31 | } 32 | } 33 | count1=0; 34 | count2=0; 35 | for(auto x:nums) 36 | { 37 | if(x==num1) 38 | count1++; 39 | if(x==num2) 40 | count2++; 41 | 42 | } 43 | vector ans; 44 | if(count1>nums.size()/3) 45 | cout<nums.size()/3) 47 | cout< 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | int main() 11 | { 12 | Node* head1 = new Node(); 13 | Node* head2 = new Node(); 14 | Node* one = new Node(); 15 | Node* two = new Node(); 16 | Node* three = new Node(); 17 | Node* four = new Node(); 18 | Node* five = new Node(); 19 | Node* six = new Node(); 20 | head1->val = 1; 21 | head2->val = 1; 22 | one->val = 2; 23 | two->val = 3; 24 | three->val = 4; 25 | four->val = 5; 26 | five->val = 8; 27 | six->val = 2; 28 | head1->next = one; 29 | one->next = three; 30 | three->next = four; 31 | head2->next = two; 32 | two->next = four; 33 | four->next = five; 34 | five->next = six; 35 | six->next = NULL; 36 | 37 | Node* temp = head1; 38 | while(temp) 39 | { 40 | cout<val<<"->"; 41 | temp = temp->next; 42 | } 43 | cout<<"NULL"<val<<"->"; 49 | temp = temp->next; 50 | } 51 | cout<<"NULL"<next; 59 | b=b==NULL?head1:b->next; 60 | } 61 | cout<val<.nav-link{ 29 | color:#df271a; 30 | font-weight:700 31 | } 32 | .navbar-light .navbar-nav .nav-link::before{ 33 | background-color:currentColor; 34 | bottom:-1px; 35 | content:""; 36 | height:1px; 37 | left:auto; 38 | right:0; 39 | position:absolute; 40 | -webkit-transition:width .2s ease-in-out; 41 | -o-transition:width .2s ease-in-out; 42 | transition:width .2s ease-in-out; 43 | width:0 44 | } 45 | .navbar-light .navbar-nav .nav-link:hover{ 46 | color:#000 47 | } 48 | .navbar-light .navbar-nav .nav-link:hover::before{ 49 | left:0; 50 | right:auto; 51 | width:100% 52 | } 53 | .nav-link svg{ 54 | width:auto; 55 | height:25px; 56 | vertical-align:text-top 57 | } 58 | .navbar-light .navbar-nav .nav-link:hover{ 59 | color:#dc143c 60 | } 61 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Guessing Game Challenge.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | num = random.randint(1,100) 4 | 5 | print("WELCOME TO GUESS ME!") 6 | print("I'm thinking of a number between 1 and 100") 7 | print("If your guess is more than 10 away from my number, I'll tell you you're COLD") 8 | print("If your guess is within 10 of my number, I'll tell you you're WARM") 9 | print("If your guess is farther than your most recent guess, I'll say you're getting COLDER") 10 | print("If your guess is closer than your most recent guess, I'll say you're getting WARMER") 11 | print("LET'S PLAY!") 12 | 13 | guesses = [0] 14 | 15 | while True: 16 | 17 | guess = int(input("I'm thinking of a number between 1 and 100.\n What is your guess? ")) 18 | 19 | if guess < 1 or guess > 100: 20 | print('OUT OF BOUNDS! Please try again: ') 21 | continue 22 | 23 | if guess == num: 24 | print(f'CONGRATULATIONS, YOU GUESSED IT IN ONLY {len(guesses)} GUESSES!!') 25 | break 26 | 27 | guesses.append(guess) 28 | 29 | if guesses[-2]: 30 | if abs(num-guess) < abs(num-guesses[-2]): 31 | print('WARMER!') 32 | else: 33 | print('COLDER!') 34 | 35 | else: 36 | if abs(num-guess) <= 10: 37 | print('WARM!') 38 | else: 39 | print('COLD!') -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/hashing/4sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector nums = {4,4,1,2,3,4,2,3,2,1,1}; 7 | int target = 9; 8 | vector>ans; 9 | if(nums.size()<4) 10 | return 0; 11 | int n = nums.size(); 12 | sort(nums.begin(), nums.end()); 13 | 14 | for(int i=0;i0 and nums[i]==nums[i-1]) 17 | continue; 18 | for(int j=i+1;ji+1 and nums[j]==nums[j-1]) 21 | continue; 22 | int l = j+1; 23 | int r = n-1; 24 | int x = target - nums[i] - nums[j]; 25 | 26 | while(lj+1 and nums[l]==nums[l-1]) 29 | { 30 | l++; 31 | continue; 32 | } 33 | if(r temp; 41 | temp.push_back(nums[i]); 42 | temp.push_back(nums[j]); 43 | temp.push_back(nums[l]); 44 | temp.push_back(nums[r]); 45 | cout<x) 51 | { 52 | r--; 53 | } 54 | else if(nums[l]+nums[r] 18 | using namespace std; 19 | 20 | void squareSort(vector &arr, vector &ans){ 21 | int n = arr.size(); 22 | int left = 0, right = n-1; 23 | for(int i = n-1; i >= 0; i--){ 24 | if(abs(arr[left]) >= abs(arr[right])) 25 | { 26 | ans[i] = arr[left] * arr[left]; 27 | left++; 28 | } 29 | else{ 30 | ans[i] = arr[right] * arr[right]; 31 | right--; 32 | } 33 | } 34 | } 35 | int main() { 36 | int n; 37 | cin>>n; 38 | vector arr(n); 39 | for(int i = 0; i < n; i++) 40 | cin>>arr[i]; 41 | vector ans(n); 42 | squareSort(arr, ans); 43 | for(auto x: ans) cout< varHeight: 51 | i[1] = random.randrange(-50,5) 52 | i[0] = random.randrange(width) 53 | 54 | pygame.display.flip() 55 | clock.tick(FPS) 56 | 57 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/BestTimeToBuyAndSellStockOne.java: -------------------------------------------------------------------------------- 1 | //Question Link= https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ 2 | 3 | 4 | import java.util.*; 5 | 6 | public class BestTimeToBuyAndSellStockOne{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | int prices[]={1,3,4,2,6,1,6}; 10 | System.out.println(maxProfit(prices)); 11 | } 12 | 13 | 14 | public static int maxProfit(int[] prices) { 15 | Map mp=new HashMap<>(); 16 | return solve(prices,0,true,1,mp); 17 | } 18 | 19 | public static int solve(int price[],int i,boolean canBuy,int count,Map mp){ 20 | 21 | if(i>=price.length || count<=0) return 0; 22 | 23 | String key=i+"!"+canBuy+"!"+count; 24 | 25 | if(mp.containsKey(key)) return mp.get(key); 26 | 27 | if(canBuy){ 28 | 29 | int idle=solve(price,i+1,canBuy,count,mp); 30 | int buying=(-1*price[i])+solve(price,i+1,false,count,mp); 31 | mp.put(key,Math.max(idle,buying)); 32 | return mp.get(key); 33 | 34 | }else{ 35 | 36 | int idle=solve(price,i+1,canBuy,count,mp); 37 | int selling=price[i]+solve(price,i+1,true,count-1,mp); 38 | mp.put(key,Math.max(idle,selling)); 39 | return mp.get(key); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/Threadmethods.java: -------------------------------------------------------------------------------- 1 | class A extends Thread // uses of yield(), stop(), sleep() methods 2 | { 3 | public void run() 4 | { 5 | for(int i=1;i<=5;i++) 6 | { 7 | if (i==1) yield(); 8 | System.out.println("\tFrom Thread A : i="+i); 9 | } 10 | System.out.println("Exit from A"); 11 | } 12 | } 13 | class B extends Thread 14 | { 15 | public void run() 16 | { 17 | for(int j=1;j<=5;j++) 18 | { 19 | System.out.println("\tFrom Thread B : j="+j); 20 | if (j==3) stop(); 21 | } 22 | System.out.println("Exit from B"); 23 | } 24 | } 25 | class C extends Thread 26 | { 27 | public void run() 28 | { 29 | for(int k=1;k<=5;k++) 30 | { 31 | System.out.println("\tFrom Thread C : k="+j); 32 | if (k==1) 33 | try 34 | { 35 | sleep(1000); 36 | } 37 | catch (Exception e) 38 | { 39 | } 40 | } 41 | System.out.println("Exit from C"); 42 | } 43 | } 44 | class ThreadMethods 45 | { 46 | public static void main (String args[]) 47 | { 48 | A threadA = new A(); 49 | B threadB = new B(); 50 | C threadC = new C(); 51 | System.out.println("Start thread A"); 52 | threadA.start(); 53 | System.out.println("Start thread B"); 54 | threadB.start(); 55 | System.out.println("Start thread C"); 56 | threadC.start(); 57 | System.out.println("End of main thread") 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Golang Programs/countdown_timer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | type countdown struct { 11 | t int 12 | d int 13 | h int 14 | m int 15 | s int 16 | } 17 | 18 | func getTimeRemaining(t time.Time) countdown { 19 | currentTime := time.Now() 20 | difference := t.Sub(currentTime) 21 | 22 | total := int(difference.Seconds()) 23 | days := int(total / (60 * 60 * 24)) 24 | hours := int(total / (60 * 60) % 24) 25 | minutes := int(total/60) % 60 26 | seconds := int(total % 60) 27 | 28 | return countdown{ 29 | t: total, 30 | d: days, 31 | h: hours, 32 | m: minutes, 33 | s: seconds, 34 | } 35 | } 36 | 37 | func main() { 38 | deadline := flag.String("deadline", "", "The deadline for the countdown timer in RFC3339 format (e.g. 2019-12-25T15:00:00+01:00)") 39 | flag.Parse() 40 | 41 | if *deadline == "" { 42 | flag.PrintDefaults() 43 | os.Exit(1) 44 | } 45 | 46 | v, err := time.Parse(time.RFC3339, *deadline) 47 | if err != nil { 48 | fmt.Println(err) 49 | os.Exit(1) 50 | } 51 | 52 | for range time.Tick(1 * time.Second) { 53 | timeRemaining := getTimeRemaining(v) 54 | 55 | if timeRemaining.t <= 0 { 56 | fmt.Println("Countdown reached!") 57 | break 58 | } 59 | 60 | fmt.Printf("Days: %d Hours: %d Minutes: %d Seconds: %d\n", timeRemaining.d, timeRemaining.h, timeRemaining.m, timeRemaining.s) 61 | } 62 | } -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/QuickSort.py: -------------------------------------------------------------------------------- 1 | #Quick Sort using Python. 2 | def quickSort(alist): 3 | quickSortHelper(alist,0,len(alist)-1) 4 | def quickSortHelper(alist,first,last): 5 | if first= pivotvalue and rightmark >= leftmark: 18 | rightmark = rightmark -1 19 | if rightmark < leftmark: 20 | done = True 21 | else: 22 | temp = alist[leftmark] 23 | alist[leftmark] = alist[rightmark] 24 | alist[rightmark] = temp 25 | temp = alist[first] 26 | alist[first] = alist[rightmark] 27 | alist[rightmark] = temp 28 | return rightmark 29 | # Enter the list of numbers to be sorted. 30 | n=int(input("Enter the number of elements: ")) 31 | alist=[] 32 | for i in range(0, n): 33 | x=int(input("Enter the element: ")) 34 | alist.append(x) 35 | quickSort(alist) # Calling the function. 36 | print(alist) #Printing the Sorted List. 37 | 38 | # Aashu Kumar -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Maximize_Power.java: -------------------------------------------------------------------------------- 1 | package CodeChef; 2 | import java.util.*; 3 | public class Maximize_Power { 4 | public static void main(String[] args) { 5 | List arr = new ArrayList(); 6 | arr.add(2); 7 | arr.add(4); 8 | arr.add(2); 9 | arr.add(1); 10 | arr.add(6); 11 | List power = new ArrayList(); 12 | power.add(4); 13 | power.add(1); 14 | power.add(1); 15 | power.add(3); 16 | 17 | int sum=0; 18 | List a = new ArrayList(); 19 | for(int i=0; i set = new HashSet(); 48 | for(Integer n : a){ 49 | set.add(n); 50 | } 51 | int max = Collections.max(set); 52 | a = new ArrayList(set); 53 | System.out.println(a); 54 | System.out.println(a.get(a.size()-2)+max); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/linkedlist/merge2list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | int main() 11 | { 12 | Node* head1 = new Node(); 13 | Node* head2 = new Node(); 14 | Node* one = new Node(); 15 | Node* two = new Node(); 16 | Node* three = new Node(); 17 | Node* four = new Node(); 18 | head1->val = 1; 19 | head2->val = 1; 20 | one->val = 2; 21 | two->val = 3; 22 | three->val = 4; 23 | four->val = 5; 24 | head1->next = one; 25 | one->next = three; 26 | head2->next = two; 27 | two->next = four; 28 | three->next = NULL; 29 | four->next = NULL; 30 | Node* temp = head1; 31 | while(temp) 32 | { 33 | cout<val<<"->"; 34 | temp = temp->next; 35 | } 36 | cout<<"NULL"<val<<"->"; 42 | temp = temp->next; 43 | } 44 | cout<<"NULL"<val>head2->val) 48 | { 49 | swap(head1,head2); 50 | } 51 | Node* res = head1; 52 | 53 | while(head1!=NULL and head2!=NULL) 54 | { 55 | Node* tmp = NULL; 56 | while(head1!=NULL and head1->val<=head2->val) 57 | { 58 | tmp = head1; 59 | head1 = head1->next; 60 | } 61 | tmp->next = head2; 62 | swap(head1,head2); 63 | } 64 | 65 | while(res!=NULL) 66 | { 67 | cout<val<<"->"; 68 | res = res->next; 69 | } 70 | cout<<"NULL"< 0): 29 | 30 | # Print front of queue and 31 | # remove it from queue 32 | print(queue[0].data, end = " ") 33 | node = queue.pop(0) 34 | 35 | # Enqueue left child 36 | if node.left is not None: 37 | queue.append(node.left) 38 | 39 | # Enqueue right child 40 | if node.right is not None: 41 | queue.append(node.right) 42 | 43 | 44 | # Driver Program to test above function 45 | root = Node(1) 46 | root.left = Node(2) 47 | root.right = Node(3) 48 | root.left.left = Node(4) 49 | root.left.right = Node(5) 50 | root.right.left = Node(6) 51 | root.right.right = Node(7) 52 | root.right.left.right = Node(8) 53 | root.right.right.right = Node(9) 54 | 55 | print("Level Order Traversal of binary tree is -") 56 | printLevelOrder(root) 57 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Raspberrypi_LED.py: -------------------------------------------------------------------------------- 1 | #Created by Akshar Singh 2 | #IMPORTANT - CAN ONLY WORK ON RASPBERRY PI OPERATING SYSTEM 3 | import RPi.GPIO as GPIO 4 | from time import sleep 5 | 6 | #GPIO.setwarnings(False) 7 | GPIO.setmode(GPIO.BOARD) #use phyical pin numbering 8 | 9 | c = 0 10 | #Light on 11 | def lighton(): 12 | GPIO.setup(8,GPIO.OUT,initial=GPIO.LOW)#spicifies the pin number to be the output pin 13 | #initial value is low(OFF) 14 | c=c+1 15 | while True: 16 | GPIO.output(8,GPIO.HIGH) 17 | 18 | #Light off 19 | def lightoff(): 20 | if(c==1): 21 | GPIO.output(8,GPIO.LOW) 22 | 23 | #Blinking 24 | def lightblink(): 25 | GPIO.setup(8,GPIO.OUT,initial=GPIO.LOW) 26 | while True: #running forever 27 | GPIO.output(8,GPIO.HIGH) #Turn on 28 | sleep(1) 29 | GPIO.output(8,GPIO.LOW) #Turn off 30 | sleep(1) 31 | #light is on for 1 sec and then gets off for 1 second 32 | 33 | #Control Brightness 34 | def brightness(): 35 | #GPIO.PWM(PIN NUMBER,MAX BRIGHTNESS) 36 | GPIO.setup(8,GPIO.OUT,initial=GPIO.HIGH) 37 | P = GPIO.PWM(8,100) #PWM - Pulse width modulation(reducing avg power delivered by an electrical signal) 38 | P.start(0) #LED starts with 0 % brightness 39 | 40 | while True: 41 | #LED's brightness is increasing gradually 42 | for i in range(100): 43 | P.start(i) 44 | sleep(0.5) 45 | #LED's brightness is decreasing gradually 46 | for i in range(100): 47 | P.start(100-i) 48 | sleep(0.5) 49 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/Toggle_Bulbs.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Toggle The Bulbs 4 | 5 | There are N bulbs that are initially off. In the first round, you turn ON all the bulbs, 6 | then you turn off every second bulb in the second round. 7 | On the third round, you toggle every third bulb 8 | (turning ON if it's OFF or vice-versa). 9 | For the Ith round, you toggle every Ith bulb. 10 | For the Nth round, you only toggle the last bulb. 11 | Return the number of bulbs that are ON after the N rounds. 12 | Example 1: 13 | Input: 14 | 3 15 | Output: 16 | 1 17 | Explanation: 18 | At first, the status of the three bulbs is [OFF, OFF, OFF]. 19 | After the first round, the status of the three bulbs is [ON, ON, ON]. 20 | After the second round, the status of the three bulbs is [ON, OFF, ON]. 21 | After the third round, the status of the three bulbs is [ON, OFF, OFF]. 22 | So you should return 1, because there is only one bulb that is ON. 23 | Example 2: 24 | Input: 25 | 1 26 | Output: 27 | 1 28 | Explanation: 29 | You should return 1, because there is only one bulb. 30 | */ 31 | // SOlultion: SQRT(N) <--- is the Answer 32 | import java.util.*; 33 | public class Toggle_Bulbs { 34 | public static void main(String[] args) { 35 | Scanner sc = new Scanner(System.in); 36 | int n = sc.nextInt(); 37 | int[] bulbs= new int[n]; 38 | 39 | for(int i=0;i 0 and not inside(balls[0]): 52 | balls.pop(0) 53 | 54 | if not inside(bird): 55 | draw(False) 56 | return 57 | 58 | for ball in balls: 59 | if abs(ball - bird) < 15: 60 | draw(False) 61 | return 62 | 63 | draw(True) 64 | ontimer(move, 50) 65 | 66 | 67 | setup(420, 420, 370, 0) 68 | hideturtle() 69 | up() 70 | tracer(False) 71 | onscreenclick(tap) 72 | move() 73 | done() 74 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/InfiniteSortedArray.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class InfiniteSortedArray { 4 | public static void main(String[] args) { 5 | int[] arr = { 3, 5, 7, 9, 10, 13, 27, 90, 200, 300 }; 6 | int target = 10; 7 | 8 | System.out.println(ans(arr, target)); 9 | } 10 | 11 | static int ans(int[] arr, int target) { 12 | // first find the box 13 | // first start with a box of size 2 14 | int start = 0; 15 | int end = 1; 16 | 17 | // condition for the target to lie in the range 18 | while (target > arr[end]) { 19 | int newstart = end + 1; 20 | end = end + (end - start + 1) * 2; 21 | start = newstart; 22 | 23 | } 24 | return binarysearch(arr, target, start, end); 25 | } 26 | 27 | static int binarysearch(int[] arr, int target, int start, int end) { 28 | while (start <= end) { 29 | // finding the middle element 30 | // int mid = (start + end) / 2 not using this because mmight be the integer 31 | // exceeds the java capacity 32 | int mid = start + (end - start) / 2; 33 | if (target < arr[mid]) { 34 | end = mid - 1; 35 | } else if (target > arr[mid]) { 36 | start = mid + 1; 37 | } else { 38 | // answer found 39 | return mid; 40 | } 41 | } 42 | return -1; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/gui.java: -------------------------------------------------------------------------------- 1 | import javafx.application.Application; 2 | import javafx.event.ActionEvent; 3 | import javafx.event.EventHandler; 4 | import javafx.geometry.Insets; 5 | import javafx.scene.Scene; 6 | import javafx.scene.control.Button; 7 | import javafx.scene.control.TextField; 8 | import javafx.scene.layout.BorderPane; 9 | import javafx.scene.layout.VBox; 10 | import javafx.stage.Stage; 11 | 12 | public class driverClass extends Application{ 13 | 14 | public static void main(String[] args) { 15 | // TODO Auto-generated method stub 16 | launch(args); 17 | } 18 | 19 | @Override 20 | public void start(Stage primaryStage) throws Exception { 21 | // TODO Auto-generated method stub 22 | primaryStage.setTitle("Open Source For You - First program"); 23 | TextField textField = new TextField(); 24 | Button btn = new Button("Click me to reveal the above text"); 25 | btn.setOnAction(new EventHandler() { 26 | 27 | @Override 28 | public void handle(ActionEvent event) { 29 | // TODO Auto-generated method stub 30 | System.out.println("Entered text is " + textField.getText()); 31 | textField.clear(); 32 | } 33 | }); 34 | BorderPane pane = new BorderPane(); 35 | pane.setPadding(new Insets(70)); 36 | VBox paneCenter = new VBox(); 37 | paneCenter.setSpacing(10); 38 | pane.setCenter(paneCenter); 39 | paneCenter.getChildren().add(textField); 40 | paneCenter.getChildren().add(btn); 41 | Scene scene= new Scene(pane, 400, 200); 42 | primaryStage.setScene(scene); 43 | primaryStage.show(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /scripts/scroll.js: -------------------------------------------------------------------------------- 1 | window.onscroll = scrollFunc; 2 | var scrollButton = document.getElementById('backToTop') 3 | 4 | function scrollFunc() { 5 | if (document.body.scrollTop > 150 || document.documentElement.scrollTop > 150) { 6 | scrollButton.style.display = "block" 7 | } else { 8 | scrollButton.style.display = "none" 9 | } 10 | } 11 | scrollButton.onclick = function() { 12 | scrollButton.classList.add('startscrolling') 13 | scrollTo(document.documentElement, 0, 1250, function() { 14 | scrollButton.classList.remove('startscrolling') 15 | }); 16 | } 17 | scrollButton.onmousedown = function() { 18 | scrollButton.classList.add("mousedown") 19 | } 20 | scrollButton.onmouseup = function(){ 21 | scrollButton.classList.remove("mousedown") 22 | } 23 | function scrollTo(element, to, duration, callback) { 24 | var start = element.scrollTop, 25 | change = (to - start), 26 | currentTime = 0, 27 | increment = 20 28 | var animateScroll = function() { 29 | currentTime += increment 30 | var val = Math.easeInOutQuad(currentTime, start, change, duration) 31 | element.scrollTop = val 32 | if (currentTime < duration) { 33 | setTimeout(animateScroll,increment) 34 | } else if(callback && typeof callback === 'function'){ 35 | callback() 36 | } 37 | } 38 | animateScroll() 39 | } 40 | Math.easeInOutQuad = function(t, b, c, d) { 41 | t /= d/2 42 | if (t < 1) return (c/2*t*t) + b 43 | t-- 44 | return -c/2 * (t*(t-2) - 1) + b 45 | } 46 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Guessthenumber.py: -------------------------------------------------------------------------------- 1 | import random 2 | input('==================PRESS ENTER TO START THE GAME==================',end='\n\n\n\n\n') 3 | 4 | 5 | 6 | 7 | 8 | print(' | ||||||||||| | | |||||||| ||||||||| ||||||||| =================') 9 | print(' | | | | \\ \\ \\ =============== ===============') 10 | print(' | | /|||| | | |||||| \\ \\ ======================') 11 | print(' | |_____|___| | / // \\\\ \\\\= ---KHUSHANK ===================') 12 | print(' | |_________ ||||||/ |||||||| ||||||||| |||||||||| ================================== ', end='\n\n') 13 | 14 | points = 0 15 | while True: 16 | Guess = int(input('Guess a number between 1 and 60 :', end='\r')) 17 | num = int(random.random()*61) 18 | points+=abs(Guess - num) 19 | print(f'Actual number is {num}. You are off by {abs(Guess-num)}\nyour current score is {points}'end='\r') 20 | ask = input('do you want to play more(y/n): ', end='\r') 21 | if ask == 'n':break 22 | 23 | #HIGH SCORE 24 | HIGH = open("HIGH SCORE.txt") 25 | highscore = HIGH.readlines() 26 | highscore.append('0') 27 | HIGH.close() 28 | 29 | highscore = max(int(highscore[0]), points) 30 | 31 | HIGH = open("HIGH SCORE.txt", "w") 32 | HIGH.write(highscore) 33 | HIGH.close() 34 | print(f'Your score is: {points}\nHIGH SCORE: {highscore}') 35 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/port_scanner.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Author: smit-sms 3 | 'pip install pyfiglet' to see the ascii banner 4 | 5 | USAGE 6 | - Run the script by 'python port_scanner.py ' 7 | - Replace the with the URL of your choice, for eg. 'python port_scanner.py 127.0.0.1' 8 | ''' 9 | 10 | # Importing the libraries 11 | import pyfiglet 12 | import sys 13 | import socket 14 | from datetime import datetime 15 | 16 | # Printing the Ascii Banner 17 | ascii_banner = pyfiglet.figlet_format("PORT SCANNER") 18 | print(ascii_banner) 19 | 20 | # Defining a target 21 | if len(sys.argv) == 2: 22 | # Translate hostname to IPv4 Address 23 | target = socket.gethostbyname(sys.argv[1]) 24 | else: 25 | print("Invalid amount of Argument") 26 | 27 | print(" -" * 50) 28 | print(" Scanning Target: " + target) 29 | print(" Scanning started at: " + str(datetime.now())) 30 | print(" -" * 50) 31 | 32 | try: 33 | # Recursively scan ports between 1 to 65,535 34 | for port in range(1, 65535): 35 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 36 | socket.setdefaulttimeout(1) 37 | 38 | # Returns an error indicator 39 | result = s.connect_ex((target,port)) 40 | if result == 0: 41 | print("\nPort {} is open.".format(port)) 42 | s.close() 43 | 44 | except KeyboardInterrupt: 45 | print("\n Exiting Program.") 46 | sys.exit() 47 | except socket.gaierror: 48 | print("\n Hostname Could Not Be Resolved. Please try again with other Hostname.") 49 | sys.exit() 50 | except socket.error: 51 | print("\n Server not responding. Please try again after sometime.") 52 | sys.exit() 53 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/BMI Calculator.py: -------------------------------------------------------------------------------- 1 | 2 | #input height 3 | a= int(input((" Height in 1.inches or 2. feet and inches or 3.centimeters? choose and type 1 or 2 or 3 ->"))) 4 | 5 | if a==1: 6 | Height = float(input(" Enter your height: ")) 7 | Height*=2.54 8 | elif ( a==2 ): 9 | Height_1 = str(input(" Enter in this format: 5'4 or foot'inches ->" )) 10 | Height = float(Height_1[0]) *12 *2.54 + float(Height_1[2]) *2.54 11 | 12 | 13 | #input weight 14 | b= int( input (" Weight in 1.kg or 2.pounds? choose and type 1 or 2 ->")) 15 | 16 | Weight = float( input(" Enter your Weight-> ")) 17 | if b==2: 18 | Weight*=0.453592 19 | 20 | #convert height into metres 21 | Height = Height / 100 22 | 23 | #calculate BMI 24 | BMI = Weight / (Height*Height) 25 | 26 | #printing BMI 27 | print(f"Your Body Mass Index is: {BMI}") 28 | 29 | #printing results 30 | if( BMI > 0): 31 | if( BMI <= 16 ): 32 | print("You are severely underweight") 33 | elif( BMI <= 17 ): 34 | print("You are moderately underweight") 35 | elif( BMI <= 18.5 ): 36 | print("You are mildly underweight") 37 | elif ( BMI <= 25 ): 38 | print("You are healthy") 39 | elif ( BMI <= 30 ): 40 | print("You are overweight") 41 | elif ( BMI <= 35 ): 42 | print("You belong to obesity class I") 43 | elif ( BMI <= 40 ): 44 | print("You belong to obesity class II") 45 | else: 46 | print("You belong to obesity class III") 47 | else: 48 | print("Enter valid details") 49 | 50 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/C++ Programs/linkedlist/listCycle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | 11 | int main() 12 | { 13 | 14 | Node* head = new Node(); 15 | Node* one = new Node(); 16 | Node* two = new Node(); 17 | Node* three = new Node(); 18 | Node* four = new Node(); 19 | head->val = 5; 20 | one->val = 2; 21 | two->val = 3; 22 | three->val = 1; 23 | four->val = 4; 24 | head->next = one; 25 | one->next = two; 26 | two->next = three; 27 | three->next = four; 28 | four->next = two; 29 | 30 | if (head == NULL || head->next == NULL) 31 | { 32 | cout<<"No cycle"<next; 42 | if (secondp->next == NULL) 43 | { 44 | cout<<"No cycle"<next->next; 48 | if (firstp == secondp) { isCycle = true; break; } 49 | } 50 | 51 | if(!isCycle) 52 | { 53 | cout<<"No cycle"<next; 59 | secondp = secondp->next; 60 | } 61 | 62 | cout<val< 2 | using namespace std; 3 | 4 | class Node { 5 | public: 6 | int val; 7 | Node* next; 8 | }; 9 | 10 | int main() 11 | { 12 | Node* head1 = new Node(); 13 | Node* head2 = new Node(); 14 | Node* one = new Node(); 15 | Node* two = new Node(); 16 | Node* three = new Node(); 17 | Node* four = new Node(); 18 | Node* five = new Node(); 19 | head1->val = 7; 20 | head2->val = 3; 21 | one->val = 5; 22 | two->val = 8; 23 | three->val = 9; 24 | four->val = 1; 25 | five->val = 6; 26 | head1->next = one; 27 | one->next = three; 28 | head2->next = two; 29 | two->next = four; 30 | three->next = NULL; 31 | four->next = five; 32 | five->next = NULL; 33 | Node* temp = head1; 34 | while(temp) 35 | { 36 | cout<val<<"->"; 37 | temp = temp->next; 38 | } 39 | cout<<"NULL"<val<<"->"; 45 | temp = temp->next; 46 | } 47 | cout<<"NULL"<val; 58 | head1 = head1->next; 59 | } 60 | if(head2) 61 | { 62 | sum+=head2->val; 63 | head2 = head2->next; 64 | } 65 | sum+=carry; 66 | carry = sum/10; 67 | sum%=10; 68 | Node* new_node = new Node(); 69 | new_node->val = sum; 70 | temp->next = new_node; 71 | temp = temp->next; 72 | } 73 | 74 | dummy = dummy->next; 75 | while(dummy!=NULL) 76 | { 77 | cout<val<<"->"; 78 | dummy = dummy->next; 79 | } 80 | cout<<"NULL"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | vector> matrix = {{1,0,1},{1,1,0},{1,1,1}}; 7 | int fr =0, fc= 0; 8 | for(int i=0;i height: 25 | # Calculate the ratio 26 | ratio = height/width 27 | # Resize the image 28 | img = img.resize((Resolution, int(Resolution*ratio)), Image.Resampling.LANCZOS) 29 | # Crop the image 30 | img = img.crop((0, 0, Resolution, Resolution)) 31 | # If height is greater than width 32 | elif height > width: 33 | # Calculate the ratio 34 | ratio = width/height 35 | # Resize the image 36 | img = img.resize((int(Resolution*ratio), Resolution), Image.Resampling.LANCZOS) 37 | # Crop the image 38 | img = img.crop((0, 0, Resolution, Resolution)) 39 | # If width and height are equal 40 | else: 41 | # Resize the image 42 | img = img.resize((Resolution, Resolution), Image.Resampling.LANCZOS) 43 | # Save the image 44 | img.save(file) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/java/queue/ArrayQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package queue; 7 | 8 | /** 9 | * 10 | * @author Zohaib Hassan Soomro 11 | */ 12 | public class ArrayQueue implements Queue { 13 | 14 | private int size; 15 | private Object array[]; 16 | 17 | public ArrayQueue(int capacity) { 18 | array = new Object[capacity]; 19 | } 20 | 21 | @Override 22 | public Object first() { 23 | if (this.isEmpty()) { 24 | throw new IllegalStateException("Queue is empty!"); 25 | } 26 | return array[0]; 27 | } 28 | 29 | @Override 30 | public Object remove() { 31 | if (this.isEmpty()) { 32 | throw new IllegalStateException("Queue is empty!"); 33 | } 34 | Object obj = array[0]; 35 | System.arraycopy(array, 1, array, 0, size); 36 | array[--size] = null; 37 | return obj; 38 | } 39 | 40 | @Override 41 | public void add(Object obj) { 42 | if (size == this.array.length) { 43 | resizeArray(); 44 | } 45 | array[size++] = obj; 46 | } 47 | 48 | @Override 49 | public int size() { 50 | return size; 51 | } 52 | 53 | @Override 54 | public boolean isEmpty() { 55 | return size == 0; 56 | } 57 | 58 | public void resizeArray() { 59 | Object[] array2 = this.array; 60 | this.array = new Object[2 * size]; 61 | System.arraycopy(array2, 0, this.array, 0, array2.length); 62 | } 63 | 64 | public static void main(String[] args) { 65 | ArrayQueue queue = new ArrayQueue(2); 66 | queue.add(5); 67 | queue.add(50); 68 | queue.add("Hello!"); 69 | System.out.println(queue.remove()); 70 | System.out.println(queue.remove()); 71 | System.out.println(queue.first()); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contribution Rules📚: 3 | 4 | - You are allowed to make pull requests that break the rules. We just merge it ;) 5 | - Do NOT add any build steps e.g npm install (we want to keep this a simple static site) 6 | - Do NOT remove other content. 7 | - Styling/code can be pretty, ugly or stupid, big or small as long as it works 8 | - Add your name to the contributorsList file 9 | - Try to keep pull requests small to minimize merge conflicts 10 | 11 | 12 | ## Getting Started 🤩🤗: 13 | 14 | - Fork this repo (button on top) 15 | - Clone on your local machine 16 | 17 | ```terminal 18 | git clone https://github.com/fineanmol/Hacktoberfest2022.git 19 | ``` 20 | - Navigate to project directory. 21 | ```terminal 22 | cd Hacktoberfest2022 23 | ``` 24 | 25 | - Create a new Branch 26 | 27 | ```markdown 28 | git checkout -b my-new-branch 29 | ``` 30 | - Add your Name to `contributors/contributorsList.js` 31 | ```markdown 32 | git add . 33 | ``` 34 | - Commit your changes. 35 | 36 | ```markdown 37 | git commit -m "Relevant message" 38 | ``` 39 | - Then push 40 | ```markdown 41 | git push origin my-new-branch 42 | ``` 43 | 44 | 45 | - Create a new pull request from your forked repository 46 | 47 |
48 | 49 | ## Avoid Conflicts {Syncing your fork} 50 | 51 | An easy way to avoid conflicts is to add an 'upstream' for your git repo, as other PR's may be merged while you're working on your branch/fork. 52 | 53 | ```terminal 54 | git remote add upstream https://github.com/fineanmol/Hacktoberfest2022 55 | ``` 56 | 57 | You can verify that the new remote has been added by typing 58 | ```terminal 59 | git remote -v 60 | ``` 61 | 62 | To pull any new changes from your parent repo simply run 63 | ```terminal 64 | git merge upstream/master 65 | ``` 66 | 67 | This will give you any eventual conflicts and allow you to easily solve them in your repo. It's a good idea to use it frequently in between your own commits to make sure that your repo is up to date with its parent. 68 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/Edge.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Objects; 3 | 4 | /** 5 | * 6 | * @author Santiago Tumbaco 7 | */ 8 | public class Edge { 9 | 10 | private Vertex origen; 11 | private Vertex destino; 12 | private E data; 13 | private int peso; 14 | 15 | public Edge(Vertex origen, Vertex destino, E data, int peso){ 16 | this.origen = origen; 17 | this.destino = destino; 18 | this.data = data; 19 | this.peso = peso; 20 | } 21 | 22 | public Vertex getOrigen() { 23 | return origen; 24 | } 25 | 26 | public void setOrigen(Vertex origen) { 27 | this.origen = origen; 28 | } 29 | 30 | public Vertex getDestino() { 31 | return destino; 32 | } 33 | 34 | public void setDestino(Vertex destino) { 35 | this.destino = destino; 36 | } 37 | 38 | public int getPeso() { 39 | return peso; 40 | } 41 | 42 | public void setPeso(int peso) { 43 | this.peso = peso; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if(!(o instanceof Edge)) 49 | return false; 50 | 51 | Edge edge = (Edge) o; 52 | 53 | if(edge.getOrigen().getData().equals(origen.getData()) && 54 | edge.getDestino().getData().equals(destino.getData())) 55 | return true; 56 | 57 | return false; 58 | } 59 | 60 | @Override 61 | public int hashCode() { 62 | int hash = 7; 63 | hash = 73 * hash + Objects.hashCode(this.origen); 64 | hash = 73 * hash + Objects.hashCode(this.destino); 65 | hash = 73 * hash + Objects.hashCode(this.data); 66 | hash = 73 * hash + this.peso; 67 | return hash; 68 | } 69 | 70 | @Override 71 | public String toString(){ 72 | return String.format("(%s, %s, %s, %d)",origen, destino, data, peso); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Zoom_automation.py: -------------------------------------------------------------------------------- 1 | # Here we will make a Zoom automation system 2 | # Replace all the url with the appropriate url of the images in your file explorer. 3 | 4 | import os 5 | import pyautogui 6 | import pandas as pd 7 | import time 8 | from datetime import datetime 9 | 10 | 11 | 12 | def signIn(meeting_id, password): 13 | 14 | #Opening Zoom application 15 | os.startfile(r"C:\Users\ratul\Desktop\PICS\Zoom") 16 | time.sleep(2) 17 | 18 | 19 | # Now we operate the button to join a meeting 20 | join = pyautogui.locateCenterOnScreen("Zoom-Automation\zoom_join1.png") #Replace the zoom button url with the url in your machine. 21 | pyautogui.moveTo(join) 22 | pyautogui.click() 23 | 24 | 25 | 26 | 27 | # meeting id 28 | meetingidbtn = pyautogui.locateCenterOnScreen("Zoom-Automation\meetingid.jpg") 29 | pyautogui.moveTo(meetingidbtn) 30 | pyautogui.write(meeting_id) 31 | time.sleep(1) 32 | 33 | #enter 34 | pyautogui.press('enter') 35 | 36 | 37 | #passcode blank 38 | passcode= pyautogui.locateCenterOnScreen("Zoom-Automation\passcode.jpg") 39 | pyautogui.moveTo(passcode) 40 | pyautogui.write(password) 41 | time.sleep(1) 42 | 43 | #enter 44 | pyautogui.press('enter') 45 | 46 | 47 | #Read excel sheet 48 | df = pd.read_excel('Zoom-Automation\zoom1.xlsx') #df stands for data frame 49 | 50 | 51 | while True: 52 | # Would be checking the date time continiusly in an infinite loop 53 | 54 | now = datetime.now().strftime("%H:%M") #will be looking at the Date and only hours and minutes. 55 | 56 | if now in str(df['Timings']): 57 | 58 | # for iterating 59 | mylist=df["Timings"] 60 | mylist=[i.strftime("%H:%M") for i in mylist] 61 | c= [i for i in range(len(mylist)) if mylist[i]==now] 62 | row = df.loc[c] 63 | 64 | # row = df.loc[df['Timings'] == now] #loc used to locate specific rows 65 | 66 | id = str(row.iloc[0,1]) 67 | password = str(row.iloc[0,2]) 68 | 69 | signIn(id, password) 70 | time.sleep(50) 71 | print('signed in !!') 72 | 73 | repeat(password) -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/AnagramTechniques.java: -------------------------------------------------------------------------------- 1 | package Arrays; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class AnagramTechniques { 8 | 9 | 10 | 11 | public static boolean isAnnagramUsingFrequencyCounter(String s, String t) { 12 | // You can use py counters -- return Counter(s) == Counter(t) 13 | 14 | } 15 | public static boolean isAnagramUsingSorting(String s, String t) { 16 | if (s.length() != t.length()) return false; 17 | // You can use py counters -- return Counter(s) == Counter(t) 18 | // You can also use sroting -- sorted(s) == sorted(t) -- PY || O(nlogn) /O(1) 19 | char[] str1 = s.toCharArray(); 20 | char[] str2 = t.toCharArray(); 21 | Arrays.sort(str1); 22 | Arrays.sort(str2); 23 | return Arrays.equals(str1, str2); 24 | } 25 | 26 | public static boolean isAnagramIUsingHash(String s, String t) { 27 | 28 | if (s.length() != t.length()) return false; 29 | // You can use py counters -- return Counter(s) == Counter(t) 30 | 31 | // Use hashing 32 | Map smap = new HashMap(); 33 | Map tmap = new HashMap(); 34 | 35 | String sArray[] = s.split(""); 36 | String tArray[] = t.split(""); 37 | 38 | for (int i = 0; i < sArray.length; i++) { 39 | 40 | if (smap.containsKey(sArray[i])) { 41 | smap.put(sArray[i], smap.get(sArray[i]) + 1); 42 | } else { 43 | smap.put(sArray[i], 1); 44 | } 45 | 46 | if (tmap.containsKey(tArray[i])) { 47 | tmap.put(tArray[i], tmap.get(tArray[i]) + 1); 48 | } else { 49 | tmap.put(tArray[i], 1); 50 | } 51 | } 52 | 53 | for (String ch : smap.keySet()) { 54 | if (smap.get(ch) != tmap.get(ch)) return false; 55 | } 56 | 57 | return true; 58 | } 59 | 60 | public static void main(String[] args) { 61 | String s = "anagramz", t = "managraq"; 62 | System.out.println(isAnagramIUsingHash(s, t)); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/LogIn/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin: 0; 3 | padding: 0; 4 | display: flex; 5 | justify-content: center; 6 | align-items: center; 7 | min-height: 100vh; 8 | font-family: 'Jost', sans-serif; 9 | background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e); 10 | } 11 | .main{ 12 | width: 350px; 13 | height: 500px; 14 | background: red; 15 | overflow: hidden; 16 | background: url("https://doc-08-2c-docs.googleusercontent.com/docs/securesc/68c90smiglihng9534mvqmq1946dmis5/fo0picsp1nhiucmc0l25s29respgpr4j/1631524275000/03522360960922298374/03522360960922298374/1Sx0jhdpEpnNIydS4rnN4kHSJtU1EyWka?e=view&authuser=0&nonce=gcrocepgbb17m&user=03522360960922298374&hash=tfhgbs86ka6divo3llbvp93mg4csvb38") no-repeat center/ cover; 17 | border-radius: 10px; 18 | box-shadow: 5px 20px 50px #000; 19 | } 20 | #chk{ 21 | display: none; 22 | } 23 | .signup{ 24 | position: relative; 25 | width:100%; 26 | height: 100%; 27 | } 28 | label{ 29 | color: #fff; 30 | font-size: 2.3em; 31 | justify-content: center; 32 | display: flex; 33 | margin: 60px; 34 | font-weight: bold; 35 | cursor: pointer; 36 | transition: .5s ease-in-out; 37 | } 38 | input{ 39 | width: 60%; 40 | height: 20px; 41 | background: #e0dede; 42 | justify-content: center; 43 | display: flex; 44 | margin: 20px auto; 45 | padding: 10px; 46 | border: none; 47 | outline: none; 48 | border-radius: 5px; 49 | } 50 | button{ 51 | width: 60%; 52 | height: 40px; 53 | margin: 10px auto; 54 | justify-content: center; 55 | display: block; 56 | color: #fff; 57 | background: #573b8a; 58 | font-size: 1em; 59 | font-weight: bold; 60 | margin-top: 20px; 61 | outline: none; 62 | border: none; 63 | border-radius: 5px; 64 | transition: .2s ease-in; 65 | cursor: pointer; 66 | } 67 | button:hover{ 68 | background: #6d44b8; 69 | } 70 | .login{ 71 | height: 460px; 72 | background: #eee; 73 | border-radius: 60% / 10%; 74 | transform: translateY(-180px); 75 | transition: .8s ease-in-out; 76 | } 77 | .login label{ 78 | color: #573b8a; 79 | transform: scale(.6); 80 | } 81 | 82 | #chk:checked ~ .login{ 83 | transform: translateY(-500px); 84 | } 85 | #chk:checked ~ .login label{ 86 | transform: scale(1); 87 | } 88 | #chk:checked ~ .signup label{ 89 | transform: scale(.6); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/FizzBuzzSetImplementation.java: -------------------------------------------------------------------------------- 1 | // FizzBuzz Java implementation using sets 2 | // Author: @muhazafasa 3 | 4 | import java.util.LinkedList; 5 | import java.util.HashSet; 6 | import java.util.Random; 7 | import java.util.Scanner; 8 | 9 | interface Result { 10 | String result(int x); 11 | } 12 | 13 | public class FizzBuzzSetImplementation { 14 | public static void main(String[] args) { 15 | class Pair { 16 | public final X first; 17 | public final Y second; 18 | public Pair(X first, Y second) { 19 | this.first = first; 20 | this.second = second; 21 | } 22 | } 23 | 24 | HashSet fizz = new HashSet(); 25 | for (int i = 3; i <= 100; i += 3) 26 | fizz.add(i); 27 | 28 | HashSet buzz = new HashSet(); 29 | for (int i = 5; i <= 100; i += 5) 30 | buzz.add(i); 31 | 32 | HashSet fizzBuzz = new HashSet(fizz); 33 | fizzBuzz.retainAll(buzz); 34 | 35 | HashSet rest = new HashSet(); 36 | for (int i = 1; i <= 100; ++i) 37 | rest.add(i); 38 | rest.removeAll(fizz); 39 | rest.removeAll(buzz); 40 | 41 | Result fizzResult = x -> "Fizz"; 42 | Result buzzResult = x -> "Buzz"; 43 | Result fizzBuzzResult = x -> "FizzBuzz"; 44 | Result restResult = x -> String.format("%d", x); 45 | 46 | LinkedList, Result>> results = new LinkedList, Result>>(); 47 | results.add(new Pair(fizzBuzz, fizzBuzzResult)); 48 | results.add(new Pair(fizz, fizzResult)); 49 | results.add(new Pair(buzz, buzzResult)); 50 | results.add(new Pair(rest, restResult)); 51 | 52 | Random rand = new Random(); 53 | Scanner scan = new Scanner(System.in); 54 | 55 | while (true) { 56 | int number = rand.nextInt(99) + 1; 57 | for (var type : results) 58 | if (type.first.contains(number)) { 59 | System.out.println(type.second.result(number)); 60 | break; 61 | } 62 | scan.nextLine(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/Greatestelement.java: -------------------------------------------------------------------------------- 1 | /* 2 | Question : Next Greater Element on Right 3 | 4 | 1. You are given a number n, representing the size of array a. 5 | 2. You are given n numbers, representing elements of array a. 6 | 3. You are required to "next greater element on the right" for all elements of array 7 | 4. Input and output is handled for you. 8 | 9 | "Next greater element on the right" of an element x is defined as the first element to right of x having value greater than x. 10 | Note -> If an element does not have any element on it's right side greater than it, consider -1 as it's "next greater element on right" 11 | e.g. 12 | for the array [2 5 9 3 1 12 6 8 7] 13 | Next greater for 2 is 5 14 | Next greater for 5 is 9 15 | Next greater for 9 is 12 16 | Next greater for 3 is 12 17 | Next greater for 1 is 12 18 | Next greater for 12 is -1 19 | Next greater for 6 is 8 20 | Next greater for 8 is -1 21 | Next greater for 7 is -1 22 | 23 | */ 24 | 25 | //Code 26 | import java.io.*; 27 | import java.util.*; 28 | 29 | public class Greatestelement 30 | { 31 | public static void display(int[] a) 32 | { 33 | StringBuilder sb = new StringBuilder(); 34 | 35 | for(int val: a){ 36 | sb.append(val + "\n"); 37 | } 38 | System.out.println(sb); 39 | } 40 | 41 | public static void main(String[] args) throws Exception 42 | { 43 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 44 | 45 | int n = Integer.parseInt(br.readLine()); 46 | int[] a = new int[n]; 47 | for(int i = 0; i < n; i++){ 48 | a[i] = Integer.parseInt(br.readLine()); 49 | } 50 | 51 | int[] nge = solve(a); 52 | display(nge); 53 | } 54 | 55 | public static int[] solve(int[] arr) 56 | { 57 | int nge[] = new int[arr.length]; 58 | Stack st = new Stack<>(); 59 | st.push(arr[arr.length - 1]); 60 | nge[arr.length - 1] = -1; 61 | for(int i=arr.length - 2;i>=0;i--) 62 | { 63 | while(st.size() > 0 && arr[i] >= st.peek()) 64 | { 65 | st.pop(); 66 | } 67 | if(st.size() == 0) 68 | { 69 | nge[i] = -1; 70 | } 71 | else{ 72 | nge[i] = st.peek(); 73 | } 74 | st.push(arr[i]); 75 | } 76 | return nge; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /tic-tac-toe board.java: -------------------------------------------------------------------------------- 1 | package practical17; 2 | 3 | import java.io.FileInputStream; 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.scene.image.Image; 7 | import javafx.scene.image.ImageView; 8 | import javafx.scene.layout.GridPane; 9 | import javafx.stage.Stage; 10 | 11 | public class Practical17 extends Application { 12 | 13 | @Override 14 | 15 | public void start(Stage primaryStage) throws Exception { 16 | 17 | GridPane root = new GridPane(); 18 | 19 | Image img; 20 | 21 | ImageView img_view; 22 | for (int i = 0; i < 3; i++) { 23 | 24 | for (int j = 0; j < 3; j++) { 25 | int n = (int) (Math.random() * 2); 26 | 27 | if(n==0) 28 | { FileInputStream fin; 29 | fin = new FileInputStream("C://Users//SI//OneDrive//Desktop//java_image/X.gif"); 30 | //fin=("E:/x.gif"); 31 | img = new Image(fin); 32 | img_view = new ImageView(img); 33 | root.add(img_view, j, i); 34 | 35 | } 36 | else if(n==1) 37 | { 38 | FileInputStream fin; 39 | //fin = new FileInputStream("C:/Users/SI/OneDrive/Desktop/BE SEM 4/05_ OBJECT ORRIENTED PROGRAMMING -1/220133107008/O.jpg"); 40 | fin = new FileInputStream("C://Users//SI//OneDrive//Desktop//java_image/O.gif"); 41 | img = new Image(fin); 42 | img_view = new ImageView(img); 43 | root.add(img_view, j, i); 44 | 45 | } 46 | else{ 47 | continue; 48 | } 49 | } 50 | 51 | } 52 | 53 | Scene scene = new Scene(root, 200, 200); 54 | primaryStage.setScene(scene); 55 | primaryStage.setTitle("Tic-Tac-Toe Board Demo"); 56 | 57 | primaryStage.show(); 58 | 59 | } 60 | 61 | 62 | public static void main(String[] args) { 63 | 64 | launch(args); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/heapheapsort.py: -------------------------------------------------------------------------------- 1 | from math import floor 2 | 3 | class MaxHeap: 4 | def __init__(self): 5 | self.heap = [None] 6 | self.size = 0 7 | 8 | def push(self, ele): 9 | self.size += 1 10 | if len(self.heap) > self.size: 11 | self.heap[self.size] = ele 12 | else: 13 | self.heap.append(ele) 14 | self.perculate_up() 15 | 16 | def perculate_up(self): 17 | if self.size <= 1: return 18 | cur = self.size 19 | parent = floor(cur / 2) 20 | while parent > 0: 21 | if self.heap[parent] < self.heap[cur]: 22 | self.heap[parent], self.heap[cur] = self.heap[cur], self.heap[parent] 23 | cur = parent 24 | parent = floor(cur / 2) 25 | 26 | def pop(self): 27 | if self.size < 1: return 28 | self.heap[1], self.heap[self.size] = self.heap[self.size], self.heap[1] 29 | self.size -= 1 30 | self.perculate_down() 31 | return self.heap[self.size + 1] 32 | 33 | def perculate_down(self): 34 | if self.size < 2: return 35 | cur = 1 36 | c1 = cur * 2 37 | c2 = cur * 2 + 1 38 | while c1 <= self.size or c2<= self.size: 39 | if self.heap[c1] > self.heap[cur]: 40 | self.heap[c1], self.heap[cur] = self.heap[cur], self.heap[c1] 41 | cur = c1 42 | c1 = cur * 2 43 | c2 = cur * 2 + 1 44 | elif c2 <= self.size and self.heap[c2] > self.heap[cur]: 45 | self.heap[c2], self.heap[cur] = self.heap[cur], self.heap[c2] 46 | cur = c2 47 | c1 = cur * 2 48 | c2 = cur * 2 + 1 49 | else: 50 | break 51 | class HeapSort: 52 | def __init__(self): 53 | self.max_heap_obj = MaxHeap() 54 | 55 | def sort(self, elements): 56 | reverse_sorted_elements = [] 57 | for ele in elements: 58 | self.max_heap_obj.push(ele) 59 | 60 | for _ in range(len(elements)): 61 | reverse_sorted_elements.append(self.max_heap_obj.pop()) 62 | 63 | sorted_elements = self.max_heap_obj.heap[1:] 64 | 65 | return sorted_elements, reverse_sorted_elements 66 | 67 | HeapSort().sort([10, 8, 1, 2, 6, 7, 8, 4, 5, 1, 2, 3, 19]) 68 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/java/queue/LinkedQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package queue; 7 | 8 | /** 9 | * 10 | * @author Zohaib Hassan Soomro 11 | */ 12 | public class LinkedQueue implements Queue { 13 | 14 | private int size; 15 | private Node head = new Node(null); 16 | 17 | private class Node { 18 | 19 | private Object object; 20 | private Node previous = this; 21 | private Node next = this; 22 | 23 | public Node(Object obj) { 24 | this.object = obj; 25 | } 26 | 27 | public Node(Object object, Node previous, Node next) { 28 | this.object = object; 29 | this.previous = previous; 30 | this.next = next; 31 | } 32 | 33 | } 34 | 35 | @Override 36 | public Object first() { 37 | if (this.isEmpty()) { 38 | throw new IllegalStateException("Queue is empty!"); 39 | } 40 | return head.next.object; 41 | } 42 | 43 | @Override 44 | public Object remove() { 45 | if (this.isEmpty()) { 46 | throw new IllegalStateException("Queue is empty!"); 47 | } 48 | Object firstElement = head.next.object; 49 | head.next = head.next.next; 50 | head.next.previous = head; 51 | size--; 52 | return firstElement; 53 | } 54 | 55 | @Override 56 | public void add(Object obj) { 57 | head.previous = head.previous.next = new Node(obj, head.previous, head); 58 | size++; 59 | } 60 | 61 | @Override 62 | public int size() { 63 | return size; 64 | } 65 | 66 | @Override 67 | public boolean isEmpty() { 68 | return size == 0; 69 | } 70 | 71 | public static void main(String[] args) { 72 | LinkedQueue carsBought = new LinkedQueue(); 73 | LinkedQueue carsSold = new LinkedQueue(); 74 | carsBought.add(1000); 75 | carsBought.add(2000); 76 | carsBought.add(500); 77 | carsSold.add(1100); 78 | carsSold.add(1999); 79 | carsSold.add(600); 80 | int totalProfit = 0; 81 | int size = carsBought.size(); 82 | for (int i = 0; i < size; i++) { 83 | totalProfit += (int) carsSold.remove() - (int) carsBought.remove(); 84 | } 85 | System.out.println("Total Profit On these Three Cars: "+totalProfit); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Misc/majority_Element.java: -------------------------------------------------------------------------------- 1 | 2 | // import java.util.Arrays; 3 | import java.util.HashMap; 4 | 5 | public class majority_Element { 6 | public static void main(String[] args) { 7 | int[] nums = { 2, 2, 1, 1, 1, 2, 2 }; 8 | int answer = optimal(nums); 9 | System.out.println(answer); 10 | } 11 | 12 | // private static int brute(int[] nums) { 13 | // int n = nums.length; 14 | // for (int i = 0; i < n; i++) { 15 | // int count = 0; 16 | // int element = nums[i]; 17 | // for (int j = 0; j < n; j++) { 18 | // if (i != j) { 19 | // if (nums[j] == element) { 20 | // count++; 21 | // } 22 | // } 23 | // if (count > n / 2) { 24 | // return element; 25 | // } 26 | // } 27 | // } 28 | // return -1; 29 | // } 30 | 31 | // private static int better1(int[] nums) { 32 | // Arrays.sort(nums); 33 | // if (nums.length <= 1) 34 | // return nums[0]; 35 | // Arrays.sort(nums); 36 | // int count = 1; 37 | // for (int i = 0; i < nums.length - 1; i++) { 38 | // if (nums[i] == nums[i + 1]) { 39 | // count++; 40 | // } else { 41 | // count = 1; 42 | // } 43 | // if (count > nums.length / 2) 44 | // return nums[i]; 45 | // } 46 | // return -1; 47 | // } 48 | 49 | // private static int better2(int[] nums) { 50 | // Arrays.sort(nums); 51 | // return nums[nums.length / 2]; 52 | // } 53 | 54 | private static int optimal(int[] nums) { 55 | if (nums.length <= 1) 56 | return nums[0]; 57 | HashMap map = new HashMap(); 58 | for (int i = 0; i < nums.length; i++) { 59 | if (map.containsKey(nums[i])) { 60 | int count = map.get(nums[i]) + 1; 61 | if (count > nums.length / 2) 62 | return nums[i]; 63 | else 64 | map.put(nums[i], count); 65 | 66 | } else 67 | map.put(nums[i], 1); 68 | } 69 | return -1; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/java/stack/RPN.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package stack; 7 | 8 | import java.util.Arrays; 9 | 10 | /** 11 | * 12 | * @author Zohaib Hassan Soomro 13 | */ 14 | ///////////Reverse Polish Notation i.e 7 2 + 5 2- * = (7+2)*(5-2) 15 | public class RPN { 16 | 17 | public RPN(String[] array) { 18 | Stack stack = new ArrayStack(array.length); 19 | // or 20 | // Stack stack = new LinkedStack(); 21 | for (int i = 0; i < array.length; i++) { 22 | String input = array[i]; 23 | if (isAnOperator(input)) { 24 | double lastElement = Double.parseDouble((String) stack.pop()); 25 | double secondlastElement = Double.parseDouble((String) stack.pop()); 26 | double result = evaluate(secondlastElement, lastElement, input); 27 | stack.push("" + result); 28 | } else { 29 | stack.push(input); 30 | } 31 | } 32 | } 33 | //DMAS= Division, Multiplication, Addition, Subtraction 34 | 35 | /////checks if input is an operator 36 | private boolean isAnOperator(String operator) { 37 | return (operator.length() == 1 && ("DMAS".indexOf(operator) >= 0 || "dmas".indexOf(operator) >= 0)); 38 | } 39 | 40 | /////evaluates last two digits with corresponding operation 41 | private double evaluate(double x, double y, String op) { 42 | double z = 0; 43 | switch (op) { 44 | case "a": 45 | case "A": 46 | z = x + y; 47 | break; 48 | case "s": 49 | case "S": 50 | z = x - y; 51 | break; 52 | 53 | case "m": 54 | case "M": 55 | z = x * y; 56 | break; 57 | 58 | case "d": 59 | case "D": 60 | z = x / y; 61 | break; 62 | } 63 | System.out.println(x + " " + op + " " + y + " = " + z); 64 | return z; 65 | } 66 | 67 | public static void main(String[] args) { 68 | String str = new String("7 2 s 5 8 4 D m 2 d D 2 a"); //works on both lowercase & uppercase// (((7-2) / ((5*(8/4)) /2))+2)=3 69 | String[] array = str.split(" "); 70 | new RPN(array); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tree.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void markParents(BinaryTreeNode *root, unordered_map *, BinaryTreeNode *> &parent_track, BinaryTreeNode *target) 5 | { 6 | queue *> queue; 7 | queue.push(root); 8 | while (!queue.empty()) 9 | { 10 | BinaryTreeNode *current = queue.front(); 11 | queue.pop(); 12 | if (current->left) 13 | { 14 | parent_track[current->left] = current; 15 | queue.push(current->left); 16 | } 17 | if (current->right) 18 | { 19 | parent_track[current->right] = current; 20 | queue.push(current->right); 21 | } 22 | } 23 | } 24 | 25 | vector *> printNodesAtDistanceK(BinaryTreeNode *root, BinaryTreeNode *target, int k) 26 | { 27 | unordered_map *, BinaryTreeNode *> parent_track; 28 | 29 | markParents(root, parent_track, target); 30 | 31 | unordered_map *, bool> visited; 32 | 33 | queue *> queue; 34 | queue.push(target); 35 | visited[target] = true; 36 | int curr_level = 0; 37 | 38 | while (!queue.empty()) 39 | { 40 | int size = queue.size(); 41 | 42 | if (curr_level++ == k) 43 | break; 44 | 45 | for (int i = 0; i < size; i++) 46 | { 47 | BinaryTreeNode *current = queue.front(); 48 | queue.pop(); 49 | if (current->left && !visited[current->left]) 50 | { 51 | queue.push(current->left); 52 | visited[current->left] = true; 53 | } 54 | if (current->right && !visited[current->right]) 55 | { 56 | queue.push(current->right); 57 | visited[current->right] = true; 58 | } 59 | if (parent_track[current] && !visited[parent_track[current]]) 60 | { 61 | queue.push(parent_track[current]); 62 | visited[parent_track[current]] = true; 63 | } 64 | } 65 | } 66 | vector *> result; 67 | while (!queue.empty()) 68 | { 69 | BinaryTreeNode *current = queue.front(); 70 | queue.pop(); 71 | result.push_back(current); 72 | } 73 | return result; 74 | } 75 | -------------------------------------------------------------------------------- /logo.html: -------------------------------------------------------------------------------- 1 |
2 |

Logo Design Pure HTML CSS

3 |

MAHI WEB

4 | 87 |
88 | 91 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/voice_activated_calculator.py: -------------------------------------------------------------------------------- 1 | import speech_recognition as sr 2 | import datetime 3 | import webbrowser as wb 4 | import os 5 | import pyttsx3 6 | import wikipedia 7 | import pywhatkit 8 | import pyjokes as pj 9 | import smtplib 10 | import requests 11 | from bs4 import BeautifulSoup 12 | import winsound 13 | import operator 14 | import random 15 | 16 | def speech(audio): 17 | engine.setProperty('rate', 175) 18 | voices = engine.getProperty('voices') # getting details of current voice 19 | # engine.setProperty('voice', voices[1].id) # changing index, changes voices. o for male 20 | engine.setProperty('voice', voices[0].id) 21 | engine.say(audio) 22 | engine.runAndWait() 23 | 24 | def takeCommand(): 25 | # It takes microphone input from the user and returns string output 26 | 27 | r = sr.Recognizer() 28 | with sr.Microphone() as source: 29 | r.adjust_for_ambient_noise(source, duration=1) 30 | print() 31 | print("Listening...") 32 | print() 33 | # r.pause_threshold = 1 34 | audio = r.listen(source) 35 | 36 | try: 37 | print("Recognizing...") 38 | print() 39 | query = r.recognize_google(audio, language='en-in') 40 | print(f"you said: {query}\n") 41 | 42 | except Exception as e: 43 | print("Say that again please...") 44 | print() 45 | print(e) 46 | return "None" 47 | return query 48 | 49 | def calculate(): 50 | r = sr.Recognizer() 51 | with sr.Microphone() as source: 52 | speech("say what you want to calculate, example 3 plus 3") 53 | print("Listening...") 54 | r.adjust_for_ambient_noise(source) 55 | audio = r.listen(source) 56 | my_string = r.recognize_google(audio) 57 | print(my_string) 58 | 59 | def get_operator_fn(op): 60 | return { 61 | '+': operator.add, 62 | '-': operator.sub, 63 | '*': operator.mul, 64 | 'divided': operator.__truediv__, 65 | }[op] 66 | 67 | def evel_binary(op1, oper, op2): 68 | op1, op2 = int(op1), int(op2) 69 | return get_operator_fn(oper)(op1, op2) 70 | 71 | speech("your result is ") 72 | speech(evel_binary(*(my_string.split()))) 73 | 74 | 75 | while True: 76 | 77 | speechInput = takeCommand().lower() 78 | 79 | calculate() 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/Balancedbrackets.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Question : Balanced Brackets 4 | 5 | 1. You are given a string exp representing an expression. 6 | 2. You are required to check if the expression is balanced i.e. closing brackets and opening brackets match up well. 7 | 8 | e.g. 9 | [(a + b) + {(c + d) * (e / f)}] -> true 10 | [(a + b) + {(c + d) * (e / f)]} -> false 11 | [(a + b) + {(c + d) * (e / f)} -> false 12 | ([(a + b) + {(c + d) * (e / f)}] -> false 13 | 14 | */ 15 | 16 | //Code 17 | import java.io.*; 18 | import java.util.*; 19 | public class Balancedbrackets 20 | { 21 | public static void main(String[] args) 22 | { 23 | Scanner sc = new Scanner(System.in); 24 | String str = sc.nextLine(); 25 | Stack st = new Stack<>(); 26 | for(int i=0;ist, char corresoch) 73 | { 74 | if(st.size() == 0) 75 | { 76 | return false; 77 | } 78 | else if(st.peek() != corresoch) 79 | { 80 | return false; 81 | } 82 | else{ 83 | st.pop(); 84 | return true; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Java_Programs/Data_structure/GraphMA.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | 4 | /** 5 | * 6 | * @author Santiago Tumbaco 7 | */ 8 | public class GraphMA { 9 | 10 | private ArrayList vertex; 11 | private int[][] matrix; 12 | private int capacity = 100; 13 | private boolean directed; 14 | 15 | public GraphMA(boolean directed){ 16 | vertex = new ArrayList<>(); 17 | matrix = new int[capacity][capacity]; 18 | this.directed = directed; 19 | } 20 | 21 | public boolean isEmpty() { 22 | return vertex.isEmpty(); 23 | } 24 | 25 | public boolean addVertex(E data) { 26 | return (data != null && !vertex.contains(data)) ? vertex.add(data) : false; 27 | } 28 | 29 | public boolean addEdge(E origen, E destino, int peso) { 30 | int io = vertex.indexOf(origen); 31 | int id = vertex.indexOf(destino); 32 | if ((io != -1 && id != -1) && peso != 0 && matrix[io][id] == 0) { 33 | matrix[io][id] = peso; 34 | if (!directed) { 35 | matrix[id][io] = peso; 36 | } 37 | return true; 38 | } 39 | return false; 40 | } 41 | 42 | public boolean removeVertex(E data) { 43 | int i = vertex.indexOf(data); 44 | if (i == -1) { 45 | return false; 46 | } 47 | 48 | for (int j = i; j < vertex.size(); j++) { 49 | matrix[j] = matrix[j + 1]; 50 | 51 | for (int k = 0; k < vertex.size(); k++) { 52 | matrix[k][j] = matrix[k][j + 1]; 53 | } 54 | } 55 | vertex.remove(i); 56 | return true; 57 | } 58 | 59 | public int indegree(E data) { 60 | int i = vertex.indexOf(data); 61 | int grado = 0; 62 | 63 | if (i == -1) { 64 | return -1; 65 | } 66 | 67 | for (int j = 0; j < vertex.size(); j++) { 68 | if (matrix[j][i] != 0) { 69 | grado++; 70 | } 71 | } 72 | 73 | return grado; 74 | } 75 | 76 | public int outdegree(E data) { 77 | int i = vertex.indexOf(data); 78 | int grado = 0; 79 | 80 | if (i == -1) { 81 | return -1; 82 | } 83 | 84 | for (int j = 0; j < vertex.size(); j++) { 85 | if (matrix[i][j] != 0) { 86 | grado++; 87 | } 88 | } 89 | 90 | return grado; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Implementation_of_DS/BSTsort.c: -------------------------------------------------------------------------------- 1 | //sorting using binary tree 2 | #include 3 | #include 4 | 5 | struct node{ 6 | struct node *left; 7 | int data; 8 | struct node *right; 9 | }; 10 | 11 | void insert(struct node *, int element); 12 | 13 | int * traversal(struct node *node ,int *sort, int *count); 14 | 15 | int main() 16 | { 17 | unsigned int n; 18 | printf("Enter elements you want to add in array: "); 19 | scanf("%d", &n); 20 | int arr[n]; 21 | printf("Enter elements now: \n"); 22 | 23 | for(int i=0;ileft=NULL; 35 | root->right=NULL; 36 | root->data=arr[0]; 37 | 38 | 39 | for(int i=1;idata){ 64 | if(node->left==NULL){ 65 | struct node *newNode; 66 | newNode=(struct node *)malloc(sizeof(struct node)); 67 | newNode->data=element; 68 | newNode->left=NULL; 69 | newNode->right=NULL; 70 | 71 | node->left=newNode; 72 | } 73 | else{ 74 | insert(node->left, element); 75 | } 76 | } 77 | else if(element>=node->data){ 78 | if(node->right==NULL){ 79 | struct node *newNode; 80 | newNode=(struct node *)malloc(sizeof(struct node)); 81 | newNode->data=element; 82 | newNode->left=NULL; 83 | newNode->right=NULL; 84 | 85 | node->right=newNode; 86 | } 87 | else{ 88 | insert(node->right, element); 89 | } 90 | 91 | } 92 | } 93 | 94 | 95 | int * traversal(struct node *node, int *sort, int *count){ 96 | if(node!=NULL){ 97 | sort=traversal(node->left, sort, count); 98 | *(sort+ *count)=node->data; 99 | (*count)++; 100 | printf("\n"); 101 | sort=traversal(node->right, sort, count); 102 | 103 | } 104 | return sort; 105 | 106 | } 107 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Color_Detection.py: -------------------------------------------------------------------------------- 1 | 2 | import cv2 3 | import numpy as np 4 | import pandas as pd 5 | import argparse 6 | 7 | #Creating argument parser to take image path from command line 8 | ap = argparse.ArgumentParser() 9 | ap.add_argument('-i', '--image', required=True, help="Image Path") 10 | args = vars(ap.parse_args()) 11 | img_path = args['image'] 12 | 13 | #Reading the image with opencv 14 | img = cv2.imread(img_path) 15 | 16 | #declaring global variables (are used later on) 17 | clicked = False 18 | r = g = b = xpos = ypos = 0 19 | 20 | #Reading csv file with pandas and giving names to each column 21 | index=["color","color_name","hex","R","G","B"] 22 | csv = pd.read_csv('colors.csv', names=index, header=None) 23 | 24 | #function to calculate minimum distance from all colors and get the most matching color 25 | def getColorName(R,G,B): 26 | minimum = 10000 27 | for i in range(len(csv)): 28 | d = abs(R- int(csv.loc[i,"R"])) + abs(G- int(csv.loc[i,"G"]))+ abs(B- int(csv.loc[i,"B"])) 29 | if(d<=minimum): 30 | minimum = d 31 | cname = csv.loc[i,"color_name"] 32 | return cname 33 | 34 | #function to get x,y coordinates of mouse double click 35 | def draw_function(event, x,y,flags,param): 36 | if event == cv2.EVENT_LBUTTONDBLCLK: 37 | global b,g,r,xpos,ypos, clicked 38 | clicked = True 39 | xpos = x 40 | ypos = y 41 | b,g,r = img[y,x] 42 | b = int(b) 43 | g = int(g) 44 | r = int(r) 45 | 46 | cv2.namedWindow('image') 47 | cv2.setMouseCallback('image',draw_function) 48 | 49 | while(1): # while loop execution stops when condition is false. 50 | 51 | cv2.imshow("image",img) 52 | if (clicked): 53 | 54 | #cv2.rectangle(image, startpoint, endpoint, color, thickness)-1 fills entire rectangle 55 | cv2.rectangle(img,(20,20), (750,60), (b,g,r), -1) 56 | 57 | #Creating text string to display( Color name and RGB values ) 58 | text = getColorName(r,g,b) + ' R='+ str(r) + ' G='+ str(g) + ' B='+ str(b) 59 | 60 | #cv2.putText(img,text,start,font(0-7),fontScale,color,thickness,lineType ) 61 | cv2.putText(img, text,(50,50),2,0.8,(255,255,255),2,cv2.LINE_AA) 62 | 63 | #For very light colours we will display text in black colour 64 | if(r+g+b>=600): 65 | cv2.putText(img, text,(50,50),2,0.8,(0,0,0),2,cv2.LINE_AA) 66 | 67 | clicked=False 68 | 69 | #Break the loop when user hits 'esc' key 70 | if cv2.waitKey(20) & 0xFF ==27: 71 | break 72 | 73 | cv2.destroyAllWindows() 74 | 75 | #python color_detection.py -i ->to run the file 76 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/pattern.py: -------------------------------------------------------------------------------- 1 | val = int(input("Give your value in stars: ")) 2 | #for square 3 | def square(num): 4 | num = val 5 | for i in range(num): 6 | for j in range(num): 7 | print("*", end = " ") 8 | print() 9 | #increasing triangle 10 | def increasing_triangle(num): 11 | num = val 12 | for i in range(num): 13 | for j in range(i+1): 14 | print("*", end = " ") 15 | print() 16 | #decreasing triangle 17 | def decreasing_triangle(num): 18 | num = val 19 | for i in range(num): 20 | for j in range(i,n): 21 | print("*", end = " ") 22 | print() 23 | #right sided triangle (increasing star) 24 | def right_sided_triangle_inc(num): 25 | num = val 26 | for i in range(num): 27 | for j in range(i,num): 28 | print("",end = " ") 29 | for j in range(i+1): 30 | print("*", end = " ") 31 | print() 32 | #right sided triangle (decreasing star) 33 | def right_sided_triangle_dec(num): 34 | num = val 35 | for i in range(num): 36 | for j in range(i+1): 37 | print("",end = " ") 38 | for j in range(i,num): 39 | print("*", end = " ") 40 | print() 41 | #hill pattern 42 | def hill_pattern(num): 43 | num = val 44 | for i in range(num): 45 | for j in range(i,num): 46 | print(" ", end = " ") 47 | for j in range(i): 48 | print("*",end = " ") 49 | for j in range(i+1): 50 | print("*",end = " ") 51 | print() 52 | #reverse hill pattern 53 | def reverse_hill_pattern(num): 54 | num = val 55 | for i in range(num): 56 | for j in range(i+1): 57 | print(" ", end = " ") 58 | for j in range(i,n-1): 59 | print("*",end = " ") 60 | for j in range(i,n): 61 | print("*",end = " ") 62 | print() 63 | #diamond pattern 64 | def diamond(num): 65 | num = val 66 | for i in range(num): 67 | print(" " * (num - i), "*" * (2*i + 1)) 68 | for i in range(num - 2, -1, -1): 69 | print(" " * (num - i), "*" * (2*i + 1)) 70 | 71 | #comment out other lines below here while printing one funnction 72 | square(val) #square 73 | increasing_triangle(val) #increasing triangle 74 | decreasing_triangle(val) #decreasing triangle 75 | right_sided_triangle_inc(val) #right sided triangle (increasing star) 76 | right_sided_triangle_dec(val) #right sided triangle (decreasing star) 77 | hill_pattern(val) #hill pattern 78 | reverse_hill_pattern(val) #reverse hill pattern 79 | diamond(val) #diamond pattern -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/Alarm Clock In Python: -------------------------------------------------------------------------------- 1 | """ Alarm Clock 2 | 3 | ---------------------------------------- 4 | 5 | """ 6 | 7 | import datetime 8 | 9 | import os 10 | 11 | import time 12 | 13 | import random 14 | 15 | import webbrowser 16 | 17 | # If video URL file does not exist, create one 18 | 19 | if not os.path.isfile("youtube_alarm_videos.txt"): 20 | 21 | print('Creating "youtube_alarm_videos.txt"...') 22 | 23 | with open("youtube_alarm_videos.txt", "w") as alarm_file: 24 | 25 | alarm_file.write("https://www.youtube.com/watch?v=anM6uIZvx74") 26 | 27 | def check_alarm_input(alarm_time): 28 | 29 | """Checks to see if the user has entered in a valid alarm time""" 30 | 31 | if len(alarm_time) == 1: # [Hour] Format 32 | 33 | if alarm_time[0] < 24 and alarm_time[0] >= 0: 34 | 35 | return True 36 | 37 | if len(alarm_time) == 2: # [Hour:Minute] Format 38 | 39 | if alarm_time[0] < 24 and alarm_time[0] >= 0 and \ 40 | 41 | alarm_time[1] < 60 and alarm_time[1] >= 0: 42 | 43 | return True 44 | 45 | elif len(alarm_time) == 3: # [Hour:Minute:Second] Format 46 | 47 | if alarm_time[0] < 24 and alarm_time[0] >= 0 and \ 48 | 49 | alarm_time[1] < 60 and alarm_time[1] >= 0 and \ 50 | 51 | alarm_time[2] < 60 and alarm_time[2] >= 0: 52 | 53 | return True 54 | 55 | return False 56 | 57 | # Get user input for the alarm time 58 | 59 | print("Set a time for the alarm (Ex. 06:30 or 18:30:00)") 60 | 61 | while True: 62 | 63 | alarm_input = input(">> ") 64 | 65 | try: 66 | 67 | alarm_time = [int(n) for n in alarm_input.split(":")] 68 | 69 | if check_alarm_input(alarm_time): 70 | 71 | break 72 | 73 | else: 74 | 75 | raise ValueError 76 | 77 | except ValueError: 78 | 79 | print("ERROR: Enter time in HH:MM or HH:MM:SS format") 80 | 81 | # Convert the alarm time from [H:M] or [H:M:S] to seconds 82 | 83 | seconds_hms = [3600, 60, 1] # Number of seconds in an Hour, Minute, and Second 84 | 85 | alarm_seconds = sum([a*b for a,b in zip(seconds_hms[:len(alarm_time)], alarm_time)]) 86 | 87 | # Get the current time of day in seconds 88 | 89 | now = datetime.datetime.now() 90 | 91 | current_time_seconds = sum([a*b for a,b in zip(seconds_hms, [now.hour, now.minute, now.second])]) 92 | 93 | # Calculate the number of seconds until alarm goes off 94 | 95 | time_diff_seconds = alarm_seconds - current_time_seconds 96 | 97 | # If time difference is negative, set alarm for next day 98 | 99 | if time_diff_seconds < 0: 100 | 101 | time_diff_seconds += 86400 # number of seconds in a day 102 | 103 | # Display the amount of time until the alarm goes off 104 | 105 | print("Alarm set to go off in %s" % datetime.timedelta(seconds=time_diff_seconds)) 106 | 107 | # Sleep until the alarm goes off 108 | 109 | time.sleep(time_diff_seconds) 110 | 111 | # Time for the alarm to go off 112 | 113 | print("Wake Up!") 114 | 115 | # Load list of possible video URLs 116 | 117 | with open("youtube_alarm_videos.txt", "r") as alarm_file: 118 | 119 | videos = alarm_file.readlines() 120 | 121 | # Open a random video from the list 122 | 123 | webbrowser.open(random.choice(videos)) 124 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Python_Programs/alarm_clock.py: -------------------------------------------------------------------------------- 1 | 2 | # Import Required Library 3 | from tkinter import * 4 | import datetime 5 | import time 6 | import winsound 7 | from threading import * 8 | 9 | # Create Object 10 | root = Tk() 11 | 12 | # Set geometry 13 | root.geometry("400x200") 14 | 15 | # Use Threading 16 | def Threading(): 17 | t1=Thread(target=alarm) 18 | t1.start() 19 | 20 | def alarm(): 21 | # Infinite Loop 22 | while True: 23 | # Set Alarm 24 | set_alarm_time = f"{hour.get()}:{minute.get()}:{second.get()}" 25 | 26 | # Wait for one seconds 27 | time.sleep(1) 28 | 29 | # Get current time 30 | current_time = datetime.datetime.now().strftime("%H:%M:%S") 31 | print(current_time,set_alarm_time) 32 | 33 | # Check whether set alarm is equal to current time or not 34 | if current_time == set_alarm_time: 35 | print("Time to Wake up") 36 | # Playing sound continuously 37 | winsound.PlaySound("sound.wav",winsound.SND_ASYNC|winsound.SND_LOOP|winsound.SND_FILENAME) 38 | 39 | # Add Labels, Frame, Button, Optionmenus 40 | Label(root,text="Alarm Clock",font=("Helvetica 20 bold"),fg="red").pack(pady=10) 41 | Label(root,text="Set Time",font=("Helvetica 15 bold")).pack() 42 | 43 | frame = Frame(root) 44 | frame.pack() 45 | 46 | hour = StringVar(root) 47 | hours = ('Hr','00', '01', '02', '03', '04', '05', '06', '07', 48 | '08', '09', '10', '11', '12', '13', '14', '15', 49 | '16', '17', '18', '19', '20', '21', '22', '23', '24' 50 | ) 51 | hour.set(hours[0]) 52 | 53 | hrs = OptionMenu(frame, hour, *hours) 54 | hrs.pack(side=LEFT) 55 | 56 | minute = StringVar(root) 57 | minutes = ('Min','00', '01', '02', '03', '04', '05', '06', '07', 58 | '08', '09', '10', '11', '12', '13', '14', '15', 59 | '16', '17', '18', '19', '20', '21', '22', '23', 60 | '24', '25', '26', '27', '28', '29', '30', '31', 61 | '32', '33', '34', '35', '36', '37', '38', '39', 62 | '40', '41', '42', '43', '44', '45', '46', '47', 63 | '48', '49', '50', '51', '52', '53', '54', '55', 64 | '56', '57', '58', '59', '60') 65 | minute.set(minutes[0]) 66 | 67 | mins = OptionMenu(frame, minute, *minutes) 68 | mins.pack(side=LEFT) 69 | 70 | second = StringVar(root) 71 | seconds = ('Sec','00', '01', '02', '03', '04', '05', '06', '07', 72 | '08', '09', '10', '11', '12', '13', '14', '15', 73 | '16', '17', '18', '19', '20', '21', '22', '23', 74 | '24', '25', '26', '27', '28', '29', '30', '31', 75 | '32', '33', '34', '35', '36', '37', '38', '39', 76 | '40', '41', '42', '43', '44', '45', '46', '47', 77 | '48', '49', '50', '51', '52', '53', '54', '55', 78 | '56', '57', '58', '59', '60') 79 | second.set(seconds[0]) 80 | 81 | secs = OptionMenu(frame, second, *seconds) 82 | secs.pack(side=LEFT) 83 | 84 | Button(root,text="Set Alarm",font=("Helvetica 15"),command=Threading).pack(pady=20) 85 | 86 | #Created an option button to stop the countinous alarm sound 87 | stop_alarm = lambda: winsound.PlaySound(None, winsound.SND_PURGE) 88 | button = Button(root, text='Stop Alarm', bg='red', fg='white', command=stop_alarm).pack(pady=30) 89 | 90 | # Execute Tkinter 91 | root.mainloop() 92 | -------------------------------------------------------------------------------- /Program's_Contributed_By_Contributors/Implementation_of_DS/circluar_linkedList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node{ 5 | struct node *rear; 6 | int data; 7 | struct node *front; 8 | 9 | }; 10 | struct head{ 11 | unsigned int count; 12 | struct node *front; 13 | }; 14 | void create(); 15 | void display(); 16 | void insertBegin(); 17 | 18 | int main() 19 | { 20 | int choice; 21 | struct head *head; 22 | head=(struct head *)malloc(sizeof(struct head)); 23 | head->count=0; 24 | head->front=NULL; 25 | while(1){ 26 | printf("----------------------------------\n"); 27 | printf("1: Create\n2: Insert\n3: Delete\n4: Noel\n5: isEmpty\n6: Display\n"); 28 | scanf("%d", &choice); 29 | switch(choice){ 30 | case 1/*create*/:{ 31 | int data; 32 | printf("Enter data you want to give to the beginning node: "); 33 | scanf("%d", &data); 34 | create(head, data); 35 | break; 36 | } 37 | case 2/*insert*/:{ 38 | int choiceI; 39 | printf("1: Insert At Beginning\n2: Insert At Pos\n3: Insert At End\n"); 40 | scanf("%d", &choiceI); 41 | switch(choiceI){ 42 | case 1:{ 43 | int data; 44 | printf("Enter data you want to enter at beginning: "); 45 | scanf("%d", &data); 46 | insertBegin(head, data); 47 | printf("Element is added\n"); 48 | break; 49 | } 50 | case 2:{ 51 | break; 52 | } 53 | case 3:{ 54 | break; 55 | } 56 | 57 | } 58 | break; 59 | } 60 | case 3/*delete*/:{ 61 | break; 62 | } 63 | case 4/*noel*/:{ 64 | break; 65 | } 66 | case 5/*isempty*/:{ 67 | break; 68 | } 69 | case 6/*display*/:{ 70 | display(head); 71 | break; 72 | } 73 | default :{ 74 | //exit(0); 75 | } 76 | 77 | } 78 | } 79 | return 0; 80 | } 81 | 82 | void create (struct head *head,int data){ 83 | if(head->count!=0){ 84 | head->count=0; 85 | struct node *ptr; 86 | ptr=head->front; 87 | do{ 88 | ptr=ptr->front; 89 | free(ptr->rear); 90 | }while(head->front!=ptr); 91 | head->front=NULL; 92 | } 93 | struct node * node; 94 | node=(struct node *)malloc(sizeof(struct node)); 95 | head->front=node; 96 | head->count++; 97 | node->data=data; 98 | node->front=node; 99 | node->rear=node; 100 | } 101 | 102 | void display(struct head *head){ 103 | struct node * ptr; 104 | ptr=head->front; 105 | do{ 106 | printf("%x\t%d %x\n",ptr->rear, ptr->data, ptr->front); 107 | }while(head->front!=ptr); 108 | } 109 | 110 | void insertBegin(struct head *head,int data){ 111 | struct node *ptr; 112 | ptr=(struct ptr *)malloc(sizeof(struct node)); 113 | ptr->data=data; 114 | ptr->front=head->front; 115 | ptr->rear=head->front->rear; 116 | head->front=ptr; 117 | } 118 | --------------------------------------------------------------------------------