diff --git a/Data Structures/01. Arrays/001. Arrays - DS.py b/Data Structures/01. Arrays/001. Arrays - DS.py index 7f44dd4..c17374f 100644 --- a/Data Structures/01. Arrays/001. Arrays - DS.py +++ b/Data Structures/01. Arrays/001. Arrays - DS.py @@ -1,13 +1,13 @@ -# Problem: https://www.hackerrank.com/challenges/arrays-ds/problem -# Score: 10 - - -def reverseArray(arr): - result = arr[::-1] - return result - - -arrДount = int(input()) -arr = list(map(int, input().rstrip().split())) -result = reverseArray(arr) -print(*result) +# Problem: https://www.hackerrank.com/challenges/arrays-ds/problem +# Score: 10 + + +def reverseArray(arr): + result = arr[::-1] + return result + + +arrДount = int(input()) +arr = list(map(int, input().rstrip().split())) +result = reverseArray(arr) +print(*result) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a591e63 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2022 - 2023 Mike Donaghy [CODING-Enthusiast9857] + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Python/Python: Division.py b/Python/PythonDivision.py similarity index 100% rename from Python/Python: Division.py rename to Python/PythonDivision.py diff --git a/Python/Strings/alphabetRangoli.py b/Python/Strings/alphabetRangoli.py new file mode 100644 index 0000000..45f26c1 --- /dev/null +++ b/Python/Strings/alphabetRangoli.py @@ -0,0 +1,8 @@ +from string import ascii_lowercase as chars + +def print_rangoli(size): + ans=[] + for i in range(size): + s='-'.join(chars[i:size]) + ans.append((s[::-1]+s[1:]).center(4*size-3,'-')) + print('\n'.join(ans[:0:-1]+ans)) \ No newline at end of file diff --git a/Python/Strings/capitalize.py b/Python/Strings/capitalize.py new file mode 100644 index 0000000..84e40c3 --- /dev/null +++ b/Python/Strings/capitalize.py @@ -0,0 +1,4 @@ +def solve(s): + for i in s.split(): + s = s.replace(i,i.capitalize()) + return s \ No newline at end of file diff --git a/Python/Strings/designerDoorMat.py b/Python/Strings/designerDoorMat.py new file mode 100644 index 0000000..69a88cf --- /dev/null +++ b/Python/Strings/designerDoorMat.py @@ -0,0 +1,6 @@ +N,M=map(int,input().split()) +for i in range(1,N,2): + print((i*'.|.').center(M,'-')) +print("WELCOME".center(M,'-')) +for j in range(N-2,-1,-2): + print((j*'.|.').center(M,'-')) \ No newline at end of file diff --git a/Python/Strings/findString.py b/Python/Strings/findString.py new file mode 100644 index 0000000..88e429a --- /dev/null +++ b/Python/Strings/findString.py @@ -0,0 +1,6 @@ +def count_substring(string, sub_string): + c=0 + for x in range(len(string)): + if string[x:].startswith(sub_string): + c+=1 + return c diff --git a/Python/Strings/mergeTheTools.py b/Python/Strings/mergeTheTools.py new file mode 100644 index 0000000..8338c91 --- /dev/null +++ b/Python/Strings/mergeTheTools.py @@ -0,0 +1,8 @@ +def merge_the_tools(string, k): + n=len(string) + for i in range(0,n,k): + s='' + for ele in string[i:i+k]: + if (ele not in s): + s+=ele + print(s) \ No newline at end of file diff --git a/Python/Strings/minionGame.py b/Python/Strings/minionGame.py new file mode 100644 index 0000000..92b443f --- /dev/null +++ b/Python/Strings/minionGame.py @@ -0,0 +1,18 @@ +def minion_game(string): + player1 = 0 + player2 = 0 + str_len = len(string) + for i in range(str_len): + if string[i] in "AEIOU": + player1 += (str_len)-i + else : + player2 += (str_len)-i + + if player1 > player2: + print("Kevin", player1) + elif player1 < player2: + print("Stuart",player2) + elif player1 == player2: + print("Draw") + else : + print("Draw") \ No newline at end of file diff --git a/Python/Strings/splitAndJoin.py b/Python/Strings/splitAndJoin.py new file mode 100644 index 0000000..831a17b --- /dev/null +++ b/Python/Strings/splitAndJoin.py @@ -0,0 +1,3 @@ +def split_and_join(line): + line=line.split() + return "-".join(line) \ No newline at end of file diff --git a/Python/Strings/stringFormatting.py b/Python/Strings/stringFormatting.py new file mode 100644 index 0000000..fcee168 --- /dev/null +++ b/Python/Strings/stringFormatting.py @@ -0,0 +1,10 @@ +def print_formatted(number): + l1 = len(bin(number)[2:]) + + for i in range(1,number+1): + print(str(i).rjust(l1,' '),end=" ") + print(oct(i)[2:].rjust(l1,' '),end=" ") + print(((hex(i)[2:]).upper()).rjust(l1,' '),end=" ") + print(bin(i)[2:].rjust(l1,' '),end=" ") + print("") + diff --git a/Python/Strings/stringValidators.py b/Python/Strings/stringValidators.py new file mode 100644 index 0000000..cbf67ee --- /dev/null +++ b/Python/Strings/stringValidators.py @@ -0,0 +1,8 @@ +if __name__ == '__main__': + s = input() + + print(any(c.isalnum() for c in s)) + print(any(c.isalpha() for c in s)) + print(any(c.isdigit() for c in s)) + print(any(c.islower() for c in s)) + print(any(c.isupper() for c in s)) \ No newline at end of file diff --git a/Python/Strings/swapcase.py b/Python/Strings/swapcase.py new file mode 100644 index 0000000..12033e3 --- /dev/null +++ b/Python/Strings/swapcase.py @@ -0,0 +1,2 @@ +def swap_case(s): + return s.swapcase() \ No newline at end of file diff --git a/Python/Strings/textWrap.py b/Python/Strings/textWrap.py new file mode 100644 index 0000000..a520274 --- /dev/null +++ b/Python/Strings/textWrap.py @@ -0,0 +1,9 @@ +import textwrap + +def wrap(string, max_width): + return "\n".join([string[i:i+max_width] for i in range(0,len(string),max_width)]) + +if __name__ == '__main__': + string, max_width = input(), int(input()) + result = wrap(string, max_width) + print(result) \ No newline at end of file diff --git a/Python/What's Your Name?.py b/Python/What's Your Name.py similarity index 100% rename from Python/What's Your Name?.py rename to Python/What's Your Name.py diff --git a/Python/listComprehension.py b/Python/listComprehension.py new file mode 100644 index 0000000..0483726 --- /dev/null +++ b/Python/listComprehension.py @@ -0,0 +1,7 @@ +if __name__ == '__main__': + x = int(input()) + y = int(input()) + z = int(input()) + n = int(input()) + + print([[a,b,c] for a in range(0,x+1) for b in range(0,y+1) for c in range(0,z+1) if a+b+c!=n]) \ No newline at end of file diff --git a/Python/lists.py b/Python/lists.py new file mode 100644 index 0000000..c38b2d5 --- /dev/null +++ b/Python/lists.py @@ -0,0 +1,22 @@ +if __name__ == '__main__': + N = int(input()) + c=[] + for i in range(N): + c.append(input().split()) + + result=[] + for i in range(N): + if c[i][0]=='insert': + result.insert(int(c[i][1]),int(c[i][2])) + elif c[i][0]=='print': + print(result) + elif c[i][0]=='remove': + result.remove(int(c[i][1])) + elif c[i][0]=='append': + result.append(int(c[i][1])) + elif c[i][0]=='pop': + result.pop() + elif c[i][0]=='sort': + result.sort() + elif c[i][0]=='reverse': + result.reverse() diff --git a/Python/nestedLists.py b/Python/nestedLists.py new file mode 100644 index 0000000..9428b86 --- /dev/null +++ b/Python/nestedLists.py @@ -0,0 +1,9 @@ +if __name__ == '__main__': + marksheet=[] + for _ in range(int(input())): + name = input() + score = float(input()) + marksheet.append([name,score]) + + sh = sorted(list(set([score for name, score in marksheet])))[1] + print('\n'.join([a for a,b in sorted(marksheet) if b == sh])) diff --git a/Python/tuples.py b/Python/tuples.py new file mode 100644 index 0000000..f3f193e --- /dev/null +++ b/Python/tuples.py @@ -0,0 +1,5 @@ +if __name__ == '__main__': + n = int(input()) + integer_list = map(int, input().split()) + t=tuple(integer_list) + print(hash(t)) \ No newline at end of file diff --git a/Tutorials/Cracking the Coding Interview/Trees - Is this a Binary Search Tree?.cpp b/Tutorials/Cracking the Coding Interview/Trees - Is this a Binary Search Tree.cpp similarity index 100% rename from Tutorials/Cracking the Coding Interview/Trees - Is this a Binary Search Tree?.cpp rename to Tutorials/Cracking the Coding Interview/Trees - Is this a Binary Search Tree.cpp