diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0db5873 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": true +} \ No newline at end of file diff --git a/payment.py b/payment.py new file mode 100644 index 0000000..a7f5ff7 --- /dev/null +++ b/payment.py @@ -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()