├── .gitattributes ├── .github └── workflows │ └── black.yml ├── .gitignore ├── BasicDataTypes ├── Findingthepercentage.py ├── FindtheSecondLargestNumber.py ├── ListComprehensions.py ├── Lists.py ├── NestedLists.py └── Tuples.py ├── BuiltIns ├── AnyorAll.py ├── AthleteSort.py ├── Input.py ├── PythonEvaluation.py ├── Zipped.py └── ginortS.py ├── Classes ├── Class2FindtheTorsionalAngle.py └── ClassesDealingwithComplexNumbers.py ├── ClosuresandDecorators ├── Decorators2NameDirectory.py └── StandardizeMobileNumberUsingDecorators.py ├── Collections ├── CollectionsOrderedDict.py ├── Collectionsdeque.py ├── Collectionsnamedtuple.py ├── DefaultDictTutorial.py ├── MostCommon.py ├── PilingUp.py ├── WordOrder.py └── collectionsCounter.py ├── DateandTime ├── CalendarModule.py └── TimeDelta.py ├── Debugging ├── DefaultArguments.py └── WordsScore.py ├── ErrorsandExceptions ├── Exceptions.py └── IncorrectRegex.py ├── HackerrankUtility ├── Hackerrank_Solution_Blank_File_Creator.py ├── Hackerrank_Solution_Lister.py ├── js_code.txt ├── python_info.txt └── solution_list.html ├── Hackerrank_Python_Domain.png ├── Hackerrank_Python_Domain_old.png ├── Introduction ├── ArithmeticOperators.py ├── Loops.py ├── PrintFunction.py ├── PythonDivision.py ├── PythonIfElse.py ├── SayHelloWorldWithPython.py └── Writeafunction.py ├── Itertools ├── CompresstheString.py ├── IterablesandIterators.py ├── MaximizeIt.py ├── itertoolscombinations.py ├── itertoolscombinations_with_replacement.py ├── itertoolspermutations.py └── itertoolsproduct.py ├── Math ├── FindAngleMBC.py ├── IntegersComeInAllSizes.py ├── ModDivmod.py ├── PolarCoordinates.py ├── PowerModPower.py ├── TriangleQuest.py └── TriangleQuest2.py ├── Numpy ├── ArrayMathematics.py ├── Arrays.py ├── Concatenate.py ├── DotandCross.py ├── EyeandIdentity.py ├── FloorCeilandRint.py ├── InnerandOuter.py ├── LinearAlgebra.py ├── MeanVarandStd.py ├── MinandMax.py ├── Polynomials.py ├── ShapeandReshape.py ├── SumandProd.py ├── TransposeandFlatten.py └── ZerosandOnes.py ├── PythonFunctionals ├── MapandLambdaFunction.py ├── ReduceFunction.py └── ValidatingEmailAddressesWithaFilter.py ├── RegexandParsing ├── DetectFloatingPointNumbers.py ├── DetectHTMLTagsAttributesandAttributeValues.py ├── GroupGroupsampGroupdict.py ├── HTMLParserPart1.py ├── HTMLParserPart2.py ├── HexColorCode.py ├── MatrixScript.py ├── RefindallampRefinditer.py ├── RegexSubstitution.py ├── Resplit.py ├── RestartampReend.py ├── ValidatingCreditCardNumbers.py ├── ValidatingPostalCodes.py ├── ValidatingRomanNumerals.py ├── ValidatingUID.py ├── ValidatingandParsingEmailAddresses.py └── Validatingphonenumbers.py ├── Sets ├── CheckStrictSuperset.py ├── CheckSubset.py ├── IntroductiontoSets.py ├── NoIdea.py ├── SetMutations.py ├── Setadd.py ├── SetdifferenceOperation.py ├── Setdiscardremoveamppop.py ├── SetintersectionOperation.py ├── Setsymmetric_differenceOperation.py ├── SetunionOperation.py ├── SymmetricDifference.py └── TheCaptainsRoom.py ├── Strings ├── AlphabetRangoli.py ├── Capitalize.py ├── DesignerDoorMat.py ├── Findastring.py ├── MergeTools ├── Mutations.py ├── StringFormatting.py ├── StringSplitandJoin.py ├── StringValidators.py ├── TextAlignment.py ├── TextWrap.py ├── TheMinionGame.py ├── WhatsYourName.py └── sWAPcASE.py ├── XML ├── XML1FindtheScore.py └── XML2FindtheMaximumDepth.py └── readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/workflows/black.yml: -------------------------------------------------------------------------------- 1 | name: Black 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | python-version: ["3.10"] 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Set up Python ${{ matrix.python-version }} 21 | uses: actions/setup-python@v3 22 | with: 23 | python-version: ${{ matrix.python-version }} 24 | - name: Install dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install black 28 | - name: Format all py files using black 29 | run: | 30 | black $(git ls-files '*.py') 31 | - name: Commit changes 32 | run: | 33 | git config --local user.email "action@github.com" 34 | git config --local user.name "GitHub Action" 35 | git add . 36 | git diff-index --quiet HEAD || git commit -m "Format Python code with Black" 37 | - name: Push changes 38 | run: | 39 | git push origin master 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | 49 | # Compiled python modules. 50 | *.pyc 51 | 52 | # Setuptools distribution folder. 53 | /dist/ 54 | 55 | # Python egg metadata, regenerated from source files by setuptools. 56 | /*.egg-info 57 | /*.egg 58 | 59 | # Ide preference 60 | /.idea 61 | /webapp/.idea/ 62 | /webapp/.idea/* 63 | .idea 64 | *.idea 65 | .eslintcache 66 | .eslintrc.json 67 | .vscode/ 68 | 69 | # Python Cache 70 | /__pycache__ 71 | 72 | # Virtual environments 73 | /venv/ 74 | /venv/* 75 | .env.local 76 | .env.development.local 77 | .env.test.local 78 | .env.production.local 79 | -------------------------------------------------------------------------------- /BasicDataTypes/Findingthepercentage.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Finding the percentage 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Updated : 06 February 2023 8 | Problem : https://www.hackerrank.com/challenges/finding-the-percentage/problem 9 | """ 10 | 11 | if __name__ == "__main__": 12 | n = int(input()) 13 | student_marks = {} 14 | for _ in range(n): 15 | name, *line = input().split() 16 | scores = list(map(float, line)) 17 | student_marks[name] = scores 18 | query_name = input() 19 | avg_score = sum(student_marks[query_name]) / len(student_marks[query_name]) 20 | print(f"{avg_score:.2f}") 21 | -------------------------------------------------------------------------------- /BasicDataTypes/FindtheSecondLargestNumber.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Find the Runner-Up Score! 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | n = int(input()) 12 | arr = map(int, input().split()) 13 | print(sorted(set(arr), reverse=True)[1]) 14 | -------------------------------------------------------------------------------- /BasicDataTypes/ListComprehensions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : List Comprehensions 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/list-comprehensions/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | x = int(input()) 12 | y = int(input()) 13 | z = int(input()) 14 | n = int(input()) 15 | ar = [ 16 | [i, j, k] 17 | for i in range(x + 1) 18 | for j in range(y + 1) 19 | for k in range(z + 1) 20 | if i + j + k != n 21 | ] 22 | print(ar) 23 | -------------------------------------------------------------------------------- /BasicDataTypes/Lists.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Lists 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Updated : 06 February 2023 8 | Problem : https://www.hackerrank.com/challenges/python-lists/problem 9 | """ 10 | 11 | if __name__ == "__main__": 12 | N = int(input()) 13 | ar = [] 14 | for _ in range(N): 15 | command_args = input().strip().split(" ") 16 | cmd = command_args[0] 17 | if cmd == "print": 18 | print(ar) 19 | elif cmd == "sort": 20 | ar.sort() 21 | elif cmd == "reverse": 22 | ar.reverse() 23 | elif cmd == "pop": 24 | ar.pop() 25 | elif cmd == "remove": 26 | val = int(command_args[1]) 27 | ar.remove(val) 28 | elif cmd == "append": 29 | val = int(command_args[1]) 30 | ar.append(val) 31 | elif cmd == "insert": 32 | pos = int(command_args[1]) 33 | val = int(command_args[2]) 34 | ar.insert(pos, val) 35 | -------------------------------------------------------------------------------- /BasicDataTypes/NestedLists.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Nested Lists 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/nested-list/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | students = [] 12 | scores = [] 13 | for _ in range(int(input())): 14 | name = input() 15 | score = float(input()) 16 | student = [name, score] 17 | students.append(student) 18 | scores.append(score) 19 | second_min_score = sorted(set(scores))[1] 20 | student_names = sorted( 21 | [student[0] for student in students if student[1] == second_min_score] 22 | ) 23 | print("\n".join(student_names)) 24 | -------------------------------------------------------------------------------- /BasicDataTypes/Tuples.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Tuples 3 | Subdomain : Data Types 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/python-tuples/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | n = int(input()) 12 | integer_list = map(int, input().split()) 13 | t = tuple(integer_list) 14 | print(hash(t)) 15 | -------------------------------------------------------------------------------- /BuiltIns/AnyorAll.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Any or All 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Updater : Imtiaz Ahmed 7 | Created : 15 July 2016 8 | Updated : 29 August 2022 9 | Problem : https://www.hackerrank.com/challenges/any-or-all/problem 10 | """ 11 | 12 | n = input() 13 | ar = input().split() 14 | print(all(int(i) > 0 for i in ar) and any(i == i[::-1] for i in ar)) 15 | -------------------------------------------------------------------------------- /BuiltIns/AthleteSort.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Athlete Sort 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Atharva Shah 6 | Updater : Imtiaz Ahmed 7 | Created : 3 April 2021 8 | Updated : 30 August 2022 9 | Problem : https://www.hackerrank.com/challenges/python-sort-sort/problem 10 | """ 11 | 12 | if __name__ == "__main__": 13 | n, m = map(int, input().split()) 14 | 15 | arr = [] 16 | 17 | for _ in range(n): 18 | arr.append(list(map(int, input().rstrip().split()))) 19 | 20 | k = int(input()) 21 | 22 | for i in sorted(arr, key=lambda x: x[k]): 23 | print(*i) 24 | -------------------------------------------------------------------------------- /BuiltIns/Input.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Input() 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 3 April 2021 8 | Problem : https://www.hackerrank.com/challenges/input/problem 9 | """ 10 | 11 | if __name__ == "__main__": 12 | x, k = map(int, input().strip().split()) 13 | equation = input().strip() 14 | print(eval(equation) == k) 15 | -------------------------------------------------------------------------------- /BuiltIns/PythonEvaluation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Python Evaluation 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-eval/problem 8 | """ 9 | 10 | eval(input()) 11 | -------------------------------------------------------------------------------- /BuiltIns/Zipped.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Zipped! 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Updater : Imtiaz Ahmed 7 | Created : 15 July 2016 8 | Updated : 30 August 2022 9 | Problem : https://www.hackerrank.com/challenges/zipped/problem 10 | """ 11 | 12 | N, X = map(int, input().split()) 13 | scores = [] 14 | for _ in range(X): 15 | scores.append(list(map(float, input().split()))) 16 | for i in zip(*scores): 17 | print(sum(i) / len(i)) 18 | -------------------------------------------------------------------------------- /BuiltIns/ginortS.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : ginortS 3 | Subdomain : Built-Ins 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Updater : Imtiaz Ahmed 7 | Created : 15 July 2016 8 | Updated : 29 August 2022 9 | Problem : https://www.hackerrank.com/challenges/ginorts/problem 10 | """ 11 | 12 | s = input() 13 | print( 14 | "".join( 15 | sorted( 16 | s, 17 | key=lambda x: ( 18 | x.isdigit() and int(x) % 2 == 0, 19 | x.isdigit(), 20 | x.isupper(), 21 | x.islower(), 22 | x, 23 | ), 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /Classes/Class2FindtheTorsionalAngle.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | """ 4 | Title : Class 2 - Find the Torsional Angle 5 | Subdomain : Classes 6 | Domain : Python 7 | Author : Ahmedur Rahman Shovon 8 | Updater : Imtiaz Ahmed 9 | Created : 15 July 2016 10 | Updated : 30 August 2022 11 | Problem : https://www.hackerrank.com/challenges/class-2-find-the-torsional-angle/problem 12 | """ 13 | 14 | 15 | class Points: 16 | def __init__(self, x, y, z): 17 | self.x = x 18 | self.y = y 19 | self.z = z 20 | 21 | def __sub__(self, other): 22 | return Points(self.x - other.x, self.y - other.y, self.z - other.z) 23 | 24 | def dot(self, other): 25 | return self.x * other.x + self.y * other.y + self.z * other.z 26 | 27 | def absolute(self): 28 | return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z) 29 | 30 | def cross(self, other): 31 | return Points( 32 | self.y * other.z - self.z * other.y, 33 | self.z * other.x - self.x * other.z, 34 | self.x * other.y - self.y * other.x, 35 | ) 36 | 37 | 38 | if __name__ == "__main__": 39 | points = list() 40 | for i in range(4): 41 | a = list(map(float, input().split())) 42 | points.append(a) 43 | 44 | a, b, c, d = ( 45 | Points(*points[0]), 46 | Points(*points[1]), 47 | Points(*points[2]), 48 | Points(*points[3]), 49 | ) 50 | x = (b - a).cross(c - b) 51 | y = (c - b).cross(d - c) 52 | angle = math.acos(x.dot(y) / (x.absolute() * y.absolute())) 53 | 54 | print("%.2f" % math.degrees(angle)) 55 | -------------------------------------------------------------------------------- /Classes/ClassesDealingwithComplexNumbers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Classes: Dealing with Complex Numbers 3 | Subdomain : Classes 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Updater : Imtiaz Ahmed 7 | Created : 15 July 2016 8 | Updated : 30 August 2022 9 | Problem : https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problem 10 | """ 11 | 12 | import math 13 | 14 | 15 | class Complex: 16 | def __init__(self, real, imaginary): 17 | self.real = real 18 | self.imaginary = imaginary 19 | 20 | def __add__(self, no): 21 | return Complex(self.real + no.real, self.imaginary + no.imaginary) 22 | 23 | def __sub__(self, no): 24 | return Complex(self.real - no.real, self.imaginary - no.imaginary) 25 | 26 | def __mul__(self, no): 27 | return Complex( 28 | self.real * no.real - self.imaginary * no.imaginary, 29 | self.real * no.imaginary + self.imaginary * no.real, 30 | ) 31 | 32 | def __truediv__(self, no): 33 | divider = no.real**2 + no.imaginary**2 34 | return Complex( 35 | (self.real * no.real + self.imaginary * no.imaginary) / divider, 36 | (self.imaginary * no.real - self.real * no.imaginary) / divider, 37 | ) 38 | 39 | def mod(self): 40 | return Complex(math.sqrt(self.real**2 + self.imaginary**2), 0.00) 41 | 42 | def __str__(self): 43 | if self.imaginary == 0: 44 | result = "%.2f+0.00i" % (self.real) 45 | elif self.real == 0: 46 | if self.imaginary >= 0: 47 | result = "0.00+%.2fi" % (self.imaginary) 48 | else: 49 | result = "0.00-%.2fi" % (abs(self.imaginary)) 50 | elif self.imaginary > 0: 51 | result = "%.2f+%.2fi" % (self.real, self.imaginary) 52 | else: 53 | result = "%.2f-%.2fi" % (self.real, abs(self.imaginary)) 54 | return result 55 | 56 | 57 | if __name__ == "__main__": 58 | c = map(float, input().split()) 59 | d = map(float, input().split()) 60 | x = Complex(*c) 61 | y = Complex(*d) 62 | print(*map(str, [x + y, x - y, x * y, x / y, x.mod(), y.mod()]), sep="\n") 63 | -------------------------------------------------------------------------------- /ClosuresandDecorators/Decorators2NameDirectory.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Decorators 2 - Name Directory 3 | Subdomain : Closures and Decorators 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 3 April 2021 8 | Problem : https://www.hackerrank.com/challenges/decorators-2-name-directory/problem 9 | """ 10 | 11 | import operator 12 | 13 | 14 | def person_lister(func): 15 | def inner(people): 16 | return [func(p) for p in sorted(people, key=lambda x: (int(x[2])))] 17 | 18 | return inner 19 | 20 | 21 | @person_lister 22 | def name_format(person): 23 | return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1] 24 | 25 | 26 | if __name__ == "__main__": 27 | people = [input().split() for i in range(int(input()))] 28 | print(*name_format(people), sep="\n") 29 | -------------------------------------------------------------------------------- /ClosuresandDecorators/StandardizeMobileNumberUsingDecorators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Standardize Mobile Number Using Decorators 3 | Subdomain : Closures and Decorators 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem 8 | """ 9 | 10 | # Enter your code here. Read input from STDIN. Print output to STDOUT 11 | n = int(input()) 12 | ar = [] 13 | for _ in range(n): 14 | tmp_str = input() 15 | tmp_str = tmp_str[len(tmp_str) - 10 :] 16 | ar.append(tmp_str) 17 | 18 | ar.sort() 19 | for item in ar: 20 | print(f"+91 {item[:5]} {item[5:]}") 21 | -------------------------------------------------------------------------------- /Collections/CollectionsOrderedDict.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Collections.OrderedDict() 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 26 November 2024 8 | Problem : https://www.hackerrank.com/challenges/py-collections-ordereddict/problem 9 | """ 10 | 11 | from collections import OrderedDict 12 | 13 | 14 | if __name__ == "__main__": 15 | ordered_dictionary = OrderedDict() 16 | 17 | n = int(input()) 18 | 19 | for _ in range(n): 20 | s = list(input().split()) 21 | price = int(s[len(s) - 1]) 22 | name = " ".join(s[: len(s) - 1]) 23 | 24 | if ordered_dictionary.get(name): 25 | ordered_dictionary[name] += price 26 | else: 27 | ordered_dictionary[name] = price 28 | 29 | for key, value in ordered_dictionary.items(): 30 | print(key, value) 31 | -------------------------------------------------------------------------------- /Collections/Collectionsdeque.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Collections.deque() 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/py-collections-deque/problem 8 | """ 9 | 10 | import collections 11 | 12 | n = int(input()) 13 | d = collections.deque() 14 | for _ in range(n): 15 | cmd = list(input().strip().split()) 16 | opt = cmd[0] 17 | if opt == "append": 18 | d.append(int(cmd[1])) 19 | elif opt == "appendleft": 20 | d.appendleft(int(cmd[1])) 21 | elif opt == "pop": 22 | d.pop() 23 | elif opt == "popleft": 24 | d.popleft() 25 | for i in d: 26 | print(i, end=" ") 27 | -------------------------------------------------------------------------------- /Collections/Collectionsnamedtuple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Collections.namedtuple() 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 09 February 2023 8 | Problem : https://www.hackerrank.com/challenges/py-collections-namedtuple/problem 9 | """ 10 | 11 | from collections import namedtuple 12 | 13 | n = int(input()) 14 | columns = ",".join(input().split()) 15 | Student = namedtuple("Student", columns) 16 | data = [] 17 | for i in range(n): 18 | row = input().split() 19 | s = Student._make(row) 20 | data.append(s) 21 | avg = sum(float(s.MARKS) for s in data) / n 22 | print(f"{avg:.2f}") 23 | -------------------------------------------------------------------------------- /Collections/DefaultDictTutorial.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : DefaultDict Tutorial 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/defaultdict-tutorial/problem 8 | """ 9 | 10 | from collections import defaultdict 11 | 12 | d = defaultdict(list) 13 | n, m = map(int, input().split()) 14 | for i in range(n): 15 | w = input() 16 | d[w].append(str(i + 1)) 17 | for _ in range(m): 18 | w = input() 19 | print(" ".join(d[w]) or -1) 20 | -------------------------------------------------------------------------------- /Collections/MostCommon.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Most Common 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/most-commons/problem 8 | """ 9 | 10 | import collections 11 | 12 | s = sorted(input().strip()) 13 | s_counter = collections.Counter(s).most_common() 14 | """ 15 | s_counter_length = len(s_counter) 16 | for i in range(0,s_counter_length,1): 17 | for j in range(i+1,s_counter_length,1): 18 | if (s_counter[i][1] == s_counter[j][1]) and (ord(s_counter[j][0]) < ord(s_counter[i][0])): 19 | s_counter[i],s_counter[j] = s_counter[j],s_counter[i] 20 | """ 21 | s_counter = sorted(s_counter, key=lambda x: (x[1] * -1, x[0])) 22 | for i in range(3): 23 | print(s_counter[i][0], s_counter[i][1]) 24 | -------------------------------------------------------------------------------- /Collections/PilingUp.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Piling Up! 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/piling-up/problem 8 | """ 9 | 10 | from collections import deque 11 | 12 | cas = int(input()) 13 | for _ in range(cas): 14 | n = int(input()) 15 | dq = deque(map(int, input().split())) 16 | possible = True 17 | element = (2**31) + 1 18 | while dq: 19 | left_element = dq[0] 20 | right_element = dq[-1] 21 | if left_element >= right_element and element >= left_element: 22 | element = dq.popleft() 23 | elif right_element >= left_element and element >= right_element: 24 | element = dq.pop() 25 | else: 26 | possible = False 27 | break 28 | if possible: 29 | print("Yes") 30 | else: 31 | print("No") 32 | -------------------------------------------------------------------------------- /Collections/WordOrder.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Word Order 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/word-order/problem 8 | """ 9 | 10 | from collections import Counter, OrderedDict 11 | 12 | 13 | class OrderedCounter(Counter, OrderedDict): 14 | pass 15 | 16 | 17 | word_ar = [] 18 | n = int(input()) 19 | for i in range(n): 20 | word_ar.append(input().strip()) 21 | word_counter = OrderedCounter(word_ar) 22 | print(len(word_counter)) 23 | for word in word_counter: 24 | print(word_counter[word], end=" ") 25 | -------------------------------------------------------------------------------- /Collections/collectionsCounter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : collections.Counter() 3 | Subdomain : Collections 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 26 November 2024 8 | Problem : https://www.hackerrank.com/challenges/collections-counter/problem 9 | """ 10 | 11 | import collections 12 | 13 | 14 | if __name__ == "__main__": 15 | total_shoes = int(input()) 16 | shoe_sizes = list(map(int, input().split())) 17 | inventory = collections.Counter(shoe_sizes) 18 | 19 | total_customers = int(input()) 20 | total_revenue = 0 21 | 22 | for _ in range(total_customers): 23 | size, price = map(int, input().split()) 24 | if inventory.get(size) and inventory[size] > 0: 25 | total_revenue += price 26 | inventory[size] -= 1 27 | 28 | print(total_revenue) 29 | -------------------------------------------------------------------------------- /DateandTime/CalendarModule.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Calendar Module 3 | Subdomain : Date and Time 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/calendar-module/problem 8 | """ 9 | 10 | import calendar 11 | import datetime 12 | 13 | m, d, y = map(int, input().split()) 14 | input_date = datetime.date(y, m, d) 15 | print(calendar.day_name[input_date.weekday()].upper()) 16 | -------------------------------------------------------------------------------- /DateandTime/TimeDelta.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Time Delta 3 | Subdomain : Date and Time 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-time-delta/problem 8 | """ 9 | 10 | import datetime 11 | 12 | cas = int(input()) 13 | time_format = "%a %d %b %Y %H:%M:%S %z" 14 | for _ in range(cas): 15 | timestamp1 = input().strip() 16 | timestamp2 = input().strip() 17 | time_second1 = datetime.datetime.strptime(timestamp1, time_format) 18 | time_second2 = datetime.datetime.strptime(timestamp2, time_format) 19 | print(int(abs((time_second1 - time_second2).total_seconds()))) 20 | -------------------------------------------------------------------------------- /Debugging/DefaultArguments.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Default Arguments 3 | Subdomain : Debugging 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 08 July 2018 7 | Problem : https://www.hackerrank.com/challenges/default-arguments/problem 8 | """ 9 | 10 | 11 | def print_from_stream(n, stream=EvenStream()): 12 | stream.__init__() 13 | for _ in range(n): 14 | print(stream.get_next()) 15 | -------------------------------------------------------------------------------- /Debugging/WordsScore.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Words Score 3 | Subdomain : Debugging 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 08 July 2018 7 | Problem : https://www.hackerrank.com/challenges/words-score/problem 8 | """ 9 | 10 | 11 | def is_vowel(letter): 12 | return letter in ["a", "e", "i", "o", "u", "y"] 13 | 14 | 15 | def score_words(words): 16 | score = 0 17 | for word in words: 18 | num_vowels = sum(1 for letter in word if is_vowel(letter)) 19 | score += 2 if num_vowels % 2 == 0 else 1 20 | return score 21 | -------------------------------------------------------------------------------- /ErrorsandExceptions/Exceptions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Exceptions 3 | Subdomain : Errors and Exceptions 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/exceptions/problem 8 | """ 9 | 10 | n = int(input()) 11 | for _ in range(n): 12 | a, b = input().split() 13 | try: 14 | print(int(a) // int(b)) 15 | except Exception as e: 16 | print(f"Error Code: {e}") 17 | -------------------------------------------------------------------------------- /ErrorsandExceptions/IncorrectRegex.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Incorrect Regex 3 | Subdomain : Errors and Exceptions 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/incorrect-regex/problem 8 | """ 9 | 10 | import re 11 | 12 | n = int(input()) 13 | for _ in range(n): 14 | s = input() 15 | try: 16 | re.compile(s) 17 | print(True) 18 | except Exception as e: 19 | print(False) 20 | -------------------------------------------------------------------------------- /HackerrankUtility/Hackerrank_Solution_Blank_File_Creator.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Hackerrank_Solution_Blank_File_Creator 3 | Subdomain : None 4 | Domain : None 5 | Author : Ahmedur Rahman Shovon 6 | Created : 12 July 2017 7 | """ 8 | 9 | import datetime 10 | import os 11 | import re 12 | import sys 13 | 14 | extension = ".py" 15 | domain = "Python" 16 | author = "Ahmedur Rahman Shovon" 17 | created_date = datetime.datetime.today().strftime("%d %B %Y") 18 | info_file_name = "python_info.txt" 19 | 20 | 21 | def valid_name(given_name): 22 | return re.sub(r"[^\w]", "", given_name) 23 | 24 | 25 | def write_file_header(title, subdomain): 26 | header_str = "'''\n" 27 | header_str += "Title : " + title + "\n" 28 | header_str += "Subdomain : " + subdomain + "\n" 29 | header_str += "Domain : " + domain + "\n" 30 | header_str += "Author : " + author + "\n" 31 | header_str += "Created : " + created_date + "\n" 32 | header_str += "'''\n" 33 | return header_str 34 | 35 | 36 | problem_list = "" 37 | subdomain_name = "" 38 | 39 | info_file = open(info_file_name, "r") 40 | info_file_lines = info_file.readlines() 41 | info_file.close() 42 | for line in info_file_lines: 43 | line = line.strip() 44 | if line == "": 45 | continue 46 | elif line[0] == "[": 47 | problem_list = line 48 | else: 49 | subdomain_name = line 50 | if subdomain_name != "" and problem_list != "": 51 | folder_name = valid_name(subdomain_name) 52 | if not os.path.exists(folder_name): 53 | os.makedirs(folder_name) 54 | title_ar = re.findall(r'("[^"]*")', problem_list) 55 | title_ar_len = len(title_ar) 56 | 57 | for title in title_ar: 58 | file_header_str = write_file_header(title[1:-1], subdomain_name) 59 | title_valid = valid_name(title) 60 | f = open(folder_name + "\\" + title_valid + extension, "w") 61 | f.write(file_header_str) 62 | f.close() 63 | 64 | print("Folder: " + str(folder_name) + ". Total files: " + str(title_ar_len)) 65 | subdomain_name = "" 66 | problem_list = "" 67 | -------------------------------------------------------------------------------- /HackerrankUtility/Hackerrank_Solution_Lister.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Hackerrank Solution Lister 3 | Subdomain : None 4 | Domain : None 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2017 7 | """ 8 | 9 | import os 10 | import re 11 | import sys 12 | 13 | info_file_name = "python_info.txt" 14 | 15 | 16 | def get_valid_name(given_name): 17 | return re.sub(r"[^\w]", "", given_name) 18 | 19 | 20 | problem_list = "" 21 | subdomain_name = "" 22 | extension = ".py" 23 | 24 | info_file = open(info_file_name, "r") 25 | info_file_lines = info_file.readlines() 26 | info_file.close() 27 | output_file_name = "solution_list.html" 28 | f = open(output_file_name, "w") 29 | f.write("\n") 30 | for line in info_file_lines: 31 | line = line.strip() 32 | if line == "": 33 | continue 34 | elif line[0] == "[": 35 | problem_list = line 36 | else: 37 | subdomain_name = line 38 | if subdomain_name != "" and problem_list != "": 39 | folder_name = get_valid_name(subdomain_name) 40 | title_ar = re.findall(r'("[^"]*")', problem_list) 41 | title_ar_len = len(title_ar) 42 | f.write("- " + subdomain_name + "\n") 43 | for title in title_ar: 44 | filename = get_valid_name(title[1:-1]) 45 | filepath = folder_name + "/" + filename + extension 46 | f.write(" - [" + title[1:-1] + "](" + filepath + ")\n") 47 | subdomain_name = "" 48 | problem_list = "" 49 | f.close() 50 | print("List generated successfully. Open " + output_file_name + " to view.") 51 | -------------------------------------------------------------------------------- /HackerrankUtility/js_code.txt: -------------------------------------------------------------------------------- 1 | $ar = [] 2 | $('.challengecard-title>.js-track-click').each(function(){ 3 | $title = $(this).html().trim(); 4 | $title = $title.toString().replace(/"/g,''); 5 | $title = $title.replace(/'/g,''); 6 | $ar.push($title); 7 | }) 8 | $subdomain = $('.current>a').html().trim(); 9 | console.log($subdomain); 10 | console.log($ar); 11 | -------------------------------------------------------------------------------- /HackerrankUtility/python_info.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ["Say Hello, World! With Python", "Reading Raw Input", "Python If-Else", "Arithmetic Operators", "Python: Division", "Loops", "Write a function", "Print Function"] 3 | 4 | Basic Data Types 5 | ["Lists", "Tuples", "List Comprehensions", "Find the Second Largest Number", "Nested Lists", "Finding the percentage"] 6 | 7 | Strings 8 | ["sWAP cASE", "String Split and Join", "Whats Your Name?", "Mutations", "Find a string", "String Validators", "Text Alignment", "Text Wrap", "Designer Door Mat", "String Formatting", "Alphabet Rangoli", "Capitalize!", "The Minion Game"] 9 | 10 | Sets 11 | ["Introduction to Sets", "Symmetric Difference", "No Idea!", "Set .add()", "Set .discard(), .remove() & .pop()", "Set .union() Operation", "Set .intersection() Operation", "Set .difference() Operation", "Set .symmetric_difference() Operation", "Set Mutations", "The Captains Room", "Check Subset", "Check Strict Superset"] 12 | 13 | Math 14 | ["Polar Coordinates", "Find Angle MBC", "Triangle Quest 2", "Mod Divmod", "Power - Mod Power", "Integers Come In All Sizes", "Triangle Quest"] 15 | 16 | Itertools 17 | ["itertools.product()", "itertools.permutations()", "itertools.combinations()", "itertools.combinations_with_replacement()", "Compress the String!", "Iterables and Iterators", "Maximize It!"] 18 | 19 | Collections 20 | ["collections.Counter()", "DefaultDict Tutorial", "Collections.namedtuple()", "Collections.OrderedDict()", "Word Order", "Collections.deque()", "Piling Up!", "Most Common"] 21 | 22 | Date and Time 23 | ["Calendar Module", "Time Delta"] 24 | 25 | Errors and Exceptions 26 | ["Exceptions", "Incorrect Regex"] 27 | 28 | Classes 29 | ["Classes: Dealing with Complex Numbers", "Class 2 - Find the Torsional Angle"] 30 | 31 | Built-Ins 32 | ["Zipped!", "Input()", "Python Evaluation", "Sort Data", "Any or All", "ginortS"] 33 | 34 | Python Functionals 35 | ["Map and Lambda Function", "Validating Email Addresses With a Filter"] 36 | 37 | Regex and Parsing 38 | ["Introduction to Regex Module", "Re.split()", "Group(), Groups() & Groupdict()", "Re.findall() & Re.finditer()", "Re.start() & Re.end()", "Regex Substitution", "Validating Roman Numerals", "Validating phone numbers", "Validating and Parsing Email Addresses", "Hex Color Code", "HTML Parser - Part 1", "HTML Parser - Part 2", "Detect HTML Tags, Attributes and Attribute Values", "Validating UID", "Validating Credit Card Numbers", "Validating Postal Codes", "Matrix Script"] 39 | 40 | XML 41 | ["XML 1 - Find the Score", "XML2 - Find the Maximum Depth"] 42 | 43 | Closures and Decorators 44 | ["Standardize Mobile Number Using Decorators", "Decorators 2 - Name Directory"] 45 | 46 | Numpy 47 | ["Arrays", "Shape and Reshape", "Transpose and Flatten", "Concatenate", "Zeros and Ones", "Eye and Identity", "Array Mathematics", "Floor, Ceil and Rint", "Sum and Prod", "Min and Max", "Mean, Var, and Std", "Dot and Cross", "Inner and Outer", "Polynomials", "Linear Algebra"] 48 | 49 | Debugging 50 | ["Words Score", "Default Arguments"] 51 | 52 | -------------------------------------------------------------------------------- /HackerrankUtility/solution_list.html: -------------------------------------------------------------------------------- 1 | 2 | - Introduction 3 | - [Say Hello, World! With Python](Introduction/SayHelloWorldWithPython.py) 4 | - [Reading Raw Input](Introduction/ReadingRawInput.py) 5 | - [Python If-Else](Introduction/PythonIfElse.py) 6 | - [Arithmetic Operators](Introduction/ArithmeticOperators.py) 7 | - [Python: Division](Introduction/PythonDivision.py) 8 | - [Loops](Introduction/Loops.py) 9 | - [Write a function](Introduction/Writeafunction.py) 10 | - [Print Function](Introduction/PrintFunction.py) 11 | - Basic Data Types 12 | - [Lists](BasicDataTypes/Lists.py) 13 | - [Tuples](BasicDataTypes/Tuples.py) 14 | - [List Comprehensions](BasicDataTypes/ListComprehensions.py) 15 | - [Find the Second Largest Number](BasicDataTypes/FindtheSecondLargestNumber.py) 16 | - [Nested Lists](BasicDataTypes/NestedLists.py) 17 | - [Finding the percentage](BasicDataTypes/Findingthepercentage.py) 18 | - Strings 19 | - [sWAP cASE](Strings/sWAPcASE.py) 20 | - [String Split and Join](Strings/StringSplitandJoin.py) 21 | - [Whats Your Name?](Strings/WhatsYourName.py) 22 | - [Mutations](Strings/Mutations.py) 23 | - [Find a string](Strings/Findastring.py) 24 | - [String Validators](Strings/StringValidators.py) 25 | - [Text Alignment](Strings/TextAlignment.py) 26 | - [Text Wrap](Strings/TextWrap.py) 27 | - [Designer Door Mat](Strings/DesignerDoorMat.py) 28 | - [String Formatting](Strings/StringFormatting.py) 29 | - [Alphabet Rangoli](Strings/AlphabetRangoli.py) 30 | - [Capitalize!](Strings/Capitalize.py) 31 | - [The Minion Game](Strings/TheMinionGame.py) 32 | - Sets 33 | - [Introduction to Sets](Sets/IntroductiontoSets.py) 34 | - [Symmetric Difference](Sets/SymmetricDifference.py) 35 | - [No Idea!](Sets/NoIdea.py) 36 | - [Set .add()](Sets/Setadd.py) 37 | - [Set .discard(), .remove() & .pop()](Sets/Setdiscardremoveamppop.py) 38 | - [Set .union() Operation](Sets/SetunionOperation.py) 39 | - [Set .intersection() Operation](Sets/SetintersectionOperation.py) 40 | - [Set .difference() Operation](Sets/SetdifferenceOperation.py) 41 | - [Set .symmetric_difference() Operation](Sets/Setsymmetric_differenceOperation.py) 42 | - [Set Mutations](Sets/SetMutations.py) 43 | - [The Captains Room](Sets/TheCaptainsRoom.py) 44 | - [Check Subset](Sets/CheckSubset.py) 45 | - [Check Strict Superset](Sets/CheckStrictSuperset.py) 46 | - Math 47 | - [Polar Coordinates](Math/PolarCoordinates.py) 48 | - [Find Angle MBC](Math/FindAngleMBC.py) 49 | - [Triangle Quest 2](Math/TriangleQuest2.py) 50 | - [Mod Divmod](Math/ModDivmod.py) 51 | - [Power - Mod Power](Math/PowerModPower.py) 52 | - [Integers Come In All Sizes](Math/IntegersComeInAllSizes.py) 53 | - [Triangle Quest](Math/TriangleQuest.py) 54 | - Itertools 55 | - [itertools.product()](Itertools/itertoolsproduct.py) 56 | - [itertools.permutations()](Itertools/itertoolspermutations.py) 57 | - [itertools.combinations()](Itertools/itertoolscombinations.py) 58 | - [itertools.combinations_with_replacement()](Itertools/itertoolscombinations_with_replacement.py) 59 | - [Compress the String!](Itertools/CompresstheString.py) 60 | - [Iterables and Iterators](Itertools/IterablesandIterators.py) 61 | - [Maximize It!](Itertools/MaximizeIt.py) 62 | - Collections 63 | - [collections.Counter()](Collections/collectionsCounter.py) 64 | - [DefaultDict Tutorial](Collections/DefaultDictTutorial.py) 65 | - [Collections.namedtuple()](Collections/Collectionsnamedtuple.py) 66 | - [Collections.OrderedDict()](Collections/CollectionsOrderedDict.py) 67 | - [Word Order](Collections/WordOrder.py) 68 | - [Collections.deque()](Collections/Collectionsdeque.py) 69 | - [Piling Up!](Collections/PilingUp.py) 70 | - [Most Common](Collections/MostCommon.py) 71 | - Date and Time 72 | - [Calendar Module](DateandTime/CalendarModule.py) 73 | - [Time Delta](DateandTime/TimeDelta.py) 74 | - Errors and Exceptions 75 | - [Exceptions](ErrorsandExceptions/Exceptions.py) 76 | - [Incorrect Regex](ErrorsandExceptions/IncorrectRegex.py) 77 | - Classes 78 | - [Classes: Dealing with Complex Numbers](Classes/ClassesDealingwithComplexNumbers.py) 79 | - [Class 2 - Find the Torsional Angle](Classes/Class2FindtheTorsionalAngle.py) 80 | - Built-Ins 81 | - [Zipped!](BuiltIns/Zipped.py) 82 | - [Input()](BuiltIns/Input.py) 83 | - [Python Evaluation](BuiltIns/PythonEvaluation.py) 84 | - [Sort Data](BuiltIns/SortData.py) 85 | - [Any or All](BuiltIns/AnyorAll.py) 86 | - [ginortS](BuiltIns/ginortS.py) 87 | - Python Functionals 88 | - [Map and Lambda Function](PythonFunctionals/MapandLambdaFunction.py) 89 | - [Validating Email Addresses With a Filter](PythonFunctionals/ValidatingEmailAddressesWithaFilter.py) 90 | - Regex and Parsing 91 | - [Introduction to Regex Module](RegexandParsing/IntroductiontoRegexModule.py) 92 | - [Re.split()](RegexandParsing/Resplit.py) 93 | - [Group(), Groups() & Groupdict()](RegexandParsing/GroupGroupsampGroupdict.py) 94 | - [Re.findall() & Re.finditer()](RegexandParsing/RefindallampRefinditer.py) 95 | - [Re.start() & Re.end()](RegexandParsing/RestartampReend.py) 96 | - [Regex Substitution](RegexandParsing/RegexSubstitution.py) 97 | - [Validating Roman Numerals](RegexandParsing/ValidatingRomanNumerals.py) 98 | - [Validating phone numbers](RegexandParsing/Validatingphonenumbers.py) 99 | - [Validating and Parsing Email Addresses](RegexandParsing/ValidatingandParsingEmailAddresses.py) 100 | - [Hex Color Code](RegexandParsing/HexColorCode.py) 101 | - [HTML Parser - Part 1](RegexandParsing/HTMLParserPart1.py) 102 | - [HTML Parser - Part 2](RegexandParsing/HTMLParserPart2.py) 103 | - [Detect HTML Tags, Attributes and Attribute Values](RegexandParsing/DetectHTMLTagsAttributesandAttributeValues.py) 104 | - [Validating UID](RegexandParsing/ValidatingUID.py) 105 | - [Validating Credit Card Numbers](RegexandParsing/ValidatingCreditCardNumbers.py) 106 | - [Validating Postal Codes](RegexandParsing/ValidatingPostalCodes.py) 107 | - [Matrix Script](RegexandParsing/MatrixScript.py) 108 | - XML 109 | - [XML 1 - Find the Score](XML/XML1FindtheScore.py) 110 | - [XML2 - Find the Maximum Depth](XML/XML2FindtheMaximumDepth.py) 111 | - Closures and Decorators 112 | - [Standardize Mobile Number Using Decorators](ClosuresandDecorators/StandardizeMobileNumberUsingDecorators.py) 113 | - [Decorators 2 - Name Directory](ClosuresandDecorators/Decorators2NameDirectory.py) 114 | - Numpy 115 | - [Arrays](Numpy/Arrays.py) 116 | - [Shape and Reshape](Numpy/ShapeandReshape.py) 117 | - [Transpose and Flatten](Numpy/TransposeandFlatten.py) 118 | - [Concatenate](Numpy/Concatenate.py) 119 | - [Zeros and Ones](Numpy/ZerosandOnes.py) 120 | - [Eye and Identity](Numpy/EyeandIdentity.py) 121 | - [Array Mathematics](Numpy/ArrayMathematics.py) 122 | - [Floor, Ceil and Rint](Numpy/FloorCeilandRint.py) 123 | - [Sum and Prod](Numpy/SumandProd.py) 124 | - [Min and Max](Numpy/MinandMax.py) 125 | - [Mean, Var, and Std](Numpy/MeanVarandStd.py) 126 | - [Dot and Cross](Numpy/DotandCross.py) 127 | - [Inner and Outer](Numpy/InnerandOuter.py) 128 | - [Polynomials](Numpy/Polynomials.py) 129 | - [Linear Algebra](Numpy/LinearAlgebra.py) 130 | - Debugging 131 | - [Words Score](Debugging/WordsScore.py) 132 | - [Default Arguments](Debugging/DefaultArguments.py) 133 | -------------------------------------------------------------------------------- /Hackerrank_Python_Domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsho/Hackerrank_Python_Domain_Solutions/502e8e2e00f5d1610be1ed03064366dfd15290e4/Hackerrank_Python_Domain.png -------------------------------------------------------------------------------- /Hackerrank_Python_Domain_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsho/Hackerrank_Python_Domain_Solutions/502e8e2e00f5d1610be1ed03064366dfd15290e4/Hackerrank_Python_Domain_old.png -------------------------------------------------------------------------------- /Introduction/ArithmeticOperators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Arithmetic Operators 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 April 2020 7 | Problem : https://www.hackerrank.com/challenges/python-arithmetic-operators/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | a = int(input()) 12 | b = int(input()) 13 | print(a + b) 14 | print(a - b) 15 | print(a * b) 16 | -------------------------------------------------------------------------------- /Introduction/Loops.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Loops 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 13 May 2020 7 | Problem : https://www.hackerrank.com/challenges/python-loops/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | n = int(input()) 12 | for i in range(n): 13 | print(i * i) 14 | -------------------------------------------------------------------------------- /Introduction/PrintFunction.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Print Function 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/python-print/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | n = int(input()) 12 | ar = range(1, n + 1) 13 | for i in ar: 14 | print(i, end="") 15 | 16 | """ 17 | Alternate solution: 18 | 19 | if __name__ == '__main__': 20 | n = int(input()) 21 | print("".join([str(i) for i in range(1,n+1)])) 22 | 23 | """ 24 | -------------------------------------------------------------------------------- /Introduction/PythonDivision.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Python: Division 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/python-division/problem 8 | """ 9 | 10 | if __name__ == "__main__": 11 | a = int(input()) 12 | b = int(input()) 13 | print(a // b) 14 | print(a / b) 15 | -------------------------------------------------------------------------------- /Introduction/PythonIfElse.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Python If-Else 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Utkarsh Mishra 6 | Created : 27 Jan 2021 7 | Problem : https://www.hackerrank.com/challenges/py-if-else/problem 8 | """ 9 | 10 | import sys 11 | 12 | n = int(input()) 13 | if n % 2 == 1 or n in range(5, 21): 14 | print("Weird") 15 | else: 16 | print("Not Weird") 17 | -------------------------------------------------------------------------------- /Introduction/SayHelloWorldWithPython.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Say Hello, World! With Python 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 23 July 2018 7 | Problem : https://www.hackerrank.com/challenges/py-hello-world/problem 8 | """ 9 | 10 | print("Hello, World!") 11 | -------------------------------------------------------------------------------- /Introduction/Writeafunction.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Write a function 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 06 July 2020 7 | Problem : https://www.hackerrank.com/challenges/write-a-function/problem 8 | """ 9 | 10 | 11 | def is_leap(year): 12 | leap = False 13 | leap = (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0) 14 | return leap 15 | 16 | 17 | year = int(input()) 18 | print(is_leap(year)) 19 | -------------------------------------------------------------------------------- /Itertools/CompresstheString.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Compress the String! 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/compress-the-string/problem 8 | """ 9 | 10 | import itertools 11 | 12 | s = input().strip() 13 | s_unique_element = list(set(s)) 14 | group = [] 15 | key = [] 16 | for k, g in itertools.groupby(s): 17 | group.append(list(g)) 18 | key.append(k) 19 | for i in range(len(group)): 20 | group_length = len(group[i]) 21 | k = int(key[i]) 22 | print((group_length, k), end=" ") 23 | -------------------------------------------------------------------------------- /Itertools/IterablesandIterators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Iterables and Iterators 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/iterables-and-iterators/problem 8 | """ 9 | 10 | from itertools import combinations 11 | 12 | n = int(input()) 13 | ar = input().split() 14 | k = int(input()) 15 | comb_list = list(combinations(ar, k)) 16 | a_list = [e for e in comb_list if "a" in e] 17 | print(len(a_list) / len(comb_list)) 18 | -------------------------------------------------------------------------------- /Itertools/MaximizeIt.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Maximize It! 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/maximize-it/problem 8 | """ 9 | 10 | import itertools 11 | 12 | k, m = map(int, input().split()) 13 | 14 | main_ar = [] 15 | for _ in range(k): 16 | ar = list(map(int, input().split())) 17 | main_ar.append(ar[1:]) 18 | 19 | all_combination = itertools.product(*main_ar) 20 | result = 0 21 | for single_combination in all_combination: 22 | result = max(sum(x * x for x in single_combination) % m, result) 23 | print(result) 24 | -------------------------------------------------------------------------------- /Itertools/itertoolscombinations.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : itertools.combinations() 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/itertools-combinations/problem 8 | """ 9 | 10 | from itertools import * 11 | 12 | s, n = input().split() 13 | n = int(n) + 1 14 | s = sorted(s) 15 | for i in range(1, n): 16 | for j in combinations(s, i): 17 | print("".join(j)) 18 | -------------------------------------------------------------------------------- /Itertools/itertoolscombinations_with_replacement.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : itertools.combinations_with_replacement() 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/itertools-combinations-with-replacement/problem 8 | """ 9 | 10 | from itertools import * 11 | 12 | s, n = input().split() 13 | n = int(n) 14 | s = sorted(s) 15 | for j in combinations_with_replacement(s, n): 16 | print("".join(j)) 17 | -------------------------------------------------------------------------------- /Itertools/itertoolspermutations.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : itertools.permutations() 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/itertools-permutations/problem 8 | """ 9 | 10 | import itertools 11 | 12 | s, n = list(map(str, input().split(" "))) 13 | s = sorted(s) 14 | for p in list(itertools.permutations(s, int(n))): 15 | print("".join(p)) 16 | -------------------------------------------------------------------------------- /Itertools/itertoolsproduct.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : itertools.product() 3 | Subdomain : Itertools 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/itertools-product/problem 8 | """ 9 | 10 | import itertools 11 | 12 | ar1 = list(map(int, input().split())) 13 | ar2 = list(map(int, input().split())) 14 | cross = list(itertools.product(ar1, ar2)) 15 | for i in cross: 16 | print(i, end=" ") 17 | -------------------------------------------------------------------------------- /Math/FindAngleMBC.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Find Angle MBC 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/find-angle/problem 9 | """ 10 | 11 | import math 12 | 13 | ab = float(input()) 14 | bc = float(input()) 15 | ac = math.sqrt(ab**2 + bc**2) 16 | bm = ac / 2.0 17 | mc = bm 18 | # let, 19 | b = mc 20 | c = bm 21 | a = bc 22 | # where b=c 23 | angel_b_radian = math.acos(a / (2 * b)) 24 | angel_b_degree = int(round((180 * angel_b_radian) / math.pi)) 25 | print(f"{angel_b_degree}°") 26 | -------------------------------------------------------------------------------- /Math/IntegersComeInAllSizes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Integers Come In All Sizes 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-integers-come-in-all-sizes/problem 8 | """ 9 | 10 | # Enter your code here. Read input from STDIN. Print output to STDOUT 11 | a = int(input()) 12 | b = int(input()) 13 | c = int(input()) 14 | d = int(input()) 15 | print(pow(a, b) + pow(c, d)) 16 | -------------------------------------------------------------------------------- /Math/ModDivmod.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Mod Divmod 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-mod-divmod/problem 8 | """ 9 | 10 | # Enter your code here. Read input from STDIN. Print output to STDOUT 11 | a = int(input()) 12 | b = int(input()) 13 | d = divmod(a, b) 14 | print(d[0]) 15 | print(d[1]) 16 | print(d) 17 | -------------------------------------------------------------------------------- /Math/PolarCoordinates.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Polar Coordinates 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/polar-coordinates/problem 8 | """ 9 | 10 | import cmath 11 | 12 | z = complex(input()) 13 | p = cmath.polar(z) 14 | print(p[0]) 15 | print(p[1]) 16 | -------------------------------------------------------------------------------- /Math/PowerModPower.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Power - Mod Power 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-power-mod-power/problem 8 | """ 9 | 10 | # Enter your code here. Read input from STDIN. Print output to STDOUT 11 | a = int(input()) 12 | b = int(input()) 13 | c = int(input()) 14 | print(pow(a, b)) 15 | print(pow(a, b, c)) 16 | -------------------------------------------------------------------------------- /Math/TriangleQuest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Triangle Quest 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/python-quest-1/problem 8 | """ 9 | 10 | for i in range( 11 | 1, input() 12 | ): # More than 2 lines will result in 0 score. Do not leave a blank line also 13 | print(i * ((10**i - 1) // 9)) 14 | -------------------------------------------------------------------------------- /Math/TriangleQuest2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Triangle Quest 2 3 | Subdomain : Math 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/triangle-quest-2/problem 8 | """ 9 | 10 | for i in range( 11 | 1, int(input()) + 1 12 | ): # More than 2 lines will result in 0 score. Do not leave a blank line also 13 | print(((10**i - 1) // 9) ** 2) 14 | -------------------------------------------------------------------------------- /Numpy/ArrayMathematics.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Array Mathematics 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-array-mathematics/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | if __name__ == "__main__": 14 | n, m = map(int, input().split()) 15 | 16 | ar1 = np.array([input().split() for _ in range(n)], int) 17 | ar2 = np.array([input().split() for _ in range(n)], int) 18 | 19 | print(ar1 + ar2) 20 | print(ar1 - ar2) 21 | print(ar1 * ar2) 22 | print(ar1 // ar2) 23 | print(ar1 % ar2) 24 | print(ar1**ar2) 25 | -------------------------------------------------------------------------------- /Numpy/Arrays.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Arrays 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-arrays/problem 9 | """ 10 | 11 | import numpy 12 | 13 | 14 | def arrays(arr): 15 | np_ar = numpy.array(arr, float) 16 | return np_ar[::-1] 17 | 18 | 19 | arr = input().strip().split(" ") 20 | result = arrays(arr) 21 | print(result) 22 | -------------------------------------------------------------------------------- /Numpy/Concatenate.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Concatenate 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-concatenate/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n, m, p = map(int, input().split()) 16 | 17 | arr1 = [] 18 | arr2 = [] 19 | for _ in range(n): 20 | tmp = list(map(int, input().split())) 21 | arr1.append(tmp) 22 | for _ in range(m): 23 | tmp = list(map(int, input().split())) 24 | arr2.append(tmp) 25 | np_arr1 = np.array(arr1) 26 | np_arr2 = np.array(arr2) 27 | print(np.concatenate((np_arr1, np_arr2), axis=0)) 28 | -------------------------------------------------------------------------------- /Numpy/DotandCross.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Dot and Cross 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-dot-and-cross/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | if __name__ == "__main__": 14 | n = int(input()) 15 | 16 | arr1 = np.array([input().split() for _ in range(n)], int) 17 | arr2 = np.array([input().split() for _ in range(n)], int) 18 | 19 | print(np.dot(arr1, arr2)) 20 | -------------------------------------------------------------------------------- /Numpy/EyeandIdentity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Eye and Identity 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-eye-and-identity/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | np.set_printoptions(legacy="1.13") 16 | n, m = map(int, input().split()) 17 | print(np.eye(n, m, k=0)) 18 | -------------------------------------------------------------------------------- /Numpy/FloorCeilandRint.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Floor, Ceil and Rint 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/floor-ceil-and-rint/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | np.set_printoptions(legacy="1.13") 16 | arr = np.array(input().split(), float) 17 | print(np.floor(arr)) 18 | print(np.ceil(arr)) 19 | print(np.rint(arr)) 20 | 21 | # Alternate solution 22 | # print(*(f(A) for f in [np.floor, np.ceil, np.rint]), sep='\n') 23 | -------------------------------------------------------------------------------- /Numpy/InnerandOuter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Inner and Outer 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-inner-and-outer/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | arr1 = np.array(list(map(int, input().split()))) 16 | arr2 = np.array(list(map(int, input().split()))) 17 | 18 | print(np.inner(arr1, arr2)) 19 | print(np.outer(arr1, arr2)) 20 | -------------------------------------------------------------------------------- /Numpy/LinearAlgebra.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Linear Algebra 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-linear-algebra/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | np.set_printoptions(legacy="1.13") 16 | n = int(input()) 17 | array = np.array([input().split() for _ in range(n)], float) 18 | print(np.linalg.det(array)) 19 | -------------------------------------------------------------------------------- /Numpy/MeanVarandStd.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Mean, Var, and Std 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-mean-var-and-std/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n, m = map(int, input().split()) 16 | arr = np.array([input().split() for _ in range(n)], int) 17 | 18 | print(np.mean(arr, axis=1)) 19 | print(np.var(arr, axis=0)) 20 | print(round(np.std(arr, axis=None), 11)) 21 | -------------------------------------------------------------------------------- /Numpy/MinandMax.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Min and Max 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-min-and-max/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n, m = map(int, input().split()) 16 | arr = np.array([input().split() for _ in range(n)], int) 17 | result = np.max(np.min(arr, axis=1)) 18 | print(result) 19 | -------------------------------------------------------------------------------- /Numpy/Polynomials.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Polynomials 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-polynomials/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | p = np.array(list(map(float, input().split())), float) 16 | x = float(input()) 17 | print(np.polyval(p, x)) 18 | -------------------------------------------------------------------------------- /Numpy/ShapeandReshape.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Shape and Reshape 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-shape-reshape/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | array = list(map(int, input().split())) 16 | np_arr = np.array(array) 17 | print(np.reshape(np_arr, (3, 3))) 18 | -------------------------------------------------------------------------------- /Numpy/SumandProd.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Sum and Prod 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-sum-and-prod/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n, m = map(int, input().split()) 16 | 17 | arr = np.array([input().split() for _ in range(n)], int) 18 | 19 | s = np.sum(arr, axis=0) 20 | print(np.prod(s)) 21 | -------------------------------------------------------------------------------- /Numpy/TransposeandFlatten.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Transpose and Flatten 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-transpose-and-flatten/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n, m = map(int, input().split()) 16 | arr = [] 17 | for _ in range(n): 18 | row = list(map(int, input().split())) 19 | arr.append(row) 20 | 21 | np_arr = np.array(arr) 22 | print(np.transpose(np_arr)) 23 | print(np_arr.flatten()) 24 | -------------------------------------------------------------------------------- /Numpy/ZerosandOnes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Zeros and Ones 3 | Subdomain : Numpy 4 | Domain : Python 5 | Author : Md Samshad Rahman 6 | Created : 15 July 2016 7 | Updated : 25 November 2024 8 | Problem : https://www.hackerrank.com/challenges/np-zeros-and-ones/problem 9 | """ 10 | 11 | import numpy as np 12 | 13 | 14 | if __name__ == "__main__": 15 | n_arr = list(map(int, input().split())) 16 | n = tuple(n_arr) 17 | print(np.zeros(n, dtype=np.int32)) 18 | print(np.ones(n, dtype=np.int32)) 19 | -------------------------------------------------------------------------------- /PythonFunctionals/MapandLambdaFunction.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Map and Lambda Function 3 | Subdomain : Python Functionals 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/map-and-lambda-expression/problem 9 | """ 10 | 11 | cube = lambda x: x * x * x 12 | 13 | 14 | def fibonacci(n): 15 | ar = [0, 1] 16 | if n < 2: 17 | return ar[:n] 18 | for i in range(2, n): 19 | ar.append(ar[i - 1] + ar[i - 2]) 20 | return ar 21 | 22 | 23 | if __name__ == "__main__": 24 | n = int(input()) 25 | print(list(map(cube, fibonacci(n)))) 26 | -------------------------------------------------------------------------------- /PythonFunctionals/ReduceFunction.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Reduce Function 3 | Subdomain : Python Functionals 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 24 January 2017 7 | Problem : https://www.hackerrank.com/challenges/reduce-function/problem 8 | """ 9 | 10 | from fractions import Fraction 11 | from functools import reduce 12 | 13 | 14 | def product(fracs): 15 | t = Fraction(reduce(lambda x, y: x * y, fracs)) 16 | return t.numerator, t.denominator 17 | 18 | 19 | if __name__ == "__main__": 20 | fracs = [] 21 | for _ in range(int(input())): 22 | fracs.append(Fraction(*map(int, input().split()))) 23 | result = product(fracs) 24 | print(*result) 25 | 26 | """ 27 | 3 28 | 1 2 29 | 3 4 30 | 10 6 31 | """ 32 | -------------------------------------------------------------------------------- /PythonFunctionals/ValidatingEmailAddressesWithaFilter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating Email Addresses With a Filter 3 | Subdomain : Python Functionals 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/validate-list-of-email-address-with-filter/problem 9 | """ 10 | 11 | import re 12 | 13 | 14 | def fun(s): 15 | return re.search(r"^[\w-]+@[a-zA-Z0-9]+\.[a-zA-Z]{1,3}$", s) 16 | 17 | 18 | def filter_mail(emails): 19 | return list(filter(fun, emails)) 20 | 21 | 22 | if __name__ == "__main__": 23 | n = int(input()) 24 | emails = [] 25 | for _ in range(n): 26 | emails.append(input()) 27 | 28 | filtered_emails = filter_mail(emails) 29 | filtered_emails.sort() 30 | print(filtered_emails) 31 | -------------------------------------------------------------------------------- /RegexandParsing/DetectFloatingPointNumbers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Detect Floating Point Numbers 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Atharva Shah 6 | Created : 3 April 2021 7 | Problem : https://www.hackerrank.com/challenges/introduction-to-regex/problem 8 | """ 9 | 10 | from re import compile, match 11 | 12 | pattern = compile("^[-+]?\d*\.\d+$") 13 | for _ in range(int(input())): 14 | print(bool(pattern.match(input()))) 15 | -------------------------------------------------------------------------------- /RegexandParsing/DetectHTMLTagsAttributesandAttributeValues.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Detect HTML Tags, Attributes and Attribute Values 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/detect-html-tags-attributes-and-attribute-values/problem 8 | """ 9 | 10 | from html.parser import HTMLParser 11 | 12 | 13 | class CustomHTMLParser(HTMLParser): 14 | def handle_starttag(self, tag, attrs): 15 | print(tag) 16 | self.handle_attrs(attrs) 17 | 18 | def handle_startendtag(self, tag, attrs): 19 | print(tag) 20 | self.handle_attrs(attrs) 21 | 22 | def handle_attrs(self, attrs): 23 | for attrs_pair in attrs: 24 | print("->", attrs_pair[0].strip(), ">", attrs_pair[1].strip()) 25 | 26 | 27 | n = int(input()) 28 | html_string = "".join(input() for _ in range(n)) 29 | customHTMLParser = CustomHTMLParser() 30 | customHTMLParser.feed(html_string) 31 | customHTMLParser.close() 32 | -------------------------------------------------------------------------------- /RegexandParsing/GroupGroupsampGroupdict.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Group(), Groups() & Groupdict() 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/re-group-groups/problem 8 | """ 9 | 10 | import re 11 | 12 | s = input() 13 | res = re.search(r"([A-Za-z0-9])\1", s) 14 | if res is None: 15 | print(-1) 16 | else: 17 | print(res[1]) 18 | -------------------------------------------------------------------------------- /RegexandParsing/HTMLParserPart1.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : HTML Parser - Part 1 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/html-parser-part-1/problem 8 | """ 9 | 10 | from html.parser import HTMLParser 11 | 12 | 13 | class CustomHTMLParser(HTMLParser): 14 | def handle_attr(self, attrs): 15 | for attr_val_tuple in attrs: 16 | print("->", attr_val_tuple[0], ">", attr_val_tuple[1]) 17 | 18 | def handle_starttag(self, tag, attrs): 19 | print("Start :", tag) 20 | self.handle_attr(attrs) 21 | 22 | def handle_endtag(self, tag): 23 | print("End :", tag) 24 | 25 | def handle_startendtag(self, tag, attrs): 26 | print("Empty :", tag) 27 | self.handle_attr(attrs) 28 | 29 | 30 | parser = CustomHTMLParser() 31 | 32 | n = int(input()) 33 | 34 | s = "".join(input() for _ in range(n)) 35 | parser.feed(s) 36 | 37 | """ 38 | 2 39 | HTML Parser - I 40 |

HackerRank


41 | """ 42 | -------------------------------------------------------------------------------- /RegexandParsing/HTMLParserPart2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : HTML Parser - Part 2 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/html-parser-part-2/problem 8 | """ 9 | 10 | from html.parser import HTMLParser 11 | 12 | 13 | class CustomHTMLParser(HTMLParser): 14 | def handle_comment(self, data): 15 | number_of_line = len(data.split("\n")) 16 | if number_of_line > 1: 17 | print(">>> Multi-line Comment") 18 | else: 19 | print(">>> Single-line Comment") 20 | if data.strip(): 21 | print(data) 22 | 23 | def handle_data(self, data): 24 | if data.strip(): 25 | print(">>> Data") 26 | print(data) 27 | 28 | 29 | parser = CustomHTMLParser() 30 | 31 | n = int(input()) 32 | 33 | html_string = "".join(input().rstrip() + "\n" for _ in range(n)) 34 | parser.feed(html_string) 35 | parser.close() 36 | -------------------------------------------------------------------------------- /RegexandParsing/HexColorCode.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Hex Color Code 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/hex-color-code/problem 8 | """ 9 | 10 | import re 11 | 12 | n = int(input()) 13 | for _ in range(n): 14 | s = input() 15 | match_result = re.findall(r"(#[0-9A-Fa-f]{3}|#[0-9A-Fa-f]{6})(?:[;,.)]{1})", s) 16 | for i in match_result: 17 | if i != "": 18 | print(i) 19 | -------------------------------------------------------------------------------- /RegexandParsing/MatrixScript.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Matrix Script 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/matrix-script/problem 8 | """ 9 | 10 | import re 11 | 12 | n, m = map(int, input().split()) 13 | character_ar = [""] * (n * m) 14 | for i in range(n): 15 | line = input() 16 | for j in range(m): 17 | character_ar[i + (j * n)] = line[j] 18 | decoded_str = "".join(character_ar) 19 | final_decoded_str = re.sub( 20 | r"(?<=[A-Za-z0-9])([ !@#$%&]+)(?=[A-Za-z0-9])", " ", decoded_str 21 | ) 22 | print(final_decoded_str) 23 | -------------------------------------------------------------------------------- /RegexandParsing/RefindallampRefinditer.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Re.findall() & Re.finditer() 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/re-findall-re-finditer/problem 8 | """ 9 | 10 | import re 11 | 12 | s = input() 13 | result = re.findall( 14 | r"(?<=[QWRTYPSDFGHJKLZXCVBNMqwrtypsdfghjklzxcvbnm])([AEIOUaeiou]{2,})(?=[QWRTYPSDFGHJKLZXCVBNMqwrtypsdfghjklzxcvbnm])", 15 | s, 16 | ) 17 | if result: 18 | for i in result: 19 | print(i) 20 | else: 21 | print(-1) 22 | -------------------------------------------------------------------------------- /RegexandParsing/RegexSubstitution.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Regex Substitution 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/re-sub-regex-substitution/problem 8 | """ 9 | 10 | import re 11 | import sys 12 | 13 | n = int(input()) 14 | for line in sys.stdin: 15 | remove_and = re.sub(r"(?<= )(&&)(?= )", "and", line) 16 | remove_or = re.sub(r"(?<= )(\|\|)(?= )", "or", remove_and) 17 | print(remove_or, end="") 18 | -------------------------------------------------------------------------------- /RegexandParsing/Resplit.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Re.split() 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 3 April 2021 8 | Problem : https://www.hackerrank.com/challenges/re-split/problem 9 | """ 10 | 11 | import re 12 | 13 | regex_pattern = r"[.,]+" 14 | 15 | print("\n".join(re.split(regex_pattern, input()))) 16 | -------------------------------------------------------------------------------- /RegexandParsing/RestartampReend.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Re.start() & Re.end() 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/re-start-re-end/problem 8 | """ 9 | 10 | import re 11 | 12 | s = input().strip() 13 | k = input().strip() 14 | s_len = len(s) 15 | found_flag = False 16 | for i in range(s_len): 17 | match_result = re.match(k, s[i:]) 18 | if match_result: 19 | start_index = i + match_result.start() 20 | end_index = i + match_result.end() - 1 21 | print((start_index, end_index)) 22 | found_flag = True 23 | if found_flag == False: 24 | print("(-1, -1)") 25 | -------------------------------------------------------------------------------- /RegexandParsing/ValidatingCreditCardNumbers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating Credit Card Numbers 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/validating-credit-card-number/problem 8 | """ 9 | 10 | import re 11 | 12 | n = int(input()) 13 | for _ in range(n): 14 | credit = input().strip() 15 | credit_removed_hiphen = credit.replace("-", "") 16 | valid = True 17 | length_16 = bool(re.match(r"^[4-6]\d{15}$", credit)) 18 | length_19 = bool(re.match(r"^[4-6]\d{3}-\d{4}-\d{4}-\d{4}$", credit)) 19 | consecutive = bool(re.findall(r"(?=(\d)\1\1\1)", credit_removed_hiphen)) 20 | if length_16 == True or length_19 == True: 21 | if consecutive == True: 22 | valid = False 23 | else: 24 | valid = False 25 | if valid: 26 | print("Valid") 27 | else: 28 | print("Invalid") 29 | -------------------------------------------------------------------------------- /RegexandParsing/ValidatingPostalCodes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating Postal Codes 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/validating-postalcode/problem 8 | """ 9 | 10 | import re 11 | 12 | p = input().strip() 13 | range_check = bool(re.match(r"^[1-9][0-9]{5}$", p)) 14 | repeat_check = len(re.findall(r"(?=([0-9])[0-9]\1)", p)) 15 | print(range_check == True and repeat_check < 2) 16 | -------------------------------------------------------------------------------- /RegexandParsing/ValidatingRomanNumerals.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating Roman Numerals 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 3 April 2021 8 | Problem : https://www.hackerrank.com/challenges/validate-a-roman-number/problem 9 | """ 10 | 11 | import re 12 | 13 | regex_pattern = r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$" 14 | print(bool(re.match(regex_pattern, input()))) 15 | -------------------------------------------------------------------------------- /RegexandParsing/ValidatingUID.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating UID 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/validating-uid/problem 8 | """ 9 | 10 | import re 11 | 12 | n = int(input()) 13 | upper_check = r".*([A-Z].*){2,}" 14 | digit_check = r".*([0-9].*){3,}" 15 | alphanumeric_and_length_check = r"([A-Za-z0-9]){10}$" 16 | repeat_check = r".*(.).*\1" 17 | for _ in range(n): 18 | uid_string = input().strip() 19 | upper_check_result = bool(re.match(upper_check, uid_string)) 20 | digit_check_result = bool(re.match(digit_check, uid_string)) 21 | alphanumeric_and_length_check_result = bool( 22 | re.match(alphanumeric_and_length_check, uid_string) 23 | ) 24 | repeat_check_result = bool(re.match(repeat_check, uid_string)) 25 | if ( 26 | upper_check_result 27 | and digit_check_result 28 | and alphanumeric_and_length_check_result 29 | and not repeat_check_result 30 | ): 31 | print("Valid") 32 | else: 33 | print("Invalid") 34 | -------------------------------------------------------------------------------- /RegexandParsing/ValidatingandParsingEmailAddresses.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating and Parsing Email Addresses 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/validating-named-email-addresses/problem 8 | """ 9 | 10 | import email.utils 11 | import re 12 | 13 | n = int(input()) 14 | for _ in range(n): 15 | s = input() 16 | parsed_email = email.utils.parseaddr(s)[1].strip() 17 | match_result = bool( 18 | re.match( 19 | r"(^[A-Za-z][A-Za-z0-9\._-]+)@([A-Za-z]+)\.([A-Za-z]{1,3})$", parsed_email 20 | ) 21 | ) 22 | if match_result: 23 | print(s) 24 | -------------------------------------------------------------------------------- /RegexandParsing/Validatingphonenumbers.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Validating phone numbers 3 | Subdomain : Regex and Parsing 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 3 April 2021 8 | Problem : https://www.hackerrank.com/challenges/validating-the-phone-number/problem 9 | """ 10 | 11 | from re import compile, match 12 | 13 | n = int(input()) 14 | for _ in range(n): 15 | phone_number = input() 16 | condition = compile(r"^[7-9]\d{9}$") 17 | if bool(match(condition, phone_number)): 18 | print("YES") 19 | else: 20 | print("NO") 21 | -------------------------------------------------------------------------------- /Sets/CheckStrictSuperset.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Check Strict Superset 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-check-strict-superset/problem 9 | """ 10 | 11 | first_set = set(map(int, input().split())) 12 | number_of_other_sets = int(input()) 13 | is_strict_superset = True 14 | for _ in range(number_of_other_sets): 15 | other_set = set(map(int, input().split())) 16 | if not first_set.issuperset(other_set): 17 | is_strict_superset = False 18 | print(is_strict_superset) 19 | -------------------------------------------------------------------------------- /Sets/CheckSubset.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Check Subset 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-check-subset/problem 9 | """ 10 | 11 | number_of_testcases = int(input()) 12 | for _ in range(number_of_testcases): 13 | number_of_elements_first_set = int(input()) 14 | first_set = set(map(int, input().split())) 15 | number_of_elements_second_set = int(input()) 16 | second_set = set(map(int, input().split())) 17 | print(first_set.issubset(second_set)) 18 | -------------------------------------------------------------------------------- /Sets/IntroductiontoSets.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Introduction to Sets 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-introduction-to-sets/problem 9 | """ 10 | 11 | import statistics 12 | 13 | 14 | def average(array): 15 | distinct_heights = set(array) 16 | avg_heights = sum(distinct_heights) / len(distinct_heights) 17 | # It can also be solved using built-in function from statistics module 18 | # Uncomment the following line to use builtin function 19 | # avg_heights = statistics.mean(distinct_heights) 20 | return round(avg_heights, 3) 21 | 22 | 23 | if __name__ == "__main__": 24 | n = int(input()) 25 | arr = list(map(int, input().split())) 26 | result = average(arr) 27 | print(result) 28 | -------------------------------------------------------------------------------- /Sets/NoIdea.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : No Idea! 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/no-idea/problem 9 | """ 10 | 11 | from collections import Counter 12 | 13 | n, m = map(int, input().split()) 14 | data = list(map(int, input().split())) 15 | data_counter = Counter(data) 16 | data_set = set(data) 17 | set_a = set(map(int, input().split())) 18 | set_b = set(map(int, input().split())) 19 | happiness = 0 20 | for i in data_set & set_a: 21 | happiness += data_counter[i] 22 | for i in data_set & set_b: 23 | happiness -= data_counter[i] 24 | print(happiness) 25 | -------------------------------------------------------------------------------- /Sets/SetMutations.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set Mutations 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-set-mutations/problem 9 | """ 10 | 11 | number_of_elements = int(input()) 12 | initial_set = set(map(int, input().split())) 13 | number_of_other_sets = int(input()) 14 | for _ in range(number_of_other_sets): 15 | cmd = input().split() 16 | opt = cmd[0] 17 | other_set = set(map(int, input().split())) 18 | if opt == "difference_update": 19 | initial_set.difference_update(other_set) 20 | elif opt == "intersection_update": 21 | initial_set.intersection_update(other_set) 22 | elif opt == "symmetric_difference_update": 23 | initial_set.symmetric_difference_update(other_set) 24 | elif opt == "update": 25 | initial_set.update(other_set) 26 | print(sum(initial_set)) 27 | -------------------------------------------------------------------------------- /Sets/Setadd.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .add() 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | problem : https://www.hackerrank.com/challenges/py-set-add/problem 9 | """ 10 | 11 | n = int(input()) 12 | country_set = set() 13 | for _ in range(n): 14 | country_name = input() 15 | country_set.add(country_name) 16 | print(len(country_set)) 17 | -------------------------------------------------------------------------------- /Sets/SetdifferenceOperation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .difference() Operation 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-set-difference-operation/problem 9 | """ 10 | 11 | number_of_english_subscribers = input() 12 | english_subscribers = set(map(int, input().split())) 13 | number_of_french_subscribers = input() 14 | french_subscribers = set(map(int, input().split())) 15 | print(len(english_subscribers.difference(french_subscribers))) 16 | # Alternative solution 17 | # print(len(english_subscribers - french_subscribers)) 18 | -------------------------------------------------------------------------------- /Sets/Setdiscardremoveamppop.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .discard(), .remove() & .pop() 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/py-set-discard-remove-pop/problem 8 | """ 9 | 10 | number_of_elements = int(input()) 11 | elements = set(map(int, input().split())) 12 | number_of_commands = int(input()) 13 | for _ in range(number_of_commands): 14 | cmd = list(input().split()) 15 | if len(cmd) == 1: 16 | elements.pop() 17 | else: 18 | value = int(cmd[1]) 19 | operation = cmd[0] 20 | if operation == "discard": 21 | elements.discard(value) 22 | else: 23 | elements.remove(value) 24 | print(sum(elements)) 25 | -------------------------------------------------------------------------------- /Sets/SetintersectionOperation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .intersection() Operation 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-set-intersection-operation/problem 9 | """ 10 | 11 | number_of_english_subscribers = input() 12 | english_subscribers = set(map(int, input().split())) 13 | number_of_french_subscribers = input() 14 | french_subscribers = set(map(int, input().split())) 15 | print(len(english_subscribers.intersection(french_subscribers))) 16 | # Alternative solution 17 | # print(len(english_subscribers & french_subscribers)) 18 | -------------------------------------------------------------------------------- /Sets/Setsymmetric_differenceOperation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .symmetric_difference() Operation 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-set-symmetric-difference-operation/problem 9 | """ 10 | 11 | number_of_english_subscribers = input() 12 | english_subscribers = set(map(int, input().split())) 13 | number_of_french_subscribers = input() 14 | french_subscribers = set(map(int, input().split())) 15 | print(len(english_subscribers.symmetric_difference(french_subscribers))) 16 | # Alternative solution 17 | # print(len(english_subscribers ^ french_subscribers)) 18 | -------------------------------------------------------------------------------- /Sets/SetunionOperation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Set .union() Operation 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 19 June 2022 8 | Problem : https://www.hackerrank.com/challenges/py-set-union/problem 9 | """ 10 | 11 | number_of_english_subscribers = input() 12 | english_subscribers = set(map(int, input().split())) 13 | number_of_french_subscribers = input() 14 | french_subscribers = set(map(int, input().split())) 15 | print(len(english_subscribers.union(french_subscribers))) 16 | -------------------------------------------------------------------------------- /Sets/SymmetricDifference.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Symmetric Difference 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 15 March 2021 8 | Updated : 19 June 2022 9 | Problem : https://www.hackerrank.com/challenges/symmetric-difference/problem 10 | """ 11 | 12 | m = int(input()) 13 | set_a = set(map(int, input().split())) 14 | n = int(input()) 15 | set_b = set(map(int, input().split())) 16 | set_a_diff = set_a.difference(set_b) 17 | set_b_diff = set_b.difference(set_a) 18 | for i in sorted(set_a_diff.union(set_b_diff)): 19 | print(i) 20 | -------------------------------------------------------------------------------- /Sets/TheCaptainsRoom.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : The Captains Room 3 | Subdomain : Sets 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/py-the-captains-room/problem 8 | """ 9 | 10 | k = int(input()) 11 | room_number_list = list(map(int, input().split())) 12 | room_number_set = set(room_number_list) 13 | room_number_list_sum = sum(room_number_list) 14 | room_number_set_sum = sum(room_number_set) * k 15 | diff = room_number_set_sum - room_number_list_sum 16 | for i in room_number_set: 17 | if diff == ((k - 1) * i): 18 | print(i) 19 | break 20 | -------------------------------------------------------------------------------- /Strings/AlphabetRangoli.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Alphabet Rangoli 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/alphabet-rangoli/problem 8 | """ 9 | 10 | n = int(input().strip()) 11 | w = (n - 1) * 2 + ((n * 2) - 1) 12 | # upper half 13 | for i in range(1, n): 14 | number_of_letter = (i * 2) - 1 15 | s = "" 16 | letter_value = 97 + n - 1 17 | for i in range(number_of_letter): 18 | if i != 0: 19 | s += "-" 20 | s += chr(letter_value) 21 | if i < (number_of_letter - 1) / 2: 22 | letter_value = letter_value - 1 23 | else: 24 | letter_value = letter_value + 1 25 | print(s.center(w, "-")) 26 | 27 | 28 | # bottom half 29 | for i in range(n, 0, -1): 30 | number_of_letter = (i * 2) - 1 31 | s = "" 32 | letter_value = 97 + n - 1 33 | for i in range(number_of_letter): 34 | if i != 0: 35 | s += "-" 36 | s += chr(letter_value) 37 | if i < (number_of_letter - 1) / 2: 38 | letter_value = letter_value - 1 39 | else: 40 | letter_value = letter_value + 1 41 | print(s.center(w, "-")) 42 | -------------------------------------------------------------------------------- /Strings/Capitalize.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Capitalize! 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/capitalize/problem 8 | """ 9 | 10 | s = input() 11 | s_ar = s.split(" ") 12 | final_ar = [] 13 | space = " " 14 | for w in s_ar: 15 | final_ar.append(w.capitalize()) 16 | print(space.join(final_ar)) 17 | -------------------------------------------------------------------------------- /Strings/DesignerDoorMat.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Designer Door Mat 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/designer-door-mat/problem 8 | """ 9 | 10 | N, M = map(int, input().split()) 11 | for i in range(1, N, 2): 12 | print(int((M - 3 * i) / 2) * "-" + (i * ".|.") + int((M - 3 * i) / 2) * "-") 13 | print(int((M - 7) / 2) * "-" + "WELCOME" + int((M - 7) / 2) * "-") 14 | for i in range(N - 2, -1, -2): 15 | print(int((M - 3 * i) / 2) * "-" + (i * ".|.") + int((M - 3 * i) / 2) * "-") 16 | -------------------------------------------------------------------------------- /Strings/Findastring.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Find a string 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/find-a-string/problem 9 | """ 10 | 11 | 12 | def count_substring(string, sub_string): 13 | count_sub_string = 0 14 | for i in range(len(string) - len(sub_string) + 1): 15 | if string[i : i + len(sub_string)] == sub_string: 16 | count_sub_string += 1 17 | return count_sub_string 18 | 19 | 20 | if __name__ == "__main__": 21 | string = input().strip() 22 | sub_string = input().strip() 23 | 24 | count = count_substring(string, sub_string) 25 | print(count) 26 | -------------------------------------------------------------------------------- /Strings/MergeTools: -------------------------------------------------------------------------------- 1 | ''' 2 | Title : Merge The Tools! 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Atharva Shah 6 | Created : 15 March 2021 7 | Problem : https://www.hackerrank.com/challenges/merge-the-tools/ 8 | ''' 9 | from collections import OrderedDict 10 | 11 | def merge_the_tools(string, k): 12 | for i in range(0, len(string)-k+1, k): 13 | print(''.join(OrderedDict.fromkeys(string[i:i + k]))) 14 | 15 | if __name__ == '__main__': 16 | string, k = input(), int(input()) 17 | merge_the_tools(string, k) 18 | -------------------------------------------------------------------------------- /Strings/Mutations.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Mutations 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 July 2020 8 | Problem : https://www.hackerrank.com/challenges/python-mutations/problem 9 | """ 10 | 11 | 12 | def mutate_string(string, position, character): 13 | chars = list(string) 14 | chars[position] = character 15 | return "".join(chars) 16 | 17 | 18 | if __name__ == "__main__": 19 | s = input() 20 | i, c = input().split() 21 | s_new = mutate_string(s, int(i), c) 22 | print(s_new) 23 | -------------------------------------------------------------------------------- /Strings/StringFormatting.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : String Formatting 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/python-string-formatting/problem 9 | """ 10 | 11 | 12 | def print_formatted(number): 13 | width = len(bin(number)[2:]) 14 | for i in range(1, number + 1): 15 | o = oct(i)[2:] 16 | h = hex(i)[2:] 17 | h = h.upper() 18 | b = bin(i)[2:] 19 | d = str(i) 20 | print(f"{d:>{width}} {o:>{width}} {h:>{width}} {b:>{width}}") 21 | 22 | 23 | if __name__ == "__main__": 24 | n = int(input()) 25 | print_formatted(n) 26 | -------------------------------------------------------------------------------- /Strings/StringSplitandJoin.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : String Split and Join 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 08 July 2020 7 | Problem : https://www.hackerrank.com/challenges/python-string-split-and-join/problem 8 | """ 9 | 10 | 11 | def split_and_join(sentence): 12 | return "-".join(sentence.split()) 13 | 14 | 15 | if __name__ == "__main__": 16 | line = input() 17 | result = split_and_join(line) 18 | print(result) 19 | -------------------------------------------------------------------------------- /Strings/StringValidators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : String Validators 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 July 2020 8 | Problem : https://www.hackerrank.com/challenges/string-validators/problem 9 | """ 10 | 11 | if __name__ == "__main__": 12 | s = input() 13 | flag_alnum = False 14 | flag_alpha = False 15 | flag_digit = False 16 | flag_lower = False 17 | flag_upper = False 18 | for i in s: 19 | if i.isalnum(): 20 | flag_alnum = True 21 | if i.isalpha(): 22 | flag_alpha = True 23 | if i.isdigit(): 24 | flag_digit = True 25 | if i.islower(): 26 | flag_lower = True 27 | if i.isupper(): 28 | flag_upper = True 29 | 30 | print(flag_alnum) 31 | print(flag_alpha) 32 | print(flag_digit) 33 | print(flag_lower) 34 | print(flag_upper) 35 | -------------------------------------------------------------------------------- /Strings/TextAlignment.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Text Alignment 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 July 2020 8 | Problem : https://www.hackerrank.com/challenges/text-alignment/problem 9 | """ 10 | 11 | thickness = int(input()) 12 | c = "H" 13 | 14 | # Top Cone 15 | for i in range(thickness): 16 | print((c * i).rjust(thickness - 1) + c + (c * i).ljust(thickness - 1)) 17 | 18 | # Top Pillars 19 | for i in range(thickness + 1): 20 | print((c * thickness).center(thickness * 2) + (c * thickness).center(thickness * 6)) 21 | 22 | # Middle Belt 23 | for i in range((thickness + 1) // 2): 24 | print((c * thickness * 5).center(thickness * 6)) 25 | 26 | # Bottom Pillars 27 | for i in range(thickness + 1): 28 | print((c * thickness).center(thickness * 2) + (c * thickness).center(thickness * 6)) 29 | 30 | # Bottom Cone 31 | for i in range(thickness): 32 | print( 33 | ( 34 | (c * (thickness - i - 1)).rjust(thickness) 35 | + c 36 | + (c * (thickness - i - 1)).ljust(thickness) 37 | ).rjust(thickness * 6) 38 | ) 39 | -------------------------------------------------------------------------------- /Strings/TextWrap.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Text Wrap 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 July 2020 8 | Problem : https://www.hackerrank.com/challenges/text-wrap/problem 9 | """ 10 | 11 | import textwrap 12 | 13 | 14 | def wrap(string, max_width): 15 | return textwrap.fill(string, max_width) 16 | 17 | 18 | if __name__ == "__main__": 19 | string, max_width = input(), int(input()) 20 | result = wrap(string, max_width) 21 | print(result) 22 | -------------------------------------------------------------------------------- /Strings/TheMinionGame.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : The Minion Game 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/the-minion-game/problem 8 | """ 9 | 10 | s = input().strip() 11 | s_length = len(s) 12 | vowel_list = ["A", "E", "I", "O", "U"] 13 | stuart_point = 0 14 | kevin_point = 0 15 | for i in range(s_length): 16 | if s[i] in vowel_list: 17 | kevin_point += s_length - i 18 | else: 19 | stuart_point += s_length - i 20 | if stuart_point == kevin_point: 21 | print("Draw") 22 | elif kevin_point > stuart_point: 23 | print("Kevin", kevin_point) 24 | else: 25 | print("Stuart", stuart_point) 26 | -------------------------------------------------------------------------------- /Strings/WhatsYourName.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : Whats Your Name? 3 | Subdomain : Introduction 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Problem : https://www.hackerrank.com/challenges/whats-your-name/problem 8 | """ 9 | 10 | 11 | def print_full_name(a, b): 12 | print(f"Hello {a} {b}! You just delved into python.") 13 | 14 | 15 | if __name__ == "__main__": 16 | first_name = input() 17 | last_name = input() 18 | print_full_name(first_name, last_name) 19 | -------------------------------------------------------------------------------- /Strings/sWAPcASE.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : sWAP cASE 3 | Subdomain : Strings 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 16 July 2016 7 | Updated : 08 July 2020 8 | Problem : https://www.hackerrank.com/challenges/swap-case/problem 9 | """ 10 | 11 | 12 | def swap_case(sentence): 13 | updated_s = "" 14 | for c in sentence: 15 | if c.isupper(): 16 | updated_s += c.lower() 17 | elif c.islower(): 18 | updated_s += c.upper() 19 | else: 20 | updated_s += c 21 | return updated_s 22 | 23 | 24 | if __name__ == "__main__": 25 | s = input() 26 | result = swap_case(s) 27 | print(result) 28 | -------------------------------------------------------------------------------- /XML/XML1FindtheScore.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : XML 1 - Find the Score 3 | Subdomain : XML 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/xml-1-find-the-score/problem 9 | """ 10 | 11 | import sys 12 | import xml.etree.ElementTree as etree 13 | 14 | 15 | def get_attr_number(node): 16 | total = len(node.attrib.keys()) 17 | for child in node: 18 | if child: 19 | total += get_attr_number(child) 20 | else: 21 | total += len(child.attrib.keys()) 22 | return total 23 | 24 | 25 | if __name__ == "__main__": 26 | sys.stdin.readline() 27 | xml = sys.stdin.read() 28 | tree = etree.ElementTree(etree.fromstring(xml)) 29 | root = tree.getroot() 30 | print(get_attr_number(root)) 31 | -------------------------------------------------------------------------------- /XML/XML2FindtheMaximumDepth.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title : XML2 - Find the Maximum Depth 3 | Subdomain : XML 4 | Domain : Python 5 | Author : Ahmedur Rahman Shovon 6 | Created : 15 July 2016 7 | Updated : 08 February 2023 8 | Problem : https://www.hackerrank.com/challenges/xml2-find-the-maximum-depth/problem 9 | """ 10 | 11 | import xml.etree.ElementTree as etree 12 | 13 | maxdepth = 0 14 | 15 | 16 | def depth(elem, level): 17 | global maxdepth 18 | level = level + 1 19 | maxdepth = max(maxdepth, level) 20 | for child in elem: 21 | depth(child, level) 22 | 23 | 24 | if __name__ == "__main__": 25 | n = int(input()) 26 | xml = "" 27 | for i in range(n): 28 | xml = xml + input() + "\n" 29 | tree = etree.ElementTree(etree.fromstring(xml)) 30 | depth(tree.getroot(), -1) 31 | print(maxdepth) 32 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Hackerrank Python Domain Solutions 2 | 3 | - Solutions of **Hackerrank Python Domain** challenges. The codes may give a head start if you are stuck somewhere! 4 | - If you have better code (I like readable code rather than short liner), send pull request. 5 | - Challenges can be found in [https://www.hackerrank.com/domains/python](https://www.hackerrank.com/domains/python). 6 | - Bonus: I have created [Hackerrank_Solution_Blank_File_Creator.py](HackerrankUtility/Hackerrank_Solution_Blank_File_Creator.py) to generate the blank file for each challenges. Have a look in [HackerrankUtility](HackerrankUtility) folder. 7 | 8 |
9 | 10 | ### Hackerrank Python Domain 11 | 12 | ![alt Hackerrank Python Domain](https://raw.githubusercontent.com/arsho/Hackerrank_Python_Domain_Solutions/master/Hackerrank_Python_Domain.png) 13 | 14 | ### Solutions listed in Hackerrank_Python_Domain_Solutions 15 | 16 | 17 | - Introduction 18 | - [Say Hello, World! With Python](Introduction/SayHelloWorldWithPython.py) 19 | - [Python If-Else](Introduction/PythonIfElse.py) 20 | - [Arithmetic Operators](Introduction/ArithmeticOperators.py) 21 | - [Python: Division](Introduction/PythonDivision.py) 22 | - [Loops](Introduction/Loops.py) 23 | - [Write a function](Introduction/Writeafunction.py) 24 | - [Print Function](Introduction/PrintFunction.py) 25 | - Basic Data Types 26 | - [Lists](BasicDataTypes/Lists.py) 27 | - [Tuples](BasicDataTypes/Tuples.py) 28 | - [List Comprehensions](BasicDataTypes/ListComprehensions.py) 29 | - [Find the Runner-Up Score!](BasicDataTypes/FindtheSecondLargestNumber.py) 30 | - [Nested Lists](BasicDataTypes/NestedLists.py) 31 | - [Finding the percentage](BasicDataTypes/Findingthepercentage.py) 32 | - Strings 33 | - [sWAP cASE](Strings/sWAPcASE.py) 34 | - [String Split and Join](Strings/StringSplitandJoin.py) 35 | - [Whats Your Name?](Strings/WhatsYourName.py) 36 | - [Mutations](Strings/Mutations.py) 37 | - [Find a string](Strings/Findastring.py) 38 | - [String Validators](Strings/StringValidators.py) 39 | - [Text Alignment](Strings/TextAlignment.py) 40 | - [Text Wrap](Strings/TextWrap.py) 41 | - [Designer Door Mat](Strings/DesignerDoorMat.py) 42 | - [String Formatting](Strings/StringFormatting.py) 43 | - [Alphabet Rangoli](Strings/AlphabetRangoli.py) 44 | - [Capitalize!](Strings/Capitalize.py) 45 | - [The Minion Game](Strings/TheMinionGame.py) 46 | - Sets 47 | - [Introduction to Sets](Sets/IntroductiontoSets.py) 48 | - [Symmetric Difference](Sets/SymmetricDifference.py) 49 | - [No Idea!](Sets/NoIdea.py) 50 | - [Set .add()](Sets/Setadd.py) 51 | - [Set .discard(), .remove() & .pop()](Sets/Setdiscardremoveamppop.py) 52 | - [Set .union() Operation](Sets/SetunionOperation.py) 53 | - [Set .intersection() Operation](Sets/SetintersectionOperation.py) 54 | - [Set .difference() Operation](Sets/SetdifferenceOperation.py) 55 | - [Set .symmetric_difference() Operation](Sets/Setsymmetric_differenceOperation.py) 56 | - [Set Mutations](Sets/SetMutations.py) 57 | - [The Captains Room](Sets/TheCaptainsRoom.py) 58 | - [Check Subset](Sets/CheckSubset.py) 59 | - [Check Strict Superset](Sets/CheckStrictSuperset.py) 60 | - Math 61 | - [Polar Coordinates](Math/PolarCoordinates.py) 62 | - [Find Angle MBC](Math/FindAngleMBC.py) 63 | - [Triangle Quest 2](Math/TriangleQuest2.py) 64 | - [Mod Divmod](Math/ModDivmod.py) 65 | - [Power - Mod Power](Math/PowerModPower.py) 66 | - [Integers Come In All Sizes](Math/IntegersComeInAllSizes.py) 67 | - [Triangle Quest](Math/TriangleQuest.py) 68 | - Itertools 69 | - [itertools.product()](Itertools/itertoolsproduct.py) 70 | - [itertools.permutations()](Itertools/itertoolspermutations.py) 71 | - [itertools.combinations()](Itertools/itertoolscombinations.py) 72 | - [itertools.combinations_with_replacement()](Itertools/itertoolscombinations_with_replacement.py) 73 | - [Compress the String!](Itertools/CompresstheString.py) 74 | - [Iterables and Iterators](Itertools/IterablesandIterators.py) 75 | - [Maximize It!](Itertools/MaximizeIt.py) 76 | - Collections 77 | - [collections.Counter()](Collections/collectionsCounter.py) 78 | - [DefaultDict Tutorial](Collections/DefaultDictTutorial.py) 79 | - [Collections.namedtuple()](Collections/Collectionsnamedtuple.py) 80 | - [Collections.OrderedDict()](Collections/CollectionsOrderedDict.py) 81 | - [Word Order](Collections/WordOrder.py) 82 | - [Collections.deque()](Collections/Collectionsdeque.py) 83 | - [Piling Up!](Collections/PilingUp.py) 84 | - [Most Common](Collections/MostCommon.py) 85 | - Date and Time 86 | - [Calendar Module](DateandTime/CalendarModule.py) 87 | - [Time Delta](DateandTime/TimeDelta.py) 88 | - Errors and Exceptions 89 | - [Exceptions](ErrorsandExceptions/Exceptions.py) 90 | - [Incorrect Regex](ErrorsandExceptions/IncorrectRegex.py) 91 | - Classes 92 | - [Classes: Dealing with Complex Numbers](Classes/ClassesDealingwithComplexNumbers.py) 93 | - [Class 2 - Find the Torsional Angle](Classes/Class2FindtheTorsionalAngle.py) 94 | - Built-Ins 95 | - [Zipped!](BuiltIns/Zipped.py) 96 | - [Input()](BuiltIns/Input.py) 97 | - [Python Evaluation](BuiltIns/PythonEvaluation.py) 98 | - [Athlete Sort](BuiltIns/AthleteSort.py) 99 | - [Any or All](BuiltIns/AnyorAll.py) 100 | - [ginortS](BuiltIns/ginortS.py) 101 | - Python Functionals 102 | - [Map and Lambda Function](PythonFunctionals/MapandLambdaFunction.py) 103 | - [Validating Email Addresses With a Filter](PythonFunctionals/ValidatingEmailAddressesWithaFilter.py) 104 | - Regex and Parsing 105 | - [Detect Floating Point Numbers](RegexandParsing/DetectFloatingPointNumbers.py) 106 | - [Re.split()](RegexandParsing/Resplit.py) 107 | - [Group(), Groups() & Groupdict()](RegexandParsing/GroupGroupsampGroupdict.py) 108 | - [Re.findall() & Re.finditer()](RegexandParsing/RefindallampRefinditer.py) 109 | - [Re.start() & Re.end()](RegexandParsing/RestartampReend.py) 110 | - [Regex Substitution](RegexandParsing/RegexSubstitution.py) 111 | - [Validating Roman Numerals](RegexandParsing/ValidatingRomanNumerals.py) 112 | - [Validating phone numbers](RegexandParsing/Validatingphonenumbers.py) 113 | - [Validating and Parsing Email Addresses](RegexandParsing/ValidatingandParsingEmailAddresses.py) 114 | - [Hex Color Code](RegexandParsing/HexColorCode.py) 115 | - [HTML Parser - Part 1](RegexandParsing/HTMLParserPart1.py) 116 | - [HTML Parser - Part 2](RegexandParsing/HTMLParserPart2.py) 117 | - [Detect HTML Tags, Attributes and Attribute Values](RegexandParsing/DetectHTMLTagsAttributesandAttributeValues.py) 118 | - [Validating UID](RegexandParsing/ValidatingUID.py) 119 | - [Validating Credit Card Numbers](RegexandParsing/ValidatingCreditCardNumbers.py) 120 | - [Validating Postal Codes](RegexandParsing/ValidatingPostalCodes.py) 121 | - [Matrix Script](RegexandParsing/MatrixScript.py) 122 | - XML 123 | - [XML 1 - Find the Score](XML/XML1FindtheScore.py) 124 | - [XML2 - Find the Maximum Depth](XML/XML2FindtheMaximumDepth.py) 125 | - Closures and Decorators 126 | - [Standardize Mobile Number Using Decorators](ClosuresandDecorators/StandardizeMobileNumberUsingDecorators.py) 127 | - [Decorators 2 - Name Directory](ClosuresandDecorators/Decorators2NameDirectory.py) 128 | - Numpy 129 | - [Arrays](Numpy/Arrays.py) 130 | - [Shape and Reshape](Numpy/ShapeandReshape.py) 131 | - [Transpose and Flatten](Numpy/TransposeandFlatten.py) 132 | - [Concatenate](Numpy/Concatenate.py) 133 | - [Zeros and Ones](Numpy/ZerosandOnes.py) 134 | - [Eye and Identity](Numpy/EyeandIdentity.py) 135 | - [Array Mathematics](Numpy/ArrayMathematics.py) 136 | - [Floor, Ceil and Rint](Numpy/FloorCeilandRint.py) 137 | - [Sum and Prod](Numpy/SumandProd.py) 138 | - [Min and Max](Numpy/MinandMax.py) 139 | - [Mean, Var, and Std](Numpy/MeanVarandStd.py) 140 | - [Dot and Cross](Numpy/DotandCross.py) 141 | - [Inner and Outer](Numpy/InnerandOuter.py) 142 | - [Polynomials](Numpy/Polynomials.py) 143 | - [Linear Algebra](Numpy/LinearAlgebra.py) 144 | - Debugging 145 | - [Words Score](Debugging/WordsScore.py) 146 | - [Default Arguments](Debugging/DefaultArguments.py) 147 | 148 |
149 | 150 | 151 | ### How to use HackerrankUtility 152 | 153 | - Open [Hackerrank_Solution_Blank_File_Creator.py](HackerrankUtility/Hackerrank_Solution_Blank_File_Creator.py) and edit the author name. 154 | - Save and run the file. 155 | - Blank file to create your solution for each challenge will be created in relevent subdomain. 156 | 157 |
158 | 159 | - Watch demonstration process in [Youtube video: Hackerrank Solution Blank File Creator DEMO](https://youtu.be/G3hq5upfPEI) 160 | 161 | 162 | [![https://youtu.be/G3hq5upfPEI](http://img.youtube.com/vi/G3hq5upfPEI/0.jpg)](https://youtu.be/G3hq5upfPEI) 163 | 164 | ### Contributors 165 | 166 | [![https://github.com/arsho/Hackerrank_Python_Domain_Solutions/graphs/contributors](https://contrib.rocks/image?repo=arsho/Hackerrank_Python_Domain_Solutions)](https://github.com/arsho/Hackerrank_Python_Domain_Solutions/graphs/contributors) 167 | 168 | ### Contact 169 | 170 | If you want to contact me you can reach me at [arshovon.com](https://arshovon.com/). 171 | --------------------------------------------------------------------------------