├── assets ├── j ├── k └── logo.png ├── Programs ├── index.py ├── main.py ├── test1.py ├── abhinab.py ├── helloworld.py ├── hello_world.py ├── hellohacktoberfest.py ├── hello world by Manu MR.py ├── helloWorld.py ├── TeamsProject │ ├── core │ │ ├── llow.png │ │ ├── joinnow.png │ │ └── staysignedin.png │ ├── settings.yaml │ └── main.py ├── calcious converter.py ├── Internet_connection_cheaker.py ├── Remove special symbols or punctuation from a string ├── repwordcout.py ├── Insertion sort.py ├── selection sort.py ├── steps.cpp ├── max_min_sum.py ├── HelloWorld.java ├── array1.cpp ├── ANDSUBAR.cpp ├── Anagrams.js ├── palindrome.cpp ├── rps_in_python.py ├── merge_sort.go ├── nested_list.py ├── LeapYear.py ├── addition_of_sparse_matrix.py ├── longest palindrome.cpp ├── Indian_Flag_Drawing.py ├── articulation_points_in_a_graph.cpp ├── N_Queen.cpp ├── Merge sort.py ├── Circular-linkedlist.py ├── Djikstra_algo.cpp ├── passwordGenerator.py ├── GenericGraph.java ├── Longest_Common_Subsequence.cpp ├── TopologicalSort.cpp ├── Morse_code_translator.py ├── tic_tac_toe game.py ├── binary search tree.py ├── Basic_Linked_List_all.py ├── Hangman.py ├── index.html └── huffman-code.c ├── anagram in python ├── .github ├── PULL_REQUEST_TEMPLATE │ └── ADD_NEW_ISSUE.md ├── ISSUE_TEMPLATE │ └── event-request.md └── config.yml ├── palindrome.py ├── fibonacci.py ├── check_leapyear.py ├── Armstrong number.py ├── BinarySearch.py ├── Fibonacci sequence.py ├── agecalculator.py ├── primenumber.py ├── Linkedin_automation.py ├── Reverse_the_array.java ├── amstrg ├── Middle-Of-Linked-List.py ├── FLOYD WARSHEL ALGORITHM.py ├── LICENSE ├── Guess The Number.java ├── Password Strength Checker.java ├── brestcancer prediction.py ├── README.md ├── Encryption Decryption └── ENCRYPT-DECRYPT A MESSAGE.py └── heartattackprediction.py /assets/j: -------------------------------------------------------------------------------- 1 | j 2 | -------------------------------------------------------------------------------- /assets/k: -------------------------------------------------------------------------------- 1 | . 2 | -------------------------------------------------------------------------------- /Programs/index.py: -------------------------------------------------------------------------------- 1 | print("Hello World") -------------------------------------------------------------------------------- /Programs/main.py: -------------------------------------------------------------------------------- 1 | print("Hello World") -------------------------------------------------------------------------------- /Programs/test1.py: -------------------------------------------------------------------------------- 1 | print("Hello World!") 2 | -------------------------------------------------------------------------------- /Programs/abhinab.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | -------------------------------------------------------------------------------- /Programs/helloworld.py: -------------------------------------------------------------------------------- 1 | print ("Hello World") 2 | -------------------------------------------------------------------------------- /Programs/hello_world.py: -------------------------------------------------------------------------------- 1 | print ('Hello World') 2 | -------------------------------------------------------------------------------- /Programs/hellohacktoberfest.py: -------------------------------------------------------------------------------- 1 | print("Hello Hacktoberfest!") 2 | 3 | -------------------------------------------------------------------------------- /Programs/hello world by Manu MR.py: -------------------------------------------------------------------------------- 1 | #This program prints "Hello,World" 2 | print("Hello,World") -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lazeeez/HacktoberFest-21/HEAD/assets/logo.png -------------------------------------------------------------------------------- /Programs/helloWorld.py: -------------------------------------------------------------------------------- 1 | # This program prints Hello, world! 2 | 3 | print('Hello, world!') 4 | -------------------------------------------------------------------------------- /Programs/TeamsProject/core/llow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lazeeez/HacktoberFest-21/HEAD/Programs/TeamsProject/core/llow.png -------------------------------------------------------------------------------- /Programs/TeamsProject/core/joinnow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lazeeez/HacktoberFest-21/HEAD/Programs/TeamsProject/core/joinnow.png -------------------------------------------------------------------------------- /Programs/TeamsProject/core/staysignedin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lazeeez/HacktoberFest-21/HEAD/Programs/TeamsProject/core/staysignedin.png -------------------------------------------------------------------------------- /Programs/calcious converter.py: -------------------------------------------------------------------------------- 1 | input= input("inpur faranhite temperature:") 2 | faranhite = float(input) 3 | calcious = (faranhite - 32.0) * 5.0 / 9.0 4 | print("calcious=", calcious) 5 | 6 | -------------------------------------------------------------------------------- /anagram in python: -------------------------------------------------------------------------------- 1 | def is_anagram(str1, str2): 2 | list_str1 = list(str1) 3 | list_str1.sort() 4 | list_str2 = list(str2) 5 | list_str2.sort() 6 | 7 | return (list_str1 == list_str2) 8 | print(is_anagram('cat','rat')) 9 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/ADD_NEW_ISSUE.md: -------------------------------------------------------------------------------- 1 | ### Please provide following information 2 | 3 | - Issue 4 | - Repository 5 | - Tech stack 6 | 7 | - [ ] is it a `beginner-friendly` issue? 8 | -------------------------------------------------------------------------------- /Programs/Internet_connection_cheaker.py: -------------------------------------------------------------------------------- 1 | import urllib.request 2 | def connect(): 3 | try: 4 | urllib.request.urlopen('http://google.com') 5 | return True 6 | except: 7 | return False 8 | print( 'connected' if connect() else 'no internet!' ) 9 | -------------------------------------------------------------------------------- /Programs/Remove special symbols or punctuation from a string: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | str1 = "/siya @loves &poetry* " 4 | print("Original string is ", str1) 5 | 6 | new_str = str1.translate(str.maketrans('', '', string.punctuation)) 7 | 8 | print("New string is ", new_str) 9 | -------------------------------------------------------------------------------- /Programs/repwordcout.py: -------------------------------------------------------------------------------- 1 | # Check the repeated word in string & count them 2 | 3 | import collections 4 | input_string=input(str()) 5 | output=collections.Counter(input_string) 6 | 7 | values = output.values() 8 | values_list = list(values) 9 | ans=values_list.count(1) 10 | print(ans) -------------------------------------------------------------------------------- /palindrome.py: -------------------------------------------------------------------------------- 1 | #determine if string is a palindrome or not 2 | #copyright prashant-2906 3 | s = input() 4 | l = [] 5 | for c in s: 6 | if c.isalpha(): 7 | l.append(c.lower()) 8 | s = ''.join(l) 9 | if s == s[::-1]: 10 | print("Yes",end='') 11 | else: 12 | print("No",end='') 13 | -------------------------------------------------------------------------------- /Programs/Insertion sort.py: -------------------------------------------------------------------------------- 1 | print("Enter elements:") 2 | arr=list(map(int,input().split())) 3 | for i in range(1, len(arr)): 4 | val=arr[i] 5 | j=i-1 6 | while j>=0 and val 2 | using namespace std; 3 | int main () 4 | { 5 | for (int i = 0; i < 5; ++i) 6 | { 7 | for (int j = i; j < 5; ++j) 8 | { 9 | cout << " "; 10 | } 11 | { 12 | for (int k = 0; k < i; ++k) 13 | cout << "#"; 14 | } 15 | cout < 2 | 3 | bool anai(int n) 4 | { 5 | // bool ans; // 0-150 6 | // if(n%7==0){ 7 | // ans=true; 8 | // } 9 | // else{ 10 | // ans = false; 11 | // } 12 | // return ans; 13 | return true ? (n%7==0) : false; 14 | } 15 | 16 | 17 | int main() 18 | { 19 | for(int i = 0 ; i < 151 ; i++){ 20 | 21 | 22 | if(anai(i)==1){ 23 | std::cout << i << std::endl; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /check_leapyear.py: -------------------------------------------------------------------------------- 1 | # Python program to check if year is a leap year or not 2 | 3 | year = int(input("Enter a year: ")) 4 | 5 | if (year % 4) == 0: 6 | if (year % 100) == 0: 7 | if (year % 400) == 0: 8 | print("{0} is a leap year".format(year)) 9 | else: 10 | print("{0} is not a leap year".format(year)) 11 | else: 12 | print("{0} is a leap year".format(year)) 13 | else: 14 | print("{0} is not a leap year".format(year)) 15 | -------------------------------------------------------------------------------- /Armstrong number.py: -------------------------------------------------------------------------------- 1 | # Python program to check if the number provided by the user is an Armstrong number or not 2 | # take input from the user 3 | num = int(input("Enter a number: ")) 4 | # initialize sum 5 | sum = 0 6 | # find the sum of the cube of each digit 7 | temp = num 8 | while temp > 0: 9 | digit = temp % 10 10 | sum += digit ** 3 11 | temp //= 10 12 | # display the result 13 | if num == sum: 14 | print(num,"is an Armstrong number") 15 | else: 16 | print(num,"is not an Armstrong number") 17 | -------------------------------------------------------------------------------- /Programs/ANDSUBAR.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin>>t; 8 | while(t--) 9 | { 10 | int n,a=1; 11 | cin>>n; 12 | if(n==1) 13 | cout<<1<<"\n"; 14 | else{ 15 | while(a*2<=n) 16 | a=a*2; 17 | int b=n-a+1; 18 | if(n==a) 19 | cout< 13 | 14 | - **How many folks do you expect will attend this event?** 15 | 16 | - **When do you want this event?** 17 | 18 | - **Language of the event?** 19 | -------------------------------------------------------------------------------- /BinarySearch.py: -------------------------------------------------------------------------------- 1 | def BinarySearch(array, x, low, high): 2 | while(low <= high): 3 | mid = low+(high-low)//2 4 | 5 | if(array[mid] == x): 6 | return mid 7 | elif(array[mid] < x): 8 | low = mid+1 9 | else: 10 | high = mid-1 11 | return -1 12 | 13 | array = [44,67,78,89,90,123,334,567,889] 14 | x = 334 15 | 16 | r = BinarySearch(array, x, 0, len(array)-1) 17 | 18 | if(r != -1): 19 | print("Element is present in the array at index " + str(r)) 20 | else: 21 | print("Element is not present") -------------------------------------------------------------------------------- /Fibonacci sequence.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Program to display the Fibonacci sequence up to n-th term 5 | 6 | nterms = int(input("How many terms? ")) 7 | 8 | n1, n2 = 0, 1 9 | count = 0 10 | 11 | if nterms <= 0: 12 | print("Please enter a positive integer") 13 | 14 | elif nterms == 1: 15 | print("Fibonacci sequence upto",nterms,":") 16 | print(n1) 17 | 18 | else: 19 | print("Fibonacci sequence:") 20 | while count < nterms: 21 | print(n1) 22 | nth = n1 + n2 23 | 24 | n1 = n2 25 | n2 = nth 26 | count += 1 -------------------------------------------------------------------------------- /Programs/Anagrams.js: -------------------------------------------------------------------------------- 1 | // JavaScript Program to check if the 2 input strings are Anagrams or not. 2 | 3 | function main() { 4 | //INPUT 5 | 6 | var a = readLine().split(""); 7 | var b = readLine().split(""); 8 | var countA = a.length; 9 | var countB = b.length; 10 | var count = countA + countB; 11 | var pair = 0; 12 | for(var i = 0; i < countA;i++){ 13 | for(var j = 0; j < countB; j++){ 14 | if(a[i] == b[j]){ 15 | b.splice(j,1); 16 | pair++; 17 | break; 18 | } 19 | } 20 | } 21 | console.log(count - (pair*2)); 22 | } 23 | -------------------------------------------------------------------------------- /agecalculator.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | print(" age calculator ") 4 | birth_year = int(input("Enter your year of birth: \n")) 5 | birth_month = int(input("Enter your month of birth: \n")) 6 | birth_day = int(input("Enter your day of birth: \n")) 7 | 8 | current_year = datetime.date.today().year 9 | current_month = datetime.date.today().month 10 | current_day = datetime.date.today().day 11 | 12 | age_year = current_year - birth_year 13 | age_month = abs(current_month - birth_month) 14 | age_day = abs(current_day - birth_day) 15 | 16 | print("Your exact age is: ", age_year, "Years", age_month, "months and", age_day, "days") 17 | -------------------------------------------------------------------------------- /primenumber.py: -------------------------------------------------------------------------------- 1 | # Program to check if a number is prime or not 2 | 3 | 4 | # To take input from the user 5 | #num = int(input("Enter a number: ")) 6 | 7 | # define a flag variable 8 | flag = False 9 | 10 | # prime numbers are greater than 1 11 | if num > 1: 12 | # check for factors 13 | for i in range(2, num): 14 | if (num % i) == 0: 15 | # if factor is found, set flag to True 16 | flag = True 17 | # break out of loop 18 | break 19 | 20 | # check if flag is True 21 | if flag: 22 | print(num, "is not a prime number") 23 | else: 24 | print(num, "is a prime number") 25 | -------------------------------------------------------------------------------- /Linkedin_automation.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.keys import Keys 3 | import pyautogui as pag 4 | 5 | 6 | def login(): 7 | username = driver.find_element_by_id("login-email") 8 | username.send_keys("username") 9 | password = driver.find_element_by_id("login-password") 10 | password.send_keys("password") 11 | driver.find_element_by_id("login-submit").click() 12 | 13 | def goto_network(): 14 | driver.find_element_by_id("mynetwork-tab-icon").click() 15 | 16 | def send_requests(): 17 | n = input("Number of requests: ") 18 | 19 | for i in range(0, n): 20 | pag.click(880, 770) 21 | print("Completed!") 22 | -------------------------------------------------------------------------------- /Programs/TeamsProject/settings.yaml: -------------------------------------------------------------------------------- 1 | logindetails: 2 | username: ['username'] #Your Username that you use in Teams 3 | password: ['password'] #Password 4 | 5 | monday: 6 | starttimings: ["08:00", "11:00", "14:00", "15:51"] 7 | endtimings: ["08:50", "11:50", "15:40", "16:40"] 8 | 9 | tuesday: 10 | starttimings: ["08:00", "10:00", "14:00"] 11 | endtimings: ["08:50", "10:50", "15:40"] 12 | 13 | wednesday: 14 | starttimings: ["09:00", "14:00", "16:41"] 15 | endtimings: ["09:50", "15:40", "17:30"] 16 | 17 | thursday: 18 | starttimings: ["09:00", "11:00", "14:00", "15:51", "17:40"] 19 | endtimings: ["09:50", "11:50", "14:50", "17:30", "19:20"] 20 | 21 | friday: 22 | starttimings: ["08:00", "12:00"] 23 | endtimings: ["08:50", "12:50"] -------------------------------------------------------------------------------- /Reverse_the_array.java: -------------------------------------------------------------------------------- 1 | class Reverse_the_array { 2 | 3 | public static void main(String [] args){ 4 | 5 | int arr[]=new int[4]; 6 | // int arr2[]=new int[4]; 7 | 8 | arr[0]=10; 9 | arr[1]=20; 10 | arr[2]=30; 11 | arr[3]=40; 12 | /* 13 | for(int j=0,i=3; j<4;j++,i--){ 14 | 15 | arr2[j]=arr[i]; 16 | System.out.println(arr[i]); 17 | }*/ 18 | int x=0; 19 | for(int i=0; i 2 | #include 3 | using namespace std; 4 | bool helpingFunction(string s,int start,int last) 5 | { 6 | if(start==last || start>last) 7 | { 8 | return true; 9 | } 10 | bool is=helpingFunction(s,start+1,last-1); 11 | if(is) 12 | { 13 | if(s[start]==s[last]) 14 | { 15 | return true; 16 | } 17 | else 18 | { 19 | return false; 20 | } 21 | } 22 | else 23 | { 24 | return false; 25 | } 26 | } 27 | bool Ispalindrome(string s) 28 | { 29 | int start=0,last=s.length()-1; 30 | return helpingFunction(s,start,last); 31 | } 32 | void main() 33 | { 34 | string s="madam"; 35 | bool is=Ispalindrome(s); 36 | if(is) 37 | { 38 | cout<<"Palindrome\n"; 39 | } 40 | else 41 | { 42 | cout<<"Not Palindrome\n"; 43 | } 44 | system("pause"); 45 | } -------------------------------------------------------------------------------- /Programs/rps_in_python.py: -------------------------------------------------------------------------------- 1 | #Rock, Paper or Scissors in Python 2 | 3 | import random 4 | 5 | def rps(player): 6 | H = ["ROCK", "PAPER", "SCISSOR"] 7 | bot = random.choice(H) 8 | user = player.upper() 9 | if user == "ROCK" or user == "PAPER" or user == "SCISSOR" or user == "SCISSORS": 10 | if user == bot: 11 | print("Its a tie!!") 12 | elif ( 13 | (user == "ROCK" and bot == "SCISSOR") 14 | or (user == "PAPER" and bot == "ROCK") 15 | or ((user == "SCISSOR" or user == "SCISSORS") and bot == "PAPER") 16 | ): 17 | print("You Won!!!") 18 | else: 19 | print("You Lost :(") 20 | else: 21 | print("Invalid input.") 22 | 23 | inp = input("Your choice?: ") 24 | rps(inp) 25 | -------------------------------------------------------------------------------- /Programs/merge_sort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | nums := []int{6, 2, 7, 12, 5, 8} 7 | fmt.Println(mergeSort(nums)) 8 | } 9 | 10 | func mergeSort(items []int) []int { 11 | if len(items) < 2 { 12 | return items 13 | } 14 | 15 | first := mergeSort(items[:len(items)/2]) 16 | second := mergeSort(items[len(items)/2:]) 17 | 18 | return merge(first, second) 19 | } 20 | 21 | func merge(a []int, b []int) []int { 22 | final := []int{} 23 | 24 | i := 0 25 | j := 0 26 | 27 | for i < len(a) && j < len(b) { 28 | if a[i] < b[j] { 29 | final = append(final, a[i]) 30 | i++ 31 | } else { 32 | final = append(final, b[j]) 33 | j++ 34 | } 35 | } 36 | 37 | for ; i < len(a); i++ { 38 | final = append(final, a[i]) 39 | } 40 | 41 | for ; j < len(b); j++ { 42 | final = append(final, b[j]) 43 | } 44 | 45 | return final 46 | } 47 | -------------------------------------------------------------------------------- /Programs/nested_list.py: -------------------------------------------------------------------------------- 1 | #Given the names and grades for each student in a class of students, 2 | #store them in a nested list and print the name(s) of any student(s) having the second lowest grade. 3 | 4 | if __name__ == '__main__': 5 | students=[] 6 | print("Enter the names and scores of students:") 7 | for _ in range(int(input())): 8 | name = input() 9 | score = float(input()) 10 | students.append([name,score]) 11 | students=sorted(students,key=lambda x:x[1]) 12 | #print(students) 13 | #second_lowest_score=students[1][1] 14 | second_lowest_score=sorted(list(set(x[1]for x in students)))[1] 15 | required_data=[] 16 | for stu in students: 17 | if stu[1]==second_lowest_score: 18 | required_data.append(stu[0]) 19 | print("\nstudent(s) having the second lowest grade:") 20 | print("\n".join(sorted(required_data))) 21 | -------------------------------------------------------------------------------- /amstrg: -------------------------------------------------------------------------------- 1 | # Python program to determine whether the number is 2 | # Armstrong number or not 3 | 4 | # Function to calculate x raised to the power y 5 | def power(x, y): 6 | if y==0: 7 | return 1 8 | if y%2==0: 9 | return power(x, y/2)*power(x, y/2) 10 | return x*power(x, y/2)*power(x, y/2) 11 | 12 | # Function to calculate order of the number 13 | def order(x): 14 | 15 | # variable to store of the number 16 | n = 0 17 | while (x!=0): 18 | n = n+1 19 | x = x/10 20 | return n 21 | 22 | # Function to check whether the given number is 23 | # Armstrong number or not 24 | def isArmstrong (x): 25 | n = order(x) 26 | temp = x 27 | sum1 = 0 28 | while (temp!=0): 29 | r = temp%10 30 | sum1 = sum1 + power(r, n) 31 | temp = temp/10 32 | 33 | # If condition satisfies 34 | return (sum1 == x) 35 | 36 | 37 | # Driver Program 38 | x = 153 39 | print(isArmstrong(x)) 40 | x = 1253 41 | print(isArmstrong(x)) 42 | -------------------------------------------------------------------------------- /Programs/LeapYear.py: -------------------------------------------------------------------------------- 1 | # Checkes if a given year is leap year or not 2 | 3 | # To determine whether a year is a leap year, follow these steps: 4 | # Step 1: If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5 5 | # Step 2: If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4 6 | # Step 3: If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5 7 | # Step 4: The year is a leap year (it has 366 days) 8 | # Step 5: The year is not a leap year (it has 365 days) 9 | 10 | year = int(input("Enter a year: ")) 11 | 12 | if (year % 4) == 0: 13 | if (year % 100) == 0: 14 | if (year % 400) == 0: 15 | print("{0} is a leap year".format(year)) 16 | else: 17 | print("{0} is not a leap year".format(year)) 18 | else: 19 | print("{0} is a leap year".format(year)) 20 | else: 21 | print("{0} is not a leap year".format(year)) -------------------------------------------------------------------------------- /Middle-Of-Linked-List.py: -------------------------------------------------------------------------------- 1 | # Python program to find the middle of a given linked list 2 | 3 | class Node: 4 | def __init__(self, value): 5 | self.data = value 6 | self.next = None 7 | 8 | class LinkedList: 9 | 10 | def __init__(self): 11 | self.head = None 12 | 13 | # create Node and and make linked list 14 | def push(self, new_data): 15 | new_node = Node(new_data) 16 | new_node.next = self.head 17 | self.head = new_node 18 | 19 | def printMiddle(self): 20 | temp = self.head 21 | count = 0 22 | 23 | while self.head: 24 | 25 | # only update when count is odd 26 | if (count & 1): 27 | temp = temp.next 28 | self.head = self.head.next 29 | 30 | # increment count in each iteration 31 | count += 1 32 | 33 | print(temp.data) 34 | 35 | # Driver code 36 | llist = LinkedList() 37 | llist.push(1) 38 | llist.push(20) 39 | llist.push(100) 40 | llist.push(15) 41 | llist.push(35) 42 | llist.printMiddle() 43 | -------------------------------------------------------------------------------- /FLOYD WARSHEL ALGORITHM.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # The number of vertices 4 | nV = 4 5 | 6 | INF = 999 7 | 8 | 9 | # Algorithm implementation 10 | def floyd_warshall(G): 11 | distance = list(map(lambda i: list(map(lambda j: j, i)), G)) 12 | 13 | # Adding vertices individually 14 | for k in range(nV): 15 | for i in range(nV): 16 | for j in range(nV): 17 | distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]) 18 | print_solution(distance) 19 | 20 | 21 | # Printing the solution 22 | def print_solution(distance): 23 | for i in range(nV): 24 | for j in range(nV): 25 | if(distance[i][j] == INF): 26 | print("INF", end=" ") 27 | else: 28 | print(distance[i][j], end=" ") 29 | print(" ") 30 | 31 | 32 | G = [[0, 3, INF, 5], 33 | [2, 0, INF, 4], 34 | [INF, 1, 0, INF], 35 | [INF, INF, 2, 0]] 36 | floyd_warshall(G) 37 | -------------------------------------------------------------------------------- /Programs/addition_of_sparse_matrix.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat May 22 00:27:36 2021 4 | 5 | @author: SHRIDHAR KAPSE 6 | """ 7 | 8 | value=[] 9 | for j in range(2): 10 | lis=[] 11 | for i in range(3): 12 | b=int(input("Enter no:", )) 13 | lis.insert(i,b) 14 | 15 | value.insert(j,lis) 16 | print(value) 17 | 18 | key=[] 19 | 20 | for j in range(2): 21 | lis1=[] 22 | for i in range(3): 23 | a=() 24 | a=tuple(map(int,input("Enter the tuple:", ))) 25 | 26 | lis1.insert(i,a) 27 | 28 | key.insert(j,lis1) 29 | 30 | print(key) 31 | d=[] 32 | d3={} 33 | for j in range(2): 34 | dict={} 35 | 36 | for i in range(3): 37 | dict[key[j][i]]=value[j][i] 38 | d.append(dict) 39 | print('d',j,'=',d[j]) 40 | 41 | d.append(d3) 42 | d[2]=d[0].copy() 43 | d[2].update(d[1]) 44 | for i,j in d[0]: 45 | for x,y in d[1]: 46 | if i==x: 47 | d[2][i]=j+y 48 | 49 | 50 | print(d[2]) 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Lajat5 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Programs/longest palindrome.cpp: -------------------------------------------------------------------------------- 1 | // A C++ solution for longest palindrome 2 | #include 3 | using namespace std; 4 | 5 | // Function to print a substring str[low..high] 6 | void printSubStr(string str, int low, int high) 7 | { 8 | for (int i = low; i <= high; ++i) 9 | cout << str[i]; 10 | } 11 | 12 | // This function prints the 13 | // longest palindrome substring 14 | // It also returns the length 15 | // of the longest palindrome 16 | int longestPalSubstr(string str) 17 | { 18 | // get length of input string 19 | int n = str.size(); 20 | 21 | // All substrings of length 1 22 | // are palindromes 23 | int maxLength = 1, start = 0; 24 | 25 | // Nested loop to mark start and end index 26 | for (int i = 0; i < str.length(); i++) { 27 | for (int j = i; j < str.length(); j++) { 28 | int flag = 1; 29 | 30 | // Check palindrome 31 | for (int k = 0; k < (j - i + 1) / 2; k++) 32 | if (str[i + k] != str[j - k]) 33 | flag = 0; 34 | 35 | // Palindrome 36 | if (flag && (j - i + 1) > maxLength) { 37 | start = i; 38 | maxLength = j - i + 1; 39 | } 40 | } 41 | } 42 | 43 | cout << "Longest palindrome substring is: "; 44 | printSubStr(str, start, start + maxLength - 1); 45 | 46 | // return length of LPS 47 | return maxLength; 48 | } 49 | 50 | // Driver Code 51 | int main() 52 | { 53 | string str = "malayalamgeeks"; 54 | cout << "\nLength is: " 55 | << longestPalSubstr(str); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Programs/Indian_Flag_Drawing.py: -------------------------------------------------------------------------------- 1 | """ Using Turtle library of python We Drawing Indian Flag""" 2 | 3 | import turtle 4 | from turtle import* 5 | 6 | #screen for output 7 | screen = turtle.Screen() 8 | 9 | # Defining a turtle Instance 10 | t = turtle.Turtle() 11 | speed(0) 12 | 13 | # initially penup() 14 | t.penup() 15 | t.goto(-400, 250) 16 | t.pendown() 17 | 18 | # Orange Rectangle 19 | #white rectangle 20 | t.color("orange") 21 | t.begin_fill() 22 | t.forward(800) 23 | t.right(90) 24 | t.forward(167) 25 | t.right(90) 26 | t.forward(800) 27 | t.end_fill() 28 | t.left(90) 29 | t.forward(167) 30 | 31 | # Green Rectangle 32 | t.color("green") 33 | t.begin_fill() 34 | t.forward(167) 35 | t.left(90) 36 | t.forward(800) 37 | t.left(90) 38 | t.forward(167) 39 | t.end_fill() 40 | 41 | # Big Blue Circle 42 | t.penup() 43 | t.goto(70, 0) 44 | t.pendown() 45 | t.color("navy") 46 | t.begin_fill() 47 | t.circle(70) 48 | t.end_fill() 49 | 50 | # Big White Circle 51 | t.penup() 52 | t.goto(60, 0) 53 | t.pendown() 54 | t.color("white") 55 | t.begin_fill() 56 | t.circle(60) 57 | t.end_fill() 58 | 59 | # Mini Blue Circles 60 | t.penup() 61 | t.goto(-57, -8) 62 | t.pendown() 63 | t.color("navy") 64 | for i in range(24): 65 | t.begin_fill() 66 | t.circle(3) 67 | t.end_fill() 68 | t.penup() 69 | t.forward(15) 70 | t.right(15) 71 | t.pendown() 72 | 73 | # Small Blue Circle 74 | t.penup() 75 | t.goto(20, 0) 76 | t.pendown() 77 | t.begin_fill() 78 | t.circle(20) 79 | t.end_fill() 80 | # Spokes 81 | t.penup() 82 | t.goto(0, 0) 83 | t.pendown() 84 | t.pensize(2) 85 | for i in range(24): 86 | t.forward(60) 87 | t.backward(60) 88 | t.left(15) 89 | 90 | #to hold the 91 | #output window 92 | turtle.done() 93 | -------------------------------------------------------------------------------- /Programs/articulation_points_in_a_graph.cpp: -------------------------------------------------------------------------------- 1 | //Articulation Point and Bridges 2 | void articulationPointAndBridge(int u) { 3 | dfs_low[u] = dfs_num[u] = dfsNumberCounter++; // dfs_low[u] <= dfs_num[u] 4 | for (int j = 0; j < (int)AdjList[u].size(); j++) { 5 | ii v = AdjList[u][j]; 6 | if (dfs_num[v.first] == UNVISITED) { // a tree edge 7 | dfs_parent[v.first] = u; 8 | if (u == dfsRoot) rootChildren++; // special case if u is a root 9 | articulationPointAndBridge(v.first); 10 | if (dfs_low[v.first] >= dfs_num[u] && u!=dfsRoot) // for articulation point 11 | articulation_vertex[u] = true; // store this information first 12 | if (dfs_low[v.first] > dfs_num[u]) // for bridge 13 | printf(" Edge (%d, %d) is a bridge\n", u, v.first); 14 | dfs_low[u] = min(dfs_low[u], dfs_low[v.first]); // update dfs_low[u] 15 | } 16 | else if (v.first != dfs_parent[u]) // a back edge and not direct cycle 17 | dfs_low[u] = min(dfs_low[u], dfs_num[v.first]); // update dfs_low[u] 18 | } } 19 | // inside int main() 20 | dfsNumberCounter = 0; dfs_num.assign(V, UNVISITED); dfs_low.assign(V, 0); 21 | dfs_parent.assign(V, 0); articulation_vertex.assign(V, 0); 22 | printf("Bridges:\n"); 23 | for (int i = 0; i < V; i++) 24 | if (dfs_num[i] == UNVISITED) { 25 | dfsRoot = i; rootChildren = 0; articulationPointAndBridge(i); 26 | articulation_vertex[dfsRoot] = (rootChildren > 1); } // special case 27 | printf("Articulation Points:\n"); 28 | for (int i = 0; i < V; i++) 29 | if (articulation_vertex[i]) 30 | printf(" Vertex %d\n", i); 31 | -------------------------------------------------------------------------------- /Programs/N_Queen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int n, sol = 1; 4 | 5 | int is_this_safe(char board[n][n], int row, int col) 6 | { 7 | for (int i = 0; i < col; i++) 8 | { 9 | if (board[row][i] == 'Q') 10 | return 0; 11 | } 12 | for (int i = row, j = col; i >= 0 && j >= 0; j--, i--) 13 | { 14 | if (board[i][j] == 'Q') 15 | return 0; 16 | } 17 | for (int i = row, j = col; i < n && j >= 0; i++, j--) 18 | { 19 | if (board[i][j] == 'Q') 20 | return 0; 21 | } 22 | return 1; 23 | } 24 | 25 | int keep_solving_forward(char board[n][n], int col) 26 | { 27 | if (col == n) 28 | { 29 | printf("Solution %d\n", sol); 30 | sol++; 31 | for (int i = 0; i < n; i++) 32 | { 33 | for (int j = 0; j < n; j++) 34 | { 35 | printf("%c ", board[i][j]); 36 | } 37 | printf("\n"); 38 | } 39 | return 1; 40 | } 41 | for (int i = 0; i < n; i++) 42 | { 43 | if (is_this_safe(board, i, col) == 1) 44 | { 45 | board[i][col] = 'Q'; 46 | keep_solving_forward(board, col + 1); 47 | board[i][col] = '*'; 48 | } 49 | } 50 | return 0; 51 | } 52 | int main() 53 | { 54 | printf("Enter the number of queens: "); 55 | scanf("%d", &n); 56 | char board[n][n]; 57 | for (int i = 0; i < n; i++) 58 | { 59 | for (int j = 0; j < n; j++) 60 | { 61 | board[i][j] = '*'; 62 | } 63 | } 64 | keep_solving_forward(board, 0); 65 | if (!sol) 66 | { 67 | printf("No solution exists"); 68 | } 69 | else 70 | { 71 | printf("There are %d solutions for %d X %d chessboard", sol - 1, n, n); 72 | } 73 | return 0; 74 | } -------------------------------------------------------------------------------- /Programs/Merge sort.py: -------------------------------------------------------------------------------- 1 | # Python program for implementation of MergeSort 2 | 3 | # Merges two subarrays of arr[]. 4 | # First subarray is arr[l..m] 5 | # Second subarray is arr[m+1..r] 6 | 7 | 8 | def merge(arr, l, m, r): 9 | n1 = m - l + 1 10 | n2 = r - m 11 | 12 | # create temp arrays 13 | L = [0] * (n1) 14 | R = [0] * (n2) 15 | 16 | # Copy data to temp arrays L[] and R[] 17 | for i in range(0, n1): 18 | L[i] = arr[l + i] 19 | 20 | for j in range(0, n2): 21 | R[j] = arr[m + 1 + j] 22 | 23 | # Merge the temp arrays back into arr[l..r] 24 | i = 0 # Initial index of first subarray 25 | j = 0 # Initial index of second subarray 26 | k = l # Initial index of merged subarray 27 | 28 | while i < n1 and j < n2: 29 | if L[i] <= R[j]: 30 | arr[k] = L[i] 31 | i += 1 32 | else: 33 | arr[k] = R[j] 34 | j += 1 35 | k += 1 36 | 37 | # Copy the remaining elements of L[], if there 38 | # are any 39 | while i < n1: 40 | arr[k] = L[i] 41 | i += 1 42 | k += 1 43 | 44 | # Copy the remaining elements of R[], if there 45 | # are any 46 | while j < n2: 47 | arr[k] = R[j] 48 | j += 1 49 | k += 1 50 | 51 | # l is for left index and r is right index of the 52 | # sub-array of arr to be sorted 53 | 54 | 55 | def mergeSort(arr, l, r): 56 | if l < r: 57 | 58 | # Same as (l+r)//2, but avoids overflow for 59 | # large l and h 60 | m = l+(r-l)//2 61 | 62 | # Sort first and second halves 63 | mergeSort(arr, l, m) 64 | mergeSort(arr, m+1, r) 65 | merge(arr, l, m, r) 66 | 67 | 68 | # Driver code to test above 69 | arr = [12, 11, 13, 5, 6, 7] 70 | n = len(arr) 71 | print("Given array is") 72 | for i in range(n): 73 | print("%d" % arr[i]), 74 | 75 | mergeSort(arr, 0, n-1) 76 | print("\n\nSorted array is") 77 | for i in range(n): 78 | print("%d" % arr[i]), 79 | 80 | # This code is contributed by Mohit Kumra 81 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Comment to be posted to on first time issues 2 | newIssueWelcomeComment: | 3 | Hey, this is not the right place to open an issue. 4 | 5 | **Are you looking for beginner-friendly issues? Check out [this](https://github.com/Lazeeez/HacktoberFest-21) repo.** 6 | 7 | 📢 Spread the word about [@Lazeeez/HacktoberFest-21](https://github.com/Lazeeez/HacktoberFest-21) repo across your social media channels to help get others involved! 8 | 9 | [![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/Lazeeez) 10 | 11 | **Check out few other repos below** 🚀 12 | 13 | **Show some ❤️** 14 | - Consider leaving a ⭐ [here](https://github.com/Lazeeez/HacktoberFest-21). 15 | - Follow @Lazeeez for more updates. 16 | 17 | #### Say Hi on [Twitter](https://twitter.com/Lajat05)! 👋 18 | 19 | # Comment to be posted to on PRs from first time contributors in your repository 20 | newPRWelcomeComment: | 21 | Hey, this is not the right place to raise a pull request! 🤗 22 | 23 | **Are you looking for beginner-friendly issues? Check out [this](https://github.com/Lazeeez/HacktoberFest-21/) repo.** 24 | 25 | 📢 Spread the word about [@Lazeeez/HacktoberFest-21](https://github.com/Lazeeez/HacktoberFest-21) repo across your social media channels to help get others involved! 26 | 27 | **Check out few other repos below** 🚀 28 | 29 | **Show some ❤️** 30 | - Consider leaving a ⭐ [here](https://github.com/Lazeeez/HacktoberFest-21). 31 | - Follow @Lazeeez for more updates. 32 | 33 | #### Say Hi on [Twitter](https://twitter.com/Lajat05)! 👋 34 | 35 | Wishing you a great Hacktoberfest 2021 36 | 37 | # Comment to be posted to on pull requests merged by a first time user 38 | firstPRMergeComment: | 39 | Congrats on merging your first pull request! 🙌🎉⚡️ 40 | Show some love by starring a few of my [repositories](https://github.com/vinitshahdeo?tab=repositories). 41 | -------------------------------------------------------------------------------- /Programs/Circular-linkedlist.py: -------------------------------------------------------------------------------- 1 | #Represents the node of list. 2 | class Node: 3 | def __init__(self,data): 4 | self.data = data; 5 | self.next = None; 6 | 7 | class CreateList: 8 | #Declaring head and tail pointer as null. 9 | def __init__(self): 10 | self.head = Node(None); 11 | self.tail = Node(None); 12 | self.head.next = self.tail; 13 | self.tail.next = self.head; 14 | 15 | #This function will add the new node at the end of the list. 16 | def add(self,data): 17 | newNode = Node(data); 18 | #Checks if the list is empty. 19 | if self.head.data is None: 20 | #If list is empty, both head and tail would point to new node. 21 | self.head = newNode; 22 | self.tail = newNode; 23 | newNode.next = self.head; 24 | else: 25 | #tail will point to new node. 26 | self.tail.next = newNode; 27 | #New node will become new tail. 28 | self.tail = newNode; 29 | #Since, it is circular linked list tail will point to head. 30 | self.tail.next = self.head; 31 | 32 | #Displays all the nodes in the list 33 | def display(self): 34 | current = self.head; 35 | if self.head is None: 36 | print("List is empty"); 37 | return; 38 | else: 39 | print("Nodes of the circular linked list: "); 40 | #Prints each node by incrementing pointer. 41 | print(current.data), 42 | while(current.next != self.head): 43 | current = current.next; 44 | print(current.data), 45 | 46 | 47 | class CircularLinkedList: 48 | cl = CreateList(); 49 | #Adds data to the list 50 | cl.add(1); 51 | cl.add(2); 52 | cl.add(3); 53 | cl.add(4); 54 | #Displays all the nodes present in the list 55 | cl.display(); 56 | -------------------------------------------------------------------------------- /Programs/Djikstra_algo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | vector dijkstra(vector >& adj,map,int>& C,int& source,int& n,int& m){ 5 | const int inf = INT_MAX; 6 | //using min heap to obtain next lesser edge 7 | priority_queue,vector >,greater > >q; 8 | 9 | //Initializing distance to infinity 10 | vectordist(n+1,inf); 11 | q.push({0,source}); 12 | vectorvisited(n+1,false); 13 | dist[source]=0; 14 | 15 | 16 | while(!q.empty()){ 17 | auto z=q.top(); 18 | q.pop(); 19 | int y=z.first; 20 | int x=z.second; 21 | if(visited[x])continue; 22 | visited[x]=true; 23 | for(int i : adj[x]){ 24 | if(!visited[i]){ 25 | if(dist[i]>y+C[{x,i}]){ 26 | dist[i]=y+C[{x,i}]; 27 | q.push({dist[i],i}); 28 | } 29 | } 30 | } 31 | } 32 | return dist; 33 | } 34 | 35 | int main(){ 36 | int n,m; 37 | cin>>n>>m; 38 | //Adjacency List to store the graph 39 | vector >adj(n+1); 40 | 41 | //Map to store the edge lengths 42 | map,int>C; 43 | for(int i=0;i>x>>y>>cost; 46 | if(x==y)continue; 47 | if(C.find({x,y})==C.end()){ 48 | adj[x].push_back(y); 49 | C[{x,y}]=cost; 50 | } 51 | else{ 52 | C[{x,y}]=min(C[{x,y}],cost); 53 | } 54 | } 55 | 56 | int source; 57 | cin>>source; 58 | 59 | vectordist = dijkstra(adj,C,source,n,m); 60 | 61 | //Printing distance of all points from source 62 | for(int i=1;i<=n;i++)cout<', 22 | '*', '(', ')', '<'] 23 | 24 | # combines all the character arrays above to form one array 25 | COMBINED_LIST = DIGITS + UPCASE_CHARACTERS + LOCASE_CHARACTERS + SYMBOLS 26 | 27 | # randomly select at least one character from each character set above 28 | rand_digit = random.choice(DIGITS) 29 | rand_upper = random.choice(UPCASE_CHARACTERS) 30 | rand_lower = random.choice(LOCASE_CHARACTERS) 31 | rand_symbol = random.choice(SYMBOLS) 32 | 33 | # combine the character randomly selected above 34 | # at this stage, the password contains only 4 characters but 35 | # we want a 12-character password 36 | temp_pass = rand_digit + rand_upper + rand_lower + rand_symbol 37 | 38 | 39 | # now that we are sure we have at least one character from each 40 | # set of characters, we fill the rest of 41 | # the password length by selecting randomly from the combined 42 | # list of character above. 43 | for x in range(MAX_LEN - 4): 44 | temp_pass = temp_pass + random.choice(COMBINED_LIST) 45 | 46 | # convert temporary password into array and shuffle to 47 | # prevent it from having a consistent pattern 48 | # where the beginning of the password is predictable 49 | temp_pass_list = array.array('u', temp_pass) 50 | random.shuffle(temp_pass_list) 51 | 52 | # traverse the temporary password array and append the chars 53 | # to form the password 54 | password = "" 55 | for x in temp_pass_list: 56 | password = password + x 57 | 58 | # print out password 59 | print(password) 60 | -------------------------------------------------------------------------------- /Programs/GenericGraph.java: -------------------------------------------------------------------------------- 1 | package competitiveProgramming; 2 | 3 | import java.util.*; 4 | 5 | public class GenericGraph { 6 | 7 | private HashMap> map; 8 | private List dfs_vis = new ArrayList<>(); 9 | 10 | public GenericGraph() { 11 | map = new HashMap<>(); 12 | } 13 | 14 | public void addVertex(T label) { 15 | map.put(label, new LinkedList()); 16 | } 17 | 18 | public void addEdge(T init, T fin, boolean undirected) { 19 | if(!map.containsKey(init)) { 20 | addVertex(init); 21 | } 22 | 23 | if(!map.containsKey(fin)) { 24 | addVertex(fin); 25 | } 26 | 27 | map.get(init).add(fin); 28 | 29 | if(undirected) { 30 | map.get(fin).add(init); 31 | } 32 | } 33 | 34 | public boolean hasVertex(T v) { 35 | return map.containsKey(v); 36 | } 37 | 38 | public boolean hasEdge(T src, T des) { 39 | return map.get(src).contains(des); 40 | } 41 | 42 | public int numVertices() { 43 | return map.keySet().size(); 44 | } 45 | 46 | 47 | @Override 48 | public String toString() { 49 | 50 | String s = ""; 51 | 52 | for(T i: map.keySet()) { 53 | s += i.toString() + ":"; 54 | 55 | for(T j: map.get(i)) { 56 | s += j.toString() + " "; 57 | } 58 | s += "\n"; 59 | } 60 | 61 | return s; 62 | } 63 | 64 | public List dfs(T n) { 65 | 66 | dfs_vis.add(n); 67 | 68 | for(T i : map.get(n)) { 69 | if(!dfs_vis.contains(i)) { 70 | dfs(i); 71 | } 72 | } 73 | return dfs_vis; 74 | } 75 | 76 | public HashMap bfs(T n) { 77 | int v = numVertices(); 78 | Queue q = new LinkedList<>(); 79 | ArrayList vis = new ArrayList<>(); 80 | HashMap dis = new HashMap<>(); 81 | 82 | q.add(n); 83 | vis.add(n); 84 | dis.put(n, 0); 85 | 86 | while(!q.isEmpty()) { 87 | T cur = q.poll(); 88 | 89 | for(T i : map.get(cur)) { 90 | if(!vis.contains(i)) { 91 | vis.add(i); 92 | dis.put(i, dis.get(cur) + 1); 93 | q.add(i); 94 | } 95 | } 96 | } 97 | 98 | return dis; 99 | } 100 | 101 | public boolean hasPath(T src, T des) { 102 | ArrayList dfs_list = (ArrayList) dfs(src); 103 | 104 | if(dfs_list.contains(des)) { 105 | return true; 106 | } else { 107 | return false; 108 | } 109 | 110 | } 111 | 112 | } -------------------------------------------------------------------------------- /Programs/Longest_Common_Subsequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int max(int a,int b) 4 | { 5 | if(a=t[i][j-1]) 65 | { 66 | t[i][j]=t[i-1][j]; 67 | d[i][j]='u'; 68 | } 69 | else 70 | { 71 | t[i][j]=t[i][j-1]; 72 | d[i][j]='l'; 73 | } 74 | } 75 | } 76 | } 77 | printf("\n "); 78 | k=min(m,n); 79 | k--; 80 | i=m,j=n; 81 | while(i>0 && j>0) 82 | { 83 | if(d[i][j]=='d') 84 | { 85 | c[k]=a[i-1]; 86 | len++; 87 | i--; 88 | j--; 89 | k--; 90 | } 91 | else if(d[i][j]=='u') 92 | { 93 | i--; 94 | } 95 | else 96 | { 97 | j--; 98 | } 99 | } 100 | temp=min(m,n); 101 | printf("Longest Common Sequence:"); 102 | for(i=k;i 2 | using namespace std; 3 | 4 | //Using BFS Algorithm 5 | //Intuition- indegree zero nodes wont have any edges so they are placed before. 6 | //indegree is being reduced as zero indegree nodes where taken beforehand. 7 | 8 | class Solution 9 | { 10 | public: 11 | //Function to return list containing vertices in Topological order. 12 | //BFS Algo is used 13 | vector topoSort(int V, vector adj[]) 14 | { 15 | queueq; 16 | vectorindegree(V,0); 17 | for(int i=0;itopo; 28 | while(!q.empty()) 29 | { 30 | int node=q.front(); 31 | q.pop(); 32 | topo.push_back(node); 33 | for(auto it:adj[node]) 34 | { 35 | indegree[it]--; 36 | if(indegree[it]==0) 37 | q.push(it); 38 | } 39 | } 40 | return topo; 41 | } 42 | }; 43 | 44 | int check(int V, vector &res, vector adj[]) { 45 | vector map(V, -1); 46 | for (int i = 0; i < V; i++) { 47 | map[res[i]] = i; 48 | } 49 | for (int i = 0; i < V; i++) { 50 | for (int v : adj[i]) { 51 | if (map[i] > map[v]) return 0; 52 | } 53 | } 54 | return 1; 55 | } 56 | 57 | int main() { 58 | int T; 59 | cin >> T; 60 | while (T--) { 61 | int N, E; 62 | cin >> E >> N; 63 | int u, v; 64 | 65 | vector adj[N]; 66 | 67 | for (int i = 0; i < E; i++) { 68 | cin >> u >> v; 69 | adj[u].push_back(v); 70 | } 71 | 72 | Solution obj; 73 | vector res = obj.topoSort(N, adj); 74 | 75 | cout << check(N, res, adj) << endl; 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | //DFS Algorithm for topo sort 82 | /* 83 | void topoDFS(int node,vector&vis,stack&s,vectoradj[]) 84 | { 85 | vis[node]=1; 86 | for(auto it:adj[node]) 87 | { 88 | if(!vis[it]) 89 | topoDFS(it,vis,s,adj); 90 | } 91 | s.push(node); 92 | } 93 | vector topoSort(int V, vector adj[]) 94 | { 95 | stacks; 96 | vectorvis(V,0); 97 | 98 | for(int i=0;itopo; 104 | while(!s.empty()) 105 | { 106 | topo.push_back(s.top()); 107 | s.pop(); 108 | } 109 | return topo; 110 | } 111 | */ -------------------------------------------------------------------------------- /Programs/Morse_code_translator.py: -------------------------------------------------------------------------------- 1 | # Python program to implement Morse Code Translator 2 | # Dictionary representing the morse code chart 3 | MORSE_CODE_DICT = { 'A':'.-', 'B':'-...', 4 | 'C':'-.-.', 'D':'-..', 'E':'.', 5 | 'F':'..-.', 'G':'--.', 'H':'....', 6 | 'I':'..', 'J':'.---', 'K':'-.-', 7 | 'L':'.-..', 'M':'--', 'N':'-.', 8 | 'O':'---', 'P':'.--.', 'Q':'--.-', 9 | 'R':'.-.', 'S':'...', 'T':'-', 10 | 'U':'..-', 'V':'...-', 'W':'.--', 11 | 'X':'-..-', 'Y':'-.--', 'Z':'--..', 12 | '1':'.----', '2':'..---', '3':'...--', 13 | '4':'....-', '5':'.....', '6':'-....', 14 | '7':'--...', '8':'---..', '9':'----.', 15 | '0':'-----', ', ':'--..--', '.':'.-.-.-', 16 | '?':'..--..', '/':'-..-.', '-':'-....-', 17 | '(':'-.--.', ')':'-.--.-'} 18 | 19 | # Function to encrypt the string 20 | # according to the morse code chart 21 | def encrypt(message): 22 | cipher = '' 23 | for letter in message: 24 | if letter != ' ': 25 | 26 | # Looks up the dictionary and adds the 27 | # correspponding morse code 28 | # along with a space to separate 29 | # morse codes for different characters 30 | cipher += MORSE_CODE_DICT[letter] + ' ' 31 | else: 32 | # 1 space indicates different characters 33 | # and 2 indicates different words 34 | cipher += ' ' 35 | 36 | return cipher 37 | 38 | # Function to decrypt the string 39 | # from morse to english 40 | def decrypt(message): 41 | 42 | # extra space added at the end to access the 43 | # last morse code 44 | message += ' ' 45 | 46 | decipher = '' 47 | citext = '' 48 | for letter in message: 49 | 50 | # checks for space 51 | if (letter != ' '): 52 | 53 | # counter to keep track of space 54 | i = 0 55 | 56 | # storing morse code of a single character 57 | citext += letter 58 | 59 | # in case of space 60 | else: 61 | # if i = 1 that indicates a new character 62 | i += 1 63 | 64 | # if i = 2 that indicates a new word 65 | if i == 2 : 66 | 67 | # adding space to separate words 68 | decipher += ' ' 69 | else: 70 | 71 | # accessing the keys using their values (reverse of encryption) 72 | decipher += list(MORSE_CODE_DICT.keys())[list(MORSE_CODE_DICT 73 | .values()).index(citext)] 74 | citext = '' 75 | 76 | return decipher 77 | 78 | # function to run the program 79 | def main(): 80 | print("\n----------***WELCOME TO Morse Code Translator***-------------") 81 | user_input = str(input("\nEnter 1 to ENCRYPT & 2 for DECRYPT: ")) 82 | if user_input == str(1): 83 | message = str(input("Enter txt to: ")) 84 | result = encrypt(message.upper()) 85 | print (result) 86 | if user_input == str(2): 87 | message = input("Enter code : ") 88 | result = decrypt(message) 89 | print (result) 90 | else: 91 | print("Please Enter correct input") 92 | 93 | # Executes the main function 94 | if __name__ == '__main__': 95 | main() 96 | -------------------------------------------------------------------------------- /Programs/tic_tac_toe game.py: -------------------------------------------------------------------------------- 1 | # Tic Tac Toe code 2 | # Simple project to make CPU vs CPU game with random selection & see which cpu is lucky. 3 | # CPU vs CPU game mode. Start it enjoy watching them play. 4 | 5 | import numpy as np 6 | import random 7 | from time import sleep 8 | 9 | # Creates an empty board 10 | def create_board(): 11 | return(np.array([[0, 0, 0], 12 | [0, 0, 0], 13 | [0, 0, 0]])) 14 | 15 | # Check for empty places on board 16 | def possibilities(board): 17 | l = [] 18 | 19 | for i in range(len(board)): 20 | for j in range(len(board)): 21 | 22 | if board[i][j] == 0: 23 | l.append((i, j)) 24 | return(l) 25 | 26 | # Select a random place for the player 27 | def random_place(board, player): 28 | selection = possibilities(board) 29 | current_loc = random.choice(selection) 30 | board[current_loc] = player 31 | return(board) 32 | 33 | # Checks whether the player has three 34 | # of their marks in a horizontal row 35 | def row_win(board, player): 36 | for x in range(len(board)): 37 | win = True 38 | 39 | for y in range(len(board)): 40 | if board[x, y] != player: 41 | win = False 42 | continue 43 | 44 | if win == True: 45 | return(win) 46 | return(win) 47 | 48 | # Checks whether the player has three 49 | # of their marks in a vertical row 50 | def col_win(board, player): 51 | for x in range(len(board)): 52 | win = True 53 | 54 | for y in range(len(board)): 55 | if board[y][x] != player: 56 | win = False 57 | continue 58 | 59 | if win == True: 60 | return(win) 61 | return(win) 62 | 63 | # Checks whether the player has three 64 | # of their marks in a diagonal row 65 | def diag_win(board, player): 66 | win = True 67 | y = 0 68 | for x in range(len(board)): 69 | if board[x, x] != player: 70 | win = False 71 | if win: 72 | return win 73 | win = True 74 | if win: 75 | for x in range(len(board)): 76 | y = len(board) - 1 - x 77 | if board[x, y] != player: 78 | win = False 79 | return win 80 | 81 | # Evaluates whether there is 82 | # a winner or a tie 83 | def evaluate(board): 84 | winner = 0 85 | 86 | for player in [1, 2]: 87 | if (row_win(board, player) or 88 | col_win(board,player) or 89 | diag_win(board,player)): 90 | 91 | winner = player 92 | 93 | if np.all(board != 0) and winner == 0: 94 | winner = -1 95 | return winner 96 | 97 | # Main function to start the game 98 | def play_game(): 99 | board, winner, counter = create_board(), 0, 1 100 | print(board) 101 | sleep(2) 102 | 103 | while winner == 0: 104 | for player in [1, 2]: 105 | board = random_place(board, player) 106 | print("Board after " + str(counter) + " move") 107 | print(board) 108 | sleep(2) 109 | counter += 1 110 | winner = evaluate(board) 111 | if winner != 0: 112 | break 113 | return(winner) 114 | 115 | # Driver Code 116 | print("Winner is: " + str(play_game())) 117 | -------------------------------------------------------------------------------- /Guess The Number.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | import java.util.Random; 4 | 5 | public class GuessTheNumber 6 | 7 | { 8 | 9 | public static void main(String [] args) 10 | 11 | { 12 | 13 | Random obj=new Random(); 14 | 15 | int a=obj.nextInt(101); 16 | 17 | System.out.println("Generated Number= "+a); 18 | 19 | Scanner input=new Scanner(System.in); 20 | 21 | System.out.println("Number Generated Successfully!!\n\nNow start Guessing the Number."); 22 | 23 | System.out.println("Are you Ready?? Enter Yes or No."); 24 | 25 | String b=input.next(); 26 | 27 | int count1=0,count2=0,count3=0; 28 | 29 | if(b.equalsIgnoreCase("yes")) 30 | 31 | { 32 | 33 | for(int i=0;i<50;i++) 34 | 35 | { 36 | 37 | System.out.println("Make a Guess."); 38 | 39 | int x=input.nextInt(); 40 | 41 | if(a-x>0) 42 | 43 | { 44 | 45 | System.out.println("Oops!! not a right guess. \nHint: Increse your Number."); 46 | 47 | count1++; 48 | 49 | int c1=count1+count2+count3; 50 | 51 | System.out.println("No. of attempts= "+c1); 52 | 53 | System.out.println("Unsuccessful attempts= "+c1+" Successful attempts= 0"); 54 | 55 | System.out.println("\nIf you want to continue, go ahead and enter Y for Yes. \nElse,want to leave game enter N for No."); 56 | 57 | String c=input.next(); 58 | 59 | if(c.equalsIgnoreCase("n")) 60 | 61 | break; 62 | 63 | } 64 | 65 | else if(a-x<0) 66 | 67 | { 68 | 69 | System.out.println("Oops!! not a right guess. \nHint: Decrese your Number."); 70 | 71 | count2++; 72 | 73 | int c2=count1+count2+count3; 74 | 75 | System.out.println("No. of attempts= "+c2); 76 | 77 | System.out.println("Unsuccessful attempts= "+c2+" Successful attempts= 0"); 78 | 79 | System.out.println("\nIf you want to continue, go ahead and enter Y for Yes. \nElse,want to leave game enter N for No."); 80 | 81 | String d=input.next(); 82 | 83 | //count2++; 84 | 85 | if(d.equalsIgnoreCase("n")) 86 | 87 | break; 88 | 89 | } 90 | 91 | else if(a-x==0) 92 | 93 | { 94 | 95 | System.out.println("Congrats!! You Guessed it Right."); 96 | 97 | count3++; 98 | 99 | int c3=count1+count2+count3; 100 | 101 | System.out.println("No. of attempts= "+c3); 102 | 103 | System.out.println("Unsuccessful attempts= "+(c3-1)+" Successful attempts= 1."); 104 | 105 | break; 106 | 107 | } 108 | 109 | } 110 | 111 | } 112 | 113 | } 114 | 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Password Strength Checker.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | import java.lang.*; 4 | 5 | class thread1 extends Thread 6 | 7 | { 8 | 9 | public void fun() 10 | 11 | { 12 | 13 | try 14 | 15 | { 16 | 17 | System.out.println("Please, wait while we are processing.\n");Thread.sleep(2000); 18 | 19 | Thread.sleep(5000); 20 | 21 | } 22 | 23 | catch(Exception e) 24 | 25 | { 26 | 27 | //e.printStackTrace(); 28 | 29 | System.out.println(e.getMessage()); 30 | 31 | } 32 | 33 | } 34 | 35 | } 36 | 37 | public class PasswordStrengthChecker 38 | 39 | { 40 | 41 | public static void main(String [] args) 42 | 43 | { 44 | 45 | Scanner input=new Scanner(System.in); 46 | 47 | System.out.println("Enter your password= "); 48 | 49 | String a=input.nextLine(); 50 | 51 | thread1 obj=new thread1(); 52 | 53 | obj.start(); 54 | 55 | obj.fun(); 56 | 57 | int count1=0,count2=0,count3=0; 58 | 59 | for(int i=0;i=8) 80 | 81 | { 82 | 83 | for(int i=0;i30%\nHint: Try to use Upper Case Characters or Special Characters."); 112 | 113 | } 114 | 115 | 116 | 117 | else if(count2>0 && count3==0) 118 | 119 | { 120 | 121 | System.out.println("Somewhat Strong Password.\nStrength= 50%\nHint: Try to use Special Characters."); 122 | 123 | } 124 | 125 | 126 | 127 | else if(count2==0 && count3>0) 128 | 129 | { 130 | 131 | System.out.println("Strong Password.\nStrength= 80%\nHint: Try to use Upper Case Characters."); 132 | 133 | } 134 | 135 | 136 | 137 | else if(count2>0 && count3>0) 138 | 139 | { 140 | 141 | System.out.println("Very Strong Password.\nStrength= 100%"); 142 | 143 | System.out.println("You can go by this!!"); 144 | 145 | } 146 | 147 | 148 | 149 | } 150 | 151 | } 152 | 153 | } 154 | 155 | -------------------------------------------------------------------------------- /Programs/binary search tree.py: -------------------------------------------------------------------------------- 1 | # Python3 program to implement 2 | # optimized delete in BST. 3 | 4 | class Node: 5 | 6 | # Constructor to create a new node 7 | def __init__(self, key): 8 | self.key = key 9 | self.left = None 10 | self.right = None 11 | 12 | 13 | # A utility function to do 14 | # inorder traversal of BST 15 | def inorder(root): 16 | if root is not None: 17 | inorder(root.left) 18 | print(root.key, end=" ") 19 | inorder(root.right) 20 | 21 | 22 | # A utility function to insert a 23 | # new node with given key in BST 24 | def insert(node, key): 25 | # If the tree is empty, 26 | # return a new node 27 | if node is None: 28 | return Node(key) 29 | 30 | # Otherwise recur down the tree 31 | if key < node.key: 32 | node.left = insert(node.left, key) 33 | else: 34 | node.right = insert(node.right, key) 35 | 36 | # return the (unchanged) node pointer 37 | return node 38 | 39 | 40 | # Given a binary search tree 41 | # and a key, this function 42 | # delete the key and returns the new root 43 | def deleteNode(root, key): 44 | # Base Case 45 | if root is None: 46 | return root 47 | 48 | # Recursive calls for ancestors of 49 | # node to be deleted 50 | if key < root.key: 51 | root.left = deleteNode(root.left, key) 52 | return root 53 | 54 | elif key > root.key: 55 | root.right = deleteNode(root.right, key) 56 | return root 57 | 58 | # We reach here when root is the node 59 | # to be deleted. 60 | 61 | # If one of the children is empty 62 | 63 | if root.left is None: 64 | temp = root.right 65 | root = None 66 | return temp 67 | 68 | elif root.right is None: 69 | temp = root.left 70 | root = None 71 | return temp 72 | 73 | # If both children exist 74 | 75 | succParent = root 76 | 77 | # Find Successor 78 | 79 | succ = root.right 80 | 81 | while succ.left != None: 82 | succParent = succ 83 | succ = succ.left 84 | 85 | # Delete successor.Since successor 86 | # is always left child of its parent 87 | # we can safely make successor's right 88 | # right child as left of its parent. 89 | # If there is no succ, then assign 90 | # succ->right to succParent->right 91 | if succParent != root: 92 | succParent.left = succ.right 93 | else: 94 | succParent.right = succ.right 95 | 96 | # Copy Successor Data to root 97 | 98 | root.key = succ.key 99 | 100 | return root 101 | 102 | 103 | # Driver code 104 | """ Let us create following BST 105 | 50 106 | / \ 107 | 30 70 108 | / \ / \ 109 | 20 40 60 80 """ 110 | 111 | root = None 112 | root = insert(root, 50) 113 | root = insert(root, 30) 114 | root = insert(root, 20) 115 | root = insert(root, 40) 116 | root = insert(root, 70) 117 | root = insert(root, 60) 118 | root = insert(root, 80) 119 | 120 | # print("Inorder traversal of the given tree") 121 | # inorder(root) 122 | 123 | # print("\nDelete 20") 124 | # root = deleteNode(root, 50) 125 | # print("Inorder traversal of the modified tree") 126 | # inorder(root) 127 | # 128 | 129 | 130 | 131 | 132 | print(root.left.key) 133 | # print("\nDelete 30") 134 | # root = deleteNode(root, 30) 135 | # print("Inorder traversal of the modified tree") 136 | # inorder(root) 137 | # 138 | # print("\nDelete 50") 139 | # root = deleteNode(root, 50) 140 | # print("Inorder traversal of the modified tree") 141 | # inorder(root) 142 | -------------------------------------------------------------------------------- /brestcancer prediction.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.ensemble import RandomForestClassifier 5 | import tkinter as tk 6 | class Predictor: 7 | 8 | def has_disease(self, row): 9 | self.train(self) 10 | #Class: (2 for benign, 4 for malignant) 11 | return True if self.predict(self, row) == 4 else False 12 | 13 | @staticmethod 14 | def train(self): 15 | dataset = pd.read_csv('./data/breast-cancer.csv') 16 | dataset = dataset[dataset.Bare_Nuclei != '?'] 17 | dataset = dataset.drop(['Sample code number'], axis=1) 18 | y = dataset['Class'] 19 | X = dataset.drop(['Class'], axis=1) 20 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=0) 21 | self.classifier = RandomForestClassifier(n_estimators=10, criterion='entropy', random_state=0) 22 | self.classifier.fit(X_train, y_train) 23 | score = self.classifier.score(X_test, y_test) 24 | print('--Training Complete--') 25 | print('Score: ' + str(score)) 26 | 27 | @staticmethod 28 | def predict(self, row): 29 | user_df = np.array(row).reshape(1, 9) 30 | # user_df = self.standardScaler.transform(user_df) 31 | predicted = self.classifier.predict(user_df) 32 | print("Predicted: " + str(predicted[0])) 33 | return predicted[0] 34 | 35 | 36 | la=str() 37 | def onClick(): 38 | row=[[cthick.get(),ucsize.get(),ucshape.get(),ma.get(),cecsize.get(),bn.get(),bc.get(),nn.get(),mito.get()]] 39 | print(row) 40 | predictor = Predictor() 41 | o = predictor.has_disease(row) 42 | root2 = tk.Tk() 43 | root2.title("Prediction Window") 44 | if (o == True): 45 | print("Person Have Breast Cancer") 46 | la="Person Have Breast Cancer" 47 | tk.Label(root2, text=la, font=("times new roman", 20), fg="white", bg="maroon", height=2).grid(row=0, column=1) 48 | else: 49 | print("Person Is Healthy") 50 | la="Person Is Healthy" 51 | tk.Label(root2, text=la, font=("times new roman", 20), fg="white", bg="green", height=2).grid(row=0, column=1) 52 | 53 | return True 54 | root = tk.Tk() 55 | root.title("Breast Cancer Predictor") 56 | tk.Label(root,text="""Fill Values between 1 - 10""",font=("times new roman", 12)).grid(row=0) 57 | tk.Label(root,text='Clump Thickness ',padx=20, font=("times new roman", 12)).grid(row=1,column=0) 58 | cthick = tk.IntVar() 59 | tk.Entry(root,textvariable=cthick).grid(row=1,column=1) 60 | 61 | tk.Label(root,text="""Uniformity of Cell Size""",padx=20, font=("times new roman", 12)).grid(row=2,column=0) 62 | ucsize = tk.IntVar() 63 | tk.Entry(root,textvariable=ucsize).grid(row=2,column=1) 64 | 65 | tk.Label(root,text='Uniformity of Cell Shape', font=("times new roman", 12)).grid(row=3,column=0) 66 | ucshape = tk.IntVar() 67 | tk.Entry(root,textvariable=ucshape).grid(row=3,column=1) 68 | 69 | tk.Label(root,text='Marginal Adhesion', font=("times new roman", 12)).grid(row=4,column=0) 70 | ma = tk.IntVar() 71 | tk.Entry(root,textvariable=ma).grid(row=4,column=1) 72 | 73 | tk.Label(root,text='Single Epithelial Cell Size', font=("times new roman", 12)).grid(row=5,column=0) 74 | cecsize = tk.IntVar() 75 | tk.Entry(root,textvariable=cecsize).grid(row=5,column=1) 76 | 77 | tk.Label(root,text="""Bare Nuclei""",padx=20, font=("times new roman", 12)).grid(row=6,column=0) 78 | bn=tk.IntVar() 79 | tk.Entry(root,textvariable=bn).grid(row=6,column=1) 80 | 81 | tk.Label(root,text="""Bland Chromatin""",padx=20, font=("times new roman", 12)).grid(row=7,column=0) 82 | bc=tk.IntVar() 83 | tk.Entry(root,textvariable=bc).grid(row=7,column=1) 84 | 85 | tk.Label(root,text='Normal Nucleoli', font=("times new roman", 12)).grid(row=8,column=0) 86 | nn = tk.IntVar() 87 | tk.Entry(root,textvariable=nn).grid(row=8,column=1) 88 | 89 | tk.Label(root,text="""Mitoses""",padx=20, font=("times new roman", 12)).grid(row=9,column=0) 90 | mito=tk.IntVar() 91 | tk.Entry(root,textvariable=mito).grid(row=9,column=1) 92 | 93 | tk.Button(root, text='Predict', command=onClick).grid(row=11, column=1) 94 | 95 | root.mainloop() 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![Hacktoberfest 2021](./assets/logo.png)](https://github.com/Lazeeez/HacktoberFest-21) 3 | # Hacktoberfest 2021 4 | 5 | [![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/vinitshahdeo) [![GitHub license](https://img.shields.io/github/license/vinitshahdeo/HacktoberFest2K19?logo=GITHUB&style=flat)](https://github.com/vinitshahdeo/Hacktoberfest2021/blob/master/LICENSE) 6 | 7 | > ### A mentorship initiative to help beginners kickstarting their open-source journey by completing Hacktoberfest'21 challenge. 8 | 9 | Here's a home to your queries and quest for potential issues to contribute. I've compiled a handpicked list of **beginner-friendly issues** (& repositories) ahead of time so that you can get the ball rolling once Hacktoberfest kicks off! 🚀 10 | 11 | If you are a beginner, I'll will guide you on getting started with open source and completing your Hacktoberfest challenge. You can begin by introducing yourself in your branch description. If you happen to be experienced in this field, I would be more than grateful to onboard you as a mentor. 12 | 13 | ## Your First PR 14 | 15 | All you need to know is a programming language! Voila, you're just a step away from opening your first pull request! 16 | 17 | **Here's the issue: [Add More Programs](https://github.com/Lazeeez/HacktoberFest-21/issues/1)** 18 | 19 | ## Contributing 20 | 21 | - Feel free to [raise a PR](https://github.com/Lazeeez/HacktoberFest-21/pulls) to add beginner-friendly issues (& repos). 22 | - Kindly follow [this format](https://github.com/Lazeeez/HacktoberFest-21/blob/main/.github/PULL_REQUEST_TEMPLATE/ADD_NEW_ISSUE.md) to raise the PR. 23 | 24 | 25 | ## Need help 26 | 27 | Are you a beginner looking for help in kickstarting your open-source journey? Start a discussion here. 28 | 29 | - Additionally, you can reach out to me to get 1:1 help to resolve your queries. 30 | 31 | ### As a mentor, I will: 32 | 33 | 🙏 **resolve beginner's doubts** 34 | 35 | 👍 **share beginner-friendly issues (& repositories)**. 36 | 37 | 💬 **engage with other community members**. 38 | 39 | 🤝 **welcome and help others to finish the Hacktoberfest challenge**. 40 | 41 | 42 | ## What is Hacktoberfest? 43 | Hacktoberfest, in its 8th year, is a month-long celebration of open source software run by DigitalOcean. During the month of October, we invite you to join open-source software enthusiasts, beginners, and the developer community by contributing to open-source projects. You can do this in a variety of ways: 44 | 45 | ## How do I get started? 46 | 1. Visit the official HactoberFest website [here](https://hacktoberfest.digitalocean.com/) 47 | 2. Click on the 'Start Hacking' Button. 48 | 3. Login using your Github/ Gitlab account. It is crucial that you have a Github or Gitlab account to take part in Hactoberfest. 49 | 4. And you're all set! 50 | 51 | ## What do I do next? 52 | 1. Logging in through your Github/Gitlab account allows Hacktoberfest to track your progress. You are required to: 53 | 2. Make 4 succesful PRs in to a HactoberFest marked repository or need to have 'hacktoberfest-accepted' label to your PR. 54 | 3. Pull Requests made between October 1st and October 31st (both dates included) will be counted. 55 | 56 | ## How to contribute to this project? 57 | 1. Choose language. 58 | 2. Select problem which you want to solve. 59 | 3. Fork this repository (Click the Fork button in the top right of this page, click your Profile Image). 60 | 4. Clone your fork down to your local machine. 61 | ``` 62 | git clone https://github.com/your-username/hacktoberfest.git 63 | ``` 64 | 5. Create a branch. 65 | ``` 66 | git checkout -b branch-name 67 | ``` 68 | 6. Make your changes (choose from any task below). 69 | 7. Commit and push. 70 | ``` 71 | git add --all 72 | git commit -m "Add *your feature*" 73 | git push origin branch-name 74 | ``` 75 | 8. Create a new pull request from your forked repository (Click the `New Pull Request` button located at the top of your repo). 76 | 9. Wait for your PR review and merge approval! 77 | 78 | --------- 79 | 80 | ```javascript 81 | 82 | if (isAwesome) { 83 | // thanks in advance :p 84 | starThisRepository(); 85 | } 86 | 87 | ``` 88 | 89 | ----------- 90 | -------------------------------------------------------------------------------- /Programs/Basic_Linked_List_all.py: -------------------------------------------------------------------------------- 1 | class Node: 2 | #Initialize node oject 3 | def __init__(self, data): 4 | self.data = data #assign data 5 | self.next = None #declare next as null 6 | 7 | class LinkedList: 8 | #Initialize head 9 | def __init__(self): 10 | self.head = None 11 | 12 | #### Insert in the beginning 13 | def push(self, content): 14 | #Allocate node, Put data 15 | new_node = Node(content) 16 | #attach head after new_node 17 | new_node.next = self.head 18 | #set new_node as current head 19 | self.head = new_node 20 | 21 | #### Insert in the middle 22 | def insertAfter(self, prev_node, content): 23 | if prev_node is None: 24 | print("Prev Node invalid") 25 | return 26 | 27 | new_node = Node(content) 28 | new_node.next = prev_node.next 29 | prev_node.next = new_node 30 | 31 | #### Insert at last 32 | def append(self, content): 33 | 34 | new_node = Node(content) 35 | #If Linkedlist is empty 36 | if self.head is None: 37 | self.head = new_node 38 | return 39 | #Else, traverse to last node 40 | last = self.head 41 | while (last.next): 42 | last = last.next 43 | #attach new node 44 | last.next = new_node 45 | 46 | ### PRINT LIST 47 | def printlist(self): 48 | temp = self.head 49 | while (temp): 50 | print(temp.data) 51 | temp = temp.next 52 | 53 | #### Delete node using key 54 | def deleteNode_key(self, key): 55 | temp = self.head 56 | #for head node 57 | if temp is not None: 58 | if temp.data == key: 59 | self.head = temp.next 60 | temp = None 61 | return 62 | #moving ahead from head node, until key found 63 | while(temp is not None): 64 | if temp.data == key: 65 | break 66 | prev = temp 67 | temp = temp.next 68 | #if not found 69 | if temp == None: 70 | return 71 | #Unlink node 72 | prev.next = temp.next 73 | temp = None 74 | 75 | #### Delete node using position 76 | def deleteNode_pos(self, pos): 77 | if self.head is None: 78 | return 79 | 80 | temp = self.head 81 | #to delete head 82 | if pos == 0: 83 | self.head = temp.next 84 | temp = None 85 | return 86 | #find previous node of the node to be deleted 87 | for i in range(pos-1): 88 | temp = temp.next 89 | if temp is None: 90 | break 91 | 92 | if temp is None: 93 | return 94 | if temp.next is None: 95 | return 96 | #store next to next node to be deleted 97 | next = temp.next.next 98 | #unlink 99 | temp.next = None 100 | temp.next = next 101 | 102 | #### Find length 103 | def listlength(self): 104 | len = 0 105 | if self.head is None: 106 | print("Len = ",len) 107 | return 108 | 109 | temp = self.head 110 | while temp: 111 | len += 1 112 | temp = temp.next 113 | print("Len = ", len) 114 | 115 | #### REVERSE 116 | def reverse(self): 117 | prev = None 118 | current = self.head 119 | while(current is not None): 120 | next = current.next 121 | current.next = prev 122 | prev = current 123 | current = next 124 | self.head = prev 125 | 126 | 127 | if __name__ == '__main__': 128 | list1 = LinkedList() 129 | list1.append(6) 130 | list1.append(3) 131 | list1.push(4) 132 | list1.insertAfter(list1.head.next, 1) 133 | 134 | list1.printlist() 135 | print("______") 136 | 137 | list1.listlength() 138 | print("______") 139 | 140 | list1.deleteNode_key(4) 141 | list1.printlist() 142 | print("______") 143 | 144 | list1.reverse() 145 | list1.printlist() 146 | print("______") 147 | 148 | list1.deleteNode_pos(1) 149 | list1.printlist() 150 | print("______") 151 | 152 | 153 | -------------------------------------------------------------------------------- /Encryption Decryption/ENCRYPT-DECRYPT A MESSAGE.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import random 3 | import base64 4 | window = Tk() 5 | window.geometry("1200x600") 6 | window.title("ENCRYPT/DECRYPT MESSAGE WINDOW") 7 | Tops = Frame(window, width = 1600, relief = RIDGE) 8 | Tops.pack(side = TOP) 9 | f1 = Frame(window, width = 800, height = 700, relief = RIDGE) 10 | f1.pack(side = TOP) 11 | lblInfo = Label(Tops, font = ('Lucida Console', 50, 'bold'), text = "\nENCRYPT/DECRYPT MESSAGE\n\n", fg = "Black", bd = 10, anchor='w') 12 | lblInfo.grid(row = 0, column = 0) 13 | 14 | Msg = StringVar() 15 | psd = StringVar() 16 | mode = StringVar() 17 | Result = StringVar() 18 | 19 | # labels 20 | lblMsg = Label(f1, font = ('Times New Roman', 16, 'bold'), text = "MESSAGE", bd = 16, anchor = "w") 21 | 22 | lblMsg.grid(row = 0, column = 0) 23 | 24 | txtMsg = Entry(f1, font = ('Times New Roman', 16, 'bold'), textvariable = Msg, bd = 10, insertwidth = 4, bg = "white", justify = 'right') 25 | 26 | txtMsg.grid(row = 0, column = 1) 27 | 28 | lblpsd = Label(f1, font = ('Times New Roman', 16, 'bold'), text = "PASSWORD KEY", bd = 16, anchor = "w") 29 | 30 | lblpsd.grid(row = 1, column = 1) 31 | 32 | txtpsd = Entry(f1, font = ('Times New Roman', 16, 'bold'), textvariable = psd, bd = 10, insertwidth = 4, bg = "white", justify = 'right') 33 | 34 | txtpsd.grid(row = 1, column = 2) 35 | 36 | lblmode = Label(f1, font = ('Times New Roman', 16, 'bold'), text = "MODE(e - Encrypts, d - Decrypts)", bd = 16, anchor = "w") 37 | 38 | lblmode.grid(row = 2, column = 1) 39 | 40 | txtmode = Entry(f1, font = ('Times New Roman', 16, 'bold'), textvariable = mode, bd = 10, insertwidth = 4, bg = "white", justify = 'right') 41 | 42 | txtmode.grid(row = 2, column = 2) 43 | 44 | lblService = Label(f1, font = ('Times New Roman', 16, 'bold'), text = "Resulted Message", bd = 16, anchor = "w") 45 | 46 | lblService.grid(row = 0, column = 3) 47 | 48 | txtService = Entry(f1, font = ('Times New Roman', 16, 'bold'), textvariable = Result, bd = 10, insertwidth = 4, bg = "white", justify = 'right') 49 | 50 | txtService.grid(row = 0, column = 4) 51 | 52 | def encode(psd, clear): # encode function 53 | enc = [] 54 | for i in range(len(clear)): 55 | psd_c = psd[i % len(psd)] 56 | enc_c = chr((ord(clear[i]) + ord(psd_c)) % 256) 57 | enc.append(enc_c) 58 | return base64.urlsafe_b64encode("".join(enc).encode()).decode() 59 | 60 | def decode(psd, enc): # decode function 61 | dec = [] 62 | enc = base64.urlsafe_b64decode(enc).decode() 63 | for i in range(len(enc)): 64 | psd_c = psd[i % len(psd)] 65 | dec_c = chr((256 + ord(enc[i]) - ord(psd_c)) % 256) 66 | dec.append(dec_c) 67 | return "".join(dec) 68 | 69 | def Ent(): # enter function 70 | print("Message = ", (Msg.get())) 71 | clear = Msg.get() 72 | p = psd.get() 73 | m = mode.get() 74 | if (m == 'd'): 75 | Result.set(decode(p, clear)) 76 | else: 77 | Result.set(encode(p, clear)) 78 | 79 | def qExit(): # exit function 80 | window.destroy() 81 | 82 | def Reset(): # reset function 83 | Msg.set("") 84 | psd.set("") 85 | mode.set("") 86 | Result.set("") 87 | 88 | # Reset button 89 | #btnReset = 90 | Button(f1, padx = 8, pady = 4, bd = 10, fg = "black", 91 | font = ('ROG Fonts', 16, 'bold'), width = 8, text = "RESET", 92 | bg = "green", command = Reset).grid(row = 8, column = 1) 93 | 94 | # Enter button 95 | #btnEnter = 96 | Button(f1, padx = 8, pady = 4, bd = 10, fg = "black", 97 | font = ('ROG Fonts', 16, 'bold'), width = 10, text = "ENTER", 98 | bg = "powder blue", command = Ent).grid(row = 8, column = 2) 99 | 100 | # Exit button 101 | #btnExit = 102 | Button(f1, padx = 8, pady = 4, bd = 10, fg = "black", 103 | font = ('ROG Fonts', 16, 'bold'), width = 8, text = "EXIT", 104 | bg = "red", command = qExit).grid(row = 8, column = 3) 105 | 106 | window.mainloop() -------------------------------------------------------------------------------- /Programs/Hangman.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | # Initial Steps to invite in the game: 5 | print("\nWelcome to Hangman game\n") 6 | name = input("Enter your name: ") 7 | print("Hello " + name + "! Best of Luck!") 8 | time.sleep(2) 9 | print("The game is about to start!\n Let's play Hangman!") 10 | time.sleep(3) 11 | 12 | 13 | # The parameters we require to execute the game: 14 | def main(): 15 | global count 16 | global display 17 | global word 18 | global already_guessed 19 | global length 20 | global play_game 21 | words_to_guess = ["january","border","image","film","promise","kids","lungs","doll","rhyme","damage" 22 | ,"plants"] 23 | word = random.choice(words_to_guess) 24 | length = len(word) 25 | count = 0 26 | display = '_' * length 27 | already_guessed = [] 28 | play_game = "" 29 | 30 | # A loop to re-execute the game when the first round ends: 31 | 32 | def play_loop(): 33 | global play_game 34 | play_game = input("Do You want to play again? y = yes, n = no \n") 35 | while play_game not in ["y", "n","Y","N"]: 36 | play_game = input("Do You want to play again? y = yes, n = no \n") 37 | if play_game == "y": 38 | main() 39 | elif play_game == "n": 40 | print("Thanks For Playing! We expect you back again!") 41 | exit() 42 | 43 | # Initializing all the conditions required for the game: 44 | def hangman(): 45 | global count 46 | global display 47 | global word 48 | global already_guessed 49 | global play_game 50 | limit = 5 51 | guess = input("This is the Hangman Word: " + display + " Enter your guess: \n") 52 | guess = guess.strip() 53 | if len(guess.strip()) == 0 or len(guess.strip()) >= 2 or guess <= "9": 54 | print("Invalid Input, Try a letter\n") 55 | hangman() 56 | 57 | 58 | elif guess in word: 59 | already_guessed.extend([guess]) 60 | index = word.find(guess) 61 | word = word[:index] + "_" + word[index + 1:] 62 | display = display[:index] + guess + display[index + 1:] 63 | print(display + "\n") 64 | 65 | elif guess in already_guessed: 66 | print("Try another letter.\n") 67 | 68 | else: 69 | count += 1 70 | 71 | if count == 1: 72 | time.sleep(1) 73 | print(" _____ \n" 74 | " | \n" 75 | " | \n" 76 | " | \n" 77 | " | \n" 78 | " | \n" 79 | " | \n" 80 | "__|__\n") 81 | print("Wrong guess. " + str(limit - count) + " guesses remaining\n") 82 | 83 | elif count == 2: 84 | time.sleep(1) 85 | print(" _____ \n" 86 | " | | \n" 87 | " | |\n" 88 | " | \n" 89 | " | \n" 90 | " | \n" 91 | " | \n" 92 | "__|__\n") 93 | print("Wrong guess. " + str(limit - count) + " guesses remaining\n") 94 | 95 | elif count == 3: 96 | time.sleep(1) 97 | print(" _____ \n" 98 | " | | \n" 99 | " | |\n" 100 | " | | \n" 101 | " | \n" 102 | " | \n" 103 | " | \n" 104 | "__|__\n") 105 | print("Wrong guess. " + str(limit - count) + " guesses remaining\n") 106 | 107 | elif count == 4: 108 | time.sleep(1) 109 | print(" _____ \n" 110 | " | | \n" 111 | " | |\n" 112 | " | | \n" 113 | " | O \n" 114 | " | \n" 115 | " | \n" 116 | "__|__\n") 117 | print("Wrong guess. " + str(limit - count) + " last guess remaining\n") 118 | 119 | elif count == 5: 120 | time.sleep(1) 121 | print(" _____ \n" 122 | " | | \n" 123 | " | |\n" 124 | " | | \n" 125 | " | O \n" 126 | " | /|\ \n" 127 | " | / \ \n" 128 | "__|__\n") 129 | print("Wrong guess. You are hanged!!!\n") 130 | print("The word was:",already_guessed,word) 131 | play_loop() 132 | 133 | if word == '_' * length: 134 | print("Congrats! You have guessed the word correctly!") 135 | play_loop() 136 | 137 | elif count != limit: 138 | hangman() 139 | 140 | 141 | main() 142 | 143 | 144 | hangman() 145 | -------------------------------------------------------------------------------- /Programs/TeamsProject/main.py: -------------------------------------------------------------------------------- 1 | import selenium 2 | from selenium import webdriver 3 | from selenium.webdriver.common.keys import Keys 4 | from selenium.webdriver.chrome.options import Options 5 | import yaml 6 | import sys 7 | import time 8 | import pyautogui as magic 9 | from selenium.common.exceptions import NoSuchElementException 10 | from datetime import date 11 | from datetime import datetime 12 | 13 | 14 | 15 | sys.tracebacklimit=0 16 | 17 | 18 | settings_path="D:\Desktop\Python Documents\TeamsProject\settings.yaml" 19 | with open(settings_path) as f: 20 | settings = yaml.load(f, Loader=yaml.FullLoader) 21 | 22 | 23 | logindetails = settings['logindetails'] 24 | username = logindetails['username'] 25 | password = logindetails['password'] 26 | 27 | mon= settings['monday'] 28 | tue= settings['tuesday'] 29 | wed= settings['wednesday'] 30 | thur= settings['thursday'] 31 | fri= settings['friday'] 32 | 33 | def initiation(): 34 | print("Class starting..") 35 | print("Initiating Bot!") 36 | print("Starting Teams") 37 | global driver 38 | options = webdriver.ChromeOptions() 39 | options.add_experimental_option('excludeSwitches', ['enable-logging']) 40 | driver= webdriver.Chrome(executable_path="C:\Program Files (x86)\chromedriver.exe", options=options) 41 | driver.get("https://teams.microsoft.com") 42 | driver.maximize_window() 43 | usernameentry() 44 | time.sleep(1) 45 | passentry() 46 | time.sleep(1) 47 | findingcal() 48 | time.sleep(1) 49 | findingactivejoinbutton() 50 | time.sleep(1) 51 | allow() 52 | time.sleep(1) 53 | finaljoin() 54 | time.sleep(1) 55 | waitingforendtime() 56 | 57 | def checkingforday(): 58 | sys.setrecursionlimit(10**9) 59 | date = datetime.now() 60 | week_num= datetime.date(date).weekday() 61 | week_days= ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] 62 | todayday= week_days[week_num] 63 | global timingstart 64 | global timingend 65 | if todayday== "Monday": 66 | timingstart= mon['starttimings'] 67 | timingend= mon['endtimings'] 68 | elif todayday== "Tuesday": 69 | timingstart= tue['starttimings'] 70 | timingend= tue['endtimings'] 71 | elif todayday== "Wednesday": 72 | timingstart= wed['starttimings'] 73 | timingend= wed['endtimings'] 74 | elif todayday== "Thursday": 75 | timingstart= thur['starttimings'] 76 | timingend= thur['endtimings'] 77 | elif todayday== "Friday": 78 | timingstart= fri['starttimings'] 79 | timingend= fri['endtimings'] 80 | print("Today is a ", todayday) 81 | waitingforstarttime() 82 | 83 | def waitingforstarttime(): 84 | print("Waiting for the class to start.") 85 | while True: 86 | curr = datetime.now().strftime("%H:%M") 87 | for now in timingstart: 88 | if now==curr: 89 | initiation() 90 | 91 | def waitingforendtime(): 92 | print("Class Joined! Waiting for class to end!") 93 | while True: 94 | curr = datetime.now().strftime("%H:%M") 95 | for now in timingend: 96 | if now==curr: 97 | meetingend() 98 | 99 | def meetingend(): 100 | driver.find_element_by_id("hangup-button").click() 101 | driver.close() 102 | checkingforday() 103 | 104 | 105 | def usernameentry(): 106 | time.sleep(1) 107 | try: 108 | driver.find_element_by_id("i0116").send_keys(username) 109 | except selenium.common.exceptions.NoSuchElementException: 110 | usernameentry() 111 | magic.press('enter') 112 | 113 | def passentry(): 114 | time.sleep(1) 115 | try: 116 | driver.find_element_by_id("i0118").send_keys(password) 117 | except selenium.common.exceptions.NoSuchElementException: 118 | passentry() 119 | time.sleep(1) 120 | magic.press('enter') 121 | remembersignin() 122 | 123 | def remembersignin(): 124 | findwindow= magic.locateCenterOnScreen("D:\Desktop\Python Documents\TeamsProject\core\staysignedin.png") 125 | if findwindow== None: 126 | remembersignin() 127 | else: 128 | magic.press('enter') 129 | 130 | 131 | def findingcal(): 132 | time.sleep(1) 133 | try: 134 | driver.find_element_by_id("app-bar-ef56c0de-36fc-4ef8-b417-3d82ba9d073c").click() 135 | except selenium.common.exceptions.NoSuchElementException: 136 | findingcal() 137 | 138 | def findingactivejoinbutton(): 139 | time.sleep(1) 140 | try: 141 | driver.find_element_by_xpath('//*[@title="Join"]').click() 142 | except selenium.common.exceptions.NoSuchElementException: 143 | findingactivejoinbutton() 144 | 145 | def allow(): 146 | perm= magic.locateCenterOnScreen('D:\Desktop\Python Documents\TeamsProject\core\llow.png') 147 | if perm==None: 148 | allow() 149 | else: 150 | magic.moveTo(perm) 151 | magic.click() 152 | 153 | def finaljoin(): 154 | time.sleep(1) 155 | try: 156 | driver.find_element_by_xpath('//*[@title="Turn camera off"]').click() 157 | except selenium.common.exceptions.NoSuchElementException: 158 | finaljoin() 159 | driver.find_element_by_xpath('//*[@title="Mute microphone"]').click() 160 | driver.find_element_by_class_name("button-col").click() 161 | 162 | 163 | checkingforday() -------------------------------------------------------------------------------- /heartattackprediction.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | from sklearn.neighbors import KNeighborsClassifier 4 | from sklearn.model_selection import train_test_split 5 | from sklearn.preprocessing import StandardScaler 6 | import tkinter as tk 7 | 8 | 9 | class Predictor: 10 | 11 | def has_disease(self, row): 12 | self.train(self) 13 | return True if self.predict(self, row) == 1 else False 14 | 15 | @staticmethod 16 | def train(self): 17 | df = pd.read_csv('./data/dataset.csv') 18 | dataset = df 19 | self.standardScaler = StandardScaler() 20 | columns_to_scale = ['age', 'sex', 'cp', 'trestbps', 'chol', 'fbs', 'restecg', 'thalach', 'exang', 'oldpeak', 21 | 'slope', 'ca', 'thal'] 22 | dataset[columns_to_scale] = self.standardScaler.fit_transform(dataset[columns_to_scale]) 23 | y = dataset['target'] 24 | X = dataset.drop(['target'], axis=1) 25 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=0) 26 | self.knn_classifier = KNeighborsClassifier(n_neighbors=8) 27 | self.knn_classifier.fit(X, y) 28 | score = self.knn_classifier.score(X_test, y_test) 29 | print('--Training Complete--') 30 | print('Score: ' + str(score)) 31 | 32 | @staticmethod 33 | def predict(self, row): 34 | user_df = np.array(row).reshape(1, 13) 35 | user_df = self.standardScaler.transform(user_df) 36 | predicted = self.knn_classifier.predict(user_df) 37 | print("Predicted: " + str(predicted[0])) 38 | return predicted[0] 39 | 40 | 41 | #row = [[37, 1, 2, 130, 250, 0, 1, 187, 0, 3.5, 0, 0, 2]] 42 | # row = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] 43 | # col = ['age', 'sex', 'cp', 'trestbps', 'chol', 'fbs', 'restecg', 'thalach', 'exang', 'oldpeak', 'slope', 'ca', 'thal'] 44 | # for i in range(0, 13): 45 | # row[0][i] = input(f"Enter {col[i]} : ") # OverWriting the List 46 | 47 | 48 | la=str() 49 | def onClick(): 50 | row=[[age.get(),gender.get(),cp.get(),tbps.get(),chol.get(),fbs.get(),restecg.get(),thalach.get(),exang.get(),oldpeak.get(),slope.get(),ca.get(),thal.get()]] 51 | print(row) 52 | predictor = Predictor() 53 | o = predictor.has_disease(row) 54 | root2 = tk.Tk() 55 | root2.title("Prediction Window") 56 | if (o == True): 57 | print("Person Have Heart Desease") 58 | la="Person Have Heart Desease" 59 | tk.Label(root2, text=la, font=("times new roman", 20), fg="white", bg="maroon", height=2).grid(row=15, column=1) 60 | else: 61 | print("Person Is Healthy") 62 | la="Person Is Healthy" 63 | tk.Label(root2, text=la, font=("times new roman", 20), fg="white", bg="green", height=2).grid(row=15, column=1) 64 | 65 | return True 66 | root = tk.Tk() 67 | root.title("Heart Disease Predictor") 68 | tk.Label(root,text="""Fill your Details""",font=("times new roman", 12)).grid(row=0) 69 | tk.Label(root,text='Age',padx=20, font=("times new roman", 12)).grid(row=1,column=0) 70 | age = tk.IntVar() 71 | tk.Entry(root,textvariable=age).grid(row=1,column=1) 72 | 73 | tk.Label(root,text="""Sex""",padx=20, font=("times new roman", 12)).grid(row=2,column=0) 74 | gender = tk.IntVar() 75 | tk.Radiobutton(root,text="Male (1)",padx=20,variable=gender,value=1).grid(row=2,column=1) 76 | tk.Radiobutton(root,text="Female (0)",padx=20,variable=gender,value=0).grid(row=2,column=2) 77 | 78 | tk.Label(root,text='cp: chest pain type (0-3]', font=("times new roman", 12)).grid(row=3,column=0) 79 | cp = tk.IntVar() 80 | tk.Entry(root,textvariable=cp).grid(row=3,column=1) 81 | 82 | tk.Label(root,text='trestbps: resting blood pressure', font=("times new roman", 12)).grid(row=4,column=0) 83 | tbps = tk.IntVar() 84 | tk.Entry(root,textvariable=tbps).grid(row=4,column=1) 85 | 86 | tk.Label(root,text='chol: serum cholestoral in mg/dl', font=("times new roman", 12)).grid(row=5,column=0) 87 | chol = tk.IntVar() 88 | tk.Entry(root,textvariable=chol).grid(row=5,column=1) 89 | 90 | tk.Label(root,text="""fbs: (fasting blood sugar > 120 mg/dl)""",padx=20, font=("times new roman", 12)).grid(row=6,column=0) 91 | fbs=tk.IntVar() 92 | tk.Radiobutton(root,text="True (1)",padx=20,variable=fbs,value=1).grid(row=6,column=1) 93 | tk.Radiobutton(root,text="False (0)",padx=20,variable=fbs,value=0).grid(row=6,column=2) 94 | 95 | tk.Label(root,text="""restecg: resting electrocardiographic results""",padx=20, font=("times new roman", 12)).grid(row=7,column=0) 96 | restecg=tk.IntVar() 97 | tk.Radiobutton(root,text="0",padx=20,variable=restecg,value=0).grid(row=7,column=1) 98 | tk.Radiobutton(root,text="1",padx=20,variable=restecg,value=1).grid(row=7,column=2) 99 | tk.Radiobutton(root,text="2",padx=20,variable=restecg,value=2).grid(row=7,column=3) 100 | 101 | tk.Label(root,text='thalach: maximum heart rate achieved', font=("times new roman", 12)).grid(row=8,column=0) 102 | thalach = tk.IntVar() 103 | tk.Entry(root,textvariable=thalach).grid(row=8,column=1) 104 | 105 | tk.Label(root,text="""exang: exercise induced angina """,padx=20, font=("times new roman", 12)).grid(row=9,column=0) 106 | exang=tk.IntVar() 107 | tk.Radiobutton(root,text="Yes (1)",padx=20,variable=exang,value=1).grid(row=9,column=1) 108 | tk.Radiobutton(root,text="No (0)",padx=20,variable=exang,value=0).grid(row=9,column=2) 109 | 110 | tk.Label(root,text='oldpeak : ST depression induced by exercise relative to rest', font=("times new roman", 12)).grid(row=10,column=0) 111 | oldpeak = tk.DoubleVar() 112 | tk.Entry(root,textvariable=oldpeak).grid(row=10,column=1) 113 | 114 | tk.Label(root,text="""slope: the slope of the peak exercise ST segment""",padx=20, font=("times new roman", 12)).grid(row=11,column=0) 115 | slope=tk.IntVar() 116 | tk.Radiobutton(root,text="upsloping (0)",padx=20,variable=slope,value=0).grid(row=11,column=1) 117 | tk.Radiobutton(root,text="flat (1)",padx=20,variable=slope,value=1).grid(row=11,column=2) 118 | tk.Radiobutton(root,text="downsloping (2)",padx=20,variable=slope,value=2).grid(row=11,column=3) 119 | 120 | tk.Label(root,text="""ca: number of major vessels (0-4) colored by flourosop""",padx=20, font=("times new roman", 12)).grid(row=12,column=0) 121 | ca=tk.IntVar() 122 | tk.Radiobutton(root,text="0",padx=20,variable=ca,value=0).grid(row=12,column=1) 123 | tk.Radiobutton(root,text="1",padx=20,variable=ca,value=1).grid(row=12,column=2) 124 | tk.Radiobutton(root,text="2",padx=20,variable=ca,value=2).grid(row=12,column=3) 125 | tk.Radiobutton(root,text="3",padx=20,variable=ca,value=3).grid(row=12,column=4) 126 | tk.Radiobutton(root,text="4",padx=20,variable=ca,value=4).grid(row=12,column=5) 127 | 128 | tk.Label(root,text="""thal""",padx=20, font=("times new roman", 12)).grid(row=13,column=0) 129 | thal=tk.IntVar() 130 | tk.Radiobutton(root,text="0",padx=20,variable=thal,value=0).grid(row=13,column=1) 131 | tk.Radiobutton(root,text="1",padx=20,variable=thal,value=1).grid(row=13,column=2) 132 | tk.Radiobutton(root,text="2",padx=20,variable=thal,value=2).grid(row=13,column=3) 133 | tk.Radiobutton(root,text="3",padx=20,variable=thal,value=3).grid(row=13,column=4) 134 | 135 | tk.Button(root, text='Predict', command=onClick).grid(row=14, column=2, sticky=tk.W, pady=4) 136 | 137 | root.mainloop() 138 | -------------------------------------------------------------------------------- /Programs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | PONG GAME 10 | 11 | 116 | 117 | 118 | 119 |
120 |
121 |
122 |
123 |
124 |
125 |

