├── LANGUAGE PROFICIENCY ├── C++ │ ├── Strings │ │ ├── AttributeParser.cpp │ │ ├── Strings.cpp │ │ └── StringStream.cpp │ ├── Introduction │ │ ├── SayHelloWorldWithCPlusPlus.cpp │ │ ├── BasicDataTypes.cpp │ │ ├── InputAndOutput.cpp │ │ ├── Pointer.cpp │ │ ├── Functions.cpp │ │ ├── ArraysIntroduction.cpp │ │ ├── VariableSizedArrays.cpp │ │ ├── ConditionalStatements.cpp │ │ └── ForLoop.cpp │ ├── STL │ │ ├── VectorSort.cpp │ │ ├── MapsStl.cpp │ │ ├── VectorErase.cpp │ │ ├── PrintPretty.cpp │ │ ├── LowerBoundStl.cpp │ │ ├── SetsStl.cpp │ │ └── DequeStl.cpp │ ├── Classes │ │ ├── Structs.cpp │ │ ├── InheritedCode.cpp │ │ ├── ClassesAndObjects.cpp │ │ ├── ExceptionalServer.cpp │ │ ├── Class.cpp │ │ ├── VirtualFunctions.cpp │ │ ├── BoxIt.cpp │ │ └── AbstractClassesPolymorphism.cpp │ ├── Inheritance │ │ ├── InheritanceIntroduction.cpp │ │ ├── MultiLevelInheritance.cpp │ │ ├── RectangleArea.cpp │ │ ├── AccessingInheritedFunctions.cpp │ │ └── MagicSpells.cpp │ └── Other Concepts │ │ ├── PreprocessorSolution.cpp │ │ ├── ClassTemplateSpecialization.cpp │ │ ├── ClassTemplates.cpp │ │ ├── OverloadOperators.cpp │ │ ├── OperatorOverloading.cpp │ │ └── AttendingWorkshops.cpp ├── Shell │ ├── Bash │ │ ├── LetsEcho.sh │ │ ├── APersonalizedEcho.sh │ │ ├── ArithmeticOperations.sh │ │ ├── LoopingWithNumbers.sh │ │ ├── LoopingAndSkipping.sh │ │ ├── TheWorldOfNumbers.sh │ │ ├── ComputeTheAverage.sh │ │ ├── GettingStartedWithConditionals.sh │ │ ├── ComparingNumbers.sh │ │ ├── MoreOnConditionals.sh │ │ └── FunctionsAndFractalsRecursiveTreesBash.sh │ ├── Grep Sed Awk │ │ ├── Grep#1.sh │ │ ├── Grep#2.sh │ │ ├── Grep#3.sh │ │ ├── GrepB.sh │ │ ├── SedCommand#2.sh │ │ ├── SedCommand#3.sh │ │ ├── Awk4.sh │ │ ├── SedCommand#1.sh │ │ ├── SedCommand#4.sh │ │ ├── GrepA.sh │ │ ├── SedCommand#5.sh │ │ ├── Awk1.sh │ │ ├── Awk2.sh │ │ └── Awk3.sh │ ├── Text Processing │ │ ├── Paste3.sh │ │ ├── Paste1.sh │ │ ├── Paste4.sh │ │ ├── SortCommand#1.sh │ │ ├── UniqCommand#1.sh │ │ ├── Cut#7.sh │ │ ├── Cut#8.sh │ │ ├── Cut#9.sh │ │ ├── Paste2.sh │ │ ├── SortCommand#2.sh │ │ ├── SortCommand#3.sh │ │ ├── SortCommand#4.sh │ │ ├── TrCommand#1.sh │ │ ├── TrCommand#2.sh │ │ ├── TrCommand#3.sh │ │ ├── UniqCommand#4.sh │ │ ├── Cut#1.sh │ │ ├── HeadOfATextFile#1.sh │ │ ├── HeadOfATextFile#2.sh │ │ ├── TailOfATextFile#1.sh │ │ ├── TailOfATextFile#2.sh │ │ ├── UniqCommand#2.sh │ │ ├── Cut#6.sh │ │ ├── SortCommand#5.sh │ │ ├── SortCommand#6.sh │ │ ├── SortCommand#7.sh │ │ ├── UniqCommand#3.sh │ │ ├── cut#2.sh │ │ ├── cut#3.sh │ │ ├── cut#4.sh │ │ ├── MiddleOfATextFile.sh │ │ └── Cut#5.sh │ └── Arrays in Bash │ │ ├── LonelyIntegerBash.sh │ │ ├── SliceAnArray.sh │ │ ├── DisplayAnElementOfAnArray.sh │ │ ├── ReadInAnArray.sh │ │ ├── FilterAnArrayWithPatterns.sh │ │ ├── RemoveTheFirstCapitalLetterFromEachElement.sh │ │ ├── CountTheNumberOfElementsInAnArray.sh │ │ └── ConcatenateAnArrayWithItself.sh ├── Python │ ├── Math │ │ ├── TriangleQuest.py │ │ ├── TriangleQuest2.py │ │ ├── ModDivmod.py │ │ ├── PowerModPower.py │ │ ├── IntegersComeInAllSizes.py │ │ ├── FindAngleMBC.py │ │ └── PolarCoordinates.py │ ├── Introduction │ │ ├── SayHelloWorldWithPython.py │ │ ├── Loops.py │ │ ├── PrintFunction.py │ │ ├── ArithmeticOperators.py │ │ ├── PythonDivision.py │ │ ├── WriteAFunction.py │ │ └── PythonIfElse.py │ ├── Sets │ │ ├── SetAdd.py │ │ ├── SetUnion.py │ │ ├── SetDifference.py │ │ ├── CheckSubset.py │ │ ├── SetIntersection.py │ │ ├── SetSymmetricDifference.py │ │ ├── CheckStrictSuperset.py │ │ ├── TheCaptiansRoom.py │ │ ├── SetMutations.py │ │ ├── IntroductionToSets.py │ │ ├── NoIdea.py │ │ ├── SymmetricDifference.py │ │ └── SetDiscardRemovePop.py │ ├── .idea │ │ ├── encodings.xml │ │ ├── libraries │ │ │ └── R_User_Library.xml │ │ ├── misc.xml │ │ ├── vcs.xml │ │ ├── modules.xml │ │ ├── Python.iml │ │ └── workspace.xml │ ├── Itertools │ │ ├── itertools_permutations.py │ │ ├── itertools_product.py │ │ ├── itertools_combinations.py │ │ ├── compress_the_string.py │ │ ├── iterables_and_iterators.py │ │ ├── itertools_combinations_with_replacement.py │ │ └── maximize_it.py │ ├── Basic Data Types │ │ ├── Tuples.py │ │ ├── FindTheRunnerUpScore.py │ │ ├── ListComprehensions.py │ │ ├── NestedLists.py │ │ ├── FindingThePercentage.py │ │ └── Lists.py │ └── Strings │ │ ├── StringSplitAndJoin.py │ │ ├── DesignerDoorMat.py │ │ ├── StringValidators.py │ │ ├── SwapCase.py │ │ ├── WhatsYourName.py │ │ ├── TextWrap.py │ │ ├── Mutations.py │ │ ├── StringFormatting.py │ │ ├── MergeTheTools.py │ │ ├── AlphabetRangoli.py │ │ ├── FindAString.py │ │ ├── Capitalize.py │ │ ├── TheMinionGame.py │ │ └── TextAlignment.py ├── Java │ ├── Introduction │ │ ├── WelcomeToJava.java │ │ ├── JavaEndOfFile.java │ │ ├── JavaStdInAndStdOut1.java │ │ ├── JavaOutputFormatting.java │ │ ├── JavaLoops1.java │ │ ├── JavaStaticInitializerBlock.java │ │ ├── JavaLoops2.java │ │ ├── JavaIfElse.java │ │ ├── JavaCurrencyFormatter.java │ │ ├── JavaDatatypes.java │ │ ├── JavaIntToString.java │ │ └── JavaDateAndTime.java │ ├── Strings │ │ ├── JavaSubstring.java │ │ ├── JavaRegex.java │ │ ├── JavaStringTokens.java │ │ ├── PatternSyntaxChecker.java │ │ ├── JavaStringsIntroduction.java │ │ ├── ValidUsernameRegularExpression.java │ │ ├── TagContentExtractor.java │ │ ├── JavaSubstringComparisons.java │ │ ├── JavaAnagrams.java │ │ └── JavaRegex2DuplicateWords.java │ ├── BigNumber │ │ ├── JavaBigInteger.java │ │ ├── JavaPrimalityTest.java │ │ └── JavaBigDecimal.java │ └── Data Structures │ │ ├── Java1DArray.java │ │ ├── Java2DArray.java │ │ ├── JavaSubarray.java │ │ ├── JavaArraylist.java │ │ └── JavaList.java └── C │ ├── Conditionals and Loops │ ├── SumOfDigitsOfAFiveDigitNumber.c │ ├── PrintingPatternsUsingLoops.c │ ├── BitwiseOperators.c │ ├── ForLoopInC.c │ └── ConditionalStatementsInC.c │ ├── Introduction │ ├── HelloWorld.c │ ├── PointersInC.c │ ├── SumAndDifferenceOfTwoNumbers.c │ ├── PlayingWithCharacters.c │ └── FunctionsInC.c │ ├── Arrays and Strings │ ├── 1DArraysInC.c │ ├── PrintingTokens.c │ ├── ArrayReversal.c │ ├── DigitFrequency.c │ └── DynamicArrayInC.c │ ├── Functions │ ├── CalculateTheNthTerm.c │ ├── StudentsMarksSum.c │ ├── PermutationsOfStrings.c │ ├── SortingArrayOfStrings.c │ ├── QueryingTheDocument.c │ └── VariadicFunctionsInC.c │ └── Structs and Enums │ ├── BoxesThroughATunnel.c │ ├── SmallTrianglesLargeTriangles.cpp │ ├── PostTransition.c │ └── StructuringTheDocument.c ├── TUTORIALS └── Javascript │ ├── create_a_rectangle_object.js │ ├── functions.js │ ├── button.js │ ├── let_and_const.js │ ├── arrow_functions.js │ ├── bitwise_operators.js │ ├── regular_expressions_3.js │ ├── try_catch_and_finally.js │ ├── regular_expressions_1.js │ ├── javascript_dates.js │ ├── count_objects.js │ ├── regular_expressions_2.js │ ├── buttonsGrid.js │ ├── loops.js │ ├── classes.js │ ├── inheritance.js │ ├── throw.js │ ├── if_else.js │ ├── arrays.js │ ├── hello_world.js │ ├── switch.js │ ├── template_literals.js │ ├── arithmetic_operators.js │ ├── data_types.js │ └── binaryCalculator.js └── images └── HackerRankLogo.svg /LANGUAGE PROFICIENCY/C++/Strings/AttributeParser.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/LetsEcho.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo HELLO 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Grep#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -w the 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Grep#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -iw the 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Grep#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -iv the 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Paste3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | paste -s 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Paste1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | paste -d';' -s 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Paste4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | paste - - - 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/UniqCommand#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | uniq $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/GrepB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep '\([0-9]\) *\1' 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d' ' -f4 $1 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d' ' -f1-3 $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d$'\t' -f2- $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Paste2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | paste -d';' - - - 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -r $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -n $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -nr $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/TrCommand#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr '()' '[]' $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/TrCommand#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr -d [a-z] $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/TrCommand#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr -s ' ' ' ' 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/UniqCommand#4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | uniq -u $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c3 "${1:-/dev/stdin}" 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/HeadOfATextFile#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 20 $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/HeadOfATextFile#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -c20 $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/TailOfATextFile#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n20 $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/TailOfATextFile#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -c20 $1 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/UniqCommand#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | uniq -c | cut -c7- 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/SedCommand#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed 's/thy/your/ig' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/SedCommand#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed 's/thy/{&}/ig' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c13- "${1:-/dev/stdin}" 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -t $'\t' -k2 -nr 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -t $'\t' -k2 -n 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/SortCommand#7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort -t $'|' -k2 -nr 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/UniqCommand#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | uniq -ic | cut -c7- 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/cut#2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c 2,7 "${1:-/dev/stdin}" 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/cut#3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c2-7 "${1:-/dev/stdin}" 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/cut#4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c-4 "${1:-/dev/stdin}" 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/APersonalizedEcho.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read name 3 | echo "Welcome $name" 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Awk4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | awk 'ORS = NR % 2 ? ";" : "\n"' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/SedCommand#1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed 's/\bthe\b /this /' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/SedCommand#4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed 's/[0-9]\+ /**** /g' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/MiddleOfATextFile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n22 $1 | tail -n11 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Text Processing/Cut#5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d$'\t' -f1,2,3 "${1:-/dev/stdin}" 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/TriangleQuest.py: -------------------------------------------------------------------------------- 1 | for i in range(1,int(input())): 2 | print ((10 ** i) // 9 * i) 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/ArithmeticOperations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read e 3 | printf "%.3f" $(echo "$e" | bc -l) 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/GrepA.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -iw 'the\|that\|then\|those' < /dev/stdin 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/SayHelloWorldWithPython.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | print("Hello, World") 3 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/SedCommand#5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sed -r 's/(.+ )(.+ )(.+ )(....)/\4 \3\2\1/' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/TriangleQuest2.py: -------------------------------------------------------------------------------- 1 | for i in range(1,int(input())+1): 2 | print ( ((10**i)//9) ** 2 ) 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/ModDivmod.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | d = int(input()) 3 | print(n // d, n % d, divmod(n,d), sep = '\n') 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/LoopingWithNumbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in {1..50} 3 | do 4 | echo $i 5 | done 6 | 7 | 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetAdd.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | s = set() 3 | for _ in range(n): 4 | s.add(input()) 5 | 6 | print(len(s)) 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Awk1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | awk '{if(length($4) == 0) print "Not all scores are available for "$1;}' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/LonelyIntegerBash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read n 3 | arr=($(cat)) 4 | arr=${arr[*]} 5 | echo $((${arr// /^})) 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/PowerModPower.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | c = int(input()) 4 | print(pow(a, b), pow(a,b, c), sep='\n') 5 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/SliceAnArray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read line 3 | do 4 | a=("${a[@]}" $line) 5 | done 6 | echo ${a[@]:3:5} 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/DisplayAnElementOfAnArray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read line 3 | do 4 | a=("${a[@]}" $line) 5 | done 6 | echo ${a[3]} 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Awk2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | awk '{if($2 >= 50 && $3 >= 50 && $4 >= 50) print $1 " : Pass"; else print $1 " : Fail"}' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/Loops.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | for i in range(0, n): 4 | print(i ** 2) 5 | 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/ReadInAnArray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | i=0 3 | while read line 4 | do 5 | a[$i]=$line 6 | ((i+=1)) 7 | done 8 | echo ${a[@]} 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/PrintFunction.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | for i in range(n): 4 | print(i+1, end = '') 5 | 6 | 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/IntegersComeInAllSizes.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | c = int(input()) 4 | d = int(input()) 5 | 6 | print(pow(a, b) + pow(c, d)) 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Grep Sed Awk/Awk3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | awk '{avg = ($2 + $3 + $4) / 3; print $0 " :" ,avg >= 80 ? "A" : avg >=60 ? "B" : avg >= 50 ? "C": "FAIL"}' 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/FindAngleMBC.py: -------------------------------------------------------------------------------- 1 | import math 2 | AB = int(input()) 3 | BC = int(input()) 4 | 5 | print((str(int(round(math.degrees(math.atan2(AB, BC)))))) + '°') 6 | 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/FilterAnArrayWithPatterns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read line 3 | do 4 | a=("${a[@]}" $line) 5 | done 6 | b=(${a[@]/*[aA]*/}) 7 | echo ${b[@]} 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/RemoveTheFirstCapitalLetterFromEachElement.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for line in `cat`; do 3 | a=("${a[@]}" $line) 4 | done 5 | echo ${a[@]/[A-Z]/.} 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/CountTheNumberOfElementsInAnArray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | i = 1 3 | while read line 4 | do 5 | a=("${a[@]}" $line) 6 | ((i+=1)) 7 | done 8 | echo $i 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/SayHelloWorldWithCPlusPlus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello, World!"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/LoopingAndSkipping.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for n in {1..99} 3 | do 4 | if (($n % 2 != 0)); then 5 | echo $n 6 | fi 7 | done 8 | 9 | 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Arrays in Bash/ConcatenateAnArrayWithItself.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for line in `cat`; do 3 | a=("${a[@]}" $line) 4 | done 5 | b=("${a[@]}" "${a[@]}" "${a[@]}") 6 | echo ${b[@]} 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/TheWorldOfNumbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read a 3 | read b 4 | echo $(($a + $b)) 5 | echo $(($a - $b)) 6 | echo $(($a * $b)) 7 | echo $(($a / $b)) 8 | 9 | 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/libraries/R_User_Library.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetUnion.py: -------------------------------------------------------------------------------- 1 | e = int(input()) 2 | E = set(map(int, input().split())) 3 | f = int(input()) 4 | F = set(map(int, input().split())) 5 | S = E.union(F) 6 | print(len(S)) 7 | 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/itertools_permutations.py: -------------------------------------------------------------------------------- 1 | from itertools import permutations 2 | s, n = input().split() 3 | 4 | for p in sorted(list(permutations(s, int(n)))): 5 | print(''.join(p)) 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetDifference.py: -------------------------------------------------------------------------------- 1 | e = int(input()) 2 | E = set(map(int, input().split())) 3 | f = int(input()) 4 | F = set(map(int, input().split())) 5 | S = E.difference(F) 6 | print(len(S)) 7 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/create_a_rectangle_object.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Complete the Rectangle function 3 | */ 4 | function Rectangle(a, b) { 5 | return {length: a, width: b, perimeter: 2 * (a + b), area: a * b} 6 | } 7 | 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/Tuples.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | integer_list = map(int, input().split()) 4 | t = tuple(integer_list) 5 | print(hash(t)) 6 | 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/CheckSubset.py: -------------------------------------------------------------------------------- 1 | for _ in range(int(input())): 2 | _, A = input(), set(map(int, input().split())) 3 | _, B = input(), set(map(int, input().split())) 4 | print(A.issubset(B)) 5 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetIntersection.py: -------------------------------------------------------------------------------- 1 | e = int(input()) 2 | E = set(map(int, input().split())) 3 | f = int(input()) 4 | F = set(map(int, input().split())) 5 | S = E.intersection(F) 6 | print(len(S)) 7 | 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/itertools_product.py: -------------------------------------------------------------------------------- 1 | from itertools import product 2 | a = map(int, input().split()) 3 | b = map(int,input().split()) 4 | 5 | for t in list(product(a, b)): 6 | print(t, end = " ") 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/ComputeTheAverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read n 3 | sum=0 4 | for ((i = 0; i < n; i++)); 5 | do 6 | read var 7 | sum=$((sum + var)) 8 | done 9 | printf "%.3f" `echo "$sum/$n" | bc -l` 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/FindTheRunnerUpScore.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | arr = list(set(map(int, input().split()))) 4 | arr.sort(reverse=True) 5 | print(arr[1]) 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/ArithmeticOperators.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | a = int(input()) 3 | b = int(input()) 4 | 5 | print(a + b) 6 | print(a - b) 7 | print(a * b) 8 | 9 | 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetSymmetricDifference.py: -------------------------------------------------------------------------------- 1 | e = int(input()) 2 | E = set(map(int, input().split())) 3 | f = int(input()) 4 | F = set(map(int, input().split())) 5 | S = E.symmetric_difference(F) 6 | print(len(S)) 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/GettingStartedWithConditionals.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read i 3 | if [[ "$i" = 'y' || "$i" = 'Y' ]]; then 4 | echo "YES" 5 | elif [[ "$i" = 'n' || "$i" = 'N' ]]; then 6 | echo "NO" 7 | fi 8 | 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/WelcomeToJava.java: -------------------------------------------------------------------------------- 1 | public class WelcomeToJava { 2 | public static void main(String [] args) { 3 | System.out.println("Hello, World."); 4 | System.out.println("Hello, Java."); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/StringSplitAndJoin.py: -------------------------------------------------------------------------------- 1 | def split_and_join(line): 2 | return ('-'.join(line.split())) 3 | 4 | if __name__ == '__main__': 5 | line = input() 6 | result = split_and_join(line) 7 | print(result) 8 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/functions.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Create the function factorial here 3 | */ 4 | function factorial(n) { 5 | let ans = n; 6 | for(let i = n - 1; i > 1; i --) { 7 | ans *= i; 8 | } 9 | return ans; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/DesignerDoorMat.py: -------------------------------------------------------------------------------- 1 | n, width = map(int, input().split()) 2 | list = [('.|.' * (2*i + 1)).center(width, '-') for i in range (n//2)] 3 | print ('\n'.join(list + ['WELCOME'.center(width, '-')] + list[::-1])) 4 | 5 | 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/StringValidators.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | s = input() 3 | for method in [str.isalnum, str.isalpha, str.isdigit, str.islower, str.isupper]: 4 | print(any(method(c) for c in s)) 5 | 6 | 7 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/SwapCase.py: -------------------------------------------------------------------------------- 1 | def swap_case(s): 2 | return (''.join([c.upper() if c.islower() else c.lower() for c in s])) 3 | 4 | if __name__ == '__main__': 5 | s = input() 6 | result = swap_case(s) 7 | print(result) 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/itertools_combinations.py: -------------------------------------------------------------------------------- 1 | from itertools import combinations 2 | s, k = input().split() 3 | s = sorted(s) 4 | k = int(k) 5 | 6 | for i in range(1, k+1): 7 | for c in combinations(s, i): 8 | print(''.join(c)) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/CheckStrictSuperset.py: -------------------------------------------------------------------------------- 1 | A = set(map(int, input().split())) 2 | r = True 3 | for _ in range(int(input())): 4 | B = set(map(int, input().split())) 5 | if A.issuperset(B) == False: 6 | r = False 7 | 8 | print(r) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/PythonDivision.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | a = int(input()) 3 | b = int(input()) 4 | 5 | # from python 3, 6 | # / - float divison // - integral division 7 | print(a // b) 8 | print(a / b) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/TheCaptiansRoom.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | _, l = input(), list(map(int, input().split())) 3 | rooms = set(l) 4 | 5 | c = Counter(l) 6 | for r in rooms: 7 | if c[r] == 1: 8 | print(r) 9 | break 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/ComparingNumbers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read X 3 | read Y 4 | if ((X > Y)); then 5 | echo "X is greater than Y" 6 | elif ((X < Y)); then 7 | echo "X is less than Y" 8 | else 9 | echo "X is equal to Y" 10 | fi 11 | 12 | 13 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/compress_the_string.py: -------------------------------------------------------------------------------- 1 | # Enter your code here. Read input from STDIN. Print output to STDOUT 2 | from itertools import groupby 3 | s = list(map(int, input())) 4 | for i, j in groupby(s): 5 | print(tuple([len(list(j)), i]),end = ' ') 6 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/iterables_and_iterators.py: -------------------------------------------------------------------------------- 1 | from itertools import combinations 2 | _ = input() 3 | 4 | s = input().split() 5 | k = int(input()) 6 | 7 | c = list(combinations(s, k)) 8 | a = [i for i in c if 'a' in i] 9 | print(len(a)/ len(c)) 10 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetMutations.py: -------------------------------------------------------------------------------- 1 | _ , A = int(input()), set(map(int, input().split())) 2 | q = int(input()) 3 | for _ in range(q): 4 | command, B = input().split()[0], set(map(int, input().split())) 5 | getattr(A, command)(B) 6 | 7 | print(sum(A)) 8 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/button.js: -------------------------------------------------------------------------------- 1 | var btn = document.createElement("Button"); 2 | 3 | btn.innerHTML = "0"; 4 | btn.id = "btn"; 5 | btn.className = "btnClass"; 6 | 7 | document.body.appendChild(btn); 8 | 9 | btn.onclick = function() { 10 | btn.innerHTML++; 11 | } 12 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/itertools_combinations_with_replacement.py: -------------------------------------------------------------------------------- 1 | from itertools import combinations_with_replacement 2 | 3 | s, k = input().split() 4 | s = sorted(s) 5 | k = int(k) 6 | 7 | for c in combinations_with_replacement(s, k): 8 | print(''.join(c)) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/WhatsYourName.py: -------------------------------------------------------------------------------- 1 | def print_full_name(a, b): 2 | print("Hello %s %s! You just delved into python."%(a, b)) 3 | 4 | if __name__ == '__main__': 5 | first_name = input() 6 | last_name = input() 7 | print_full_name(first_name, last_name) 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/MoreOnConditionals.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read X 3 | read Y 4 | read Z 5 | 6 | if ((X == Y && Y == Z)); then 7 | echo "EQUILATERAL" 8 | elif ((X == Y || X == Z || Y == Z)); then 9 | echo "ISOSCELES" 10 | else 11 | echo "SCALENE" 12 | fi 13 | 14 | 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/TextWrap.py: -------------------------------------------------------------------------------- 1 | import textwrap 2 | 3 | def wrap(string, max_width): 4 | return textwrap.fill(string, max_width) 5 | 6 | if __name__ == '__main__': 7 | string, max_width = input(), int(input()) 8 | result = wrap(string, max_width) 9 | print(result) 10 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/let_and_const.js: -------------------------------------------------------------------------------- 1 | // Write your code here. Read input using 'readLine()' and print output using 'console.log()'. 2 | const PI = Math.PI; 3 | let r = readLine(); 4 | // Print the area of the circle: 5 | console.log(PI * r * r); 6 | // Print the perimeter of the circle: 7 | console.log(2 * PI * r); 8 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/ListComprehensions.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | x = int(input()) 3 | y = int(input()) 4 | z = int(input()) 5 | n = int(input()) 6 | 7 | lst = [[i,j,k] for i in range(0,x+1) for j in range(0,y+1) for k in range (0,z+1) if i+j+k != n] 8 | print(lst) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/arrow_functions.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Modify and return the array so that all even elements are doubled and all odd elements are tripled. 3 | * 4 | * Parameter(s): 5 | * nums: An array of numbers. 6 | */ 7 | function modifyArray(nums) { 8 | return nums.map(num => num & 1 ? num * 3 : num * 2); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/Mutations.py: -------------------------------------------------------------------------------- 1 | def mutate_string(string, position, character): 2 | s = string[:position] + character + string[position+1:] 3 | return s 4 | 5 | if __name__ == '__main__': 6 | s = input() 7 | i, c = input().split() 8 | s_new = mutate_string(s, int(i), c) 9 | print(s_new) 10 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/bitwise_operators.js: -------------------------------------------------------------------------------- 1 | function getMaxLessThanK(n , k) { 2 | let max = 0; 3 | for(let i = 1; i <= n; i ++) { 4 | for(let j = i + 1; j <= n; j ++) { 5 | let and = i & j; 6 | if( and < k && max < and ) { 7 | max = and; 8 | } 9 | } 10 | } 11 | return max; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/regular_expressions_3.js: -------------------------------------------------------------------------------- 1 | function regexVar() { 2 | /* 3 | * Declare a RegExp object variable named 're' 4 | * It must match ALL occurrences of numbers in a string. 5 | */ 6 | const re = /\d+/g; 7 | 8 | /* 9 | * Do not remove the return statement 10 | */ 11 | return re; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/IntroductionToSets.py: -------------------------------------------------------------------------------- 1 | def average(array): 2 | sum = 0 3 | for h in set(array): 4 | sum += h 5 | return sum / len(set(array)) 6 | 7 | if __name__ == '__main__': 8 | n = int(input()) 9 | arr = list(map(int, input().split())) 10 | result = average(arr) 11 | print(result) 12 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/StringFormatting.py: -------------------------------------------------------------------------------- 1 | def print_formatted(number): 2 | width = len("{0:b}".format(number)) 3 | for i in range(1, number+1): 4 | print("{0:{width}d} {0:{width}o} {0:{width}X} {0:{width}b}".format(i, width= width)) 5 | 6 | if __name__ == '__main__': 7 | n = int(input()) 8 | print_formatted(n) 9 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/try_catch_and_finally.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Complete the reverseString function 3 | * Use console.log() to print to stdout. 4 | */ 5 | function reverseString(s) { 6 | try { 7 | s = s.split('').reverse().join(''); 8 | } catch(e) { 9 | console.log(e.message); 10 | } finally { 11 | console.log(s); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Itertools/maximize_it.py: -------------------------------------------------------------------------------- 1 | from itertools import product 2 | 3 | k, m = map(int, input().split()) 4 | ll = [] 5 | 6 | for _ in range(k): 7 | l = list(map(int, input().split()))[1:] 8 | ll.append(l) 9 | 10 | res = -1 11 | for i in product(*ll): 12 | res = max(res, sum(x ** 2 for x in i)%m) 13 | 14 | print(res) 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/NestedLists.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | i = int(input()) 3 | marksheet = [ [input(), float( input() )] for _ in range(i)] 4 | 5 | scores = sorted(set([entry[1] for entry in marksheet])) 6 | 7 | for name in sorted([entry[0] for entry in marksheet if entry[1] == scores[1]]): 8 | print(name) 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/WriteAFunction.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | def is_leap(year): 3 | leap = False 4 | 5 | if year % 100 == 0: 6 | if year % 400 == 0: 7 | leap = True 8 | elif year % 4 == 0: 9 | leap = True 10 | 11 | return leap 12 | 13 | year = int(input()) 14 | print(is_leap(year)) 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/NoIdea.py: -------------------------------------------------------------------------------- 1 | n, m = map(int, input().split()) 2 | arr = list(map(int, input().split())) 3 | seta = set(map(int, input().split())) 4 | setb = set(map(int, input().split())) 5 | happiness = 0 6 | 7 | for i in arr: 8 | if i in seta: 9 | happiness += 1 10 | elif i in setb: 11 | happiness -= 1 12 | 13 | print(happiness) 14 | 15 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/regular_expressions_1.js: -------------------------------------------------------------------------------- 1 | function regexVar() { 2 | /* 3 | * Declare a RegExp object variable named 're' 4 | * It must match a string that starts and ends with the same vowel (i.e., {a, e, i, o, u}) 5 | */ 6 | const re = /^([aeiou]).*\1$/ 7 | /* 8 | * Do not remove the return statement 9 | */ 10 | return re; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SymmetricDifference.py: -------------------------------------------------------------------------------- 1 | m = int(input()) 2 | M = set(input().split()) 3 | n = int(input()) 4 | N = set(input().split()) 5 | l = [] 6 | 7 | for c in M: 8 | if c not in N: 9 | l.append(int(c)) 10 | 11 | for c in N: 12 | if c not in M: 13 | l.append(int(c)) 14 | 15 | l.sort() 16 | 17 | for c in l: 18 | print(c) 19 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/javascript_dates.js: -------------------------------------------------------------------------------- 1 | // The days of the week are: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" 2 | function getDayName(dateString) { 3 | const weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; 4 | const day = new Date(dateString).getDay(); 5 | 6 | return weekDays[day]; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaEndOfFile.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | int n = 1; 8 | Scanner sc = new Scanner(System.in); 9 | while(sc.hasNext()){ 10 | System.out.println(n++ + " " + sc.nextLine()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Conditionals and Loops/SumOfDigitsOfAFiveDigitNumber.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | 8 | int n, sum = 0; 9 | scanf("%d", &n); 10 | while(n > 0) { 11 | sum += n %10; 12 | n = n/10; 13 | } 14 | printf("%d", sum); 15 | return 0; 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/count_objects.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Return a count of the total number of objects 'o' satisfying o.x == o.y. 3 | * 4 | * Parameter(s): 5 | * objects: an array of objects with integer properties 'x' and 'y' 6 | */ 7 | function getCount(objects) { 8 | let count = 0; 9 | for(let o of objects) { 10 | if(o.x === o.y) count ++; 11 | } 12 | return count; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/BasicDataTypes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // Complete the code. 7 | int n; 8 | long l; 9 | char c; 10 | float f; 11 | double d; 12 | scanf("%d%ld%*c%c%f%lf", &n, &l, &c, &f, &d); 13 | printf("%d\n%ld\n%c\n%.3f\n%.9lf\n", n , l, c, f, d); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Strings/Strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | string s1, s2; 7 | cin >> s1 >> s2; 8 | cout << s1.size() << ' '<< s2.size() << endl; 9 | cout << s1 + s2 << endl; 10 | char t = s1[0]; 11 | s1[0] = s2 [0]; 12 | s2[0] = t; 13 | cout << s1 << ' ' << s2; 14 | return 0; 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/InputAndOutput.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 11 | int a, b, c; 12 | cin >> a >> b >> c; 13 | cout << a + b + c << endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/regular_expressions_2.js: -------------------------------------------------------------------------------- 1 | function regexVar() { 2 | /* 3 | * Declare a RegExp object variable named 're' 4 | * It must match a string that starts with 'Mr.', 'Mrs.', 'Ms.', 'Dr.', or 'Er.', 5 | * followed by one or more letters. 6 | */ 7 | const re = /^(Mr|Mrs|Ms|Dr|Er)\.[a-zA-Z]*$/; 8 | /* 9 | * Do not remove the return statement 10 | */ 11 | return re; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/buttonsGrid.js: -------------------------------------------------------------------------------- 1 | var l = "4"; 2 | var a = ["1", "2", "3", "6", "9", "8", "7", "4"]; 3 | var b = ["1", "2", "3", "6", "9", "8", "7", "4"]; 4 | 5 | var rotate = function() { 6 | for (var i = 7; i > 0; i--) { 7 | a[i] = a[i - 1]; 8 | } 9 | 10 | a[0] = l; 11 | l = a[7]; 12 | 13 | for (var i = 0; i < 8; i++) { 14 | document.getElementById("btn" + b[i]).innerText = a[i]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Introduction/PythonIfElse.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | 10 | 11 | if __name__ == '__main__' : 12 | n = int(input()) 13 | if n % 2 != 0 : 14 | print("Weird") 15 | else : 16 | if n >= 6 and n <=20 : 17 | print("Weird") 18 | else : 19 | print("Not Weird") 20 | 21 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/loops.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Complete the vowelsAndConsonants function. 3 | * Print your output using 'console.log()'. 4 | */ 5 | function vowelsAndConsonants(s) { 6 | let consonants = []; 7 | let vowels = 'aeiou'; 8 | for(let c of s) { 9 | if (vowels.includes(c)) console.log(c); 10 | else consonants.push(c); 11 | } 12 | for(let c of consonants) { 13 | console.log(c); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/Pointer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void update(int *a,int *b) { 4 | // Complete this function 5 | int t = *a; 6 | *a = *a + *b; 7 | *b = t > *b ? t - *b : *b - t; 8 | } 9 | 10 | int main() { 11 | int a, b; 12 | int *pa = &a, *pb = &b; 13 | 14 | scanf("%d %d", &a, &b); 15 | update(pa, pb); 16 | printf("%d\n%d", a, b); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Introduction/HelloWorld.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | 5 | char s[100]; 6 | scanf("%[^\n]%*c", &s); 7 | // [^\n] - everything upto \n, but not \n 8 | // %c - scan \n 9 | // * - discard what is scanned 10 | 11 | /* Enter your code here. Read input from STDIN. Print output to STDOUT*/ 12 | printf("Hello, World!\n"); 13 | printf("%s", s); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Introduction/PointersInC.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void update(int *a,int *b) { 4 | // Complete this function 5 | int t = *a; 6 | *a = *a + *b; 7 | *b = t > *b ? t - *b : *b - t; 8 | } 9 | 10 | int main() { 11 | int a, b; 12 | int *pa = &a, *pb = &b; 13 | 14 | scanf("%d %d", &a, &b); 15 | update(pa, pb); 16 | printf("%d\n%d", a, b); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Math/PolarCoordinates.py: -------------------------------------------------------------------------------- 1 | # Enter your code here. Read input from STDIN. Print output to STDOUT 2 | import cmath 3 | 4 | # input is of type complex 5 | c = complex(input()) 6 | # cmath.polar(x) returns a pair (abs(x), phase(x)) 7 | # * prefix unpacks list and passes them as seperate arguments to the function 8 | # use sep = '\n' to print function to print on new lines 9 | print(*cmath.polar(c), sep='\n') 10 | 11 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Arrays and Strings/1DArraysInC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | int n, sum = 0; 8 | scanf("%d", &n); 9 | int * arr = (int *)malloc(n * sizeof(int)); 10 | for(int i = 0; i < n; i ++) { 11 | scanf("%d", arr + i); 12 | sum += arr [i]; 13 | } 14 | printf("%d", sum); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Introduction/SumAndDifferenceOfTwoNumbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | int a,b; 9 | float c,d; 10 | 11 | scanf("%d", &a); 12 | scanf("%d", &b); 13 | printf("%d %d\n", a + b, a - b); 14 | 15 | scanf("%f", &c); 16 | scanf("%f", &d); 17 | printf("%.1f %.1f", c + d, c - d); 18 | 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaStdInAndStdOut1.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner scan = new Scanner(System.in); 7 | int a = scan.nextInt(); 8 | int b = scan.nextInt(); 9 | int c = scan.nextInt(); 10 | 11 | System.out.println(a); 12 | System.out.println(b); 13 | System.out.println(c); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/MergeTheTools.py: -------------------------------------------------------------------------------- 1 | def merge_the_tools(string, k): 2 | l = [] 3 | for s in [string[i: k+i] for i in range(0, len(string), k)]: 4 | t = [] 5 | for c in s: 6 | if c not in t: 7 | t.append(c) 8 | l.append(''.join(t)) 9 | 10 | print('\n'.join(l)) 11 | 12 | 13 | if __name__ == '__main__': 14 | string, k = input(), int(input()) 15 | merge_the_tools(string, k) 16 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/FindingThePercentage.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | student_marks = {} 4 | for _ in range(n): 5 | name, *line = input().split() 6 | scores = list(map(float, line)) 7 | student_marks[name] = scores 8 | 9 | query_name = input() 10 | sum = 0; 11 | for score in student_marks[query_name]: 12 | sum += score 13 | sum /= 3 14 | print("%.2f"%sum) 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Sets/SetDiscardRemovePop.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | s = set(map(int, input().split())) 3 | N = int(input()) 4 | for _ in range (N): 5 | command = input().split() 6 | if command[0] == 'pop': 7 | s.pop() 8 | elif command[0] == 'discard': 9 | s.discard(int(command[1])) 10 | elif command[0] == 'remove': 11 | s.remove(int(command[1])) 12 | 13 | sum = 0 14 | for x in s: 15 | sum += x 16 | print(sum) 17 | 18 | 19 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/AlphabetRangoli.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | def print_rangoli(size): 4 | width = 4 * (size - 1) + 1 # 2 * (size - 1) on each side + 1 in centre 5 | l = [] 6 | for i in range(size): 7 | s = '-'.join(string.ascii_lowercase[i:n]) 8 | l.append((s[::-1] + s[1:]).center(width, '-')) 9 | 10 | print('\n'.join(l[::-1] + l[1:])) 11 | 12 | if __name__ == '__main__': 13 | n = int(input()) 14 | print_rangoli(n) 15 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Arrays and Strings/PrintingTokens.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | 8 | char *s; 9 | s = malloc(1024 * sizeof(char)); 10 | scanf("%[^\n]", s); 11 | s = realloc(s, strlen(s) + 1); 12 | for(int i = 0; i < strlen(s); i ++) { 13 | if(s[i] == ' ') s[i] = '\n'; 14 | } 15 | printf("%s", s); 16 | free(s); 17 | return 0; 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/classes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Implement a Polygon class with the following properties: 3 | * 1. A constructor that takes an array of integer side lengths. 4 | * 2. A 'perimeter' method that returns the sum of the Polygon's side lengths. 5 | */ 6 | class Polygon { 7 | constructor(sides) { 8 | this.sides = sides; 9 | } 10 | } 11 | 12 | Polygon.prototype.perimeter = function() { 13 | return this.sides.reduce((curr, next) => curr + next, 0); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/inheritance.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Implement a Polygon class with the following properties: 3 | * 1. A constructor that takes an array of integer side lengths. 4 | * 2. A 'perimeter' method that returns the sum of the Polygon's side lengths. 5 | */ 6 | class Polygon { 7 | constructor(sides) { 8 | this.sides = sides; 9 | } 10 | } 11 | 12 | Polygon.prototype.perimeter = function() { 13 | return this.sides.reduce((curr, next) => curr + next, 0); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/throw.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Complete the isPositive function. 3 | * If 'a' is positive, return "YES". 4 | * If 'a' is 0, throw an Error with the message "Zero Error" 5 | * If 'a' is negative, throw an Error with the message "Negative Error" 6 | */ 7 | function isPositive(a) { 8 | if(a == 0) { 9 | throw new Error("Zero Error"); 10 | } else if (a < 0) { 11 | throw new Error("Negative Error"); 12 | } else { 13 | return "YES"; 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/FindAString.py: -------------------------------------------------------------------------------- 1 | def count_substring(string, sub_string): 2 | count = 0 3 | l = len(string) 4 | size = len(sub_string) 5 | for i in range (l - size + 1): 6 | if(string[i:size+i] == sub_string): 7 | count += 1 8 | return count 9 | 10 | if __name__ == '__main__': 11 | string = input().strip() 12 | sub_string = input().strip() 13 | 14 | count = count_substring(string, sub_string) 15 | print(count) 16 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Introduction/PlayingWithCharacters.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #define MAX_LEN 100 6 | 7 | int main() 8 | { 9 | char ch, s[MAX_LEN], sen[MAX_LEN]; 10 | scanf("%c", &ch); 11 | printf("%c\n", ch); 12 | 13 | scanf("%s", s); 14 | printf("%s\n", s); 15 | scanf("\n"); 16 | 17 | scanf("%[^\n]%*c]", sen); 18 | printf("%s\n", sen); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaSubstring.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) { 10 | Scanner in = new Scanner(System.in); 11 | String S = in.next(); 12 | int start = in.nextInt(); 13 | int end = in.nextInt(); 14 | System.out.println(S.substring(start,end)); 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/if_else.js: -------------------------------------------------------------------------------- 1 | function getGrade(score) { 2 | let grade; 3 | // Write your code here 4 | if (score > 25) { 5 | grade = 'A'; 6 | } else if (score > 20 && score <= 25) { 7 | grade = 'B'; 8 | } else if (score > 15 && score <= 20) { 9 | grade = 'C'; 10 | } else if (score > 10 && score <= 15) { 11 | grade = 'D'; 12 | } else if (score > 5 && score <= 10) { 13 | grade = 'E'; 14 | } else { 15 | grade = 'F'; 16 | } 17 | 18 | return grade; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/Functions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int max_of_four(int a, int b, int c, int d) { 6 | int t1 = a > b ? a : b; 7 | int t2 = c > d ? c : d; 8 | int max = t1 > t2 ? t1 : t2; 9 | return max; 10 | } 11 | 12 | 13 | int main() { 14 | int a, b, c, d; 15 | scanf("%d %d %d %d", &a, &b, &c, &d); 16 | int ans = max_of_four(a, b, c, d); 17 | printf("%d", ans); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/arrays.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Return the second largest number in the array. 3 | * @param {Number[]} nums - An array of numbers. 4 | * @return {Number} The second largest number in the array. 5 | **/ 6 | function getSecondLargest(nums) { 7 | // Complete the function 8 | let max = 0; 9 | 10 | for(let n of nums) { 11 | if(n > max) max = n; 12 | } 13 | 14 | let s = 0; 15 | 16 | for (let n of nums) { 17 | if(n > s && n < max) s = n; 18 | } 19 | 20 | return s; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/VectorSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | int size, a; 11 | cin >> size; 12 | vector v; 13 | for(int i = 0; i < size; i ++) { 14 | cin >> a; 15 | v.push_back(a); 16 | } 17 | sort(v.begin(), v.end()); 18 | for(int i = 0; i < size; i ++) { 19 | cout << v[i] << " "; 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Introduction/FunctionsInC.c: -------------------------------------------------------------------------------- 1 | #include 2 | /* 3 | Add `int max_of_four(int a, int b, int c, int d)` here. 4 | */ 5 | 6 | int max_of_four(int a, int b, int c, int d) { 7 | int ans; 8 | a = a > b ? a : b; 9 | c = c > d ? c : d; 10 | ans = a > c ? a : c; 11 | return ans; 12 | } 13 | 14 | int main() { 15 | int a, b, c, d; 16 | scanf("%d %d %d %d", &a, &b, &c, &d); 17 | int ans = max_of_four(a, b, c, d); 18 | printf("%d", ans); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/Capitalize.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | # Complete the solve function below. 10 | def solve(s): 11 | name = [ word.capitalize() for word in s.split(' ')] 12 | return ' '.join(name) 13 | 14 | if __name__ == '__main__': 15 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 16 | 17 | s = input() 18 | 19 | result = solve(s) 20 | 21 | fptr.write(result + '\n') 22 | 23 | fptr.close() 24 | 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/BigNumber/JavaBigInteger.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | BigInteger a = new BigInteger(sc.next()); 12 | BigInteger b = new BigInteger(sc.next()); 13 | System.out.println(a.add(b)); 14 | System.out.println(a.multiply(b)); 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/ArraysIntroduction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 11 | int n; 12 | cin >> n; 13 | int arr [n]; 14 | for (int i = 0; i < n; i ++) { 15 | cin >> arr[i]; 16 | } 17 | for (int i = n-1; i >= 0; i --) { 18 | cout << arr[i] << " "; 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/Structs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | struct Student { 9 | int age; 10 | char first_name[51]; 11 | char last_name[51]; 12 | int standard; 13 | }; 14 | 15 | int main() { 16 | Student st; 17 | 18 | cin >> st.age >> st.first_name >> st.last_name >> st.standard; 19 | cout << st.age << " " << st.first_name << " " << st.last_name << " " << st.standard; 20 | 21 | return 0; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Arrays and Strings/ArrayReversal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int num, *arr, i; 7 | scanf("%d", &num); 8 | arr = (int*) malloc(num * sizeof(int)); 9 | for(i = 0; i < num; i++) { 10 | scanf("%d", arr + i); 11 | } 12 | 13 | for(int i = 0, j = num-1; i <= j; i++, j --) { 14 | int t = arr[i]; 15 | arr[i] = arr [j]; 16 | arr[j] = t; 17 | } 18 | 19 | for(i = 0; i < num; i++) 20 | printf("%d ", *(arr + i)); 21 | return 0; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaRegex.java: -------------------------------------------------------------------------------- 1 | import java.util.regex.Matcher; 2 | import java.util.regex.Pattern; 3 | import java.util.Scanner; 4 | 5 | class Solution{ 6 | 7 | public static void main(String[] args){ 8 | Scanner in = new Scanner(System.in); 9 | while(in.hasNext()){ 10 | String IP = in.next(); 11 | System.out.println(IP.matches(new MyRegex().pattern)); 12 | } 13 | 14 | } 15 | } 16 | 17 | class MyRegex { 18 | String pattern = "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/hello_world.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A line of code that prints "Hello, World!" on a new line is provided in the editor. 3 | * Write a second line of code that prints the contents of 'parameterVariable' on a new line. 4 | * 5 | * Parameter: 6 | * parameterVariable - A string of text. 7 | **/ 8 | function greeting(parameterVariable) { 9 | // This line prints 'Hello, World!' to the console: 10 | console.log('Hello, World!'); 11 | console.log(parameterVariable); 12 | // Write a line of code that prints parameterVariable to stdout using console.log: 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Data Structures/Java1DArray.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | 7 | Scanner scan = new Scanner(System.in); 8 | int n = scan.nextInt(); 9 | int [] a = new int[n]; 10 | for(int i = 0; i < n; i ++) { 11 | a[i] = scan.nextInt(); 12 | } 13 | scan.close(); 14 | 15 | // Prints each sequential element in array a 16 | for (int i = 0; i < a.length; i++) { 17 | System.out.println(a[i]); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaStringTokens.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | Scanner scan = new Scanner(System.in); 8 | String s = scan.nextLine().trim(); 9 | scan.close(); 10 | 11 | String [ ] tokens = s.split("[^\\p{Alpha}]+"); 12 | int size = s.isEmpty() ? 0 : tokens.length; 13 | 14 | System.out.println(size); 15 | for(String token : tokens ) { 16 | System.out.println(token); 17 | } 18 | } 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Functions/CalculateTheNthTerm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int find_nth_term(int n, int a, int b, int c) { 7 | if (n == 1) return a; 8 | if (n == 2) return b; 9 | if (n == 3) return c; 10 | else return(find_nth_term(n-1, a, b, c) + find_nth_term(n-2, a, b, c) + find_nth_term(n-3, a, b, c)); 11 | } 12 | 13 | int main() { 14 | int n, a, b, c; 15 | 16 | scanf("%d %d %d %d", &n, &a, &b, &c); 17 | int ans = find_nth_term(n, a, b, c); 18 | 19 | printf("%d", ans); 20 | return 0; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/Python.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Arrays and Strings/DigitFrequency.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | 8 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 9 | char s[1000]; 10 | int arr[10] = {0}; 11 | scanf("%s",s); 12 | 13 | for(int i = 0; i < strlen(s); i ++) { 14 | int j = s[i] - 48; 15 | if( j >= 0 && j <= 9 ) { 16 | arr[j]++; 17 | } 18 | } 19 | 20 | for(int i = 0; i < 10; i ++) { 21 | printf("%d ", arr[i]); 22 | } 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaOutputFormatting.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner sc=new Scanner(System.in); 7 | System.out.println("================================"); 8 | for(int i=0;i<3;i++){ 9 | String s1=sc.next(); 10 | int x=sc.nextInt(); 11 | 12 | System.out.println(String.format("%-15s%03d", s1, x)); 13 | } 14 | System.out.println("================================"); 15 | 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/switch.js: -------------------------------------------------------------------------------- 1 | function getLetter(s) { 2 | let letter; 3 | // Write your code here 4 | switch(s.charAt(0)) { 5 | case 'a': 6 | case 'e': 7 | case 'i': 8 | case 'o': 9 | case 'u': 10 | letter = 'A'; 11 | break; 12 | 13 | case 'b': 14 | case 'c': 15 | case 'd': 16 | case 'f': 17 | case 'g': 18 | letter = 'B'; 19 | break; 20 | 21 | case 'h': 22 | case 'j': 23 | case 'k': 24 | case 'l': 25 | case 'm': 26 | letter = 'C'; 27 | break; 28 | 29 | default: 30 | letter = 'D'; 31 | } 32 | return letter; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/PatternSyntaxChecker.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.util.regex.*; 3 | 4 | public class Solution 5 | { 6 | public static void main(String[] args){ 7 | Scanner in = new Scanner(System.in); 8 | int testCases = Integer.parseInt(in.nextLine()); 9 | while(testCases>0){ 10 | String pattern = in.nextLine(); 11 | try { 12 | Pattern p = Pattern.compile(pattern); 13 | System.out.println("Valid"); 14 | } catch (Exception e) { 15 | System.out.println("Invalid"); 16 | } 17 | 18 | } 19 | } 20 | } 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/TheMinionGame.py: -------------------------------------------------------------------------------- 1 | def minion_game(string): 2 | vowels = ['A', 'E', 'I', 'O', 'U'] 3 | l = len(string) 4 | total = (l * (l + 1) ) / 2 5 | 6 | stuart = 0 7 | 8 | for i in range(len(string)): 9 | if string[i] not in vowels: 10 | stuart += len(string) - i 11 | 12 | kevin = total - stuart 13 | 14 | if(kevin > stuart): 15 | print("Kevin %d"%kevin) 16 | elif(kevin < stuart): 17 | print("Stuart %d"%stuart) 18 | else: 19 | print("Draw") 20 | 21 | if __name__ == '__main__': 22 | s = input() 23 | minion_game(s) 24 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Strings/StringStream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | vector parseInts(string str) { 7 | stringstream ss(str); 8 | int a; 9 | char ch; 10 | vector v; 11 | while(ss >> a) 12 | { 13 | v.push_back(a); 14 | ss >> ch; 15 | } 16 | return v; 17 | } 18 | 19 | int main() { 20 | string str; 21 | cin >> str; 22 | vector integers = parseInts(str); 23 | for(int i = 0; i < integers.size(); i++) { 24 | cout << integers[i] << "\n"; 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaStringsIntroduction.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | 8 | Scanner sc=new Scanner(System.in); 9 | String A=sc.next(); 10 | String B=sc.next(); 11 | 12 | System.out.println(A.length() + B.length()); 13 | if(A.compareTo(B) > 0) System.out.println("Yes"); 14 | else System.out.println("No"); 15 | System.out.println(A.substring(0,1).toUpperCase() + A.substring(1) + ' ' + B.substring(0,1).toUpperCase() + B.substring(1)); 16 | } 17 | } 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/BigNumber/JavaPrimalityTest.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | private static final Scanner scanner = new Scanner(System.in); 12 | 13 | public static void main(String[] args) { 14 | String n = scanner.nextLine(); 15 | BigInteger a = new BigInteger(n); 16 | if(a.isProbablePrime(1)) System.out.println("prime"); 17 | else System.out.println("not prime"); 18 | 19 | scanner.close(); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaLoops1.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | 12 | 13 | private static final Scanner scanner = new Scanner(System.in); 14 | 15 | public static void main(String[] args) { 16 | int N = scanner.nextInt(); 17 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 18 | for ( int i = 1; i < 11; i ++ ) { 19 | System.out.println(N +" x "+ i + " = " + N*i); 20 | } 21 | scanner.close(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/VariableSizedArrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | int n, q; 11 | cin >> n >> q; 12 | int* outer[n]; 13 | for(int i = 0; i < n; i ++) { 14 | int size; 15 | cin >> size; 16 | outer[i] = new int [size]; 17 | for (int j = 0; j < size; j ++) { 18 | cin >> outer [i][j]; 19 | } 20 | } 21 | 22 | for (int i = 0; i < q; i ++) { 23 | int j,k; 24 | cin >> j >> k; 25 | cout << outer[j][k] << endl; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Data Structures/Java2DArray.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | 4 | class Solution{ 5 | public static void main(String []argh){ 6 | int[][] arr = new int[10][10]; 7 | Scanner sc = new Scanner(System.in); 8 | for(int i=0;i<6;i++){ 9 | for(int j=0;j<6;j++){ 10 | arr[i][j]=sc.nextInt(); 11 | 12 | } 13 | } 14 | int maxi=-100000; 15 | for(int i=0;i<6;i++){ 16 | for(int j=0;j<6;j++){ 17 | if(i<=3 && j<=3){ 18 | int sum=arr[i][j]+arr[i][j+1]+arr[i][j+2]+(arr[i+1][j+1])+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]; 19 | if(sum>maxi) maxi=sum; 20 | } 21 | } 22 | } 23 | System.out.println(maxi); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/MapsStl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | int main() { 11 | int q; 12 | cin >> q; 13 | 14 | map m; 15 | 16 | for (int i = 0; i> t >> name; 21 | if (t == 1){ 22 | cin >> marks; 23 | m[name] += marks; 24 | } 25 | else if (t == 2) 26 | m.erase(name); 27 | else 28 | cout << m[name] << "\n"; 29 | } 30 | return 0; 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/VectorErase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | int size, a; 11 | cin >> size; 12 | vector v; 13 | 14 | for(int i = 0; i < size; i ++) { 15 | cin >> a; 16 | v.push_back(a); 17 | } 18 | 19 | int p; 20 | cin >> p; 21 | v.erase(v.begin() + p - 1); 22 | 23 | int m, n; 24 | cin >> m >> n; 25 | v.erase(v.begin() + m - 1, v.begin() + n -1); 26 | 27 | cout << v.size() << endl; 28 | for(int i = 0; i < v.size(); i ++) 29 | cout << v[i] << " "; 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Data Structures/JavaSubarray.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | Scanner sc = new Scanner(System.in); 8 | int n = sc.nextInt(); 9 | int [] arr = new int [n]; 10 | for(int i = 0; i < n; i ++) { 11 | arr[i] = sc.nextInt(); 12 | } 13 | 14 | int count = 0, sum = 0; 15 | for(int i = 0; i < n; i ++) { 16 | for(int j = i; j < n; j ++) { 17 | sum += arr[j]; 18 | if(sum < 0) count ++; 19 | } 20 | sum = 0; 21 | } 22 | System.out.println(count); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/PrintPretty.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int T; cin >> T; 7 | cout << setiosflags(ios::uppercase); 8 | cout << setw(0xf) << internal; 9 | while(T--) { 10 | double A; cin >> A; 11 | double B; cin >> B; 12 | double C; cin >> C; 13 | cout << hex << left << showbase << nouppercase; 14 | cout << (long long)A << endl; 15 | 16 | cout << dec << right << setw(15) << setfill('_') << showpos << fixed << setprecision(2); 17 | cout << B << endl; 18 | 19 | cout << uppercase << noshowpos << scientific << setprecision(9); 20 | cout << C << endl; 21 | 22 | 23 | } 24 | return 0; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaStaticInitializerBlock.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | static int B, H; 9 | static boolean flag; 10 | static Scanner sc = new Scanner(System.in); 11 | static{ 12 | B = sc.nextInt(); 13 | H = sc.nextInt(); 14 | if(B > 0 && H > 0) flag = true; 15 | else System.out.println("java.lang.Exception: Breadth and height must be positive"); 16 | } 17 | public static void main(String[] args){ 18 | if(flag){ 19 | int area=B*H; 20 | System.out.print(area); 21 | } 22 | 23 | }//end of main 24 | 25 | }//end of class 26 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaLoops2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | 4 | class Solution{ 5 | public static void main(String []argh){ 6 | Scanner in = new Scanner(System.in); 7 | int t=in.nextInt(); 8 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | 6 | void check(int i, int j, int first, int last, int n) { 7 | if(n >=1 ){ 8 | if (i == first || i == last || j == first || j == last) 9 | printf("%d ", n); 10 | else 11 | check(i, j, first + 1, last - 1, n - 1); 12 | } 13 | } 14 | 15 | int main() 16 | { 17 | int n; 18 | scanf("%d", &n); 19 | int rows = 2 * n - 1; 20 | 21 | for (int i = 0; i < rows; i ++) { 22 | for (int j = 0; j < rows; j ++) { 23 | check(i, j, 0, rows - 1, n); 24 | } 25 | printf("\n"); 26 | } 27 | return 0; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Inheritance/InheritanceIntroduction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | class Triangle{ 10 | public: 11 | void triangle(){ 12 | cout << "I am a triangle\n"; 13 | } 14 | }; 15 | 16 | class Isosceles : public Triangle{ 17 | public: 18 | void isosceles(){ 19 | cout << "I am an isosceles triangle\n"; 20 | } 21 | void description() { 22 | cout << "In an isosceles triangle two sides are equal\n"; 23 | } 24 | }; 25 | 26 | int main(){ 27 | Isosceles isc; 28 | isc.isosceles(); 29 | isc.description(); 30 | isc.triangle(); 31 | return 0; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/ValidUsernameRegularExpression.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class UsernameValidator { 3 | 4 | public static final String regularExpression = "\\b[a-zA-Z]\\w{7,29}\\b"; 5 | } 6 | 7 | 8 | public class Solution { 9 | private static final Scanner scan = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = Integer.parseInt(scan.nextLine()); 13 | while (n-- != 0) { 14 | String userName = scan.nextLine(); 15 | 16 | if (userName.matches(UsernameValidator.regularExpression)) { 17 | System.out.println("Valid"); 18 | } else { 19 | System.out.println("Invalid"); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Conditionals and Loops/BitwiseOperators.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void calculate_the_maximum(int n, int k) { 7 | int amax, omax, xmax; 8 | amax = omax = xmax = 0; 9 | for(int i = 1; i < n; i ++) { 10 | for(int j = i+1; j <= n; j ++) { 11 | amax = (i & j) > amax && (i & j) < k ? i & j : amax; 12 | omax = (i | j) > omax && (i | j) < k ? i | j : omax; 13 | xmax = (i ^ j) > xmax && (i ^ j) < k ? i ^ j : xmax; 14 | } 15 | } 16 | printf("%d\n", amax); 17 | printf("%d\n", omax); 18 | printf("%d\n", xmax); 19 | } 20 | 21 | int main() { 22 | int n, k; 23 | 24 | scanf("%d %d", &n, &k); 25 | calculate_the_maximum(n, k); 26 | 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Inheritance/MultiLevelInheritance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | class Triangle{ 9 | public: 10 | void triangle(){ 11 | cout<<"I am a triangle\n"; 12 | } 13 | }; 14 | 15 | class Isosceles : public Triangle{ 16 | public: 17 | void isosceles(){ 18 | cout<<"I am an isosceles triangle\n"; 19 | } 20 | }; 21 | 22 | class Equilateral : public Isosceles { 23 | public: 24 | void equilateral(){ 25 | cout<<"I am an equilateral triangle\n"; 26 | } 27 | }; 28 | 29 | int main(){ 30 | 31 | Equilateral eqr; 32 | eqr.equilateral(); 33 | eqr.isosceles(); 34 | eqr.triangle(); 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Strings/TextAlignment.py: -------------------------------------------------------------------------------- 1 | thickness = int(input()) #This must be an odd number 2 | c = 'H' 3 | 4 | #Top Cone 5 | for i in range(thickness): 6 | print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1)) 7 | 8 | #Top Pillars 9 | for i in range(thickness+1): 10 | print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6)) 11 | 12 | #Middle Belt 13 | for i in range((thickness+1)//2): 14 | print((c*thickness*5).center(thickness*6)) 15 | 16 | #Bottom Pillars 17 | for i in range(thickness+1): 18 | print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6)) 19 | 20 | #Bottom Cone 21 | for i in range(thickness): 22 | print(((c*(thickness-i-1)).rjust(thickness)+c+(c*(thickness-i-1)).ljust(thickness)).rjust(thickness*6)) 23 | 24 | 25 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/LowerBoundStl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | int size, a; 11 | cin >> size; 12 | vector v; 13 | 14 | for(int i = 0; i < size; i ++) { 15 | cin >> a; 16 | v.push_back(a); 17 | } 18 | 19 | int q; 20 | cin >> q; 21 | 22 | for(int i = 0; i < q; i ++) { 23 | int n; 24 | cin >> n; 25 | vector :: iterator low = lower_bound(v.begin(), v.end(), n); 26 | if (v[low - v.begin()] == n) 27 | cout << "Yes" << " " << low - v.begin() + 1 << endl; 28 | else 29 | cout << "No" << " " << low - v.begin() + 1 << endl; 30 | } 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/arithmetic_operators.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Calculate the area of a rectangle. 3 | * 4 | * length: The length of the rectangle. 5 | * width: The width of the rectangle. 6 | * 7 | * Return a number denoting the rectangle's area. 8 | **/ 9 | function getArea(length, width) { 10 | let area; 11 | // Write your code here 12 | area = length * width; 13 | return area; 14 | } 15 | 16 | /** 17 | * Calculate the perimeter of a rectangle. 18 | * 19 | * length: The length of the rectangle. 20 | * width: The width of the rectangle. 21 | * 22 | * Return a number denoting the perimeter of a rectangle. 23 | **/ 24 | function getPerimeter(length, width) { 25 | let perimeter; 26 | // Write your code here 27 | perimeter = length + width; 28 | perimeter *= 2; 29 | return perimeter; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/STL/SetsStl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | 10 | int main() { 11 | int q; 12 | cin >> q; 13 | set s; 14 | for(int i = 0; i < q; i ++) { 15 | int t, x; 16 | cin >> t >> x; 17 | switch(t) { 18 | case 1: 19 | s.insert(x); 20 | break; 21 | case 2: 22 | s.erase(x); 23 | break; 24 | case 3: 25 | set :: iterator p = s.find(x); 26 | if (p == s.end()) cout << "No" << endl; 27 | else cout << "Yes" << endl; 28 | break; 29 | 30 | } 31 | } 32 | return 0; 33 | } 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaIfElse.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | 12 | 13 | private static final Scanner scanner = new Scanner(System.in); 14 | 15 | public static void main(String[] args) { 16 | int N = scanner.nextInt(); 17 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 18 | if(N % 2 == 1) { 19 | System.out.println("Weird"); 20 | } else { 21 | if (N >= 6 && N <= 20) { 22 | System.out.println("Weird"); 23 | } else { 24 | System.out.println("Not Weird"); 25 | } 26 | } 27 | scanner.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/Basic Data Types/Lists.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | arr = [] 3 | for i in range(int(input())): 4 | s = input().split() 5 | for i in range(1, len(s)): 6 | s[i] = int(s[i]) 7 | 8 | if(s[0] == "insert"): 9 | arr.insert(s[1], s[2]) 10 | 11 | elif (s[0] == "append"): 12 | arr.append(s[1]) 13 | 14 | elif (s[0] == "remove"): 15 | arr.remove(s[1]) 16 | 17 | elif (s[0] == "pop"): 18 | arr.pop() 19 | 20 | elif (s[0] == "print"): 21 | print(arr) 22 | 23 | elif (s[0] == "sort"): 24 | arr.sort() 25 | 26 | elif (s[0] == "reverse"): 27 | arr.reverse() 28 | 29 | 30 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Structs and Enums/BoxesThroughATunnel.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX_HEIGHT 41 4 | 5 | struct box 6 | { 7 | int length; 8 | int height; 9 | int width; 10 | }; 11 | 12 | typedef struct box box; 13 | 14 | int get_volume(box b) { 15 | return (b.length * b.height * b.width); 16 | } 17 | 18 | int is_lower_than_max_height(box b) { 19 | if(b.height < MAX_HEIGHT) return 1; 20 | else return 0; 21 | } 22 | 23 | int main() 24 | { 25 | int n; 26 | scanf("%d", &n); 27 | box *boxes = malloc(n * sizeof(box)); 28 | for (int i = 0; i < n; i++) { 29 | scanf("%d%d%d", &boxes[i].length, &boxes[i].width, &boxes[i].height); 30 | } 31 | for (int i = 0; i < n; i++) { 32 | if (is_lower_than_max_height(boxes[i])) { 33 | printf("%d\n", get_volume(boxes[i])); 34 | } 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/PreprocessorSolution.cpp: -------------------------------------------------------------------------------- 1 | #define toStr(x) #x 2 | #define io(s) cin >> s 3 | #define foreach(list, index) for(int index = 0; index < list.size(); index++) 4 | #define FUNCTION(name, op) void name(int &x, int y){ if(!(x op y)) x = y; } 5 | #define INF 1e9 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | #if !defined toStr || !defined io || !defined FUNCTION || !defined INF 12 | #error Missing preprocessor definitions 13 | #endif 14 | 15 | FUNCTION(minimum, <) 16 | FUNCTION(maximum, >) 17 | 18 | int main(){ 19 | int n; cin >> n; 20 | vector v(n); 21 | foreach(v, i) { 22 | io(v)[i]; 23 | } 24 | int mn = INF; 25 | int mx = -INF; 26 | foreach(v, i) { 27 | minimum(mn, v[i]); 28 | maximum(mx, v[i]); 29 | } 30 | int ans = mx - mn; 31 | cout << toStr(Result =) <<' '<< ans; 32 | return 0; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/ConditionalStatements.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | int main() 8 | { 9 | int n; 10 | cin >> n; 11 | cin.ignore(numeric_limits::max(), '\n'); 12 | 13 | // Write Your Code Here 14 | 15 | if ( n==1 ) { 16 | printf("one"); 17 | } else if ( n==2 ) { 18 | printf("two"); 19 | } else if ( n==3 ) { 20 | printf("three"); 21 | } else if ( n==4 ) { 22 | printf("four"); 23 | } else if ( n==5 ) { 24 | printf("five"); 25 | } else if ( n==6 ) { 26 | printf("six"); 27 | } else if ( n==7 ) { 28 | printf("seven"); 29 | } else if ( n==8 ) { 30 | printf("eight"); 31 | } else if ( n==9 ) { 32 | printf("nine"); 33 | } else { 34 | printf("Greater than 9"); 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/TagContentExtractor.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution{ 8 | public static void main(String[] args){ 9 | 10 | Scanner in = new Scanner(System.in); 11 | int testCases = Integer.parseInt(in.nextLine()); 12 | while(testCases>0){ 13 | String line = in.nextLine(); 14 | 15 | String s = "<([^>]+)>([^<>]+)"; 16 | Pattern p = Pattern.compile(s); 17 | Matcher m = p.matcher(line); 18 | boolean found = true; 19 | while(m.find()) { 20 | System.out.println(m.group(2)); 21 | found = false; 22 | } 23 | 24 | if(found) { 25 | System.out.println("None"); 26 | } 27 | 28 | testCases--; 29 | } 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Data Structures/JavaArraylist.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | Scanner sc = new Scanner(System.in); 8 | int l = sc.nextInt(); 9 | ArrayList [ ] list = new ArrayList[l]; 10 | 11 | for(int i = 0; i < l; i ++) { 12 | int n = sc.nextInt(); 13 | list[i] = new ArrayList(); 14 | while(n -- > 0) { 15 | list[i].add(sc.nextInt()); 16 | } 17 | } 18 | 19 | int q = sc.nextInt(); 20 | while(q -- > 0) { 21 | int x = sc.nextInt(); 22 | int y = sc.nextInt(); 23 | 24 | try { 25 | System.out.println(list[x - 1].get(y - 1)); 26 | } catch (Exception e) { 27 | System.out.println("ERROR!"); 28 | } 29 | } 30 | 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Inheritance/RectangleArea.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Rectangle { 6 | protected: 7 | int width; 8 | int height; 9 | 10 | public: 11 | void display() { 12 | cout << width << ' ' << height << endl; 13 | } 14 | }; 15 | 16 | class RectangleArea : public Rectangle { 17 | public: 18 | void read_input() { 19 | cin >> width >> height; 20 | } 21 | void display() { 22 | cout << width * height; 23 | } 24 | }; 25 | 26 | 27 | int main() 28 | { 29 | /* 30 | * Declare a RectangleArea object 31 | */ 32 | RectangleArea r_area; 33 | 34 | /* 35 | * Read the width and height 36 | */ 37 | r_area.read_input(); 38 | 39 | /* 40 | * Print the width and height 41 | */ 42 | r_area.Rectangle::display(); 43 | 44 | /* 45 | * Print the area 46 | */ 47 | r_area.display(); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaSubstringComparisons.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution { 4 | 5 | public static String getSmallestAndLargest(String s, int k) { 6 | String substring = s.substring(0, k); 7 | String smallest = substring; 8 | String largest = substring; 9 | 10 | int n = s.length() - k + 1; 11 | 12 | for(int i = 1; i < n; i ++) { 13 | substring = s.substring(i, i + k); 14 | smallest = substring.compareTo(smallest) < 0 ? substring : smallest; 15 | largest = substring.compareTo(largest) > 0 ? substring : largest; 16 | } 17 | return smallest + "\n" + largest; 18 | } 19 | 20 | 21 | public static void main(String[] args) { 22 | Scanner scan = new Scanner(System.in); 23 | String s = scan.next(); 24 | int k = scan.nextInt(); 25 | scan.close(); 26 | 27 | System.out.println(getSmallestAndLargest(s, k)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Functions/StudentsMarksSum.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int marks_summation(int* marks, int number_of_students, char gender) { 7 | int sum = 0; 8 | if (gender == 'b'){ 9 | for(int i = 0; i < number_of_students; i += 2) sum += marks[i]; 10 | } else { 11 | for (int i = 1; i < number_of_students; i += 2) sum += marks[i]; 12 | } 13 | return sum; 14 | } 15 | 16 | int main() { 17 | int number_of_students; 18 | char gender; 19 | int sum; 20 | 21 | scanf("%d", &number_of_students); 22 | int *marks = (int *) malloc(number_of_students * sizeof (int)); 23 | 24 | for (int student = 0; student < number_of_students; student++) { 25 | scanf("%d", (marks + student)); 26 | } 27 | 28 | scanf(" %c", &gender); 29 | sum = marks_summation(marks, number_of_students, gender); 30 | printf("%d", sum); 31 | free(marks); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Structs and Enums/SmallTrianglesLargeTriangles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct triangle 6 | { 7 | int a; 8 | int b; 9 | int c; 10 | }; 11 | 12 | typedef struct triangle triangle; 13 | int area(triangle t) { 14 | return((t.a+t.b+t.c)*(t.a+t.b-t.c)*(t.a+t.c-t.b)*(t.b+t.c-t.a)); 15 | } 16 | void sort_by_area(triangle* tr, int n) { 17 | for(int i = 0; i < n - 1; i ++) 18 | for(int j = i + 1; j < n; j ++) 19 | if(area(tr[i]) > area(tr[j])) { 20 | triangle t = tr[i]; 21 | tr[i] = tr[j]; 22 | tr[j] = t; 23 | } 24 | } 25 | 26 | int main() 27 | { 28 | int n; 29 | scanf("%d", &n); 30 | triangle *tr = malloc(n * sizeof(triangle)); 31 | for (int i = 0; i < n; i++) { 32 | scanf("%d%d%d", &tr[i].a, &tr[i].b, &tr[i].c); 33 | } 34 | sort_by_area(tr, n); 35 | for (int i = 0; i < n; i++) { 36 | printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/BigNumber/JavaBigDecimal.java: -------------------------------------------------------------------------------- 1 | import java.math.BigDecimal; 2 | import java.util.*; 3 | class Solution{ 4 | 5 | public static void main(String []args){ 6 | //Input 7 | Scanner sc= new Scanner(System.in); 8 | int n=sc.nextInt(); 9 | String []s=new String[n+2]; 10 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | void printKMax(int arr[], int n, int k){ 6 | deque d; 7 | for(int i=0;i=arr[d.back()]){ 10 | d.pop_back(); 11 | } 12 | d.push_back(i); 13 | } 14 | for(int i=k;i=arr[d.back()]) 22 | { 23 | d.pop_back(); 24 | } 25 | d.push_back(i); 26 | } 27 | cout<> t; 35 | while(t>0) { 36 | int n,k; 37 | cin >> n >> k; 38 | int i; 39 | int arr[n]; 40 | for(i=0;i> arr[i]; 42 | printKMax(arr, n, k); 43 | t--; 44 | } 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaAnagrams.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution { 4 | 5 | static boolean isAnagram(String a, String b) { 6 | if(a.length() != b.length()) 7 | return false; 8 | 9 | a = a.toLowerCase(); 10 | b = b.toLowerCase(); 11 | 12 | int [] frequency = new int [26]; 13 | 14 | for(char c: a.toCharArray()) { 15 | frequency[c-97]++; 16 | } 17 | for(char c: b.toCharArray()) { 18 | frequency[c-97]--; 19 | } 20 | 21 | for (int i : frequency) { 22 | if(i != 0) return false; 23 | } 24 | 25 | return true; 26 | } 27 | 28 | public static void main(String[] args) { 29 | 30 | Scanner scan = new Scanner(System.in); 31 | String a = scan.next(); 32 | String b = scan.next(); 33 | scan.close(); 34 | boolean ret = isAnagram(a, b); 35 | System.out.println( (ret) ? "Anagrams" : "Not Anagrams" ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Strings/JavaRegex2DuplicateWords.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.util.regex.Matcher; 3 | import java.util.regex.Pattern; 4 | 5 | public class DuplicateWords { 6 | 7 | public static void main(String[] args) { 8 | 9 | String regex = "(\\b\\w+\\b)(\\s+\\1\\b)+"; 10 | Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); 11 | 12 | Scanner in = new Scanner(System.in); 13 | int numSentences = Integer.parseInt(in.nextLine()); 14 | 15 | while (numSentences-- > 0) { 16 | String input = in.nextLine(); 17 | 18 | Matcher m = p.matcher(input); 19 | 20 | // Check for subsequences of input that match the compiled pattern 21 | while (m.find()) { 22 | input = input.replaceAll(m.group(0), m.group(1)); 23 | } 24 | 25 | // Prints the modified sentence. 26 | System.out.println(input); 27 | } 28 | 29 | in.close(); 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaDatatypes.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.lang.Math; 4 | 5 | 6 | 7 | class Solution{ 8 | public static void main(String []argh) 9 | { 10 | 11 | 12 | 13 | Scanner sc = new Scanner(System.in); 14 | int t=sc.nextInt(); 15 | 16 | for(int i=0;i=-128 && x<=127)System.out.println("* byte"); 23 | if(x >= -Math.pow(2,15) && x <= Math.pow(2,15)-1)System.out.println("* short");; 24 | if(x >= -Math.pow(2,31) && x <= Math.pow(2,31)-1)System.out.println("* int");; 25 | if(x >= -Math.pow(2,63) && x <= Math.pow(2,63)-1)System.out.println("* long");; 26 | } 27 | catch(Exception e) 28 | { 29 | System.out.println(sc.next()+" can't be fitted anywhere."); 30 | } 31 | 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Data Structures/JavaList.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) { 10 | 11 | Scanner sc = new Scanner(System.in); 12 | LinkedList list = new LinkedList(); 13 | int n = sc.nextInt(); 14 | for(int i = 0; i < n; i ++) { 15 | list.add(sc.nextInt()); 16 | } 17 | int q = sc.nextInt(); 18 | while(q-- > 0) { 19 | String s = sc.next(); 20 | if(s.equals("Insert")) { 21 | int index = sc.nextInt(); 22 | int value = sc.nextInt(); 23 | list.add(index, value); 24 | } else { 25 | int value = sc.nextInt(); 26 | list.remove(value); 27 | } 28 | } 29 | Iterator iterator = list.iterator(); 30 | while(iterator.hasNext()) { 31 | System.out.print(iterator.next() + " "); 32 | } 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/InheritedCode.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | class BadLengthException : public exception { 8 | int n; 9 | public: 10 | BadLengthException(int num) { 11 | n = num; 12 | } 13 | int what() { 14 | return n; 15 | } 16 | }; 17 | 18 | bool checkUsername(string username) { 19 | bool isValid = true; 20 | int n = username.length(); 21 | if(n < 5) { 22 | throw BadLengthException(n); 23 | } 24 | for(int i = 0; i < n-1; i++) { 25 | if(username[i] == 'w' && username[i+1] == 'w') { 26 | isValid = false; 27 | } 28 | } 29 | return isValid; 30 | } 31 | 32 | int main() { 33 | int T; cin >> T; 34 | while(T--) { 35 | string username; 36 | cin >> username; 37 | try { 38 | bool isValid = checkUsername(username); 39 | if(isValid) { 40 | cout << "Valid" << '\n'; 41 | } else { 42 | cout << "Invalid" << '\n'; 43 | } 44 | } catch (BadLengthException e) { 45 | cout << "Too short: " << e.what() << '\n'; 46 | } 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/ClassTemplateSpecialization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | enum class Fruit { apple, orange, pear }; 4 | enum class Color { red, green, orange }; 5 | 6 | template struct Traits; 7 | template <> 8 | struct Traits{ 9 | static string name(int index){ 10 | switch(index){ 11 | case 0:return "apple"; 12 | case 1: return "orange" ; 13 | case 2: return "pear"; 14 | } 15 | return "unknown"; 16 | } 17 | }; 18 | template <> 19 | struct Traits{ 20 | static string name(int index){ 21 | switch(index){ 22 | case 0:return "red"; 23 | case 1: return "green" ; 24 | case 2: return "orange"; 25 | } 26 | return "unknown"; 27 | } 28 | }; 29 | 30 | int main() 31 | { 32 | int t = 0; std::cin >> t; 33 | 34 | for (int i=0; i!=t; ++i) { 35 | int index1; std::cin >> index1; 36 | int index2; std::cin >> index2; 37 | cout << Traits::name(index1) << " "; 38 | cout << Traits::name(index2) << "\n"; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Introduction/ForLoop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // Complete the code. 7 | int start, end; 8 | scanf("%d%d", &start, &end); 9 | for (int i = start; i <= end; i ++) { 10 | if(i >= 1 && i <= 9) { 11 | if(i == 1) { 12 | printf("one\n"); 13 | } else if (i == 2) { 14 | printf("two\n"); 15 | } else if (i == 3) { 16 | printf("three\n"); 17 | } else if (i == 4) { 18 | printf("four\n"); 19 | } else if (i == 5) { 20 | printf("five\n"); 21 | } else if (i == 6) { 22 | printf("six\n"); 23 | } else if (i == 7) { 24 | printf("seven\n"); 25 | } else if (i == 8) { 26 | printf("eight\n"); 27 | } else if (i == 9) { 28 | printf("nine\n"); 29 | } 30 | } else if (i > 9){ 31 | if(i % 2 == 0) { 32 | printf("even\n"); 33 | } else { 34 | printf("odd\n"); 35 | } 36 | } 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Conditionals and Loops/ForLoopInC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | int a, b; 9 | scanf("%d\n%d", &a, &b); 10 | // Complete the code. 11 | for (int i = a; i <= b; i ++) { 12 | if(i >= 1 && i <= 9) { 13 | if(i == 1) { 14 | printf("one\n"); 15 | } else if(i == 2) { 16 | printf("two\n"); 17 | } else if(i == 3) { 18 | printf("three\n"); 19 | } else if(i == 4) { 20 | printf("four\n"); 21 | } else if(i == 5) { 22 | printf("five\n"); 23 | } else if(i == 6) { 24 | printf("six\n"); 25 | } else if(i == 7) { 26 | printf("seven\n"); 27 | } else if(i == 8) { 28 | printf("eight\n"); 29 | } else if(i == 9) { 30 | printf("nine\n"); 31 | } 32 | } else { 33 | if(i % 2 == 0) { 34 | printf("even\n"); 35 | } else { 36 | printf("odd\n"); 37 | } 38 | 39 | } 40 | } 41 | return 0; 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/ClassesAndObjects.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | class Student { 9 | int scores[5]; 10 | public: 11 | void input(){ 12 | for(int i = 0; i < 5; i++) { 13 | cin >> scores[i]; 14 | } 15 | } 16 | int calculateTotalScore(){ 17 | int sum = 0; 18 | for (int i = 0; i < 5; i++) { 19 | sum += scores[i]; 20 | } 21 | return sum; 22 | } 23 | }; 24 | int main() { 25 | int n; // number of students 26 | cin >> n; 27 | Student *s = new Student[n]; // an array of n students 28 | 29 | for(int i = 0; i < n; i++){ 30 | s[i].input(); 31 | } 32 | 33 | // calculate kristen's score 34 | int kristen_score = s[0].calculateTotalScore(); 35 | 36 | // determine how many students scored higher than kristen 37 | int count = 0; 38 | for(int i = 1; i < n; i++){ 39 | int total = s[i].calculateTotalScore(); 40 | if(total > kristen_score){ 41 | count++; 42 | } 43 | } 44 | 45 | // print result 46 | cout << count; 47 | 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/ClassTemplates.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | template 10 | class AddElements { 11 | T element; 12 | public: 13 | AddElements(T val) : element(val){} 14 | T add(T val) { 15 | return element + val; 16 | } 17 | T concatenate(T val) { 18 | return element + val; 19 | } 20 | }; 21 | 22 | int main () { 23 | int n,i; 24 | cin >> n; 25 | for(i=0;i> type; 28 | if(type=="float") { 29 | double element1,element2; 30 | cin >> element1 >> element2; 31 | AddElements myfloat (element1); 32 | cout << myfloat.add(element2) << endl; 33 | } 34 | else if(type == "int") { 35 | int element1, element2; 36 | cin >> element1 >> element2; 37 | AddElements myint (element1); 38 | cout << myint.add(element2) << endl; 39 | } 40 | else if(type == "string") { 41 | string element1, element2; 42 | cin >> element1 >> element2; 43 | AddElements mystring (element1); 44 | cout << mystring.concatenate(element2) << endl; 45 | } 46 | } 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/OverloadOperators.cpp: -------------------------------------------------------------------------------- 1 | //Operator Overloading 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Complex 8 | { 9 | public: 10 | int a,b; 11 | void input(string s) 12 | { 13 | int v1=0; 14 | int i=0; 15 | while(s[i]!='+') 16 | { 17 | v1=v1*10+s[i]-'0'; 18 | i++; 19 | } 20 | while(s[i]==' ' || s[i]=='+'||s[i]=='i') 21 | { 22 | i++; 23 | } 24 | int v2=0; 25 | while(i>s1; 55 | cin>>s2; 56 | x.input(s1); 57 | y.input(s2); 58 | Complex z=x+y; 59 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | class Server { 10 | private: 11 | static int load; 12 | public: 13 | static int compute(long long A, long long B) { 14 | load += 1; 15 | if(A < 0) { 16 | throw std::invalid_argument("A is negative"); 17 | } 18 | vector v(A, 0); 19 | int real = -1, cmplx = sqrt(-1); 20 | if(B == 0) throw 0; 21 | real = (A/B)*real; 22 | int ans = v.at(B); 23 | return real + A - B*ans; 24 | } 25 | static int getLoad() { 26 | return load; 27 | } 28 | }; 29 | int Server::load = 0; 30 | 31 | int main() { 32 | int T; cin >> T; 33 | while(T--) { 34 | long long A, B; 35 | cin >> A >> B; 36 | Server s; 37 | try { 38 | int result = s.compute(A, B); 39 | cout << result << endl; 40 | } catch (std::bad_alloc& e) { 41 | cout << "Not enough memory\n"; 42 | } catch (std::exception& e) { 43 | cout << "Exception: " << e.what() << endl; 44 | } catch (exception &e){ 45 | cout << "Other Exception\n"; 46 | } catch (int i) { 47 | cout << "Other Exception\n"; 48 | } 49 | } 50 | cout << Server::getLoad() << endl; 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Shell/Bash/FunctionsAndFractalsRecursiveTreesBash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | declare -A matrix 3 | num_rows=63 4 | num_columns=100 5 | 6 | declare -a roots 7 | roots[0]=50 8 | 9 | for ((i=1;i<=num_rows;i++)) do 10 | for ((j=1;j<=num_columns;j++)) do 11 | matrix[$i,$j]='_' 12 | done 13 | done 14 | 15 | read n 16 | j=63 17 | len=16 18 | for ((i=1; i<=n; i++)) do 19 | lim=$((${#roots[@]}-1)) 20 | elems=${#roots[@]} 21 | old_j=$j 22 | for((k=0; k<=lim; k++)) do 23 | pos=${roots[$k]} 24 | #print the trunk 25 | for((m=0; m<=len-1; m++)) do 26 | matrix[$j,$pos]='1' 27 | ((j--)) 28 | done 29 | #print the branches 30 | for((m=1; m<=len; m++)) do 31 | matrix[$j,$((pos-m))]='1' 32 | matrix[$j,$((pos+m))]='1' 33 | ((j--)) 34 | done 35 | roots=("${roots[@]}" "$((pos-m+1))" "$((pos+m-1))" ) 36 | if (( $k < $lim )) 37 | then 38 | j=$old_j 39 | fi 40 | done 41 | for((k=0; k<$elems; k++)) do 42 | unset roots[$k] 43 | done 44 | roots=( "${roots[@]}" ) 45 | len=$((len/2)) 46 | done 47 | 48 | # print the matrix 49 | for ((i=1;i<=num_rows;i++)) do 50 | for ((j=1;j<=num_columns;j++)) do 51 | printf ${matrix[$i,$j]} 52 | done 53 | printf "\n" 54 | done 55 | 56 | 57 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/OperatorOverloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | class Matrix{ 8 | public: 9 | vector> a; 10 | Matrix& operator +(const Matrix &y) { 11 | for(int m = 0; m < y.a.size(); m++) 12 | for(int n = 0; n < y.a[0].size(); n ++) { 13 | a[m][n] = a[m][n] + y.a[m][n]; 14 | } 15 | return *this; 16 | } 17 | }; 18 | 19 | int main () { 20 | int cases,k; 21 | cin >> cases; 22 | for(k=0;k> n >> m; 28 | for(i=0;i b; 30 | int num; 31 | for(j=0;j> num; 33 | b.push_back(num); 34 | } 35 | x.a.push_back(b); 36 | } 37 | for(i=0;i b; 39 | int num; 40 | for(j=0;j> num; 42 | b.push_back(num); 43 | } 44 | y.a.push_back(b); 45 | } 46 | result = x+y; 47 | for(i=0;i 2 | #include 3 | #include 4 | 5 | int next_permutation(int n, char **s) 6 | { 7 | // This is a standard algorithm to generate permutations of a sequence in 8 | // lexicographic order 9 | // Use this to understand how the algorithm works https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order 10 | 11 | int k, l; 12 | // 1. find the largest index k such that s[k] < s[k+1] 13 | for (k = n - 2; k >= 0; k --) { 14 | if(strcmp(s[k], s[k+1]) < 0) break; 15 | } 16 | if (k < 0) return 0; 17 | 18 | // 2. find the largest index l greater than k such that s[k] < s[l] 19 | for (l = n -1; l > k; l --) { 20 | if(strcmp(s[k], s[l]) < 0) break; 21 | } 22 | 23 | // 3. swap elements present at k, l 24 | char * tmp = s[k]; 25 | s[k] = s[l]; 26 | s[l] = tmp; 27 | 28 | // 4. reverse the sequence of elements from k+1 to n 29 | for(int i = k + 1, j = n -1; i < j; i ++, j --) { 30 | tmp = s[i]; 31 | s[i] = s[j]; 32 | s[j] = tmp; 33 | } 34 | return 1; 35 | } 36 | 37 | int main() 38 | { 39 | char **s; 40 | int n; 41 | scanf("%d", &n); 42 | s = calloc(n, sizeof(char*)); 43 | for (int i = 0; i < n; i++) 44 | { 45 | s[i] = calloc(11, sizeof(char)); 46 | scanf("%s", s[i]); 47 | } 48 | do 49 | { 50 | for (int i = 0; i < n; i++) 51 | printf("%s%c", s[i], i == n - 1 ? '\n' : ' '); 52 | } while (next_permutation(n, s)); 53 | for (int i = 0; i < n; i++) 54 | free(s[i]); 55 | free(s); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /TUTORIALS/Javascript/data_types.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The variables 'firstInteger', 'firstDecimal', and 'firstString' are declared for you -- do not modify them. 3 | * Print three lines: 4 | * 1. The sum of 'firstInteger' and the Number representation of 'secondInteger'. 5 | * 2. The sum of 'firstDecimal' and the Number representation of 'secondDecimal'. 6 | * 3. The concatenation of 'firstString' and 'secondString' ('firstString' must be first). 7 | * 8 | * Parameter(s): 9 | * secondInteger - The string representation of an integer. 10 | * secondDecimal - The string representation of a floating-point number. 11 | * secondString - A string consisting of one or more space-separated words. 12 | **/ 13 | function performOperation(secondInteger, secondDecimal, secondString) { 14 | // Declare a variable named 'firstInteger' and initialize with integer value 4. 15 | const firstInteger = 4; 16 | 17 | // Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0. 18 | const firstDecimal = 4.0; 19 | 20 | // Declare a variable named 'firstString' and initialize with the string "HackerRank". 21 | const firstString = 'HackerRank '; 22 | 23 | // Write code that uses console.log to print the sum of the 'firstInteger' and 'secondInteger' (converted to a Number type) on a new line. 24 | console.log(firstInteger + +secondInteger); 25 | 26 | // Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number type) on a new line. 27 | console.log(firstDecimal + +secondDecimal); 28 | 29 | // Write code that uses console.log to print the concatenation of 'firstString' and 'secondString' on a new line. The variable 'firstString' must be printed first. 30 | console.log(firstString + secondString) 31 | } 32 | 33 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/Class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Student { 6 | int age; 7 | string first_name; 8 | string last_name; 9 | int standard; 10 | 11 | public: 12 | void set_age(int age); 13 | void set_first_name(string fname); 14 | void set_last_name(string lname); 15 | void set_standard(int standard); 16 | 17 | int get_age(); 18 | string get_first_name(); 19 | string get_last_name(); 20 | int get_standard(); 21 | 22 | string to_string(); 23 | 24 | }; 25 | 26 | void Student :: set_age(int a) { 27 | age = a; 28 | } 29 | 30 | void Student :: set_first_name(string fname) { 31 | first_name = fname; 32 | } 33 | 34 | void Student :: set_last_name(string lname) { 35 | last_name = lname; 36 | } 37 | 38 | void Student :: set_standard(int s) { 39 | standard = s; 40 | } 41 | 42 | int Student :: get_age() {return age;} 43 | string Student :: get_first_name() {return first_name;} 44 | string Student :: get_last_name() { return last_name;} 45 | int Student :: get_standard() {return standard;} 46 | 47 | string Student :: to_string() { 48 | char ch = ','; 49 | stringstream ss; 50 | ss << age << ch << first_name << ch << last_name << ch << standard; 51 | return ss.str(); 52 | } 53 | 54 | int main() { 55 | int age, standard; 56 | string first_name, last_name; 57 | 58 | cin >> age >> first_name >> last_name >> standard; 59 | 60 | Student st; 61 | st.set_age(age); 62 | st.set_standard(standard); 63 | st.set_first_name(first_name); 64 | st.set_last_name(last_name); 65 | 66 | cout << st.get_age() << "\n"; 67 | cout << st.get_last_name() << ", " << st.get_first_name() << "\n"; 68 | cout << st.get_standard() << "\n"; 69 | cout << "\n"; 70 | cout << st.to_string(); 71 | 72 | return 0; 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Other Concepts/AttendingWorkshops.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | struct Workshops { 5 | int start_time; 6 | int duration; 7 | int end_time; 8 | }; 9 | 10 | struct Available_Workshops { 11 | int n; 12 | vector w; 13 | }; 14 | 15 | Available_Workshops *initialize(int *start_time, int *duration, int n) { 16 | Available_Workshops *tmp = new(Available_Workshops); 17 | Workshops ws; 18 | 19 | tmp -> n = n; 20 | for (int i=0;i w.push_back(ws); 25 | } 26 | 27 | return tmp; 28 | } 29 | 30 | bool compare(Workshops w1, Workshops w2) { 31 | return (w1.end_time < w2.end_time); 32 | } 33 | 34 | int CalculateMaxWorkshops(Available_Workshops* ptr) { 35 | // sort workshops by end_time 36 | sort(ptr->w.begin(),ptr->w.end(),compare); 37 | 38 | // interval scheduling 39 | int last_processed_time=-1; 40 | int maxWorkshops=0; 41 | for (int i=0;in;i++) { 42 | if (ptr->w[i].start_time >= last_processed_time) { 43 | last_processed_time=ptr->w[i].end_time; 44 | maxWorkshops++; 45 | } 46 | } 47 | 48 | return maxWorkshops; 49 | } 50 | int main(int argc, char *argv[]) { 51 | int n; // number of workshops 52 | cin >> n; 53 | // create arrays of unknown size n 54 | int* start_time = new int[n]; 55 | int* duration = new int[n]; 56 | 57 | for(int i=0; i < n; i++){ 58 | cin >> start_time[i]; 59 | } 60 | for(int i = 0; i < n; i++){ 61 | cin >> duration[i]; 62 | } 63 | 64 | Available_Workshops * ptr; 65 | ptr = initialize(start_time,duration, n); 66 | cout << CalculateMaxWorkshops(ptr) << endl; 67 | return 0; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Java/Introduction/JavaDateAndTime.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.function.*; 8 | import java.util.regex.*; 9 | import java.util.stream.*; 10 | import static java.util.stream.Collectors.joining; 11 | import static java.util.stream.Collectors.toList; 12 | 13 | class Result { 14 | 15 | /* 16 | * Complete the 'findDay' function below. 17 | * 18 | * The function is expected to return a STRING. 19 | * The function accepts following parameters: 20 | * 1. INTEGER month 21 | * 2. INTEGER day 22 | * 3. INTEGER year 23 | */ 24 | static String [] days = {"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"}; 25 | public static String findDay(int month, int day, int year) { 26 | Calendar c = Calendar.getInstance(); 27 | c.set(year, month - 1, day); 28 | 29 | int p = c.get(Calendar.DAY_OF_WEEK); 30 | return days[p - 1]; 31 | } 32 | } 33 | 34 | public class Solution { 35 | public static void main(String[] args) throws IOException { 36 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); 37 | BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); 38 | 39 | String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" "); 40 | 41 | int month = Integer.parseInt(firstMultipleInput[0]); 42 | 43 | int day = Integer.parseInt(firstMultipleInput[1]); 44 | 45 | int year = Integer.parseInt(firstMultipleInput[2]); 46 | 47 | String res = Result.findDay(month, day, year); 48 | 49 | bufferedWriter.write(res); 50 | bufferedWriter.newLine(); 51 | 52 | bufferedReader.close(); 53 | bufferedWriter.close(); 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/VirtualFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | class Person { 9 | protected: 10 | string name; 11 | int age; 12 | public: 13 | virtual void getdata() {} 14 | virtual void putdata() {} 15 | }; 16 | 17 | class Professor : public Person { 18 | int publications; 19 | static int cur_id; 20 | int id = cur_id; 21 | public: 22 | void getdata(){ 23 | cur_id ++; 24 | cin >> name; 25 | cin >> age; 26 | cin >> publications; 27 | } 28 | void putdata() { 29 | cout << name << ' ' << age << ' ' << publications << ' ' << id << endl; 30 | } 31 | 32 | }; 33 | int Professor :: cur_id = 1; 34 | 35 | class Student : public Person { 36 | int marks[6]; 37 | int sum = 0; 38 | static int cur_id; 39 | int id = cur_id; 40 | public: 41 | void getdata(){ 42 | cur_id ++; 43 | cin >> name; 44 | cin >> age; 45 | for(int i = 0; i < 6; i ++) { 46 | cin >> marks[i]; 47 | sum += marks[i]; 48 | } 49 | } 50 | void putdata() { 51 | cout << name << ' ' << age << ' ' << sum << ' ' << id << endl; 52 | } 53 | }; 54 | int Student :: cur_id = 1; 55 | 56 | int main(){ 57 | 58 | int n, val; 59 | cin>>n; //The number of objects that is going to be created. 60 | Person *per[n]; 61 | 62 | for(int i = 0;i < n;i++){ 63 | 64 | cin>>val; 65 | if(val == 1){ 66 | // If val is 1 current object is of type Professor 67 | per[i] = new Professor; 68 | 69 | } 70 | else per[i] = new Student; // Else the current object is of type Student 71 | 72 | per[i]->getdata(); // Get the data from the user. 73 | 74 | } 75 | 76 | for(int i=0;iputdata(); // Print the required output for each object. 78 | 79 | return 0; 80 | 81 | } 82 | 83 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Conditionals and Loops/ConditionalStatementsInC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | char* readline(); 12 | 13 | 14 | 15 | int main() 16 | { 17 | char* n_endptr; 18 | char* n_str = readline(); 19 | int n = strtol(n_str, &n_endptr, 10); 20 | 21 | if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); } 22 | 23 | // Write Your Code Here 24 | if(n ==1 ) { 25 | printf("one"); 26 | } else if(n == 2) { 27 | printf("two"); 28 | } else if(n == 3) { 29 | printf("three"); 30 | } else if(n == 4) { 31 | printf("four"); 32 | } else if(n == 5) { 33 | printf("five"); 34 | } else if(n == 6) { 35 | printf("six"); 36 | } else if(n == 7) { 37 | printf("seven"); 38 | } else if(n == 8) { 39 | printf("eight"); 40 | } else if(n == 9) { 41 | printf("nine"); 42 | } else { 43 | printf("Greater than 9"); 44 | } 45 | 46 | return 0; 47 | } 48 | 49 | char* readline() { 50 | size_t alloc_length = 1024; 51 | size_t data_length = 0; 52 | char* data = malloc(alloc_length); 53 | 54 | while (true) { 55 | char* cursor = data + data_length; 56 | char* line = fgets(cursor, alloc_length - data_length, stdin); 57 | 58 | if (!line) { break; } 59 | 60 | data_length += strlen(cursor); 61 | 62 | if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; } 63 | 64 | size_t new_length = alloc_length << 1; 65 | data = realloc(data, new_length); 66 | 67 | if (!data) { break; } 68 | 69 | alloc_length = new_length; 70 | } 71 | 72 | if (data[data_length - 1] == '\n') { 73 | data[data_length - 1] = '\0'; 74 | } 75 | 76 | data = realloc(data, data_length); 77 | 78 | return data; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/BoxIt.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Box { 6 | int l, b, h; 7 | 8 | public: 9 | Box(); 10 | Box(int,int,int); 11 | Box(Box&); 12 | int getLength(); 13 | int getBreadth (); 14 | int getHeight (); 15 | long long CalculateVolume(); 16 | 17 | bool operator<(Box& b); 18 | friend ostream& operator<<(ostream& out, Box& B); 19 | }; 20 | 21 | Box :: Box () { 22 | l = b = h = 0; 23 | } 24 | 25 | Box :: Box (int length, int breadth, int height) { 26 | l = length; 27 | b = breadth; 28 | h = height; 29 | } 30 | 31 | Box :: Box (Box &B) { 32 | l = B.l; 33 | b = B.b; 34 | h = B.h; 35 | } 36 | 37 | int Box :: getLength() { 38 | return l; 39 | } 40 | 41 | int Box :: getBreadth () { 42 | return b; 43 | } 44 | 45 | int Box :: getHeight () { 46 | return h; 47 | } 48 | 49 | long long Box :: CalculateVolume() { 50 | return (long long)l * b * h; 51 | } 52 | 53 | bool Box :: operator<(Box& B) { 54 | if (l < B.l) return true; 55 | else if(b < B.b && l == B.l) return true; 56 | else if(h < B.h && b == B.b && l == B.l) return true; 57 | else return false; 58 | } 59 | 60 | ostream& operator<<(ostream& out, Box& B) { 61 | out << B.l << ' ' << B.b << ' ' << B.h; 62 | return out; 63 | } 64 | 65 | 66 | void check2() 67 | { 68 | int n; 69 | cin>>n; 70 | Box temp; 71 | for(int i=0;i>type; 75 | if(type ==1) 76 | { 77 | cout<>l>>b>>h; 83 | Box NewBox(l,b,h); 84 | temp=NewBox; 85 | cout<>l>>b>>h; 91 | Box NewBox(l,b,h); 92 | if(NewBox 2 | #include 3 | 4 | /* 5 | * This stores the total number of books in each shelf. 6 | */ 7 | int* total_number_of_books; 8 | 9 | /* 10 | * This stores the total number of pages in each book of each shelf. 11 | * The rows represent the shelves and the columns represent the books. 12 | */ 13 | int** total_number_of_pages; 14 | 15 | int main() 16 | { 17 | int total_number_of_shelves; 18 | scanf("%d", &total_number_of_shelves); 19 | 20 | int total_number_of_queries; 21 | scanf("%d", &total_number_of_queries); 22 | 23 | total_number_of_pages = (int **)malloc(total_number_of_shelves * sizeof(int*)); 24 | 25 | total_number_of_books = (int *) malloc(total_number_of_shelves * sizeof(int)); 26 | 27 | for(int i = 0; i < total_number_of_shelves; i ++) { 28 | total_number_of_books[i] = 0; 29 | } 30 | 31 | while (total_number_of_queries--) { 32 | int type_of_query; 33 | scanf("%d", &type_of_query); 34 | 35 | if (type_of_query == 1) { 36 | int x, y; 37 | scanf("%d %d", &x, &y); 38 | if(*(total_number_of_pages + x)) { 39 | *(total_number_of_pages + x) = (int *)realloc(*(total_number_of_pages + x), (total_number_of_books[x] + 1) * sizeof(int)); 40 | total_number_of_pages[x][total_number_of_books[x]] = y; 41 | } 42 | else { 43 | *(total_number_of_pages + x) = (int *)malloc(sizeof(int)); 44 | **(total_number_of_pages + x) = y; 45 | } 46 | total_number_of_books[x]++; 47 | } else if (type_of_query == 2) { 48 | int x, y; 49 | scanf("%d %d", &x, &y); 50 | printf("%d\n", *(*(total_number_of_pages + x) + y)); 51 | } else { 52 | int x; 53 | scanf("%d", &x); 54 | printf("%d\n", *(total_number_of_books + x)); 55 | } 56 | } 57 | 58 | if (total_number_of_books) { 59 | free(total_number_of_books); 60 | } 61 | 62 | for (int i = 0; i < total_number_of_shelves; i++) { 63 | if (*(total_number_of_pages + i)) { 64 | free(*(total_number_of_pages + i)); 65 | } 66 | } 67 | 68 | if (total_number_of_pages) { 69 | free(total_number_of_pages); 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Inheritance/AccessingInheritedFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class A 6 | { 7 | public: 8 | A(){ 9 | callA = 0; 10 | } 11 | private: 12 | int callA; 13 | void inc(){ 14 | callA++; 15 | } 16 | 17 | protected: 18 | void func(int & a) 19 | { 20 | a = a * 2; 21 | inc(); 22 | } 23 | public: 24 | int getA(){ 25 | return callA; 26 | } 27 | }; 28 | 29 | class B 30 | { 31 | public: 32 | B(){ 33 | callB = 0; 34 | } 35 | private: 36 | int callB; 37 | void inc(){ 38 | callB++; 39 | } 40 | protected: 41 | void func(int & a) 42 | { 43 | a = a * 3; 44 | inc(); 45 | } 46 | public: 47 | int getB(){ 48 | return callB; 49 | } 50 | }; 51 | 52 | class C 53 | { 54 | public: 55 | C(){ 56 | callC = 0; 57 | } 58 | private: 59 | int callC; 60 | void inc(){ 61 | callC++; 62 | } 63 | protected: 64 | void func(int & a) 65 | { 66 | a = a * 5; 67 | inc(); 68 | } 69 | public: 70 | int getC(){ 71 | return callC; 72 | } 73 | }; 74 | 75 | class D : public A, public B, public C 76 | { 77 | int val; 78 | public: 79 | //Initially val is 1 80 | D() 81 | { 82 | val = 1; 83 | } 84 | 85 | 86 | //Implement this function 87 | void update_val(int new_val) 88 | { while(new_val != 1) { 89 | if (new_val % 2 == 0) { 90 | A :: func(val); 91 | new_val /= 2; 92 | } else if (new_val % 3 == 0) { 93 | B :: func(val); 94 | new_val /= 3; 95 | } else { 96 | C :: func(val); 97 | new_val /= 5; 98 | } 99 | } 100 | } 101 | //For Checking Purpose 102 | void check(int); //Do not delete this line. 103 | }; 104 | 105 | 106 | 107 | void D::check(int new_val) 108 | { 109 | update_val(new_val); 110 | cout << "Value = " << val << endl << "A's func called " << getA() << " times " << endl << "B's func called " << getB() << " times" << endl << "C's func called " << getC() << " times" << endl; 111 | } 112 | 113 | 114 | int main() 115 | { 116 | D d; 117 | int new_val; 118 | cin >> new_val; 119 | d.check(new_val); 120 | 121 | } 122 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Functions/SortingArrayOfStrings.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int lexicographic_sort(const char* a, const char* b) { 5 | return (strcmp(a, b)); 6 | } 7 | 8 | int lexicographic_sort_reverse(const char* a, const char* b) { 9 | return (strcmp(b, a)); 10 | } 11 | 12 | int sort_by_number_of_distinct_characters(const char* a, const char* b) { 13 | int count[2] = {0}; // array to maintain count of characters in a, b 14 | 15 | int presencea[26] = {0}; // array to check presence of a character 16 | for (int j = 0; j < strlen(a); j++) { 17 | if (a[j] != ' ' && presencea[a[j] - 97] == 0) { 18 | presencea[a[j] - 97] = 1; 19 | count[0]++; 20 | } 21 | } 22 | 23 | int presenceb[26] = {0}; // array to check presence of a character 24 | for (int j = 0; j < strlen(b); j++) { 25 | if (b[j] != ' ' && presenceb[b[j] - 97] == 0) { 26 | presenceb[b[j] - 97] = 1; 27 | count[1]++; 28 | } 29 | } 30 | 31 | if (count[0] > count[1] || (count[0] == count[1] && strcmp(a, b) > 0) ) return 1; 32 | else return 0; 33 | } 34 | 35 | int sort_by_length(const char* a, const char* b) { 36 | if(strlen(a) > strlen(b) ){ 37 | return 1; 38 | } else if(strlen(a) == strlen(b)){ 39 | if(strcmp(a, b) > 0) return 1; 40 | else return 0; 41 | } else return 0; 42 | } 43 | 44 | void string_sort(char** arr,const int len,int (*cmp_func)(const char* a, const char* b)){ 45 | char * tmp; 46 | for(int i = 0; i < len - 1; i ++) { 47 | for (int j = i + 1; j < len ; j ++) 48 | if(cmp_func(arr[i], arr[j] ) > 0){ 49 | tmp = arr[i]; 50 | arr[i] = arr[j]; 51 | arr[j] = tmp; 52 | } 53 | } 54 | } 55 | 56 | 57 | int main() 58 | { 59 | int n; 60 | scanf("%d", &n); 61 | 62 | char** arr; 63 | arr = (char**)malloc(n * sizeof(char*)); 64 | 65 | for(int i = 0; i < n; i++){ 66 | *(arr + i) = malloc(1024 * sizeof(char)); 67 | scanf("%s", *(arr + i)); 68 | *(arr + i) = realloc(*(arr + i), strlen(*(arr + i)) + 1); 69 | } 70 | 71 | string_sort(arr, n, lexicographic_sort); 72 | for(int i = 0; i < n; i++) 73 | printf("%s\n", arr[i]); 74 | printf("\n"); 75 | 76 | string_sort(arr, n, lexicographic_sort_reverse); 77 | for(int i = 0; i < n; i++) 78 | printf("%s\n", arr[i]); 79 | printf("\n"); 80 | 81 | string_sort(arr, n, sort_by_length); 82 | for(int i = 0; i < n; i++) 83 | printf("%s\n", arr[i]); 84 | printf("\n"); 85 | 86 | string_sort(arr, n, sort_by_number_of_distinct_characters); 87 | for(int i = 0; i < n; i++) 88 | printf("%s\n", arr[i]); 89 | printf("\n"); 90 | } 91 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Classes/AbstractClassesPolymorphism.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | struct Node{ 11 | Node* next; 12 | Node* prev; 13 | int value; 14 | int key; 15 | Node(Node* p, Node* n, int k, int val):prev(p),next(n),key(k),value(val){}; 16 | Node(int k, int val):prev(NULL),next(NULL),key(k),value(val){}; 17 | }; 18 | 19 | class Cache{ 20 | 21 | protected: 22 | map mp; //map the key to the node in the linked list 23 | int cp; //capacity 24 | Node* tail; // double linked list tail pointer 25 | Node* head; // double linked list head pointer 26 | virtual void set(int, int) = 0; //set function 27 | virtual int get(int) = 0; //get function 28 | 29 | }; 30 | class LRUCache : public Cache { 31 | public: 32 | LRUCache(int c) { cp = c; } 33 | 34 | void set(int k, int v) { 35 | Node *N; 36 | 37 | if (mp.empty()) // No nodes 38 | { 39 | N = new Node(k, v); 40 | tail = head = N; 41 | mp[k] = N; 42 | 43 | return; 44 | } 45 | 46 | auto it = mp.find(k); 47 | 48 | if (it != mp.end()) // In hash table 49 | { 50 | it->second->value = v; // update value 51 | 52 | if (head == it->second) // head? 53 | return; 54 | 55 | it->second->prev->next = it->second->next; 56 | 57 | if (tail == it->second) // tail? 58 | tail = tail->prev; 59 | else // in between? 60 | it->second->next->prev = it->second->prev; 61 | 62 | it->second->next = head; 63 | it->second->prev = NULL; 64 | head->prev = it->second; 65 | head = it->second; 66 | } else // No in hash table 67 | { 68 | N = new Node(head->prev, head, k, v); // new node 69 | head->prev = N; 70 | head = N; 71 | mp[k] = N; 72 | 73 | if (mp.size() > cp) // capacity? 74 | { 75 | tail = tail->prev; 76 | mp.erase(tail->next->key); 77 | delete tail->next; 78 | tail->next = NULL; 79 | } 80 | } 81 | } 82 | 83 | int get(int k) { 84 | auto it = mp.find(k); 85 | if (it != mp.end()) 86 | return it->second->value; 87 | 88 | return -1; 89 | } 90 | }; 91 | int main() { 92 | int n, capacity,i; 93 | cin >> n >> capacity; 94 | LRUCache l(capacity); 95 | for(i=0;i> command; 98 | if(command == "get") { 99 | int key; 100 | cin >> key; 101 | cout << l.get(key) << endl; 102 | } 103 | else if(command == "set") { 104 | int key, value; 105 | cin >> key >> value; 106 | l.set(key,value); 107 | } 108 | } 109 | return 0; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C++/Inheritance/MagicSpells.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | class Spell { 7 | private: 8 | string scrollName; 9 | public: 10 | Spell(): scrollName("") { } 11 | Spell(string name): scrollName(name) { } 12 | virtual ~Spell() { } 13 | string revealScrollName() { 14 | return scrollName; 15 | } 16 | }; 17 | 18 | class Fireball : public Spell { 19 | private: int power; 20 | public: 21 | Fireball(int power): power(power) { } 22 | void revealFirepower(){ 23 | cout << "Fireball: " << power << endl; 24 | } 25 | }; 26 | 27 | class Frostbite : public Spell { 28 | private: int power; 29 | public: 30 | Frostbite(int power): power(power) { } 31 | void revealFrostpower(){ 32 | cout << "Frostbite: " << power << endl; 33 | } 34 | }; 35 | 36 | class Thunderstorm : public Spell { 37 | private: int power; 38 | public: 39 | Thunderstorm(int power): power(power) { } 40 | void revealThunderpower(){ 41 | cout << "Thunderstorm: " << power << endl; 42 | } 43 | }; 44 | 45 | class Waterbolt : public Spell { 46 | private: int power; 47 | public: 48 | Waterbolt(int power): power(power) { } 49 | void revealWaterpower(){ 50 | cout << "Waterbolt: " << power << endl; 51 | } 52 | }; 53 | 54 | class SpellJournal { 55 | public: 56 | static string journal; 57 | static string read() { 58 | return journal; 59 | } 60 | }; 61 | string SpellJournal::journal = ""; 62 | 63 | void counterspell(Spell *spell) { 64 | if (Fireball* f = dynamic_cast(spell)) f -> revealFirepower(); 65 | else if (Frostbite* fr = dynamic_cast(spell)) fr -> revealFrostpower(); 66 | else if (Waterbolt* w = dynamic_cast(spell)) w -> revealWaterpower(); 67 | else if (Thunderstorm* t = dynamic_cast(spell)) t -> revealThunderpower(); 68 | else { 69 | string x = spell -> revealScrollName(); 70 | int m = x.length(); 71 | string y = SpellJournal::journal; 72 | int n = y.length(); 73 | int array[m + 1][n + 1]; 74 | for (int i = 0; i <= m; i++) array[i][0] = 0; 75 | for (int j = 0; j <= n; j++) array[0][j] = 0; 76 | for (int i = 1; i <= m; i++) 77 | for (int j = 1; j <= n; j++) { 78 | if (x[i - 1] == y[j - 1]) 79 | array[i][j] = array[i - 1][j - 1] + 1; 80 | else 81 | array[i][j] = array[i][j - 1] > array[i - 1][j] ? array[i][j - 1] : array[i - 1][j]; 82 | } 83 | 84 | cout << array[m][n] << endl; 85 | } 86 | } 87 | 88 | class Wizard { 89 | public: 90 | Spell *cast() { 91 | Spell *spell; 92 | string s; cin >> s; 93 | int power; cin >> power; 94 | if(s == "fire") { 95 | spell = new Fireball(power); 96 | } 97 | else if(s == "frost") { 98 | spell = new Frostbite(power); 99 | } 100 | else if(s == "water") { 101 | spell = new Waterbolt(power); 102 | } 103 | else if(s == "thunder") { 104 | spell = new Thunderstorm(power); 105 | } 106 | else { 107 | spell = new Spell(s); 108 | cin >> SpellJournal::journal; 109 | } 110 | return spell; 111 | } 112 | }; 113 | 114 | int main() { 115 | int T; 116 | cin >> T; 117 | Wizard Arawn; 118 | while(T--) { 119 | Spell *spell = Arawn.cast(); 120 | counterspell(spell); 121 | } 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/C/Functions/QueryingTheDocument.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #define MAX_CHARACTERS 1005 6 | #define MAX_PARAGRAPHS 5 7 | 8 | char* kth_word_in_mth_sentence_of_nth_paragraph(char**** document, int k, int m, int n) { 9 | return document[n - 1][m - 1][k - 1]; 10 | } 11 | 12 | char** kth_sentence_in_mth_paragraph(char**** document, int k, int m) { 13 | return document[m - 1][k - 1]; 14 | } 15 | 16 | char*** kth_paragraph(char**** document, int k) { 17 | return document[k - 1]; 18 | } 19 | 20 | char**** get_document(char* text) { 21 | // doc points to an array of paragraphs 22 | char ****doc = malloc(MAX_PARAGRAPHS * sizeof(char ***)); 23 | 24 | // for each paragraph, assign an array of 1 sentence, we can reallocate later 25 | for(int i = 0; i < MAX_PARAGRAPHS; i ++) { 26 | doc[i] = malloc(1 * sizeof(char **)); 27 | } 28 | 29 | // for each sentence assign an array of 1 word 30 | for(int i = 0; i < MAX_PARAGRAPHS; i ++) { 31 | for(int j = 0; j < 1; j ++) { 32 | doc[i][j] = malloc(1 * sizeof(char*)); 33 | } 34 | } 35 | 36 | // for each word assign an array of 1 character 37 | for(int i = 0; i < MAX_PARAGRAPHS; i ++) { 38 | for(int j = 0; j < 1; j ++) { 39 | for(int k = 0; k < 1; k ++) { 40 | doc[i][j][k] = malloc(1 * sizeof(char)); 41 | } 42 | } 43 | } 44 | 45 | for(int n = 0, i = 0, j = 0, k = 0, l = 0; n < strlen(text); n ++) { 46 | if(text[n] != ' ' && text[n] != '\n' && text[n] != '.') { 47 | doc[i][j][k][l] = text[n]; 48 | l++; 49 | doc[i][j][k] = realloc(doc[i][j][k], (l + 1) * sizeof(char)); 50 | } else if(text[n] == ' ') { 51 | doc[i][j][k][l] = '\0'; 52 | l = 0; 53 | k++; 54 | doc[i][j] = realloc(doc[i][j], (k + 1) * sizeof(char*)); 55 | doc[i][j][k] = malloc(sizeof(char)); 56 | continue; 57 | } else if(text[n] == '.') { 58 | doc[i][j][k][l] = '\0'; 59 | k = l = 0; 60 | j++; 61 | doc[i] = realloc(doc[i], (j+1) * sizeof(char**)); 62 | doc[i][j] = malloc(sizeof(char*)); 63 | doc[i][j][k] = malloc(sizeof(char)); 64 | continue; 65 | } else if(text[n] == '\n') { 66 | j = k = l = 0; 67 | i++; 68 | continue; 69 | } 70 | } 71 | return doc; 72 | } 73 | 74 | 75 | char* get_input_text() { 76 | int paragraph_count; 77 | scanf("%d", ¶graph_count); 78 | 79 | char p[MAX_PARAGRAPHS][MAX_CHARACTERS], doc[MAX_CHARACTERS]; 80 | memset(doc, 0, sizeof(doc)); 81 | getchar(); 82 | for (int i = 0; i < paragraph_count; i++) { 83 | scanf("%[^\n]%*c", p[i]); 84 | strcat(doc, p[i]); 85 | if (i != paragraph_count - 1) 86 | strcat(doc, "\n"); 87 | } 88 | 89 | char* returnDoc = (char*)malloc((strlen (doc)+1) * (sizeof(char))); 90 | strcpy(returnDoc, doc); 91 | return returnDoc; 92 | } 93 | 94 | void print_word(char* word) { 95 | printf("%s", word); 96 | } 97 | 98 | void print_sentence(char** sentence) { 99 | int word_count; 100 | scanf("%d", &word_count); 101 | for(int i = 0; i < word_count; i++){ 102 | printf("%s", sentence[i]); 103 | if( i != word_count - 1) 104 | printf(" "); 105 | } 106 | } 107 | 108 | void print_paragraph(char*** paragraph) { 109 | int sentence_count; 110 | scanf("%d", &sentence_count); 111 | for (int i = 0; i < sentence_count; i++) { 112 | print_sentence(*(paragraph + i)); 113 | printf("."); 114 | } 115 | } 116 | 117 | int main() 118 | { 119 | char* text = get_input_text(); 120 | char**** document = get_document(text); 121 | 122 | int q; 123 | scanf("%d", &q); 124 | 125 | while (q--) { 126 | int type; 127 | scanf("%d", &type); 128 | 129 | if (type == 3){ 130 | int k, m, n; 131 | scanf("%d %d %d", &k, &m, &n); 132 | char* word = kth_word_in_mth_sentence_of_nth_paragraph(document, k, m, n); 133 | print_word(word); 134 | } 135 | 136 | else if (type == 2){ 137 | int k, m; 138 | scanf("%d %d", &k, &m); 139 | char** sentence = kth_sentence_in_mth_paragraph(document, k, m); 140 | print_sentence(sentence); 141 | } 142 | 143 | else{ 144 | int k; 145 | scanf("%d", &k); 146 | char*** paragraph = kth_paragraph(document, k); 147 | print_paragraph(paragraph); 148 | } 149 | printf("\n"); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /LANGUAGE PROFICIENCY/Python/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |