diff --git a/algorithms/Implementation/10-BonAppetit/ProblemStatement/bon-appetit-English.pdf b/algorithms/Implementation/10-BonAppetit/ProblemStatement/bon-appetit-English.pdf new file mode 100644 index 0000000..a6b5f85 Binary files /dev/null and b/algorithms/Implementation/10-BonAppetit/ProblemStatement/bon-appetit-English.pdf differ diff --git a/algorithms/Implementation/10-BonAppetit/Solutions/python.py b/algorithms/Implementation/10-BonAppetit/Solutions/python.py new file mode 100644 index 0000000..8e7fb9c --- /dev/null +++ b/algorithms/Implementation/10-BonAppetit/Solutions/python.py @@ -0,0 +1,14 @@ +firstLine = list(map(int, input().rstrip().split())) +costOfFood = list(map(int, input().rstrip().split())) +charged = int(input()) + +deal = 0 + +def JudgeOfCost(firstLine,costOfFood, charged): + deal = ((sum(costOfFood) - costOfFood[firstLine[1]])/2) + if (charged - deal == 0): + print("Bon Appetit") + else: + print(int(charged - deal)) + +JudgeOfCost(firstLine, costOfFood, charged) \ No newline at end of file diff --git a/algorithms/Implementation/11-SockMerchant/ProblemStatement/sock-merchant-English.pdf b/algorithms/Implementation/11-SockMerchant/ProblemStatement/sock-merchant-English.pdf new file mode 100644 index 0000000..f1d6378 Binary files /dev/null and b/algorithms/Implementation/11-SockMerchant/ProblemStatement/sock-merchant-English.pdf differ diff --git a/algorithms/Implementation/11-SockMerchant/Solutions/python.py b/algorithms/Implementation/11-SockMerchant/Solutions/python.py new file mode 100644 index 0000000..d06023d --- /dev/null +++ b/algorithms/Implementation/11-SockMerchant/Solutions/python.py @@ -0,0 +1,16 @@ +#!/bin/python3 + +import sys +from collections import * +def sockMerchant(n, ar): + numberOfPairs = 0 + c = Counter(ar) + for k in c: + numberOfPairs += c[k]//2 + return(numberOfPairs) + + +n = int(input().strip()) +ar = list(map(int, input().strip().split(' '))) +result = sockMerchant(n, ar) +print(result) diff --git a/algorithms/Implementation/6-BirthdayChocolate/ProblemStatement/the-birthday-bar-English.pdf b/algorithms/Implementation/6-BirthdayChocolate/ProblemStatement/the-birthday-bar-English.pdf new file mode 100644 index 0000000..3f37b0c Binary files /dev/null and b/algorithms/Implementation/6-BirthdayChocolate/ProblemStatement/the-birthday-bar-English.pdf differ diff --git a/algorithms/Implementation/6-BirthdayChocolate/Solutions/python.py b/algorithms/Implementation/6-BirthdayChocolate/Solutions/python.py new file mode 100644 index 0000000..8b84180 --- /dev/null +++ b/algorithms/Implementation/6-BirthdayChocolate/Solutions/python.py @@ -0,0 +1,34 @@ +#!/bin/python3 + +import sys + +def solve(n, s, d, m): + if m > n: + return 0 + + i = j = 0 + window_sum = 0 + + while j < m: + window_sum += s[j] + j += 1 + + count = 1 if window_sum == d else 0 + + while j < n: + window_sum -= s[i] + window_sum += s[j] + + if window_sum == d: + count += 1 + i += 1 + j += 1 + + return count + +n = int(input().strip()) +s = list(map(int, input().strip().split(' '))) +d, m = input().strip().split(' ') +d, m = [int(d), int(m)] +result = solve(n, s, d, m) +print(result) diff --git a/algorithms/Implementation/7-DivisibleSumPairs/ProblemStatement/divisible-sum-pairs-English.pdf b/algorithms/Implementation/7-DivisibleSumPairs/ProblemStatement/divisible-sum-pairs-English.pdf new file mode 100644 index 0000000..365e9b7 Binary files /dev/null and b/algorithms/Implementation/7-DivisibleSumPairs/ProblemStatement/divisible-sum-pairs-English.pdf differ diff --git a/algorithms/Implementation/7-DivisibleSumPairs/Solutions/python.py b/algorithms/Implementation/7-DivisibleSumPairs/Solutions/python.py new file mode 100644 index 0000000..3da5e71 --- /dev/null +++ b/algorithms/Implementation/7-DivisibleSumPairs/Solutions/python.py @@ -0,0 +1,27 @@ +#!/bin/python3 + +import sys + +def divisibleSumPairs(n, k, ar): + count = 0 + arrPairs = [] + + for x in range(len(ar)): + j = 1 + while j < len(ar): + pair = [] + if x < j and ((ar[x] + ar[j]) % k == 0): + pair.append(x) + pair.append(j) + if pair not in arrPairs: + arrPairs.append(pair) + count += 1 + j += 1 + return count + + +n, k = input().strip().split(' ') +n, k = [int(n), int(k)] +ar = list(map(int, input().strip().split(' '))) +result = divisibleSumPairs( n, k, ar) +print(result) diff --git a/algorithms/Implementation/8-MigratoryBirds/ProblemStatement/migratory-birds-English.pdf b/algorithms/Implementation/8-MigratoryBirds/ProblemStatement/migratory-birds-English.pdf new file mode 100644 index 0000000..247fda7 Binary files /dev/null and b/algorithms/Implementation/8-MigratoryBirds/ProblemStatement/migratory-birds-English.pdf differ diff --git a/algorithms/Implementation/8-MigratoryBirds/Solutions/python.py b/algorithms/Implementation/8-MigratoryBirds/Solutions/python.py new file mode 100644 index 0000000..7540d4f --- /dev/null +++ b/algorithms/Implementation/8-MigratoryBirds/Solutions/python.py @@ -0,0 +1,13 @@ +#!/bin/python3 + +import sys +from collections import * + +def migratoryBirds(n, ar): + c = Counter(ar).most_common(1) + return (c[0][0]) + +n = int(input().strip()) +ar = list(map(int, input().strip().split(' '))) +result = migratoryBirds(n, ar) +print(result) diff --git a/algorithms/Sorting/1-IntroToTutorialChallenges/ProblemStatement/tutorial-intro-English.pdf b/algorithms/Sorting/1-IntroToTutorialChallenges/ProblemStatement/tutorial-intro-English.pdf new file mode 100644 index 0000000..d6ec1ef Binary files /dev/null and b/algorithms/Sorting/1-IntroToTutorialChallenges/ProblemStatement/tutorial-intro-English.pdf differ diff --git a/algorithms/Sorting/1-IntroToTutorialChallenges/Solutions/python.py b/algorithms/Sorting/1-IntroToTutorialChallenges/Solutions/python.py new file mode 100644 index 0000000..0ffeff2 --- /dev/null +++ b/algorithms/Sorting/1-IntroToTutorialChallenges/Solutions/python.py @@ -0,0 +1,13 @@ +#!/bin/python3 + +import sys + +def introTutorial(V, arr): + return(arr.index(V)) + +if __name__ == "__main__": + V = int(input().strip()) + n = int(input().strip()) + arr = list(map(int, input().strip().split(' '))) + result = introTutorial(V, arr) + print(result) diff --git a/algorithms/Sorting/2-InsertionSortPart1/ProblemStatement/insertionsort1-English.pdf b/algorithms/Sorting/2-InsertionSortPart1/ProblemStatement/insertionsort1-English.pdf new file mode 100644 index 0000000..c4c1e1d Binary files /dev/null and b/algorithms/Sorting/2-InsertionSortPart1/ProblemStatement/insertionsort1-English.pdf differ diff --git a/algorithms/Sorting/2-InsertionSortPart1/Solutions/python.py b/algorithms/Sorting/2-InsertionSortPart1/Solutions/python.py new file mode 100644 index 0000000..926bf68 --- /dev/null +++ b/algorithms/Sorting/2-InsertionSortPart1/Solutions/python.py @@ -0,0 +1,30 @@ +#!/bin/python3 + +import sys + +def insertionSort1(n, arr): + last = arr[-1] + last = arr[-1] + x = 0 + while arr[n-(n+2) - x] > last: + arr[-1-x] = arr[n-(n+2) - x] + print (' '.join(str(y) for y in arr)) + if x+2 == len(arr): + arr[n-(n+2) - x] = last + break + else: + x += 1 + + if arr[n-(n+2) - x] < last: + arr[-x-1] = last + print (' '.join(str(y) for y in arr)) + else: + print (' '.join(str(y) for y in arr)) + + + + +if __name__ == "__main__": + n = int(input().strip()) + arr = list(map(int, input().strip().split(' '))) + insertionSort1(n, arr) diff --git a/algorithms/Sorting/3-InsertionSortPart2/ProblemStatement/insertionsort2-English.pdf b/algorithms/Sorting/3-InsertionSortPart2/ProblemStatement/insertionsort2-English.pdf new file mode 100644 index 0000000..8e20405 Binary files /dev/null and b/algorithms/Sorting/3-InsertionSortPart2/ProblemStatement/insertionsort2-English.pdf differ diff --git a/algorithms/Sorting/3-InsertionSortPart2/Solutions/python.py b/algorithms/Sorting/3-InsertionSortPart2/Solutions/python.py new file mode 100644 index 0000000..1779fc9 --- /dev/null +++ b/algorithms/Sorting/3-InsertionSortPart2/Solutions/python.py @@ -0,0 +1,21 @@ +#!/bin/python3 + +import sys + +def insertionSort2(n, l): + for i in range(1, len(l)): + j = i-1 + key = l[i] + while (j >= 0) and (l[j] > key): + l[j+1],l[j] = l[j],l[j+1] + j -= 1 + l[j+1] = key + print(" ".join(map(str,l))) + + + + +if __name__ == "__main__": + n = int(input().strip()) + arr = list(map(int, input().strip().split(' '))) + insertionSort2(n, arr) diff --git a/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/ProblemStatement/correctness-invariant-English.pdf b/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/ProblemStatement/correctness-invariant-English.pdf new file mode 100644 index 0000000..3abd150 Binary files /dev/null and b/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/ProblemStatement/correctness-invariant-English.pdf differ diff --git a/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/Solutions/python.py b/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/Solutions/python.py new file mode 100644 index 0000000..7523096 --- /dev/null +++ b/algorithms/Sorting/4-CorrectnessAndTheLoopInvariant/Solutions/python.py @@ -0,0 +1,14 @@ +def insertion_sort(l): + for i in range(1, len(l)): + j = i-1 + key = l[i] + while (j >= 0) and (l[j] > key): + l[j+1] = l[j] + j -= 1 + l[j+1] = key + + +m = int(input().strip()) +ar = [int(i) for i in input().strip().split()] +insertion_sort(ar) +print(" ".join(map(str,ar))) diff --git a/algorithms/Sorting/5-QuickSort1-Partition/ProblemStatement/quicksort1-English.pdf b/algorithms/Sorting/5-QuickSort1-Partition/ProblemStatement/quicksort1-English.pdf new file mode 100644 index 0000000..472d7b0 Binary files /dev/null and b/algorithms/Sorting/5-QuickSort1-Partition/ProblemStatement/quicksort1-English.pdf differ diff --git a/algorithms/Sorting/5-QuickSort1-Partition/Solutions/python.py b/algorithms/Sorting/5-QuickSort1-Partition/Solutions/python.py new file mode 100644 index 0000000..5d1c978 --- /dev/null +++ b/algorithms/Sorting/5-QuickSort1-Partition/Solutions/python.py @@ -0,0 +1,31 @@ +#!/bin/python3 + +import sys + +def quickSort(arr): + left = [] + equal = [] + right = [] + pivot = arr[0] + for x in arr: + if x == pivot: + equal.append(x) + elif x > pivot: + right.append(x) + else: + left.append(x) + + arr[:] =[] + arr += left + arr += equal + arr += right + return arr + + +if __name__ == "__main__": + n = int(input().strip()) + arr = list(map(int, input().strip().split(' '))) + result = quickSort(arr) + print (" ".join(map(str, result))) + + diff --git a/algorithms/Strings/CamelCase/ProblemStatement/camelcase-English.pdf b/algorithms/Strings/CamelCase/ProblemStatement/camelcase-English.pdf new file mode 100644 index 0000000..f58ba03 Binary files /dev/null and b/algorithms/Strings/CamelCase/ProblemStatement/camelcase-English.pdf differ diff --git a/algorithms/Strings/CamelCase/Solutions/python.py b/algorithms/Strings/CamelCase/Solutions/python.py new file mode 100644 index 0000000..8710e28 --- /dev/null +++ b/algorithms/Strings/CamelCase/Solutions/python.py @@ -0,0 +1,11 @@ +#!/bin/python3 + +import sys + +def camelcase(s): + return sum(1 for c in s if c.isupper()) + 1 + +if __name__ == "__main__": + s = input().strip() + result = camelcase(s) + print(result)