Skip to content

Commit

Permalink
Merge pull request #455 from amazing-AK/master
Browse files Browse the repository at this point in the history
Added a Password Generator
  • Loading branch information
fineanmol authored Oct 3, 2021
2 parents 754fd06 + 5398f8c commit 40e2ce7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@


<a class="box-item" href="https://github.com/fineanmol"><span>Anmol Agarwal</span></a>

<a class="box-item" href="https://github.com/Amitava123"><span>Amitava Mitra</span></a>
<a class="box-item" href="https://github.com/philson-philip"><span>Philson Philip</span></a>
<a class="box-item" href="https://github.com/SHIV1003"><span>Shivam Goyal</span></a>
Expand Down Expand Up @@ -583,6 +582,7 @@
<a class="box-item" href="https://github.com/a-ayush19"><span>Ayush Awasthi</span></a>
<a class="box-item" href="https://github.com/SamarthSawhney"><spann>Samarth Sawhney</span></a>
<a class="box-item" href="https://github.com/highflyer910"><span>Thea M.</span></a>

<a class="box-item" href="https://github.com/vishnuramv"><span>Vishnu Ram V</span></a>

<a class="box-item" href="https://github.com/nyctonio"><span>Ritesh Kumar</span></a>
Expand All @@ -591,6 +591,7 @@
<a class="box-item" href="https://github.com/PrajaktaSathe"><span>Prajakta Sathe</span></a>
<a class="box-item" href="https://github.com/Kaustubh251002"><span>Kaustubh Mishra</span></a>
<a class="box-item" href="https://github.com/priyanshu-28"><span>Priyanshu Pathak</span></a>
<a class="box-item" href="https://github.com/amazing-AK"><span>Aditya Krishna</span></a>



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import random

# Binary Search


def binarySearch(sortedList, key, start, end):
if start <= end:
middleIndex = (start + end) // 2
middleElement = sortedList[middleIndex]

if middleElement == key:
return middleIndex
elif middleElement < key:
location = binarySearch(sortedList, key, middleIndex + 1, end)
else:
location = binarySearch(sortedList, key, start, middleIndex - 1)

return location

return -1


myList = random.sample(range(0, 1000), 10)
target = int(input('Enter target: '))
location = binarySearch(myList, target, 0, len(myList) - 1)
print(f'Element found at index {location}.')


# Old version
# start,end
def binarySearch(key, start, end):
# If start and end are adjacent elements, element does not exist
if end == start + 1:
return -1
middleElementIndex = (start + end) // 2
middleElement = myList[middleElementIndex]
if key == middleElement:
return middleElementIndex
if key >= middleElement:
start = middleElementIndex
x = binarySearch(key, start, end)
else:
end = middleElementIndex
x = binarySearch(key, start, end)
return x


myList = [1, 2, 3, 4, 5, 12, 20, 30, 40, 45, 50, 70]
elementToBeFound = 5
print(f'List: {myList}')
x = binarySearch(elementToBeFound, 0, len(myList) - 1)
print(f'{elementToBeFound} found at index: {x}')
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import string
import random

allLetters = string.ascii_letters
allNumbers = string.digits
allSymbols = string.punctuation

allCharacters = allLetters + allNumbers + allSymbols
passwordLength = 20


temp = random.sample(allCharacters, passwordLength)
password = "".join(temp)


print(f"Generated Password: {password}")

0 comments on commit 40e2ce7

Please sign in to comment.