0

126 |

0

127 |

128 | Press Enter to Play Pong 129 |

130 |
131 | 255 | 256 | 257 | 258 | -------------------------------------------------------------------------------- /Programs/huffman-code.c: -------------------------------------------------------------------------------- 1 | // C program for Huffman Coding 2 | #include 3 | #include 4 | 5 | // This constant can be avoided by explicitly 6 | // calculating height of Huffman Tree 7 | #define MAX_TREE_HT 100 8 | 9 | // A Huffman tree node 10 | struct MinHeapNode { 11 | 12 | // One of the input characters 13 | char data; 14 | 15 | // Frequency of the character 16 | unsigned freq; 17 | 18 | // Left and right child of this node 19 | struct MinHeapNode *left, *right; 20 | }; 21 | 22 | // A Min Heap: Collection of 23 | // min-heap (or Huffman tree) nodes 24 | struct MinHeap { 25 | 26 | // Current size of min heap 27 | unsigned size; 28 | 29 | // capacity of min heap 30 | unsigned capacity; 31 | 32 | // Array of minheap node pointers 33 | struct MinHeapNode** array; 34 | }; 35 | 36 | // A utility function allocate a new 37 | // min heap node with given character 38 | // and frequency of the character 39 | struct MinHeapNode* newNode(char data, unsigned freq) 40 | { 41 | struct MinHeapNode* temp = (struct MinHeapNode*)malloc( 42 | sizeof(struct MinHeapNode)); 43 | 44 | temp->left = temp->right = NULL; 45 | temp->data = data; 46 | temp->freq = freq; 47 | 48 | return temp; 49 | } 50 | 51 | // A utility function to create 52 | // a min heap of given capacity 53 | struct MinHeap* createMinHeap(unsigned capacity) 54 | 55 | { 56 | 57 | struct MinHeap* minHeap 58 | = (struct MinHeap*)malloc(sizeof(struct MinHeap)); 59 | 60 | // current size is 0 61 | minHeap->size = 0; 62 | 63 | minHeap->capacity = capacity; 64 | 65 | minHeap->array = (struct MinHeapNode**)malloc( 66 | minHeap->capacity * sizeof(struct MinHeapNode*)); 67 | return minHeap; 68 | } 69 | 70 | // A utility function to 71 | // swap two min heap nodes 72 | void swapMinHeapNode(struct MinHeapNode** a, 73 | struct MinHeapNode** b) 74 | 75 | { 76 | 77 | struct MinHeapNode* t = *a; 78 | *a = *b; 79 | *b = t; 80 | } 81 | 82 | // The standard minHeapify function. 83 | void minHeapify(struct MinHeap* minHeap, int idx) 84 | 85 | { 86 | 87 | int smallest = idx; 88 | int left = 2 * idx + 1; 89 | int right = 2 * idx + 2; 90 | 91 | if (left < minHeap->size 92 | && minHeap->array[left]->freq 93 | < minHeap->array[smallest]->freq) 94 | smallest = left; 95 | 96 | if (right < minHeap->size 97 | && minHeap->array[right]->freq 98 | < minHeap->array[smallest]->freq) 99 | smallest = right; 100 | 101 | if (smallest != idx) { 102 | swapMinHeapNode(&minHeap->array[smallest], 103 | &minHeap->array[idx]); 104 | minHeapify(minHeap, smallest); 105 | } 106 | } 107 | 108 | // A utility function to check 109 | // if size of heap is 1 or not 110 | int isSizeOne(struct MinHeap* minHeap) 111 | { 112 | 113 | return (minHeap->size == 1); 114 | } 115 | 116 | // A standard function to extract 117 | // minimum value node from heap 118 | struct MinHeapNode* extractMin(struct MinHeap* minHeap) 119 | 120 | { 121 | 122 | struct MinHeapNode* temp = minHeap->array[0]; 123 | minHeap->array[0] = minHeap->array[minHeap->size - 1]; 124 | 125 | --minHeap->size; 126 | minHeapify(minHeap, 0); 127 | 128 | return temp; 129 | } 130 | 131 | // A utility function to insert 132 | // a new node to Min Heap 133 | void insertMinHeap(struct MinHeap* minHeap, 134 | struct MinHeapNode* minHeapNode) 135 | 136 | { 137 | 138 | ++minHeap->size; 139 | int i = minHeap->size - 1; 140 | 141 | while (i 142 | && minHeapNode->freq 143 | < minHeap->array[(i - 1) / 2]->freq) { 144 | 145 | minHeap->array[i] = minHeap->array[(i - 1) / 2]; 146 | i = (i - 1) / 2; 147 | } 148 | 149 | minHeap->array[i] = minHeapNode; 150 | } 151 | 152 | // A standard function to build min heap 153 | void buildMinHeap(struct MinHeap* minHeap) 154 | 155 | { 156 | 157 | int n = minHeap->size - 1; 158 | int i; 159 | 160 | for (i = (n - 1) / 2; i >= 0; --i) 161 | minHeapify(minHeap, i); 162 | } 163 | 164 | // A utility function to print an array of size n 165 | void printArr(int arr[], int n) 166 | { 167 | int i; 168 | for (i = 0; i < n; ++i) 169 | printf("%d", arr[i]); 170 | 171 | printf("\n"); 172 | } 173 | 174 | // Utility function to check if this node is leaf 175 | int isLeaf(struct MinHeapNode* root) 176 | 177 | { 178 | 179 | return !(root->left) && !(root->right); 180 | } 181 | 182 | // Creates a min heap of capacity 183 | // equal to size and inserts all character of 184 | // data[] in min heap. Initially size of 185 | // min heap is equal to capacity 186 | struct MinHeap* createAndBuildMinHeap(char data[], 187 | int freq[], int size) 188 | 189 | { 190 | 191 | struct MinHeap* minHeap = createMinHeap(size); 192 | 193 | for (int i = 0; i < size; ++i) 194 | minHeap->array[i] = newNode(data[i], freq[i]); 195 | 196 | minHeap->size = size; 197 | buildMinHeap(minHeap); 198 | 199 | return minHeap; 200 | } 201 | 202 | // The main function that builds Huffman tree 203 | struct MinHeapNode* buildHuffmanTree(char data[], 204 | int freq[], int size) 205 | 206 | { 207 | struct MinHeapNode *left, *right, *top; 208 | 209 | // Step 1: Create a min heap of capacity 210 | // equal to size. Initially, there are 211 | // modes equal to size. 212 | struct MinHeap* minHeap 213 | = createAndBuildMinHeap(data, freq, size); 214 | 215 | // Iterate while size of heap doesn't become 1 216 | while (!isSizeOne(minHeap)) { 217 | 218 | // Step 2: Extract the two minimum 219 | // freq items from min heap 220 | left = extractMin(minHeap); 221 | right = extractMin(minHeap); 222 | 223 | // Step 3: Create a new internal 224 | // node with frequency equal to the 225 | // sum of the two nodes frequencies. 226 | // Make the two extracted node as 227 | // left and right children of this new node. 228 | // Add this node to the min heap 229 | // '$' is a special value for internal nodes, not 230 | // used 231 | top = newNode('$', left->freq + right->freq); 232 | 233 | top->left = left; 234 | top->right = right; 235 | 236 | insertMinHeap(minHeap, top); 237 | } 238 | 239 | // Step 4: The remaining node is the 240 | // root node and the tree is complete. 241 | return extractMin(minHeap); 242 | } 243 | 244 | // Prints huffman codes from the root of Huffman Tree. 245 | // It uses arr[] to store codes 246 | void printCodes(struct MinHeapNode* root, int arr[], 247 | int top) 248 | 249 | { 250 | 251 | // Assign 0 to left edge and recur 252 | if (root->left) { 253 | 254 | arr[top] = 0; 255 | printCodes(root->left, arr, top + 1); 256 | } 257 | 258 | // Assign 1 to right edge and recur 259 | if (root->right) { 260 | 261 | arr[top] = 1; 262 | printCodes(root->right, arr, top + 1); 263 | } 264 | 265 | // If this is a leaf node, then 266 | // it contains one of the input 267 | // characters, print the character 268 | // and its code from arr[] 269 | if (isLeaf(root)) { 270 | 271 | printf("%c: ", root->data); 272 | printArr(arr, top); 273 | } 274 | } 275 | 276 | // The main function that builds a 277 | // Huffman Tree and print codes by traversing 278 | // the built Huffman Tree 279 | void HuffmanCodes(char data[], int freq[], int size) 280 | 281 | { 282 | // Construct Huffman Tree 283 | struct MinHeapNode* root 284 | = buildHuffmanTree(data, freq, size); 285 | 286 | // Print Huffman codes using 287 | // the Huffman tree built above 288 | int arr[MAX_TREE_HT], top = 0; 289 | 290 | printCodes(root, arr, top); 291 | } 292 | 293 | // Driver code 294 | int main() 295 | { 296 | 297 | char arr[] = { 'a', 'b', 'c', 'd', 'e', 'f' }; 298 | int freq[] = { 5, 9, 12, 13, 16, 45 }; 299 | 300 | int size = sizeof(arr) / sizeof(arr[0]); 301 | 302 | HuffmanCodes(arr, freq, size); 303 | 304 | return 0; 305 | } 306 | --------------------------------------------------------------------------------