From 77c685d07af6fbabdf261dc8252101618f415470 Mon Sep 17 00:00:00 2001 From: Aryan Joshi <56163093+WHITEWOLF619@users.noreply.github.com> Date: Mon, 5 Oct 2020 16:08:49 +0530 Subject: [PATCH 1/2] random password generator generates a password with a number of characters as given by the user which has alphanumeric and special characters. --- random password generator.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 random password generator.py diff --git a/random password generator.py b/random password generator.py new file mode 100644 index 0000000..708cd34 --- /dev/null +++ b/random password generator.py @@ -0,0 +1,22 @@ +import random +import string + +x=int(input("Enter the length of the password (minimum 4)")) +x=x-4 +def get_random_password(): + random_source = string.ascii_letters + string.digits + string.punctuation + password = random.choice(string.ascii_lowercase) + password += random.choice(string.ascii_uppercase) + password += random.choice(string.digits) + password += random.choice(string.punctuation) + + for i in range(x): + password += random.choice(random_source) + + password_list = list(password) + random.SystemRandom().shuffle(password_list) + password = ''.join(password_list) + return password + +print("First Random Password is ", get_random_password()) +print("Second Random Password is ", get_random_password()) From 5c6bd3ce1e001e941cd28e7fbd853571bdf6e2dd Mon Sep 17 00:00:00 2001 From: Aryan Joshi <56163093+WHITEWOLF619@users.noreply.github.com> Date: Mon, 5 Oct 2020 16:12:29 +0530 Subject: [PATCH 2/2] quick sort QuickSort is a Divide and Conquer algorithm. It picks an element as a pivot and partitions the given array around the picked pivot. There are many different versions of quickSort that pick pivot in different ways. Always pick the first element as a pivot. Always pick the last element as the pivot (implemented below) Pick a random element as a pivot. Pick the median as a pivot. The key process in quickSort is a partition(). The target of partitions is, given an array and an element x of the array as a pivot, put x at its correct position in a sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time. --- Quick_sort.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Quick_sort.py diff --git a/Quick_sort.py b/Quick_sort.py new file mode 100644 index 0000000..96087c1 --- /dev/null +++ b/Quick_sort.py @@ -0,0 +1,25 @@ + +import sys +A=[] +g = int(input("Enter number of elements : ")) + +for i in range(0, g): + ele = int(input()) + + A.append(ele) +print(A) + +for i in range(len(A)): + + + min_idx = i + for j in range(i+1, len(A)): + if A[min_idx] > A[j]: + min_idx = j + + A[i], A[min_idx] = A[min_idx], A[i] + + +print ("Sorted array") +for i in range(len(A)): + print("%d" %A[i]), \ No newline at end of file