From 170abcfba18b0f57b002a38e1225c19ff5d8deef Mon Sep 17 00:00:00 2001 From: Nitkarsh Chourasia Date: Fri, 10 May 2024 18:20:20 +0530 Subject: [PATCH 1/2] duplicates: Poor implemented programs --- TowerOfHanoi.py | 14 -------------- tower_of_hanoi.py | 43 ------------------------------------------- 2 files changed, 57 deletions(-) delete mode 100644 TowerOfHanoi.py delete mode 100644 tower_of_hanoi.py diff --git a/TowerOfHanoi.py b/TowerOfHanoi.py deleted file mode 100644 index af89032fce0..00000000000 --- a/TowerOfHanoi.py +++ /dev/null @@ -1,14 +0,0 @@ -# Recursive Python function to solve the tower of hanoi -- - -def TowerOfHanoi(n , source, destination, auxiliary): - if n==1: - print ("Move disk 1 from source",source,"to destination",destination) - return - TowerOfHanoi(n-1, source, auxiliary, destination) - print ("Move disk",n,"from source",source,"to destination",destination) - TowerOfHanoi(n-1, auxiliary, destination, source) - -# Driver code -n = 4 -TowerOfHanoi(n,'A','B','C') -# A, C, B are the name of rods diff --git a/tower_of_hanoi.py b/tower_of_hanoi.py deleted file mode 100644 index 0fbf061b96a..00000000000 --- a/tower_of_hanoi.py +++ /dev/null @@ -1,43 +0,0 @@ -"""Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move - the entire stack to another rod, obeying the following simple rules: -1) Only one disk can be moved at a time. -2) Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk - can only be moved if it is the uppermost disk on a stack. -3) No disk may be placed on top of a smaller disk. -APPROACH: -Take an example for 2 disks : -Let rod 1 = 'SOURCE', rod 2 = 'TEMPORARY', rod 3 = 'DESTINATION'. - -Step 1 : Shift first disk from 'SOURCE' to 'TEMPORARY'. -Step 2 : Shift second disk from 'SOURCE' to 'DESTINATION'. -Step 3 : Shift first disk from 'TEMPORARY' to 'DESTINATION'. - -The pattern here is : -Shift 'n-1' disks from 'SOURCE' to 'TEMPORARY'. -Shift last disk from 'SOURCE' to 'DESTINATION'. -Shift 'n-1' disks from 'TEMPORARY' to 'DESTINATION'. -""" - - -def toh(n, s, t, d): - if n == 1: - print(s, "-->", d) - return - toh(n - 1, s, d, t) - print(s, "-->", d) - toh(n - 1, t, s, d) - - -if __name__ == "__main__": - while 1: - - n = int(input("""Enter number of disks:""")) - - if n < 0: - print("Try Again with a valid input") - continue - elif n == 0: - break - toh(n, "Source", "Temporary", "Destination") - - print("ENTER 0 TO EXIT") From 4f65a3ccc501d5336b38580c007f78f7a060539d Mon Sep 17 00:00:00 2001 From: Nitkarsh Chourasia Date: Fri, 10 May 2024 18:33:51 +0530 Subject: [PATCH 2/2] refactor: Concat output --- .../passwordGenerator.py | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 password_programs_multiple/passwordGenerator.py diff --git a/password_programs_multiple/passwordGenerator.py b/password_programs_multiple/passwordGenerator.py new file mode 100644 index 00000000000..1bde3d18051 --- /dev/null +++ b/password_programs_multiple/passwordGenerator.py @@ -0,0 +1,125 @@ +# PasswordGenerator GGearing 314 01/10/19 +# modified Prince Gangurde 4/4/2020 + +from random import randint +import pycountry + +case = randint(1, 2) +number = randint(1, 999) + +# TODO: Pick random country from it + +countries = list(pycountry.countries) +country_names = [country.name for country in countries] + +print(country_names) + +# TODO: Try to add languages, too. + +specialCharacters = ( + "!", + "@", + "#", + "$", + "%", + "/", + "?", + ":", + "<", + ">", + "|", + "&", + "*", + "-", + "=", + "+", + "_", +) + +animals = ( + "ant", + "alligator", + "baboon", + "badger", + "barb", + "bat", + "beagle", + "bear", + "beaver", + "bird", + "bison", + "bombay", + "bongo", + "booby", + "butterfly", + "bee", + "camel", + "cat", + "caterpillar", + "catfish", + "cheetah", + "chicken", + "chipmunk", + "cow", + "crab", + "deer", + "dingo", + "dodo", + "dog", + "dolphin", + "donkey", + "duck", + "eagle", + "earwig", + "elephant", + "emu", + "falcon", + "ferret", + "fish", + "flamingo", + "fly", + "fox", + "frog", + "gecko", + "gibbon", + "giraffe", + "goat", + "goose", + "gorilla", +) + +colour = ( + "red", + "orange", + "yellow", + "green", + "blue", + "indigo", + "violet", + "purple", + "magenta", + "cyan", + "pink", + "brown", + "white", + "grey", + "black", +) + +chosenanimal = animals[ + randint(0, len(animals) - 1) +] # randint will return max lenght but , tuple has index from 0 to len-1 +chosencolour = colour[randint(0, len(colour) - 1)] +chosenSpecialCharacter = specialCharacters[randint(0, len(specialCharacters) - 1)] + +if case == 1: + chosenanimal = chosenanimal.upper() + print(chosencolour + str(number) + chosenanimal + chosenSpecialCharacter) +else: + chosencolour = chosencolour.upper() + print(chosenanimal + str(number) + chosencolour + chosenSpecialCharacter) + +# Try to consolidate unify the characters. + + +# The program can be further improved.