Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": true
}
45 changes: 45 additions & 0 deletions payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import random


# function to generate
# a random string
def generateOne(strlen):

# string with all the alphabets
# and a space
alphabet = "abcdefghijklmnopqrstuvwxyz "
res =""

for i in range(strlen):
res+= alphabet[random.randrange(27)]

return res

# function to determine the
# score of the generated string
def score(goal, testString):
numSame = 0

for i in range(len(goal)):
if goal[i] == testString[i]:
numSame+= 1

return numSame / len(goal)

# main function to call the previous
# two functions until the goal is achieved
def main():
goalString = "a computer science portal for geeks"
newString = generateOne(35)
best = 0
newScore = score(goalString, newString)

while newScore<1:
if newScore>best:
print(newString)
best = newScore
newString = generateOne(35)
newScore = score(goalString, newString)

# Driver code
main()