├── .gitignore ├── Python ├── findstring.py ├── The-Beatles │ ├── app.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── array.py ├── Looping-With-FizzBuzz │ ├── app.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── Your-First-If │ ├── app.py │ ├── solution.hide.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── Create-A-For-Loop │ ├── app.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── Your-First-Loop │ ├── app.py │ ├── test.py │ ├── README.md │ └── README.es.md ├── Calling-Your-First-Function │ ├── app.py │ ├── README.es.md │ ├── README.md │ └── test.py ├── factorial_digit_sum.py ├── swap.py ├── Creating-Your-First-Function │ ├── app.js │ ├── README.md │ ├── README.es.md │ └── tests.js ├── linearsearch.py ├── Random-Numbers │ ├── app.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── How-Much-The-Wedding-Costs │ ├── app.py │ ├── solution.hide.py │ ├── README.md │ ├── README.es.md │ └── test.py ├── Currency_Convertor.py ├── ShuffleDeckOfCards.py ├── Selection_Sort.py ├── Insertion_Sort.py ├── Bubble_Sort.py ├── Random-Colors-Loop │ ├── test.py │ ├── app.py │ ├── README.md │ └── README.es.md ├── 001_Basic_py_program.py ├── Kadane_Algorithm.py ├── Binary_Search.py ├── code2.py ├── SimpleCalculator.py ├── bmi_gui.py └── BST.py ├── bootstrap_use ├── css │ ├── example5.css │ ├── example8.css │ ├── example3.css │ ├── example6.css │ ├── example7.css │ ├── example9.css │ ├── example4.css │ ├── example1.css │ └── example2.css ├── example9.html ├── example7.html ├── example6.html ├── example1.html ├── example8.html ├── example10.html ├── example2.html ├── example3.html ├── example4.html └── example5.html ├── C++ ├── chill1.cpp ├── Prog Q2.7.cpp ├── 75find.cpp ├── Program 1.cpp ├── sum.cpp ├── euclid_gcd.cpp ├── Prog7 (DivideUN).cpp ├── eq.cpp ├── fibonacci.cpp ├── Kthgrammar.cpp ├── array.cpp ├── gcd_lcm.cpp ├── Nirala_op.cpp ├── code1.cpp ├── hmmm.cpp ├── concatenation_of_the_string ├── MAKETREE.cpp ├── Prog8 (Calculator).cpp ├── mergesort.cpp ├── fib%m.cpp ├── staircase.cpp ├── pro.cpp ├── avl.cpp ├── Print_matrix_spiral.cpp ├── symmetrictree.cpp ├── InvolutoryMatrix.cpp ├── circular Queue.cpp ├── bipartite.cpp ├── heap.cpp ├── transpose matrix.cpp ├── Lat.cpp ├── zigzagbinary.cpp ├── MaxSubArrayKadane.cpp ├── MaxSubArrayNaive.cpp ├── BinaryShifting.cpp ├── segmentTree.cpp ├── Yatharth.cpp └── MaxSubArrayMerge.cpp ├── Web ├── City website │ ├── README.md │ ├── about.PNG │ ├── geograpgy.PNG │ ├── homepage.PNG │ ├── img │ │ ├── arrow12.png │ │ ├── Wireframe 1.png │ │ ├── rocket12copy.png │ │ └── mountain-dusk2.jpg │ ├── font-awesome │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ ├── less │ │ │ ├── fixed-width.less │ │ │ ├── bordered-pulled.less │ │ │ ├── larger.less │ │ │ ├── list.less │ │ │ ├── font-awesome.less │ │ │ ├── core.less │ │ │ ├── stacked.less │ │ │ ├── rotated-flipped.less │ │ │ ├── path.less │ │ │ ├── animated.less │ │ │ └── mixins.less │ │ └── scss │ │ │ ├── _fixed-width.scss │ │ │ ├── _bordered-pulled.scss │ │ │ ├── _larger.scss │ │ │ ├── _list.scss │ │ │ ├── font-awesome.scss │ │ │ ├── _core.scss │ │ │ ├── _stacked.scss │ │ │ ├── _rotated-flipped.scss │ │ │ ├── _path.scss │ │ │ ├── _animated.scss │ │ │ └── _mixins.scss │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── js │ │ ├── scrolling-nav.js │ │ ├── custom.js │ │ └── jquery.scrollTo.min.js │ └── css │ │ └── scrolling-nav.css ├── padam.js ├── index.html ├── memegenerator.js ├── style.css └── movies.ejs ├── linkedin.png ├── hacktober2021.docx ├── PDFs ├── programs set 2.pdf ├── SET 1 SOLUTIONS.pdf ├── SET 2 SOLUTIONS.pdf ├── set 3 solutions.pdf └── set 4_SOLUTIONS.pdf ├── C ├── amit2.c ├── chapter 2 Q7.c ├── 2nd 1Q.c ├── 3 Q2.c ├── sort.c ├── circle.c ├── rupee and smallest possible denominationn.c ├── string_rev.c ├── Linearsearch.c ├── galois.c ├── mergeSort.c └── Linked List.c ├── Guessing Number Game in Java ├── Guessing_Game_Human_vs_CPU.class ├── Guessing_Game_Human_vs_CPU.ctxt └── Guessing_Game_Human_vs_CPU.java ├── Java ├── HW.java ├── forLoop.java ├── handlingInput.java ├── ExplicitDataType.java ├── enhancedForLoop.java ├── forLoopForArray.java ├── urlify.java ├── Ide.java ├── Ide (2).java ├── area.java ├── simple_interest.java ├── else-elseifstatement.java ├── DataTypeConversion.java ├── DoubleDataTypeExample.java ├── binary.java ├── Ide (1).java ├── RecursiveInsertionSort.java ├── linked.java ├── GCD.java ├── POJO.java ├── IfArraySorted ├── Mean.java ├── LinearSearch.java ├── 500keyboard.java ├── UserDAO.java ├── Ide (3).java ├── merge.java ├── loginpage.java ├── servelet.java ├── matrix_chain_multiplication.java ├── allocate_minimum_number_of_pages.java ├── SubsetSum.java ├── palindrome_partitioning.java └── getter.java ├── 3-820-1.cpp ├── buypasses.java ├── package.json ├── Go ├── CopyArray.go ├── ArrayIteration.go └── Arrays.go ├── 3-764-1.cpp ├── rttcallc1.py ├── 3-776-1.cpp ├── 3-753-1.cpp ├── rttcallc.py ├── 2-823-1.cpp ├── Best Time to Buy and Sell Stock with Cooldown ├── a.cpp ├── EucladianTheorem.ipynb ├── reverseproxy.cpp └── reversepxy.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /Python/findstring.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bootstrap_use/css/example5.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /C++/chill1.cpp: -------------------------------------------------------------------------------- 1 | using namespace std; 2 | 3 | -------------------------------------------------------------------------------- /Python/The-Beatles/app.py: -------------------------------------------------------------------------------- 1 | # Your code here!! 2 | -------------------------------------------------------------------------------- /Web/City website/README.md: -------------------------------------------------------------------------------- 1 | # Harrisburg-City 2 | Web develpment project 3 | -------------------------------------------------------------------------------- /Python/array.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | a=np.array(([1,2,3],[4,5,6],[7,8,9])) 3 | print(a) -------------------------------------------------------------------------------- /linkedin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/linkedin.png -------------------------------------------------------------------------------- /hacktober2021.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/hacktober2021.docx -------------------------------------------------------------------------------- /Python/Looping-With-FizzBuzz/app.py: -------------------------------------------------------------------------------- 1 | def fizz_buzz(): 2 | # your code here 3 | 4 | 5 | fizz_buzz() -------------------------------------------------------------------------------- /PDFs/programs set 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/PDFs/programs set 2.pdf -------------------------------------------------------------------------------- /PDFs/SET 1 SOLUTIONS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/PDFs/SET 1 SOLUTIONS.pdf -------------------------------------------------------------------------------- /PDFs/SET 2 SOLUTIONS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/PDFs/SET 2 SOLUTIONS.pdf -------------------------------------------------------------------------------- /PDFs/set 3 solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/PDFs/set 3 solutions.pdf -------------------------------------------------------------------------------- /PDFs/set 4_SOLUTIONS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/PDFs/set 4_SOLUTIONS.pdf -------------------------------------------------------------------------------- /Web/City website/about.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/about.PNG -------------------------------------------------------------------------------- /Python/Your-First-If/app.py: -------------------------------------------------------------------------------- 1 | 2 | total = int(input('How much money do you have in your pocket\n')) 3 | 4 | # YOUR CODE HERE -------------------------------------------------------------------------------- /Web/City website/geograpgy.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/geograpgy.PNG -------------------------------------------------------------------------------- /Web/City website/homepage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/homepage.PNG -------------------------------------------------------------------------------- /Web/City website/img/arrow12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/img/arrow12.png -------------------------------------------------------------------------------- /Python/Create-A-For-Loop/app.py: -------------------------------------------------------------------------------- 1 | def standards_maker(): 2 | #your code here 3 | 4 | #remember to call the function outside (here) -------------------------------------------------------------------------------- /Python/Your-First-Loop/app.py: -------------------------------------------------------------------------------- 1 | def start_counting(): 2 | for i in range(10): 3 | print(i) 4 | return i 5 | 6 | start_counting() -------------------------------------------------------------------------------- /Web/City website/img/Wireframe 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/img/Wireframe 1.png -------------------------------------------------------------------------------- /Web/City website/img/rocket12copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/img/rocket12copy.png -------------------------------------------------------------------------------- /Web/City website/img/mountain-dusk2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/img/mountain-dusk2.jpg -------------------------------------------------------------------------------- /Python/Calling-Your-First-Function/app.py: -------------------------------------------------------------------------------- 1 | def is_odd(my_number): 2 | return (my_number % 2 != 0) 3 | 4 | 5 | def my_main_code(): 6 | # your code here -------------------------------------------------------------------------------- /C/amit2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | double x=1.1; 5 | while(x==1.1) 6 | {printf("%0.1f\n",x); 7 | x=x-0.1; 8 | }return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/font-awesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /Python/factorial_digit_sum.py: -------------------------------------------------------------------------------- 1 | #python program to find the factorial digit sum 2 | 3 | 4 | import math 5 | n = 100 6 | print(sum(map(int, str(math.factorial(n))))) 7 | -------------------------------------------------------------------------------- /Web/City website/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Web/City website/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Web/City website/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Web/City website/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Web/City website/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /Web/City website/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /Web/City website/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /C++/Prog Q2.7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | cout <<"Maths = 90" <<"\n" <<"Physics = 77" <<"\n" <<"Chemistry 67" <<"\n"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /Guessing Number Game in Java/Guessing_Game_Human_vs_CPU.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Guessing Number Game in Java/Guessing_Game_Human_vs_CPU.class -------------------------------------------------------------------------------- /Python/swap.py: -------------------------------------------------------------------------------- 1 | def swap_case(s): 2 | s=s.swapcase() 3 | return s 4 | 5 | if __name__ == '__main__': 6 | s = input() 7 | result = swap_case(s) 8 | print(result) 9 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shubh2-0/open_source_start/HEAD/Web/City website/font-awesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /Python/Creating-Your-First-Function/app.js: -------------------------------------------------------------------------------- 1 | def addNumbers(a,b) 2 | // This is the function body. Write your code here. 3 | 4 | //Do not change the code below 5 | print(addNumbers(3,4)); 6 | -------------------------------------------------------------------------------- /Web/padam.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'Padam', 3 | github: 'DeviantPadam', 4 | email: 'padam.gupta14@gmail.com', 5 | twitter: '@xxx', 6 | facebook: 'xxx', 7 | linkedin: 'in/xxx' 8 | } -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /Python/linearsearch.py: -------------------------------------------------------------------------------- 1 | #Python program to perform Linear Search 2 | 3 | 4 | def search(arr, x): 5 | 6 | for i in range(len(arr)): 7 | 8 | if arr[i] == x: 9 | return i 10 | 11 | return -1 12 | -------------------------------------------------------------------------------- /Python/Random-Numbers/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def get_randomInt(): 4 | # CHANGE ONLY THIS LINE BELOW 5 | random_number = random.random() 6 | return random_number 7 | 8 | 9 | 10 | print(get_randomInt()) -------------------------------------------------------------------------------- /Python/How-Much-The-Wedding-Costs/app.py: -------------------------------------------------------------------------------- 1 | user_input = int(input('How many people are coming to your wedding?\n')) 2 | 3 | if user_input <= 50: 4 | price = 4000 5 | 6 | print('Your wedding will cost '+str(price)+' dollars') -------------------------------------------------------------------------------- /Java/HW.java: -------------------------------------------------------------------------------- 1 | class hello { 2 | public static void main (String args[]){ 3 | System.out.println("hello world"); 4 | System.out.println("Welcome to the world of open source"); 5 | System.out.println("It's hacktober time"); 6 | } 7 | } -------------------------------------------------------------------------------- /C++/75find.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a[]={11,13,19,25,29,36,37,38,39,41,48,57,66,68,69,72,75,84,85,86,89,90,91,92,93,94,95,97,98,99}; 6 | int i=16; 7 | 8 | cout< 2 | using namespace std; 3 | void solve() 4 | { 5 | 6 | } 7 | 8 | 9 | int main() 10 | { 11 | int t; 12 | cin>>t; 13 | while(t--) 14 | { 15 | solve(); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Guessing Number Game in Java/Guessing_Game_Human_vs_CPU.ctxt: -------------------------------------------------------------------------------- 1 | #BlueJ class context 2 | comment0.params=lower\ upper\ randnum\ count 3 | comment0.target=int\ computerGuess(int,\ int,\ int,\ int) 4 | comment1.params=args 5 | comment1.target=void\ main(java.lang.String[]) 6 | numComments=2 7 | -------------------------------------------------------------------------------- /C++/Program 1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int v,p,r,n; 6 | cout <<"Enter Value of V,P,R,N\n"; 7 | cin >>v; 8 | cin >>p; 9 | cin >>r; 10 | cin >>n; 11 | 12 | v=p(1+r)^n; 13 | 14 | cout << "V is equal to \n" < 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | float sum; 7 | 8 | cout <<"Enter The Value Of A,B and C\n"; 9 | cin >>a; 10 | cin >>b; 11 | cin >>c; 12 | 13 | sum=a+b+c; 14 | 15 | cout <<"Sum is " < 2 | using namespace std; 3 | 4 | int gcd(int a,int b) 5 | { 6 | if(b=0) return a; 7 | else 8 | return gcd(b,a%b); 9 | } 10 | 11 | int main() 12 | { 13 | int a,b; 14 | cin>>a>>b; 15 | cout< 2 | #include 3 | int main() 4 | { 5 | double b; 6 | int a; 7 | printf("enter an angle"); 8 | scanf("%d",&a); 9 | 10 | b=sin(a); 11 | printf("%If",b); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C++/Prog7 (DivideUN).cpp: -------------------------------------------------------------------------------- 1 | using namespace std; 2 | #include 3 | int main() 4 | { 5 | //Let's Divide the two numbers 6 | int a,b; 7 | cout <<"Enter The Value of A\n"; 8 | cin >>a; 9 | cout <<"Enter The Value of B\n"; 10 | cin >>b; 11 | 12 | cout <<"Divide" " " << a/b;; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C/2nd 1Q.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,e,f,g; 5 | printf("enter 5 digit no"); 6 | scanf("%d",&a); 7 | 8 | a=(b*10000)+(c*1000)+(d*100)+(e*10)+f; 9 | scanf("%d,%d,%d,%d,%d",&b,&c,&d,&e,&f); 10 | g=b+c+d+e+f; 11 | printf("sum of digits is=%d\n",g); 12 | } 13 | -------------------------------------------------------------------------------- /C++/eq.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n, sum = 0; 7 | 8 | cout << "Enter Any positive integer: "; 9 | cin >> n; 10 | 11 | for (int i = 1; i <= n; ++i) { 12 | sum += i; 13 | } 14 | 15 | cout << "Sum = " << sum; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Python/Your-First-If/solution.hide.py: -------------------------------------------------------------------------------- 1 | 2 | total = int(input('How much money do you have in your pocket\n')) 3 | 4 | # YOUR CODE HERE 5 | if total > 100: 6 | print("Give me your money!") 7 | elif total > 50: 8 | print("Buy me some coffee you cheap!") 9 | elif total <= 50: 10 | print("You are a poor guy, go away!") -------------------------------------------------------------------------------- /Java/handlingInput.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class Main{ 4 | public static void main(String[] args ){ 5 | System.out.print("First name:"); 6 | Scanner name = new Scanner(System.in); 7 | String firstName = name.next(); 8 | 9 | System.out.print("My name is " + firstName + "."); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /C++/fibonacci.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long int 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ll n; 8 | cin>>n; 9 | ll a[n]; 10 | a[0]=0; 11 | a[1]=1; 12 | for(int i=2;i<=n;i++) 13 | { 14 | a[i]=a[i-1]+a[i-2]; 15 | } 16 | cout< 2 | int main() 3 | { 4 | int a,p; 5 | printf("enter a no."); 6 | scanf("%d",&a); 7 | p=a%2; 8 | if(p==1) 9 | printf("no. is odd"); 10 | else 11 | printf("no. is even"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "contributors:add": "all-contributors add", 4 | "contributors:generate": "all-contributors generate", 5 | "contributors:init": "all-contributors init", 6 | "contributors:check": "all-contributors check" 7 | }, 8 | "devDependencies": { 9 | "all-contributors-cli": "^6.20.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Python/How-Much-The-Wedding-Costs/solution.hide.py: -------------------------------------------------------------------------------- 1 | user_input = int(input('How many people are coming to your wedding?\n')) 2 | 3 | if user_input <= 50: 4 | price = 4000 5 | elif user_input <= 100: 6 | price = 10000 7 | elif user_input <= 200: 8 | price = 15000 9 | else: 10 | price = 20000 11 | 12 | print('Your wedding will cost '+str(price)+' dollars') -------------------------------------------------------------------------------- /Python/Currency_Convertor.py: -------------------------------------------------------------------------------- 1 | from forex_python.converter import CurrencyRates 2 | c = CurrencyRates() 3 | 4 | amount = int(input("Enter the amount: ")) 5 | from_currency = input("From : ").upper() 6 | to_currency = input("To : ").upper() 7 | result = c.convert(from_currency, to_currency, amount) 8 | 9 | print("\n") 10 | print(from_currency, "to", to_currency, ": ", result) -------------------------------------------------------------------------------- /Java/ExplicitDataType.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | int number1 = 7; 4 | int number2 = 2; 5 | System.out.println(number1 / number2); 6 | 7 | // Cast number1 to a double, divide it by number2, and print it 8 | System.out.println((double)number1/number2); 9 | 10 | } 11 | } 12 | 13 | 14 | // explicitDataType 15 | -------------------------------------------------------------------------------- /C/sort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | int n; 11 | scanf("%d", &n); 12 | int *a = malloc(sizeof(int) * n); 13 | for(int a_i = 0; a_i < n; a_i++){ 14 | scanf("%d",&a[a_i]); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Go/CopyArray.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | x := [5]int{0, 5, 10, 15, 20} 7 | 8 | // Copy array values 9 | y := x 10 | 11 | // Copy by reference 12 | z := &x 13 | 14 | fmt.Printf("x: %v\n", x) 15 | fmt.Printf("y: %v\n", y) 16 | 17 | x[0] = 1 18 | 19 | fmt.Printf("x: %v\n", x) 20 | fmt.Printf("y: %v\n", y) 21 | fmt.Printf("z: %v\n", *z) 22 | } 23 | -------------------------------------------------------------------------------- /bootstrap_use/css/example3.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 15%; 3 | } 4 | 5 | #left { 6 | background-color: blue; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | } 12 | 13 | #previous { 14 | bottom: 10%; 15 | left: 15%; 16 | position: absolute; 17 | } 18 | 19 | #next { 20 | bottom: 10%; 21 | right: 15%; 22 | position: absolute; 23 | } -------------------------------------------------------------------------------- /bootstrap_use/css/example6.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 15%; 3 | } 4 | 5 | #left { 6 | background-color: blue; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | } 12 | 13 | #previous { 14 | bottom: 10%; 15 | left: 15%; 16 | position: absolute; 17 | } 18 | 19 | #next { 20 | bottom: 10%; 21 | right: 15%; 22 | position: absolute; 23 | } -------------------------------------------------------------------------------- /bootstrap_use/css/example7.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 15%; 3 | } 4 | 5 | #left { 6 | background-color: blue; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | } 12 | 13 | #previous { 14 | bottom: 10%; 15 | left: 15%; 16 | position: absolute; 17 | } 18 | 19 | #next { 20 | bottom: 10%; 21 | right: 15%; 22 | position: absolute; 23 | } -------------------------------------------------------------------------------- /bootstrap_use/css/example9.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 15%; 3 | } 4 | 5 | #left { 6 | background-color: green; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | } 12 | 13 | #previous { 14 | bottom: 10%; 15 | left: 15%; 16 | position: absolute; 17 | } 18 | 19 | #next { 20 | bottom: 10%; 21 | right: 15%; 22 | position: absolute; 23 | } -------------------------------------------------------------------------------- /bootstrap_use/css/example4.css: -------------------------------------------------------------------------------- 1 | .container-fluid { 2 | margin-top: 15%; 3 | } 4 | 5 | #left { 6 | background-color: blue; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | } 12 | 13 | #previous { 14 | bottom: 10%; 15 | left: 15%; 16 | position: absolute; 17 | } 18 | 19 | #next { 20 | bottom: 10%; 21 | right: 15%; 22 | position: absolute; 23 | } -------------------------------------------------------------------------------- /C++/Kthgrammar.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int kthGrammar(int n, int k) { 4 | //base case 5 | if(n==1&&k==1) 6 | return 0; 7 | 8 | int mid=pow(2,n-1)/2; 9 | 10 | if(k<=mid) 11 | { 12 | return kthGrammar(n-1,k); 13 | } 14 | else{ 15 | return !kthGrammar(n-1,k-mid); 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /Python/ShuffleDeckOfCards.py: -------------------------------------------------------------------------------- 1 | # Python program to shuffle a deck of cards 2 | 3 | # importing modules 4 | import itertools, random 5 | 6 | # make a deck of cards 7 | deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club'])) 8 | 9 | # shuffle the cards 10 | random.shuffle(deck) 11 | 12 | # draw five cards 13 | print("You got:") 14 | for i in range(5): 15 | print(deck[i][0], "of", deck[i][1]) 16 | -------------------------------------------------------------------------------- /Java/enhancedForLoop.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | String[] names = {"Bob", "Kate", "John"}; 4 | 5 | // Get the elements of names using a for loop, and print "My name is ____" 6 | for (String name : names){ 7 | System.out.println("My name is " + name); 8 | } 9 | } 10 | } 11 | 12 | 13 | 14 | 15 | /// Its a enhanced method of using loop for array in Java 16 | -------------------------------------------------------------------------------- /Java/forLoopForArray.java: -------------------------------------------------------------------------------- 1 | class Main { 2 | public static void main(String[] args) { 3 | String[] names = {"Bob", "Kate", "John"}; 4 | 5 | // Get the elements of names using a for loop, and print "My name is ____" 6 | for (int i = 0 ; i < names.length; i++){ 7 | System.out.println("My name is " + names[i]); 8 | } 9 | } 10 | } 11 | 12 | 13 | 14 | 15 | //Normal method of using loops in array 16 | -------------------------------------------------------------------------------- /Java/urlify.java: -------------------------------------------------------------------------------- 1 | package development; 2 | import java.util.*; 3 | public class urlify { 4 | 5 | public static void main(String[] args) { 6 | String s = "Mr JohnSmith "; 7 | String g=""; 8 | String[] k = s.split(" "); 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a[1000][1000]; 7 | long n,q; 8 | cin>>n>>q; 9 | for(long i=0;i>p; 13 | for(int j=0;j>a[i][j]; 16 | } 17 | } 18 | int s,m; 19 | for(long i=0;i>s>>m; 22 | } 23 | cout< li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Java/Ide.java: -------------------------------------------------------------------------------- 1 | /* package codechef; // don't place package name! */ 2 | 3 | import java.util.Scanner; 4 | class AddNumbers 5 | { 6 | public static void main(String args[]) 7 | { 8 | int x, y, z; 9 | 10 | System.out.println("Enter two integers to calculate their sum"); 11 | Scanner in = new Scanner(System.in); 12 | 13 | x = in.nextInt(); 14 | y = in.nextInt(); 15 | z = x + y; 16 | 17 | System.out.println("Sum of the integers = " + z); 18 | } 19 | } -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /C++/gcd_lcm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int gcd(int a, int b) { 5 | while(a > 0) { 6 | int temp = b % a; 7 | b = a; 8 | a = temp; 9 | } 10 | return b; 11 | } 12 | 13 | int lcm(int a, int b) { 14 | return (a * b) / gcd(a, b); 15 | } 16 | 17 | int main(int argc, char const *argv[]) { 18 | 19 | int a, b; 20 | cin >> a >> b; 21 | cout << "GCD: " << gcd(a, b) << " LCM: " << lcm(a, b) << endl; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C/circle.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | double r; //r=radius 5 | printf("Enter radius of circle: "); 6 | scanf("%lf",&r); 7 | double pi=3.14; 8 | if(r<10) 9 | { 10 | printf("circumference of circle with radius %lf is %lf \n",r,2*pi*r); 11 | } 12 | else if(r>10) 13 | { 14 | printf("area of circle with radius %lf is %lf \n",r,pi*r*r); 15 | } 16 | else 17 | { 18 | printf("not defined \n"); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Java/Ide (2).java: -------------------------------------------------------------------------------- 1 | /* package codechef; // don't place package name! */ 2 | 3 | import java.util.Scanner; 4 | class multiplyNumbers 5 | { 6 | public static void main(String args[]) 7 | { 8 | int x, y, z; 9 | 10 | System.out.println("Enter two integers to calculate their product"); 11 | Scanner in = new Scanner(System.in); 12 | 13 | x = in.nextInt(); 14 | y = in.nextInt(); 15 | z = x * y; 16 | 17 | System.out.println("Product of the integers = " + z); 18 | } 19 | } -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | -------------------------------------------------------------------------------- /C++/Nirala_op.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long int a,b; 6 | cin>>a>>b; 7 | if(a>b) 8 | for(long long int i=1;i<=b;i++) 9 | { 10 | if((a*i)%b==0) 11 | { 12 | cout<<(a*i); 13 | break; 14 | } 15 | } 16 | else 17 | for(long long int i=1;i<=a;i++) 18 | { 19 | if((b*i)%a==0) 20 | { 21 | cout<<(b*i); 22 | break; 23 | } 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Random Image Feed 8 | 9 | 10 | 11 | 12 |

Random Image Feed

13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /C++/code1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int n,m; 10 | cin>>n>>m; 11 | if(n%m==0) 12 | { 13 | if((n/m)%2==0) cout<<"A"; 14 | else 15 | cout<<"B"; 16 | } 17 | else 18 | { 19 | if((n/m)%2==0) cout<<"B"; 20 | else 21 | cout<<"A"; 22 | } 23 | cout<<"\n"; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C++/hmmm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | vector v; 10 | int a,b; 11 | for(int i=0;i>v[i]; 14 | a=v[0]; 15 | b=v[1]; 16 | if(i>0 && v[i]>v[i-1]) 17 | a=v[i]; 18 | } 19 | for(int i=1;iv[i-1]&& v[i]!=a) 22 | b=v[i]; 23 | } 24 | int c=(a*b); 25 | cout <arr[j]: 7 | k=j 8 | arr[i],arr[k]=arr[k],arr[i] 9 | if __name__=="__main__": 10 | average=0 11 | c=[for i in range(2000)] 12 | for i in range(1,16): 13 | start=time.time() 14 | selection_sort(c) 15 | end=time.time() 16 | average+=end-start 17 | print(f'Average is {(average*1000000)/15}') 18 | -------------------------------------------------------------------------------- /bootstrap_use/css/example2.css: -------------------------------------------------------------------------------- 1 | #left { 2 | background-color: blue; 3 | float: left; 4 | margin-left: 15%; 5 | margin-top: 10%; 6 | width: 35%; 7 | } 8 | 9 | #right { 10 | background-color: red; 11 | float: right; 12 | margin-right: 15%; 13 | margin-top: 10%; 14 | width: 35%; 15 | } 16 | 17 | #next { 18 | bottom: 10%; 19 | right: 15%; 20 | position: absolute; 21 | } 22 | 23 | #previous { 24 | bottom: 10%; 25 | left: 15%; 26 | position: absolute; 27 | } -------------------------------------------------------------------------------- /Python/Your-First-Loop/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Your First Loop 3 | 4 | If you run this code you'll see a count from 0 to 9 (White characters). 5 | 6 | 1. Fix it so that it counts up to 11, you'll see 101 on green afterwards. 7 | 8 | 9 | **Can you fix it?** 10 | 11 | 12 | ### :mag_right: Important: 13 | 14 | There's a series of exercises dedicated to Lists and Loops, we encourage you to go and finish [those](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises) after this exercise. ( 15 | 16 | And then, come back! :smiley:). -------------------------------------------------------------------------------- /Java/area.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | import java.util.Scanner; 4 | public class area { 5 | public static void main(String[] args) { 6 | Scanner scan = new Scanner(System.in); 7 | double area,circumference; 8 | 9 | System.out.println("Enter radius"); 10 | double r = scan.nextDouble(); 11 | area=Math.PI*r*r; 12 | circumference=2*Math.PI*r; 13 | System.out.println("area: "+area); 14 | System.out.println("circumference : "+circumference); 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Python/Insertion_Sort.py: -------------------------------------------------------------------------------- 1 | import time 2 | def insertion_sort(arr): 3 | for i in range(1,len(arr)): 4 | j=i-1 5 | temp=arr[i] 6 | while j>-1 and temp", element) 16 | } 17 | 18 | // Only getting value using range 19 | for _, value := range x { 20 | fmt.Println(value) 21 | } 22 | 23 | // Range and counter 24 | j := 0 25 | for range x { 26 | fmt.Println(x[j]) 27 | j++ 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Python/Your-First-Loop/README.es.md: -------------------------------------------------------------------------------- 1 | # `14` Tu primer bucle o loop 2 | 3 | Si ejecutas este código verás una cuenta de 0 a 9 (caracteres blancos). 4 | 5 | 1. Corrígelo para que cuente hasta 11,verás 101 en verde después. 6 | 7 | 8 | **¿Puedes corregirlo?** 9 | 10 | ### :mag_right: Important: 11 | 12 | Hay una serie de ejercicios dedicados a listas y bucles o loops, te invitamos a realizar [esos](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises) primero antes de continuar con el siguiente ejercicio. 13 | 14 | ¡Y luego, regresa! :smiley. 15 | -------------------------------------------------------------------------------- /C/rupee and smallest possible denominationn.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,e,f,g,h,i,j,k; 5 | printf("enter the amount"); 6 | scanf("%d",&a); 7 | 8 | b=a/100; 9 | c=a%100; 10 | d=c/50; 11 | e=c%50; 12 | f=e/10; 13 | g=e%10; 14 | h=g/5; 15 | i=g%5; 16 | j=i/2; 17 | k=i%2; 18 | 19 | printf("100 rupees=%d\n",b); 20 | printf("50 rupees=%d\n",d); 21 | printf("10 rupees=%d\n",f); 22 | printf("5 rupees=%d\n",h); 23 | printf("2 rupees=%d\n",j); 24 | printf("1 rupees=%d\n",k); 25 | } 26 | -------------------------------------------------------------------------------- /C++/concatenation_of_the_string: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main () 4 | { 5 | string str1, str2, result; 6 | int i; 7 | cout <<" Enter the first string: "; 8 | cin >> str1; 9 | cout << " Enter the second string: "; 10 | cin >> str2; 11 | for ( i = 0; i < str1.size(); i++) 12 | { 13 | result = result + str1[i]; 14 | } 15 | 16 | for ( i = 0; i < str2.size(); i++) 17 | { 18 | result = result + str2[i]; 19 | } 20 | cout << " The Concatenation of the string " << str1 << " and " << str2 << " is " <arr[j+1]: 7 | arr[j],arr[j+1]=arr[j+1],arr[j] 8 | flag=i 9 | if flag==-1: 10 | break 11 | if __name__=="__main__": 12 | average=0 13 | c=[for i in range(2000)] 14 | for i in range(1,16): 15 | start=time.time() 16 | bubble_sort(c) 17 | end=time.time() 18 | average+=end-start 19 | 20 | print(f'Average is {(average*1000000)/15}') 21 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Python/Random-Colors-Loop/test.py: -------------------------------------------------------------------------------- 1 | import io 2 | import sys 3 | sys.stdout = buffer = io.StringIO() 4 | 5 | # from app import my_function 6 | import pytest 7 | import app 8 | import os 9 | import re 10 | 11 | @pytest.mark.it('Print the correct output on the console') 12 | def test_for_file_output(capsys): 13 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 14 | with open(path, 'r') as content_file: 15 | content = content_file.read() 16 | pattern = r"print\(get_allStudentColors\(\)\)" 17 | regex = re.compile(pattern) 18 | assert bool(regex.search(content)) == True -------------------------------------------------------------------------------- /Python/Random-Numbers/test.py: -------------------------------------------------------------------------------- 1 | import io 2 | import sys 3 | sys.stdout = buffer = io.StringIO() 4 | 5 | # from app import my_function 6 | import pytest 7 | import os 8 | import re 9 | 10 | @pytest.mark.it("You should update only line 5 using randint()") 11 | def test_conditional(): 12 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 13 | with open(path, 'r') as content_file: 14 | content = content_file.read() 15 | pattern = r"random_number(\s*)=(\s*)random\.rand\w+\(1,10\)" 16 | regex = re.compile(pattern) 17 | assert bool(regex.search(content)) == True 18 | 19 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /C++/MAKETREE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class addition 4 | { 5 | public: 6 | int inita = 0, initb = 0; 7 | int *a, *b; 8 | 9 | public: 10 | addition(int x, int y) 11 | { 12 | a = &inita; 13 | b = &initb; 14 | // cout << &a << " " << &b << endl; 15 | *b = y; 16 | *a = x; 17 | // a = &x; 18 | // b = &y; 19 | } 20 | 21 | void add() 22 | { 23 | cout << (*a + *b) << endl; 24 | } 25 | }; 26 | 27 | int main() 28 | { 29 | 30 | addition a(10, 20); 31 | 32 | a.add(); 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /3-764-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void solve() 4 | { 5 | int n; 6 | cin>>n; 7 | vectora(n); 8 | for(int i=0;i>a[i]; 11 | } 12 | sort(a.begin(),a.end()); 13 | cout<>t; 40 | while(t--) 41 | { 42 | solve(); 43 | } 44 | return 0; 45 | } 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /rttcallc1.py: -------------------------------------------------------------------------------- 1 | import time 2 | import requests 3 | import math 4 | url1 = "ip1:port" 5 | url2 = "ip2:port" 6 | url3 = "ip3:port" 7 | 8 | def speedFunc(url , xa, ya , xb, yb): 9 | t1 = time.time() 10 | r = requests.get(url) 11 | t2 = time.time() 12 | # calculation of distance using this formula 13 | dis = math.sqrt( (xa - xb)*2 + (xa - xb)*2 ) 14 | rtime = int(t2-t1)/2 15 | speed = dis/rtime 16 | return speed 17 | speed12 = speedFunc(url1 , x1, y1 , x2, y2) 18 | speed23 = speedFunc(url2 , x2, y2 , x3, y3) 19 | speed31 = speedFunc(url3 , x3, y3 , x2, y2) 20 | avgspeed = (speed12 + speed23 + speed31)/3 21 | -------------------------------------------------------------------------------- /C/string_rev.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | 5 | { 6 | 7 | int i, space, rows, k=0; 8 | 9 | printf("Enter number of rows: "); 10 | 11 | scanf("%d",&rows); 12 | 13 | for(i=1; i<=rows; ++i, k=0) 14 | 15 | { 16 | 17 | for(space=1; space<=rows-i; ++space) 18 | 19 | { 20 | 21 | printf(" "); 22 | 23 | } 24 | 25 | while(k != 2*i-1) 26 | 27 | { 28 | 29 | printf("* "); 30 | 31 | ++k; 32 | 33 | } 34 | 35 | printf("\n"); 36 | 37 | } 38 | 39 | 40 | 41 | return 0; 42 | 43 | } 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Python/Random-Colors-Loop/app.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def get_color(color_number=4): 4 | # making sure is a number and not a string 5 | color_number = int(color_number) 6 | 7 | switcher={ 8 | 0:'red', 9 | 1:'yellow', 10 | 2:'blue', 11 | 3:'green', 12 | 4:'black' 13 | } 14 | return switcher.get(color_number,"Invalid Color Number") 15 | 16 | 17 | def get_allStudentColors(): 18 | 19 | example_color = 1 20 | students_array = [] 21 | #your loop here 22 | 23 | 24 | 25 | 26 | 27 | print(get_allStudentColors()) -------------------------------------------------------------------------------- /Python/001_Basic_py_program.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Hello World Program in Python (3) 3 | ''' 4 | print("Hello World!") # <- Yes thats IT. 5 | # Yeah, RIP long C++/C/Java codes. 6 | # Actually, it is short since python is a general purpose scripting language 7 | 8 | ''' 9 | To run this prorgram, first install python from python.org. 10 | Next, once python is setup, open a CMD/terminal window and run the following after navigating to your work directory: 11 | 12 | Windows and Linux: 13 | python .py 14 | ''' -------------------------------------------------------------------------------- /Java/Ide (1).java: -------------------------------------------------------------------------------- 1 | /* package codechef; // don't place package name! */ 2 | 3 | import java.util.Scanner; 4 | class subtractNumbers // class statement 5 | { 6 | public static void main(String args[]) // main from where program will start to wrok 7 | { 8 | int x, y, z; 9 | 10 | System.out.println("Enter two integers to calculate their difference"); 11 | Scanner in = new Scanner(System.in); // creating sacanner object to input output operations 12 | 13 | x = in.nextInt(); 14 | y = in.nextInt(); 15 | z = x - y; 16 | 17 | System.out.println("difference of the integers = " + z); // printing results 18 | } 19 | } -------------------------------------------------------------------------------- /Java/RecursiveInsertionSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class InsertionSort{ 4 | public static void main(int arr[], int length){ 5 | //Base Case 6 | if (n <= 1){ 7 | return; 8 | } 9 | //Sort the first n-1 elements 10 | insertionSort(arr, length-1); 11 | int last = arr[length-1]; 12 | int j = length-2; 13 | 14 | //Shift the elements of the sorted part that are greater than the value to the right 15 | while (j >= 0 && arr[j] > last) 16 | { 17 | arr[j+1] = arr[j]; 18 | j--; 19 | } 20 | arr[j+1] = last; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Python/Kadane_Algorithm.py: -------------------------------------------------------------------------------- 1 | // Kadane’s algorithm is a Dynamic Programming approach to solve “the largest contiguous elements in an array” with runtime of O(n). 2 | // Kadane’s Algorithm, aka Maximum Sum of Subarray, is an interesting algorithm problem that can be used to solve Maximum Subarray Problem. 3 | 4 | 5 | def max_subarray(A): 6 | max_so_far = A[0] 7 | elements_so_far = [A[0]] 8 | 9 | for x in A[1:]: 10 | if x > sum(elements_so_far + [x]): 11 | elements_so_far = [x] 12 | else: 13 | elements_so_far.append(x) 14 | 15 | max_so_far = max(max_so_far, sum(elements_so_far)) 16 | 17 | return max_so_far 18 | -------------------------------------------------------------------------------- /Python/Create-A-For-Loop/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Create A For Loop 3 | 4 | Loops are very useful, you don't have to repeat yourself by writing the same lines many times. 5 | 6 | The `for` loop lets you run the same code for different values. 7 | 8 | 9 | ## :mag_right: Important: 10 | 11 | Read more on loops: https://www.w3schools.com/python/python_for_loops.asp 12 | 13 | 14 | ## 📝 Instructions: 15 | 16 | 1. Create a function called `standards_maker`. 17 | 18 | 2. The function has to print 300 times the phrase "I will write questions if I am stuck". 19 | 20 | 3. Call the function `standards_maker()` 21 | 22 | ## 💡 Hint: 23 | 24 | - You can use the `range()` function in the for loop. 25 | -------------------------------------------------------------------------------- /Python/Binary_Search.py: -------------------------------------------------------------------------------- 1 | import Input 2 | import time 3 | def binary_search(arr,low,high,x): 4 | if low>high: 5 | return -1 6 | else: 7 | mid=(low+high)//2 8 | if arr[mid]==x: 9 | return mid 10 | elif arr[mid]>x: 11 | return binary_search(arr,low,mid-1,x) 12 | elif arr[mid] 50) { 4 | $(".navbar-fixed-top").addClass("top-nav-collapse"); 5 | } else { 6 | $(".navbar-fixed-top").removeClass("top-nav-collapse"); 7 | } 8 | }); 9 | 10 | //jQuery for page scrolling feature - requires jQuery Easing plugin 11 | $(function() { 12 | $('a.page-scroll').bind('click', function(event) { 13 | var $anchor = $(this); 14 | $('html, body').stop().animate({ 15 | scrollTop: $($anchor.attr('href')).offset().top 16 | }, 1500, 'easeInOutExpo'); 17 | event.preventDefault(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /C++/Prog8 (Calculator).cpp: -------------------------------------------------------------------------------- 1 | using namespace std; 2 | #include 3 | int main() 4 | { 5 | /*Here I Try To Create A Basic Calculator For Adding,Substraction,Mutiply 6 | and Divide The Two Number*/ 7 | cout <<"Let's Begin\n"; 8 | int a,b; 9 | //First We Enter The Numbers 10 | cout <<"Enter The Value Of A\n"; 11 | cin >>a; 12 | cout <<"Enter The Value Of B\n"; 13 | cin >>b; 14 | //Then Applied the Formula and Wait for Output 15 | cout <<"Sum = " < 2 | using namespace std; 3 | 4 | void insertionSort(int arr[], int n) 5 | { 6 | int i, key, j; 7 | for (i = 1; i < n; i++) 8 | { 9 | key = arr[i]; 10 | j = i - 1; 11 | 12 | while (j >= 0 && arr[j] > key) 13 | { 14 | arr[j + 1] = arr[j]; 15 | j = j - 1; 16 | } 17 | arr[j + 1] = key; 18 | } 19 | } 20 | void printArray(int arr[], int n) 21 | { 22 | int i; 23 | for (i = 0; i < n; i++) 24 | cout << arr[i] << " "; 25 | cout << endl; 26 | } 27 | 28 | int main() 29 | { 30 | int arr[] = { 12, 11, 13, 5, 6 }; 31 | int n = sizeof(arr) / sizeof(arr[0]); 32 | 33 | insertionSort(arr, n); 34 | printArray(arr, n); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Python/Create-A-For-Loop/README.es.md: -------------------------------------------------------------------------------- 1 | # `16` Crear un bucle (loop) For 2 | 3 | Los bucles o loops son muy útiles, no tienes que repetir código escribiendo las mismas líneas muchas veces. 4 | 5 | El bucle o loop `for` te permite ejecutar el mismo código varias veces para diferentes valores. 6 | 7 | ## :mag.right: Importante: 8 | 9 | Puedes leer más al respecto aquí: https://ellibrodepython.com/for-python 10 | 11 | ## 📝 Instrucciones: 12 | 13 | 1. Crea una función llamada `standards_maker()`. 14 | 15 | 2. La función tiene que imprimir 300 veces la frase "I will write questions if I am stuck". 16 | 17 | 3. Llama a la función `standards_maker()` 18 | 19 | ## 💡 Pista: 20 | 21 | - Puedes usar la función `range()` para el ciclo `for`. -------------------------------------------------------------------------------- /C++/fib%m.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define maxu INT_MAX 4 | 5 | long long find(long long m) 6 | { 7 | long long a = 0, b = 1, c = a + b; 8 | for (int i = 0; i < m * m; i++) { 9 | c = (a + b) % m; 10 | a = b; 11 | b = c; 12 | if (a == 0 && b == 1) return (i + 1); 13 | } 14 | } 15 | 16 | long long fib(long long y,long long m) 17 | { 18 | long long f[10000000]; 19 | f[0]=0; 20 | f[1]=1; 21 | for(long long i=2;i<=y;i++) 22 | f[i]=(f[i-1]+f[i-2])%m; 23 | return f[y]; 24 | } 25 | 26 | int main() 27 | { 28 | long long n,m; 29 | cin>>n>>m; 30 | long long y=n%(find(m)); 31 | long long x=fib(y,m); 32 | cout< 2 | 3 | int main() 4 | { 5 | int array[100], search, c, n, count = 0; 6 | 7 | printf("Enter number of elements in array\n"); 8 | scanf("%d", &n); 9 | 10 | printf("Enter %d numbers\n", n); 11 | 12 | for (c = 0; c < n; c++) 13 | scanf("%d", &array[c]); 14 | 15 | printf("Enter a number to search\n"); 16 | scanf("%d", &search); 17 | 18 | for (c = 0; c < n; c++) { 19 | if (array[c] == search) { 20 | printf("%d is present at location %d.\n", search, c+1); 21 | count++; 22 | } 23 | } 24 | if (count == 0) 25 | printf("%d isn't present in the array.\n", search); 26 | else 27 | printf("%d is present %d times in the array.\n", search, count); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /3-776-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void solve() 4 | { 5 | string s; 6 | cin>>s; 7 | char c; 8 | cin>>c; 9 | int n=s.size(); 10 | int flag=0; 11 | for(int i=0;i>t; 38 | while(t--) 39 | { 40 | solve(); 41 | } 42 | return 0; 43 | } 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Python/Your-First-If/README.es.md: -------------------------------------------------------------------------------- 1 | # `08` Tu primer if... 2 | 3 | La aplicación actual está preguntando cuánto dinero tiene el usuario. Una vez el usuario ingresa la cantidad, debemos 'imprimir' usando **print** una de las siguientes respuestas: 4 | 5 | ## 📝 Instrucciones: 6 | 7 | 1. Si el usuario tiene más de $100, respondemos: "Give me your money!" (Dame tu dinero) 8 | 9 | 2. Si el usuario tiene más de $50, respondemos: "Buy me some coffee you cheap!" (¡Comprame un café!). 10 | 11 | 3. Si el usuario tiene igual o menos de $50, respondemos: "You are a poor guy, go away!" (¡Eres pobre!) 12 | 13 | ## 💡 Pista: 14 | 15 | - Usa un condicional `if/else` para verificar el valor de la variable `total`. 16 | 17 | - Puedes leer más al respecto [aquí](https://docs.python.org/3/tutorial/controlflow.html#if-statements) 18 | -------------------------------------------------------------------------------- /Python/How-Much-The-Wedding-Costs/README.md: -------------------------------------------------------------------------------- 1 | 2 | # How Much The Wedding Costs (if...else) 3 | 4 | Here is a table of prices for a wedding catering company: 5 | 6 | | # of guests | price | 7 | | --------------------- | --------- | 8 | | Up to 50 people | $4,000 | 9 | | Up to 100 people | $10,000 | 10 | | Up to 200 people | $15,000 | 11 | | More than 200 people | $20,000 | 12 | 13 | 14 | ## 📝 Instructions: 15 | 16 | 1. Please write an algorithm that prompts the user for the number of people attending their wedding and prints the corresponding price in the console. 17 | 18 | For example, if the user says that `20` people are attending to the wedding, it must cost `$4,000` dollars. 19 | 20 | ## 💡 Hint: 21 | 22 | + Use if/else to divide your code and set the value of the `price` variable the right way. 23 | -------------------------------------------------------------------------------- /Python/How-Much-The-Wedding-Costs/README.es.md: -------------------------------------------------------------------------------- 1 | # `08.1` Cuánto costará la boda (if...else) 2 | 3 | Aquí tenemos una tabla de precios de una compañía de catering de bodas: 4 | 5 | | # de invitados | Precio | 6 | | --------------------- | --------- | 7 | | Hasta 50 personas | $4,000 | 8 | | Hasta 100 personas | $10,000 | 9 | | Hasta 200 personas | $15,000 | 10 | | Más de 200 personas | $20,000 | 11 | 12 | 13 | ## 📝 Instrucciones: 14 | 15 | 1. Por favor, escribe un algoritmo que pregunte por el número de invitados a la boda y que imprime el precio correspondiente en la consola. 16 | 17 | Por ejemplo, si la persona dice que `20` personas van a la boda, deberìa costar `$4,000` dólares. 18 | 19 | ## 💡 Pista: 20 | 21 | + Usa if/else para dividir el código y definir el valor de la variable `price` de forma correcta. 22 | -------------------------------------------------------------------------------- /Python/Calling-Your-First-Function/README.es.md: -------------------------------------------------------------------------------- 1 | # `10` Llamando a tu primera función 2 | 3 | Las funciones son increíbles por muchas cosas, pero principalmente porque puedes encapsular tu código 4 | en piezas y reusar esas piezas muchas veces sin tener que escribir todo el código cada vez. 5 | 6 | ## 📝 Instrucciones: 7 | 8 | 1. Por favor, escribe todo tu código dentro de la función `my_main_code`. 9 | 10 | 2. La función `is_odd` está definida al inicio del código, por favor llama a esa función pasándole el número `45345` e imprime el resultado en la consola. 11 | 12 | ## :mag_right: Importante: 13 | 14 | + Hay una serie de ejercicios dedicados a las funciones [aquí](https://github.com/4GeeksAcademy/python-functions-programming-exercises), te recomendamos realizarlos después de hacer **tu primera función** en este ejercicio. (luego..¡Regresa! :smiley:). -------------------------------------------------------------------------------- /Python/Calling-Your-First-Function/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Calling Your First Function 3 | 4 | Functions are amazing because of many things, but mainly because you can encapsulate your code in pieces and re-use those pieces several times without having to type all that code again. 5 | 6 | 7 | 8 | ## 📝 Instructions: 9 | 10 | 1. Please, write all of your code inside the `my_main_code` function. 11 | 12 | 2. The function `is_odd` is defined at the beginning of the code, please call that function passing it the number `45345` and print the result on the console. 13 | 14 | 15 | ## :mag_right: Important: 16 | 17 | There's a series of exercises dedicated to Functions [here](https://github.com/4GeeksAcademy/python-functions-programming-exercises), we encourage you to go and finish those after your **first Function exercise** (And then... come back! :smiley). 18 | -------------------------------------------------------------------------------- /3-753-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void solve() 4 | { 5 | int a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; 6 | string s,ms; 7 | cin>>ms; 8 | unordered_mapmp; 9 | for(int i=0;i>s; 14 | int x=0; 15 | for(int i=1;i>t; 47 | while(t--) 48 | { 49 | solve(); 50 | } 51 | return 0; 52 | } 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Java/Mean.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | class Mean { 4 | public static void main(String[] args) { 5 | final Scanner scan = new Scanner(System.in); 6 | 7 | int i; 8 | int j; 9 | 10 | int Median,m; 11 | 12 | float ans=0 ; 13 | System.out.println("Enter 5 numbers"); 14 | int[] arr = new int[5]; 15 | for(i=0;i<5;i++){ 16 | arr[i] = scan.nextInt(); 17 | ans=ans+arr[i]; 18 | } 19 | ans = ans/5; 20 | for(j=0;j<5;j++){ 21 | for(i=0;i<5;i++){ 22 | if(arr[i]>arr[j]){ 23 | m=arr[j]; 24 | arr[j]=arr[i]; 25 | arr[i]=m; 26 | } 27 | } 28 | } 29 | Median=arr[2]; 30 | System.out.println("Mean of 5 no. is: "+ans); 31 | 32 | System.out.println("Median of 5 no. is: "+Median); 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/animated.less: -------------------------------------------------------------------------------- 1 | // Animated Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .@{fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Java/LinearSearch.java: -------------------------------------------------------------------------------- 1 | // Java code for linearly search x in arr[]. If x 2 | // is present then return its location, otherwise 3 | // return -1 4 | class LinearSearch { 5 | // This function returns index of element x in arr[] 6 | static int search(int arr[], int n, int x) 7 | { 8 | for (int i = 0; i < n; i++) { 9 | // Return the index of the element if the element 10 | // is found 11 | if (arr[i] == x) 12 | return i; 13 | } 14 | 15 | // return -1 if the element is not found 16 | return -1; 17 | } 18 | 19 | public static void main(String[] args) 20 | { 21 | int[] arr = { 3, 4, 1, 7, 5 }; 22 | int n = arr.length; 23 | 24 | int x = 4; 25 | 26 | int index = search(arr, n, x); 27 | if (index == -1) 28 | System.out.println("Element is not present in the array"); 29 | else 30 | System.out.println("Element found at position " + index); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Python/Calling-Your-First-Function/test.py: -------------------------------------------------------------------------------- 1 | import io, mock, pytest, os, re, sys 2 | 3 | @pytest.mark.it('Use the function print()') 4 | def test_for_print(): 5 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 6 | with open(path, 'r') as content_file: 7 | content = content_file.read() 8 | regex = re.compile(r"print\s*\(.+\)") 9 | assert bool(regex.search(content)) == True 10 | 11 | @pytest.mark.it("Call the is_odd function and pass the value 45345") 12 | def test_call_is_odd(): 13 | with mock.patch('app.is_odd') as mocked_is_odd: 14 | from app import my_main_code 15 | my_main_code() 16 | mocked_is_odd.assert_called_with(45345) 17 | 18 | @pytest.mark.it('The console should output "True" inside the function my_main_code ') 19 | def test_for_file_output(capsys): 20 | from app import my_main_code 21 | my_main_code() 22 | captured = capsys.readouterr() 23 | assert captured.out == "True\n" 24 | -------------------------------------------------------------------------------- /Python/Creating-Your-First-Function/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Creating Your First Function 3 | 4 | ## 📝 Instructions: 5 | 6 | 1. The function `add_numbers` is supposed to return the sum of 2 given numbers, please 7 | complete the needed code inside of the function to make it behave as expected. 8 | 9 | ## Expected Result: 10 | 11 | The exercise should print the number 7 in the console. 12 | 13 | ## 💡 Hint: 14 | 15 | + There is a function `"add_numbers"` already declared, it is receiving 2 parameters 16 | (variables `a` and `b`), as a developer you were given a task to fill the 17 | function content with the code needed to sum variable `a` with variable `b` and 18 | return the result of that operation. 19 | 20 | ## :mag_right: Important: 21 | 22 | For practicing more with functions, 4Geeks Academy has more than 20 incremental exercises [here](https://github.com/4GeeksAcademy/python-functions-programming-exercises). 23 | You should those first and then....come back! :smiley: 24 | 25 | 26 | -------------------------------------------------------------------------------- /Python/Creating-Your-First-Function/README.es.md: -------------------------------------------------------------------------------- 1 | # `10.1` Creando tu primera función 2 | 3 | 4 | ## 📝 Instrucciones: 5 | 6 | 1. La función `add_numbers` debería devolver la suma de 2 números dados. Por favor, completa el código necesario dentro de la función para hacer que se comporte como se espera. 7 | 8 | ## Resultado esperado: 9 | 10 | El ejercicio debería escribir el número 7 en la cónsola. 11 | 12 | ## 💡 Pista: 13 | 14 | + Hay una función `add_numbers` ya declarada, que está recibiendo dos parámetros 15 | (las variables `a` y `b`). Tú debes completar el contenido de la función con el código requerido para sumar la variable `a` con la variable `b` y devolver el resultado de la operación. 16 | 17 | ## :mag_right: Importante: 18 | 19 | + Para practicar con más funciones, 4Geeks Academy tiene más de 20 ejercicios que incrementan en dificultad [aquí](https://github.com/4GeeksAcademy/python-functions-programming-exercises), 20 | (luego..¡Regresa! :smiley:). 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Python/Random-Colors-Loop/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Random Colors (Loop) 3 | 4 | We have created a function that returns a color based on a number between 1 and 4 (for any different number, it will return the color `black`). 5 | 6 | ## 📝 Instructions: 7 | 8 | Let's say that we are teachers in a 10 student classroom and we want to randomly assign ONE color, between `red`, `yellow`, `blue` and `green`, to EACH student. 9 | 10 | (only ONE color PER student) 11 | 12 | 1. Change the function `get_allStudentColors` so it returns an list of 10 colors, were each item in the list represents the color assigned to each student. 13 | 14 | ## 💡 Hint: 15 | 16 | - You have 10 students, you need to loop 10 times. 17 | 18 | - Each time you loop, generate a random number between 1-4 using the `randint()` function we saw on the last exercise. 19 | 20 | - Use the `get_color` function on this exercise to get the color name from the number you get. 21 | 22 | - call the function `get_allStudentColors` and print the result on the console. 23 | 24 | -------------------------------------------------------------------------------- /Web/memegenerator.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import styles from './styles.module.css'; 3 | import { useHistory, useLocation } from 'react-router-dom'; 4 | import { useClipboard } from 'use-clipboard-copy'; 5 | 6 | export const MemeGenerated = () => { 7 | 8 | const [copied, setCopied] = useState(false); 9 | 10 | const clipboard = useClipboard(); 11 | const history = useHistory(); 12 | const location = useLocation(); 13 | const url = new URLSearchParams(location.search).get('url'); 14 | 15 | const copyLink = () => { 16 | clipboard.copy(url); 17 | setCopied(true); 18 | }; 19 | 20 | return( 21 |
22 | 25 | { url && meme } 26 | 29 |
30 | ); 31 | }; 32 | -------------------------------------------------------------------------------- /Python/The-Beatles/README.md: -------------------------------------------------------------------------------- 1 | 2 | # The Beatles 3 | 4 | Who does not like The Beatles? 5 | 6 | A BBC study has proved that 90% of kids don't know the band.. so sad.. :( 7 | 8 | This is the chorus of one of the most famous Beatle songs: 9 | 10 | > Let it be, let it be, let it be, let it be 11 | > Whisper words of wisdom 12 | > Let it be 13 | 14 | ## 📝 Instructions: 15 | 16 | 1. Create a function called `sing()` 17 | 18 | 2. The function needs to **print** (use the `print` statement and not `return`) a string with the exact same lyrics 19 | [you can hear from the 3:10 sec to the end of the song at 3:54 sec](https://www.youtube.com/watch?v=QDYfEBY9NM4). 20 | 21 | 22 | ## Expected result: 23 | 24 | ```sh 25 | let it be, 26 | let it be, 27 | let it be, 28 | let it be, 29 | whisper words of wisdom, let it be, let it be, 30 | let it be, 31 | let it be, 32 | let it be, 33 | there will be an answer, let it be 34 | ``` 35 | 36 | ## 💡 Hint: 37 | 38 | - The words "let it be" repeat all the time, you should probably create a loop for that. 39 | -------------------------------------------------------------------------------- /rttcallc.py: -------------------------------------------------------------------------------- 1 | import time 2 | import requests 3 | def RTTCalc(url): 4 | # time when the signal is sent 5 | t1 = time.time() 6 | r = requests.get(url) 7 | # time when acknowledgement of signal 8 | # is received 9 | t2 = time.time() 10 | # total time taken 11 | rtime = int(t2-t1) 12 | return rtime 13 | 14 | url1 = "ip1:port" 15 | url2 = "ip2:port" 16 | url3 = "ip3:port" 17 | # we will half the round trip time while calculating the distance of node from other node 18 | rtd1 = (RTTCalc(url1) / 2) * avgspeed 19 | rtd2 = (RTTCalc(url2) / 2) * avgspeed 20 | rtd3 = (RTTCalc(url3) / 2)* avgspeed 21 | def pointCalc( x1, y1, r1, x2, y2, r2, x3, y3, r3): 22 | y = (( (x2 - x3 )( (x22 - x12) + (y22 - y12) + (r12 - r22) ) ) - ((x2 - x3 )( (x3*2 - x22) + (y32 - y22) + (r22 - r32) ))) / ( 2( (y1 - y2 )(x2 - x3) - (y2 - y3 )(x1 - x2) ) ) 23 | x = (( (y2 - y3 )( (y22 - y12) + (x22 - x12) + (r12 - r22) ) ) - ((y2 - y3 )( (y3*2 - y22) + (x32 - x22) + (r22 - r32) ))) / ( 2( (x1 - x2 )(y2 - y3) - (x2 - x3 )(y1 - y2) ) ) 24 | return [x , y] 25 | -------------------------------------------------------------------------------- /Python/Looping-With-FizzBuzz/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Looping With FizzBuzz 3 | 4 | This is a typical beginner test that is required to complete interviews in Google, Facebook and all the other big tech unicorns. 5 | 6 | 7 | ## 📝 Instructions: 8 | 9 | 1. Write the code needed to print in the console all the numbers from 1 to 100: 10 | 11 | + For multiples of 3, instead of the number, print "Fizz". 12 | 13 | + For multiples of 5, print "Buzz". 14 | 15 | + For numbers which are multiples of both 3 and 5, print "FizzBuzz". 16 | 17 | 18 | ## Expected result: 19 | 20 | ```py 21 | 22 | 1 23 | 2 24 | Fizz 25 | 4 26 | Buzz 27 | Fizz 28 | 7 29 | 8 30 | Fizz 31 | Buzz 32 | 11 33 | Fizz 34 | 13 35 | 14 36 | FizzBuzz 37 | 16 38 | .... 39 | .... 40 | 98 41 | Fizz 42 | Buzz 43 | 44 | 45 | ``` 46 | 47 | ### :mag_right: Important: 48 | 49 | There's a series of exercises dedicated to Lists and Loops, we encourage you to go and finish [those](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises) after this exercise. ( 50 | 51 | And then, come back! :smiley:). -------------------------------------------------------------------------------- /Java/500keyboard.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | 4 | import java.util.*; 5 | 6 | class Solution { 7 | public String[] findWords(String[] words) { 8 | String[] strs = {"QWERTYUIOP","ASDFGHJKL","ZXCVBNM"}; 9 | Map map = new HashMap<>(); 10 | for(int i = 0; i pair into the map 13 | } 14 | } 15 | List res = new LinkedList<>(); 16 | for(String w: words){ 17 | if(w.equals("")) continue; 18 | int index = map.get(w.toUpperCase().charAt(0)); 19 | for(char c: w.toUpperCase().toCharArray()){ 20 | if(map.get(c)!=index){ 21 | index = -1; //don't need a boolean flag. 22 | break; 23 | } 24 | } 25 | if(index!=-1) res.add(w);//if index != -1, this is a valid string 26 | } 27 | return res.toArray(new String[0]); 28 | } 29 | } -------------------------------------------------------------------------------- /Python/Random-Colors-Loop/README.es.md: -------------------------------------------------------------------------------- 1 | # `16` Colores aleatorios (ciclo) 2 | 3 | Hemos creado una función que devuelve un color basado en un número entre 1 y 4 (for any different number, it will return the color `black`). 4 | 5 | ## 📝 Instrucciones: 6 | 7 | Digamos que somos profesores en un aula con 10 estudiantes y queremos asignar a CADA ESTUDIANTE un color aleatorio entre `red`(rojo), `yellow` (amarillo),`blue` (azul) y `green` (verde). 8 | 9 | (solo UN color POR estudiante) 10 | 11 | 1. Cambia la función `get_allStudentColors` para que devuelva una lista con 10 colores, en donde cada elemento de la lista representa el color asignado a cada estudiante. 12 | 13 | ## 💡 Pista: 14 | 15 | - Tienes 10 estudiantes, necesitar que el ciclo itere 10 veces. 16 | 17 | - En cada iteración, genera un número aleatorio entre 1 y 4 usando la función `randint()` que hemos visto en ejercicios anteriores. 18 | 19 | - Usa la función `get_color` en este ejercicio saber qué color le corresponde al número obtenido. 20 | 21 | - Llama (ejecuta) la funcion `get_allStudentColors` e imprime su resultado en la consola 22 | 23 | -------------------------------------------------------------------------------- /Python/The-Beatles/README.es.md: -------------------------------------------------------------------------------- 1 | # `18` The Beatles 2 | 3 | ¿A quién no le gusta The Beatles? 4 | 5 | Un estudio de la BBC ha probado que el 90% de los niños y niñas no conocen la banda... muy triste... :( 6 | 7 | Este es el coro de una de las canciones más famosas de la banda: 8 | 9 | > Let it be, let it be, let it be, let it be 10 | > Whisper words of wisdom 11 | > Let it be 12 | 13 | ## 📝 Instrucciones: 14 | 15 | 1. Crea una función llamada `sing()` 16 | 17 | 2. La función necesita **print** (usa el método `print()` y no `return`) un texto con la misma letra 18 | [que puedes escuchar desde el segundo 3:10 hasta el final de la canción en el segundo 3:54](https://www.youtube.com/watch?v=QDYfEBY9NM4).. 19 | 20 | ## Resultado esperado: 21 | 22 | ```sh 23 | let it be, 24 | let it be, 25 | let it be, 26 | let it be, 27 | whisper words of wisdom, let it be, let it be, 28 | let it be, 29 | let it be, 30 | let it be, 31 | there will be an answer, let it be 32 | ``` 33 | 34 | ## 💡 Pista: 35 | 36 | - La frase "let it be" se repite todo el tiempo. Probablemente deberías usar un bucle o loop para eso :smiley: 37 | -------------------------------------------------------------------------------- /2-823-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void solve() 4 | { 5 | 6 | int n, c; 7 | cin >> n >> c; 8 | vector v(n); 9 | 10 | for (int i = 0; i < n; i++) 11 | { 12 | cin >> v[i]; 13 | } 14 | 15 | sort(v.begin(), v.end()); 16 | int ans = 0; 17 | int count = 1; 18 | for (int i = 1; i < n; i++) 19 | { 20 | if (v[i] == v[i - 1]) 21 | { 22 | count++; 23 | } 24 | else 25 | { 26 | //cout<> t; 49 | while (t--) 50 | { 51 | solve(); 52 | } 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /Python/Looping-With-FizzBuzz/README.es.md: -------------------------------------------------------------------------------- 1 | # `15` Iterando con FizzBuzz 2 | 3 | Esta es una típica prueba de principiante que es exigida para las entrevistas en Google, Facebook y las demás grandes compañías de tecnología. 4 | 5 | 6 | ## 📝 Instrucciones: 7 | 8 | 1. Escribe el código necesario para imprimer en la consola todos los números del 1 al 100: 9 | 10 | + Para múltiplos de 3, en lugar de imprimir el número, imprime "Fizz". 11 | 12 | + Para múltiplos de 5, imprime "Buzz". 13 | 14 | + Para números que son múltiplos de 3 y de 5, imprime "FizzBuzz". 15 | 16 | ## Resultado esperado: 17 | 18 | ```py 19 | 20 | 1 21 | 2 22 | Fizz 23 | 4 24 | Buzz 25 | Fizz 26 | 7 27 | 8 28 | Fizz 29 | Buzz 30 | 11 31 | Fizz 32 | 13 33 | 14 34 | FizzBuzz 35 | 16 36 | .... 37 | .... 38 | 98 39 | Fizz 40 | Buzz 41 | 42 | 43 | ``` 44 | 45 | 46 | ### :mag_right: Important: 47 | 48 | Hay una serie de ejercicios dedicados a listas y ciclos, te invitamos a realizar [esos](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises) primero antes de continuar con el siguiente ejercicio. 49 | 50 | ¡Y luego, regresa! :smiley. 51 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | .fa-icon-rotate(@degrees, @rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 17 | -webkit-transform: rotate(@degrees); 18 | -ms-transform: rotate(@degrees); 19 | transform: rotate(@degrees); 20 | } 21 | 22 | .fa-icon-flip(@horiz, @vert, @rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 24 | -webkit-transform: scale(@horiz, @vert); 25 | -ms-transform: scale(@horiz, @vert); 26 | transform: scale(@horiz, @vert); 27 | } 28 | -------------------------------------------------------------------------------- /Web/City website/font-awesome/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | @mixin fa-icon-rotate($degrees, $rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 17 | -webkit-transform: rotate($degrees); 18 | -ms-transform: rotate($degrees); 19 | transform: rotate($degrees); 20 | } 21 | 22 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 24 | -webkit-transform: scale($horiz, $vert); 25 | -ms-transform: scale($horiz, $vert); 26 | transform: scale($horiz, $vert); 27 | } 28 | -------------------------------------------------------------------------------- /Java/UserDAO.java: -------------------------------------------------------------------------------- 1 | package net.codejava; 2 | 3 | import java.sql.*; 4 | 5 | public class UserDAO { 6 | 7 | public User checkLogin(String email, String password) throws SQLException, 8 | ClassNotFoundException { 9 | String jdbcURL = "jdbc:mysql://localhost:3306/bookshop"; 10 | String dbUser = "root"; 11 | String dbPassword = "password"; 12 | 13 | Class.forName("com.mysql.jdbc.Driver"); 14 | Connection connection = DriverManager.getConnection(jdbcURL, dbUser, dbPassword); 15 | String sql = "SELECT * FROM users WHERE email = ? and password = ?"; 16 | PreparedStatement statement = connection.prepareStatement(sql); 17 | statement.setString(1, email); 18 | statement.setString(2, password); 19 | 20 | ResultSet result = statement.executeQuery(); 21 | 22 | User user = null; 23 | 24 | if (result.next()) { 25 | user = new User(); 26 | user.setFullname(result.getString("fullname")); 27 | user.setEmail(email); 28 | } 29 | 30 | connection.close(); 31 | 32 | return user; 33 | } 34 | } -------------------------------------------------------------------------------- /Best Time to Buy and Sell Stock with Cooldown: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int maxProfit(int[] prices) { 3 | // return solve(prices,0,false); 4 | return dp(prices); 5 | } 6 | public int solve(int [] prices,int idx,boolean is){ 7 | if(idx>=prices.length) 8 | return 0; 9 | if(is){ 10 | // stock sell 11 | int a=solve(prices,idx+2,false)+prices[idx]; 12 | //stock retain 13 | int b=solve(prices,idx+1,true); 14 | return Math.max(a,b); 15 | } 16 | //stock buy 17 | int a=solve(prices,idx+1,true)-prices[idx]; 18 | //stock dont buy 19 | int b=solve(prices,idx+1,false); 20 | return Math.max(a,b); 21 | } 22 | public int dp(int [] prices){ 23 | int [][] arr=new int[2][prices.length+2]; 24 | for(int col=prices.length-1;col>=0;col--){ 25 | //row==0 26 | arr[0][col]=Math.max(arr[1][col+1]-prices[col],arr[0][col+1]); 27 | //row==1 28 | arr[1][col]=Math.max(arr[0][col+2]+prices[col],arr[1][col+1]); 29 | } 30 | return arr[0][0]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /C++/pro.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | 7 | float a, b, c, x1, x2, discriminant, realPart, imaginaryPart; 8 | cout << "Enter coefficients a, b and c: "; 9 | cin >> a >> b >> c; 10 | discriminant = b*b - 4*a*c; 11 | 12 | if (discriminant > 0) { 13 | x1 = (-b + sqrt(discriminant)) / (2*a); 14 | x2 = (-b - sqrt(discriminant)) / (2*a); 15 | cout << "Roots are real and different." << endl; 16 | cout << "x1 = " << x1 << endl; 17 | cout << "x2 = " << x2 << endl; 18 | } 19 | 20 | else if (discriminant == 0) { 21 | cout << "Roots are real and same." << endl; 22 | x1 = (-b + sqrt(discriminant)) / (2*a); 23 | cout << "x1 = x2 =" << x1 << endl; 24 | } 25 | 26 | else { 27 | realPart = -b/(2*a); 28 | imaginaryPart =sqrt(-discriminant)/(2*a); 29 | cout << "Roots are complex and different." << endl; 30 | cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl; 31 | cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl; 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /C++/avl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | class Node 8 | 9 | { 10 | 11 | public: 12 | 13 | int key; 14 | 15 | Node *left; 16 | 17 | Node *right; 18 | 19 | int height; 20 | 21 | }; 22 | 23 | 24 | 25 | void preOrder(Node *root){ 26 | 27 | if(root != NULL){ 28 | 29 | cout << root->key << " "; 30 | 31 | preOrder(root->left); 32 | 33 | preOrder(root->right); 34 | 35 | } 36 | 37 | } 38 | 39 | 40 | 41 | int height(Node *N) 42 | 43 | { 44 | 45 | if (N == NULL) 46 | 47 | return 0; 48 | 49 | return N->height; 50 | 51 | } 52 | 53 | 54 | 55 | int max(int a, int b) 56 | 57 | { 58 | 59 | return (a > b)? a : b; 60 | 61 | } 62 | 63 | 64 | 65 | 66 | 67 | Node* newNode(int key) 68 | 69 | { 70 | 71 | Node* root = new Node(); 72 | 73 | root->key = key; 74 | 75 | root->left = NULL; 76 | 77 | root->right = NULL; 78 | 79 | root->height = 1; 80 | 81 | 82 | 83 | return(root); 84 | 85 | } 86 | 87 | 88 | 89 | 90 | 91 | Node *rightRotate(Node *y) 92 | 93 | -------------------------------------------------------------------------------- /C++/Print_matrix_spiral.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void spiralprint(int a[][10],int m,int n){ 4 | int strow=0; 5 | int endrow=m-1; 6 | int stcol=0; 7 | int endcol=n-1; 8 | while(strow<=endrow && stcol<=endcol){ 9 | for(int i=stcol;i<=endcol;i++){ 10 | cout<strow){ 18 | for(int i=endcol;i>=stcol;i--){ 19 | cout<stcol){ 23 | for(int i=endrow;i>=strow;i--){ 24 | cout<>row>>column; 37 | cout<<"\n Matrix is :\n"; 38 | 39 | for(int i=0;i>a[i][j]; 42 | a[i][j]=val; 43 | val++; 44 | 45 | }} 46 | for(int i=0;ileft,root->right); 18 | } 19 | bool isSymmetricTest(TreeNode* p , TreeNode* q){ 20 | if(p == NULL && q == NULL) //left & right node is NULL 21 | return true; 22 | 23 | else if(p == NULL || q == NULL) //one of them is Not NULL 24 | return false; 25 | 26 | else if(p->val!=q->val) 27 | return false; 28 | 29 | return isSymmetricTest(p->left,q->right) && isSymmetricTest(p->right,q->left); //comparing left subtree's left child with right subtree's right child --AND-- comparing left subtree's right child with right subtree's left child 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /C++/InvolutoryMatrix.cpp: -------------------------------------------------------------------------------- 1 | // Program to implement involutory matrix. 2 | #include 3 | #define N 3 4 | using namespace std; 5 | 6 | // Function for matrix multiplication. 7 | void multiply(int mat[][N], int res[][N]) 8 | { 9 | for (int i = 0; i < N; i++) { 10 | for (int j = 0; j < N; j++) { 11 | res[i][j] = 0; 12 | for (int k = 0; k < N; k++) 13 | res[i][j] += mat[i][k] * mat[k][j]; 14 | } 15 | } 16 | } 17 | 18 | // Function to check involutory matrix. 19 | bool InvolutoryMatrix(int mat[N][N]) 20 | { 21 | int res[N][N]; 22 | 23 | // multiply function call. 24 | multiply(mat, res); 25 | 26 | for (int i = 0; i < N; i++) { 27 | for (int j = 0; j < N; j++) { 28 | if (i == j && res[i][j] != 1) 29 | return false; 30 | if (i != j && res[i][j] != 0) 31 | return false; 32 | } 33 | } 34 | return true; 35 | } 36 | 37 | // Driver function. 38 | int main() 39 | { 40 | int mat[N][N] = { { 1, 0, 0 }, 41 | { 0, -1, 0 }, 42 | { 0, 0, -1 } }; 43 | 44 | // Function call. If function return 45 | // true then if part will execute otherwise 46 | // else part will execute. 47 | if (InvolutoryMatrix(mat)) 48 | cout << "Involutory Matrix"; 49 | else 50 | cout << "Not Involutory Matrix"; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /Python/The-Beatles/test.py: -------------------------------------------------------------------------------- 1 | import io 2 | import sys 3 | sys.stdout = buffer = io.StringIO() 4 | from app import sing 5 | 6 | import pytest 7 | import os 8 | import app 9 | import re 10 | 11 | 12 | @pytest.mark.it("1. You should declare a function named sing and call it in the correct way") 13 | def test_functionSing(): 14 | f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') 15 | content = f.readlines() 16 | content = [x.strip() for x in content] 17 | my_funcName = [s for s in content if "def sing():" in s] 18 | my_funcNameVar = content.index(my_funcName[0]) 19 | regex = r"def sing\(\):" 20 | my_print = [s for s in content[2:] if "sing()" in s] 21 | my_printVar = content.index(my_print[0]) 22 | regexPrint = r"sing\(\)" 23 | assert re.match(regex, content[my_funcNameVar]) 24 | assert re.match(regexPrint, content[my_printVar]) 25 | 26 | @pytest.mark.it('2. Your function needs to print the correct output') 27 | def test_for_function_output(capsys): 28 | sing() 29 | captured = capsys.readouterr() 30 | assert captured.out.lower() == "let it be,\nlet it be,\nlet it be,\nlet it be,\nwhisper words of wisdom, let it be, let it be,\nlet it be,\nlet it be,\nlet it be,\nthere will be an answer, let it be\n".lower() 31 | -------------------------------------------------------------------------------- /C++/circular Queue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | int arr[SIZE]={0}; 4 | int f=-1,r=-1; 5 | void insert(int item); 6 | void remove(); 7 | void display(); 8 | int main() 9 | { 10 | insert(10); 11 | insert(14); 12 | insert(25); 13 | insert(30); 14 | remove(); 15 | display(); 16 | } 17 | 18 | void insert(int item) 19 | { 20 | if ((f==0 && r==SIZE-1) || r==f-1) 21 | { 22 | printf("overflow"); 23 | return; 24 | } 25 | else if(f==-1 && r==-1) 26 | { 27 | f=r=0; 28 | arr[r]=item; 29 | } 30 | else if(r==SIZE-1 && f!=0) 31 | { 32 | r=0; 33 | arr[r]=item; 34 | } 35 | else 36 | { 37 | arr[++r]=item; 38 | } 39 | } 40 | void remove() 41 | { 42 | int data; 43 | data=arr[f]; 44 | if(f==-1) 45 | { 46 | printf("Queue is Empty"); 47 | return; 48 | } 49 | arr[f]=-1; 50 | if(f==r) 51 | { 52 | f=r=-1; 53 | } 54 | else if(f==SIZE-1) 55 | f=0; 56 | else 57 | ++f; 58 | } 59 | 60 | void display() 61 | { 62 | if(f==-1) 63 | { 64 | printf("queue is empty"); 65 | return; 66 | } 67 | else if(f<=r) 68 | { 69 | for(int i=f;i<=r;i++) 70 | { 71 | printf(" %d",arr[i]); 72 | } 73 | } 74 | else 75 | { 76 | for(int i=f;i 2 | void merge(int arr[], int l, int m, int r) 3 | { 4 | int i, j, k; 5 | int n1 = m - l + 1; 6 | int n2 = r - m; 7 | int L[n1], R[n2]; 8 | for (i = 0; i < n1; i++) 9 | L[i] = arr[l + i]; 10 | for (j = 0; j < n2; j++) 11 | R[j] = arr[m + 1 + j]; 12 | i = 0; 13 | j = 0; 14 | k = l; 15 | while (i < n1 && j < n2) { 16 | if (L[i] <= R[j]) { 17 | arr[k] = L[i]; 18 | i++; 19 | } 20 | else { 21 | arr[k] = R[j]; 22 | j++; 23 | } 24 | k++; 25 | } 26 | while (i < n1) { 27 | arr[k] = L[i]; 28 | i++; 29 | k++; 30 | } 31 | while (j < n2) { 32 | arr[k] = R[j]; 33 | j++; 34 | k++; 35 | } 36 | } 37 | 38 | void mergeSort(int arr[], int l, int r) 39 | { 40 | if (l < r) { 41 | int m = l + (r - l) / 2; 42 | mergeSort(arr, l, m); 43 | mergeSort(arr, m + 1, r); 44 | merge(arr, l, m, r); 45 | } 46 | } 47 | 48 | int main() 49 | { 50 | int a[10]={10,5,4,5,16,11,20,8,9,10}; 51 | mergeSort(a,0,9); 52 | for (int i = 0; i <10; i++) 53 | { 54 | printf("%d ",a[i]); 55 | } 56 | 57 | 58 | } -------------------------------------------------------------------------------- /bootstrap_use/example9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 | First, but last 20 |
21 |
22 | Second, but unordered 23 |
24 | 27 |
28 |
29 | 30 | 33 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /C++/bipartite.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | vectorarr[10]; 7 | vector::iterator ptr; 8 | void insert(int u,int v); 9 | bool bipartite(int s); 10 | int main() 11 | { 12 | insert(1,2); 13 | insert(1,3); 14 | insert(3,2); 15 | //insert(3,4); 16 | //insert(1,3); 17 | //insert(5,5); 18 | printf(bipartite(1)?"true":"false"); 19 | /*for(int i=0;i<10;i++) 20 | for(ptr=arr[i].begin();ptr!=arr[i].end();ptr++) 21 | printf("%d ",*ptr); 22 | */ 23 | } 24 | 25 | void insert(int u,int v) 26 | { 27 | arr[u].push_back(v); 28 | arr[v].push_back(u); 29 | } 30 | 31 | bool bipartite(int s) 32 | { 33 | int temp; 34 | int visited[10]={0}; 35 | int level[10]={0}; 36 | level[s]=0; 37 | visited[s]=1; 38 | //memset(visited,0,sizeof(int)); 39 | queueq; 40 | q.push(s); 41 | while(!q.empty()) 42 | { 43 | temp=q.front(); 44 | //printf("%d ",temp); 45 | q.pop(); 46 | for(ptr=arr[temp].begin();ptr!=arr[temp].end();ptr++) 47 | { 48 | printf("%d ",*ptr); 49 | if(visited[*ptr]==0) 50 | { 51 | visited[*ptr]=1; 52 | level[*ptr]=level[temp]+1; 53 | q.push(*ptr); 54 | } 55 | else if(level[*ptr]==level[temp]) 56 | { 57 | return false; 58 | } 59 | } 60 | } 61 | return true; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /C++/heap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | void max_heapify(int b[], int n, int i) { 8 | 9 | int p=i; 10 | 11 | int l=2*i+1; 12 | 13 | int r=2*i+2; 14 | 15 | if(lb[p]){ 16 | 17 | p=l; 18 | 19 | } 20 | 21 | if(rb[p]){ 22 | 23 | p=r; 24 | 25 | } 26 | 27 | if(p!=i){ 28 | 29 | int temp=b[i]; 30 | 31 | b[i]=b[p]; 32 | 33 | b[p]=temp; 34 | 35 | max_heapify(b, n, p); 36 | 37 | } 38 | 39 | } 40 | 41 | 42 | 43 | void min_heapify(int b[], int n, int i){ 44 | 45 | int p=i; 46 | 47 | int l=2*i+1; 48 | 49 | int r=2*i+2; 50 | 51 | if(l>c; 86 | 87 | switch(c){ 88 | 89 | case 1: for (int i=n/2-1;i>=0;i--) 90 | 91 | max_heapify(b, n, i); 92 | 93 | -------------------------------------------------------------------------------- /C++/transpose matrix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a[10][10], transpose[10][10], row, column, i, j; 6 | 7 | cout << "Enter rows and columns of matrix: "; 8 | cin >> row >> column; 9 | 10 | cout << "\nEnter elements of matrix: " << endl; 11 | 12 | // Storing matrix elements 13 | for (int i = 0; i < row; ++i) { 14 | for (int j = 0; j < column; ++j) { 15 | cout << "Enter element a" << i + 1 << j + 1 << ": "; 16 | cin >> a[i][j]; 17 | } 18 | } 19 | 20 | // Printing the a matrix 21 | cout << "\nEntered Matrix: " << endl; 22 | for (int i = 0; i < row; ++i) { 23 | for (int j = 0; j < column; ++j) { 24 | cout << " " << a[i][j]; 25 | if (j == column - 1) 26 | cout << endl << endl; 27 | } 28 | } 29 | 30 | // Computing transpose of the matrix 31 | for (int i = 0; i < row; ++i) 32 | for (int j = 0; j < column; ++j) { 33 | transpose[j][i] = a[i][j]; 34 | } 35 | 36 | // Printing the transpose 37 | cout << "\nTranspose of Matrix: " << endl; 38 | for (int i = 0; i < column; ++i) 39 | for (int j = 0; j < row; ++j) { 40 | cout << " " << transpose[i][j]; 41 | if (j == row - 1) 42 | cout << endl << endl; 43 | } 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /Python/SimpleCalculator.py: -------------------------------------------------------------------------------- 1 | # Program make a simple calculator 2 | 3 | # This function adds two numbers 4 | def add(x, y): 5 | return x + y 6 | 7 | # This function subtracts two numbers 8 | def subtract(x, y): 9 | return x - y 10 | 11 | # This function multiplies two numbers 12 | def multiply(x, y): 13 | return x * y 14 | 15 | # This function divides two numbers 16 | def divide(x, y): 17 | return x / y 18 | 19 | 20 | print("Select operation.") 21 | print("1.Add") 22 | print("2.Subtract") 23 | print("3.Multiply") 24 | print("4.Divide") 25 | 26 | while True: 27 | # Take input from the user 28 | choice = input("Enter choice(1/2/3/4): ") 29 | 30 | # Check if choice is one of the four options 31 | if choice in ('1', '2', '3', '4'): 32 | num1 = float(input("Enter first number: ")) 33 | num2 = float(input("Enter second number: ")) 34 | 35 | if choice == '1': 36 | print(num1, "+", num2, "=", add(num1, num2)) 37 | 38 | elif choice == '2': 39 | print(num1, "-", num2, "=", subtract(num1, num2)) 40 | 41 | elif choice == '3': 42 | print(num1, "*", num2, "=", multiply(num1, num2)) 43 | 44 | elif choice == '4': 45 | print(num1, "/", num2, "=", divide(num1, num2)) 46 | break 47 | else: 48 | print("Invalid Input") 49 | -------------------------------------------------------------------------------- /Python/bmi_gui.py: -------------------------------------------------------------------------------- 1 | ##BMI GUI 2 | 3 | from bmi import * 4 | import tkinter 5 | 6 | 7 | def calculate(): 8 | user = Patient(weight=float(weight_entry.get()), 9 | height=float(height_entry.get())) 10 | bmi_label.configure(text="Your BMI is " + 11 | str(round(user.calculate_bmi(), 2)) 12 | + " which is " 13 | + user.bmi_analysis() + ".") 14 | 15 | interface = tkinter.Tk() 16 | interface.title("BMI Calculator") 17 | interface.minsize(150, 150) 18 | 19 | # declare labels 20 | height_label = tkinter.Label(text="Height (m)") 21 | weight_label = tkinter.Label(text="Weight (Kg)") 22 | bmi_label = tkinter.Label() 23 | 24 | # declare entry boxes 25 | height_entry = tkinter.Entry(justify="right") 26 | weight_entry = tkinter.Entry(justify="right") 27 | 28 | # declare buttons 29 | calculate_button = tkinter.Button(text="Calculate", command=calculate) 30 | 31 | # place widgets on grid 32 | height_label.grid(row=0, column=0, padx=10, pady=10) 33 | height_entry.grid(row=0, column=1, padx=10, pady=10) 34 | weight_label.grid(row=1, column=0, padx=10, pady=10) 35 | weight_entry.grid(row=1, column=1, padx=10, pady=10) 36 | bmi_label.grid(row=2, column=0, columnspan=2, padx=10, pady=10) 37 | calculate_button.grid(row=4, column=1, padx=10, pady=10) 38 | 39 | # interface loop 40 | tkinter.mainloop() 41 | -------------------------------------------------------------------------------- /bootstrap_use/example7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
Deserunt minim iis incurreret cohaerescant iis ab ab
19 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20 | 21 |
22 |
23 | 24 | 27 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Python/Your-First-If/test.py: -------------------------------------------------------------------------------- 1 | # from app import my_function 2 | import pytest,os,re,io,sys, mock, json 3 | 4 | @pytest.mark.it('Use the function print()') 5 | def test_for_print(capsys): 6 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 7 | with open(path, 'r') as content_file: 8 | content = content_file.read() 9 | regex = re.compile(r"print\(.+\)") 10 | assert bool(regex.search(content)) == True 11 | 12 | @pytest.mark.it("When input for more than 100 it should print: Give me your money!") 13 | def test_for_more(stdin, capsys, app): 14 | with mock.patch('builtins.input', lambda x: 101): 15 | app() 16 | captured = capsys.readouterr() 17 | assert "Give me your money!\n" == captured.out 18 | 19 | @pytest.mark.it("When input exactly 100 should print: Buy me some coffee you cheap ") 20 | def test_between(capsys, app): 21 | with mock.patch('builtins.input', lambda x: 100): 22 | app() 23 | captured = capsys.readouterr() 24 | assert "Buy me some coffee you cheap!\n" == captured.out 25 | 26 | @pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away") 27 | def test_for_less(capsys, app): 28 | with mock.patch('builtins.input', lambda x: 50): 29 | app() 30 | captured = capsys.readouterr() 31 | assert "You are a poor guy, go away!\n" == captured.out 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Java/Ide (3).java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class BubbleSortExample { 3 | static void bubbleSort(int[] arr) { 4 | int n = arr.length; 5 | int temp = 0; 6 | for(int i=0; i < n; i++){ 7 | for(int j=1; j < (n-i); j++){ 8 | if(arr[j-1] > arr[j]){ 9 | //swap elements 10 | temp = arr[j-1]; 11 | arr[j-1] = arr[j]; 12 | arr[j] = temp; 13 | } 14 | 15 | } 16 | } 17 | 18 | } 19 | public static void main(String[] args) { 20 | int arr[] ={3,60,35,2,45,320,5}; 21 | 22 | System.out.println("Array Before Bubble Sort"); 23 | for(int i=0; i < arr.length; i++){ 24 | System.out.print(arr[i] + " "); 25 | } 26 | System.out.println(); 27 | 28 | bubbleSort(arr);//sorting array elements using bubble sort 29 | 30 | System.out.println("Array After Bubble Sort"); 31 | for(int i=0; i < arr.length; i++){ 32 | System.out.print(arr[i] + " "); 33 | } 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Web/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | .navi{ 5 | position: absolute; 6 | top: 0px; 7 | padding: 4px; 8 | margin-bottom: 50px; 9 | /* padding: 5px; */ 10 | } 11 | body { 12 | background-color:gray; 13 | display: flex; 14 | align-items: center; 15 | justify-content: center; 16 | height: 100vh; 17 | margin: 0; 18 | } 19 | .phone { 20 | position: relative; 21 | overflow: hidden; 22 | border: 3px solid #eee; 23 | border-radius: 15px; 24 | height: 600px; 25 | width: 340px; 26 | } 27 | .phone .content { 28 | opacity: 0; 29 | object-fit: cover; 30 | position: absolute; 31 | top: 0; 32 | left: 0; 33 | height: calc(100% - 60px); 34 | width: 100%; 35 | transition: opacity 0.4s ease; 36 | } 37 | .phone .content.show { 38 | opacity: 1; 39 | } 40 | 41 | nav{ 42 | position: absolute; 43 | bottom: 0; 44 | left: 0; 45 | margin-top: -5px; 46 | width: 100%; 47 | } 48 | 49 | nav ul{ 50 | background-color: #eee; 51 | display: flex; 52 | list-style-type: none; 53 | padding: 0; 54 | margin: 0; 55 | height: 60px; 56 | } 57 | nav li{ 58 | color: #777; 59 | cursor: pointer; 60 | flex: 1; 61 | padding: 10px; 62 | text-align: center; 63 | } 64 | nav ul li p 65 | { 66 | font-size: 12px; 67 | margin: 2px 0; 68 | } 69 | nav ul li:hover,nav ul li active{ 70 | color:#8e44ad; 71 | } -------------------------------------------------------------------------------- /C++/Lat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int r, c, a[100][100], b[100][100], sum[100][100], i, j; 7 | 8 | cout << "Enter number of rows (between 1 and 100): "; 9 | cin >> r; 10 | 11 | cout << "Enter number of columns (between 1 and 100): "; 12 | cin >> c; 13 | 14 | cout << endl << "Enter elements of 1st matrix: " << endl; 15 | 16 | // Storing elements of first matrix entered by user. 17 | for(i = 0; i < r; ++i) 18 | for(j = 0; j < c; ++j) 19 | { 20 | cout << "Enter element a" << i + 1 << j + 1 << " : "; 21 | cin >> a[i][j]; 22 | } 23 | 24 | // Storing elements of second matrix entered by user. 25 | cout << endl << "Enter elements of 2nd matrix: " << endl; 26 | for(i = 0; i < r; ++i) 27 | for(j = 0; j < c; ++j) 28 | { 29 | cout << "Enter element b" << i + 1 << j + 1 << " : "; 30 | cin >> b[i][j]; 31 | } 32 | 33 | // Adding Two matrices 34 | for(i = 0; i < r; ++i) 35 | for(j = 0; j < c; ++j) 36 | sum[i][j] = a[i][j] + b[i][j]; 37 | 38 | // Displaying the resultant sum matrix. 39 | cout << endl << "Sum of two matrix is: " << endl; 40 | for(i = 0; i < r; ++i) 41 | for(j = 0; j < c; ++j) 42 | { 43 | cout << sum[i][j] << " "; 44 | if(j == c - 1) 45 | cout << endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /Python/How-Much-The-Wedding-Costs/test.py: -------------------------------------------------------------------------------- 1 | # from app import my_function 2 | import pytest,os,re,io,sys, mock, json 3 | 4 | @pytest.mark.it("Between 101 and 199 guests sould be priced 15,000") 5 | def test__between_100_and_200(capsys, app): 6 | with mock.patch('builtins.input', lambda x: 199): 7 | app() 8 | captured = capsys.readouterr() 9 | price = 15000 10 | assert "Your wedding will cost "+str(price)+" dollars\n" == captured.out 11 | 12 | @pytest.mark.it("Between 100 and 51 guests sould be priced 10,000") 13 | def test_between_101_and_51(capsys, app): 14 | with mock.patch('builtins.input', lambda x: 100): 15 | app() 16 | captured = capsys.readouterr() 17 | price = 10000 18 | assert "Your wedding will cost "+str(price)+" dollars\n" == captured.out 19 | 20 | 21 | @pytest.mark.it("Less than 50 guests sould be priced 4,000") 22 | def test_less_than_50(capsys, app): 23 | with mock.patch('builtins.input', lambda x: 49): 24 | app() 25 | captured = capsys.readouterr() 26 | price = 4000 27 | "Your wedding will cost "+str(price)+" dollars\n" == captured.out 28 | 29 | @pytest.mark.it("More than 200 should be priced 20,000") 30 | def test_t(capsys, app): 31 | with mock.patch('builtins.input', lambda x: 201): 32 | app() 33 | captured = capsys.readouterr() 34 | price = 20000 35 | "Your wedding will cost "+str(price)+" dollars\n" == captured.out 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Python/Creating-Your-First-Function/tests.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | jest.dontMock('fs'); 5 | //here we are going to store and accumulate (concatenate) all the console log's from the exercise 6 | let _buffer = ""; 7 | let _log = console.log; 8 | 9 | // lets override the console.log function to mock it, 10 | // but we are also going to save what supposed to be the ouput of the console inside _buffer 11 | global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); 12 | 13 | describe('All the javascript should match', function () { 14 | beforeEach(() => { 15 | //here I import the HTML into the document 16 | }); 17 | afterEach(() => { jest.resetModules(); }); 18 | 19 | it('console.log() function should be called with the sum of 3 + 4', function () { 20 | 21 | 22 | //then I import the index.js (which should have the alert() call inside) 23 | const file = require("./app.js"); 24 | 25 | //Expect the console log to have been called with the sum of 3 + 4 at least once 26 | expect(console.log).toHaveBeenCalledWith(3+4); 27 | //and I expect the console.log to be already called just one time. 28 | expect(console.log.mock.calls.length).toBe(1); 29 | 30 | //You can also compare the entire console buffer (if there have been several console.log calls on the exercise) 31 | //expect(_buffer).toBe("Compare with the entire function buffer out"); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /Java/merge.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class merge { 4 | 5 | 6 | static int[] mergesort(int[] arr,int lo,int hi) 7 | { 8 | if(hi==lo) 9 | { int[] ba=new int[1]; 10 | ba[0]=arr[lo]; 11 | return ba; 12 | } 13 | 14 | int mid=(hi+lo)/2; 15 | 16 | int[] lsa=mergesort(arr,lo,mid); 17 | int[] rsa=mergesort(arr,mid+1,hi); 18 | int[] result=mergetwosortedarray(lsa,rsa); 19 | return result; 20 | } 21 | 22 | 23 | 24 | static int[] mergetwosortedarray(int[] l,int[] r){ 25 | 26 | int i=0,j=0,k=0; 27 | int[] result=new int[l.length+r.length]; 28 | 29 | while(ir[j]) 32 | { result[k]=r[j]; 33 | k++; 34 | j++;} 35 | 36 | else 37 | {result[k]=l[i]; 38 | k++; 39 | i++; 40 | } 41 | } 42 | 43 | while(i 2 | using namespace std; 3 | #define IOS \ 4 | ios_base::sync_with_stdio(false); \ 5 | cin.tie(NULL); \ 6 | cout.tie(NULL); 7 | #define pii 8 | #define vi vector 9 | #define vp vector> 10 | #define vpp vector, int>> 11 | #define si set 12 | #define ll long long 13 | #define ld long double 14 | #define pqf priority_queue> 15 | #define pqb priority_queue, greater> 16 | #define ps(x, y) fixed << setprecision(y) << x 17 | #define MOD 1e9 18 | #define PI 3.1415926535 19 | 20 | void swap(int *a, int *b) 21 | { 22 | int temp = *a; 23 | *a = *b; 24 | *b = temp; 25 | } 26 | int arraySum(int a[], int n) 27 | { 28 | int initial_sum = 0; 29 | return accumulate(a, a + n, initial_sum); 30 | } 31 | 32 | void solve() 33 | { 34 | string s; 35 | int k=0; 36 | cin>>s; 37 | for (int i = 0; i < s.length(); i++) 38 | { 39 | if((s[i]=='4')||s[i]=='7'){ 40 | k++; 41 | 42 | } 43 | 44 | } 45 | cout<<(k==4||k==7?"YES":"NO"); 46 | } 47 | 48 | int main() 49 | { 50 | IOS 51 | #ifndef ONLINE_JUDGE 52 | freopen("input.txt", "r", stdin); 53 | freopen("output.txt", "w", stdout); 54 | #else 55 | #endif 56 | // int t; 57 | // cin >> t; 58 | // while (t--) 59 | solve(); 60 | return 0; 61 | } -------------------------------------------------------------------------------- /bootstrap_use/example6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 | Deserunt minim iis incurreret cohaerescant iis ab ab 20 |
21 |
22 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 23 |
24 | 27 |
28 |
29 | 30 | 33 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Java/loginpage.java: -------------------------------------------------------------------------------- 1 | package net.codejava; 2 | 3 | import java.io.*; 4 | import java.sql.SQLException; 5 | 6 | import javax.servlet.*; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.*; 9 | 10 | @WebServlet("/login") 11 | public class UserLoginServlet extends HttpServlet { 12 | private static final long serialVersionUID = 1L; 13 | 14 | public UserLoginServlet() { 15 | super(); 16 | } 17 | 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 19 | throws ServletException, IOException { 20 | String email = request.getParameter("email"); 21 | String password = request.getParameter("password"); 22 | 23 | UserDAO userDao = new UserDAO(); 24 | 25 | try { 26 | User user = userDao.checkLogin(email, password); 27 | String destPage = "login.jsp"; 28 | 29 | if (user != null) { 30 | HttpSession session = request.getSession(); 31 | session.setAttribute("user", user); 32 | destPage = "home.jsp"; 33 | } else { 34 | String message = "Invalid email/password"; 35 | request.setAttribute("message", message); 36 | } 37 | 38 | RequestDispatcher dispatcher = request.getRequestDispatcher(destPage); 39 | dispatcher.forward(request, response); 40 | 41 | } catch (SQLException | ClassNotFoundException ex) { 42 | throw new ServletException(ex); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Java/servelet.java: -------------------------------------------------------------------------------- 1 | package net.codejava; 2 | 3 | import java.io.*; 4 | import java.sql.SQLException; 5 | 6 | import javax.servlet.*; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.*; 9 | 10 | @WebServlet("/login") 11 | public class UserLoginServlet extends HttpServlet { 12 | private static final long serialVersionUID = 1L; 13 | 14 | public UserLoginServlet() { 15 | super(); 16 | } 17 | 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 19 | throws ServletException, IOException { 20 | String email = request.getParameter("email"); 21 | String password = request.getParameter("password"); 22 | 23 | UserDAO userDao = new UserDAO(); 24 | 25 | try { 26 | User user = userDao.checkLogin(email, password); 27 | String destPage = "login.jsp"; 28 | 29 | if (user != null) { 30 | HttpSession session = request.getSession(); 31 | session.setAttribute("user", user); 32 | destPage = "home.jsp"; 33 | } else { 34 | String message = "Invalid email/password"; 35 | request.setAttribute("message", message); 36 | } 37 | 38 | RequestDispatcher dispatcher = request.getRequestDispatcher(destPage); 39 | dispatcher.forward(request, response); 40 | 41 | } catch (SQLException | ClassNotFoundException ex) { 42 | throw new ServletException(ex); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Python/Create-A-For-Loop/test.py: -------------------------------------------------------------------------------- 1 | import io 2 | import sys 3 | sys.stdout = buffer = io.StringIO() 4 | 5 | # from app import my_function 6 | import pytest 7 | import os 8 | import app 9 | import re 10 | 11 | @pytest.mark.it("You should declare a function named standards_maker") 12 | def test_variable_exists(): 13 | try: 14 | from app import standards_maker 15 | except ImportError: 16 | raise ImportError("The function 'standards_maker' should exist on app.py") 17 | 18 | @pytest.mark.it("You should include in the function standards_maker a for loop which prints the string in the instructions 300 times") 19 | def test_for_file_output(capsys): 20 | captured = buffer.getvalue() 21 | expected = ["I will write questions if I am stuck\n" for x in range(300)] 22 | assert captured == "".join(expected) #add \n because the console jumps the line on every print 23 | 24 | @pytest.mark.it('Use the function print()') 25 | def test_for_print(): 26 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 27 | with open(path, 'r') as content_file: 28 | content = content_file.read() 29 | regex = re.compile(r"print\(.+\)") 30 | assert bool(regex.search(content)) == True 31 | 32 | @pytest.mark.it("You should call the function standards_maker ") 33 | def test_callTheFunction(): 34 | path = os.path.dirname(os.path.abspath(__file__))+'/app.py' 35 | with open(path, 'r') as content_file: 36 | content = content_file.read() 37 | pattern = r"standards_maker\(\)" 38 | regex = re.compile(pattern) 39 | assert bool(regex.search(content)) == True 40 | -------------------------------------------------------------------------------- /Python/Looping-With-FizzBuzz/test.py: -------------------------------------------------------------------------------- 1 | import io 2 | import sys 3 | sys.stdout = buffer = io.StringIO() 4 | from app import fizz_buzz 5 | # from app import my_function 6 | import pytest 7 | import app 8 | import os 9 | import re 10 | 11 | @pytest.mark.it("1. Don't change or remove the existing code") 12 | def test_forExistingCode(capsys): 13 | f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') 14 | content = f.readlines() 15 | content = [x.strip() for x in content] 16 | my_code = [s for s in content if "def fizz_buzz():" in s] 17 | my_codeVar = content.index(my_code[0]) 18 | regex = r"def fizz_buzz\(\):" 19 | my_codeCall = [s for s in content[3:] if "fizz_buzz()" in s] 20 | my_codeCallVar = content.index(my_codeCall[0]) 21 | regexCall = r"fizz_buzz\(\)" 22 | 23 | assert re.match(regex, content[my_codeVar]) 24 | assert re.match(regexCall, content[my_codeCallVar]) 25 | 26 | @pytest.mark.it('2. Your function needs to print the correct output') 27 | def test_for_function_output(capsys): 28 | fizz_buzz() 29 | captured = capsys.readouterr() 30 | assert captured.out == "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz\n" 31 | -------------------------------------------------------------------------------- /Java/matrix_chain_multiplication.java: -------------------------------------------------------------------------------- 1 | //Initial Template for Java 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | class matrix_chain 7 | { 8 | public static void main(String args[])throws IOException 9 | { 10 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 11 | int t = Integer.parseInt(in.readLine()); 12 | while(t-- > 0){ 13 | int N = Integer.parseInt(in.readLine()); 14 | String input_line[] = in.readLine().trim().split("\\s+"); 15 | int arr[]= new int[N]; 16 | for(int i = 0; i < N; i++) 17 | arr[i] = Integer.parseInt(input_line[i]); 18 | 19 | Solution ob = new Solution(); 20 | System.out.println(ob.matrixMultiplication(N, arr)); 21 | } 22 | } 23 | } 24 | // } Driver Code Ends 25 | 26 | 27 | //User function Template for Java 28 | 29 | class Solution{ 30 | static int[][] memo = new int[100][100];; 31 | static int matrixMultiplication(int n, int arr[]) 32 | { 33 | 34 | for(int[] row:memo) 35 | Arrays.fill(row,-1); 36 | return solve(arr,1,n-1); 37 | 38 | } 39 | public static int solve(int [] a,int i,int j) 40 | { 41 | if(i>=j) 42 | return 0; 43 | if(memo[i][j]!=-1) 44 | return memo[i][j]; 45 | memo[i][j] = Integer.MAX_VALUE; 46 | for(int k = i;k0) 10 | { 11 | int n=sc.nextInt(); 12 | int a[]=new int[n]; 13 | 14 | for(int i=0;imid) 58 | return false; 59 | if(sum+a[i]>mid) 60 | { s++; 61 | sum = a[i]; 62 | if(s>m) 63 | return false; 64 | } 65 | else 66 | sum+= a[i]; 67 | } 68 | 69 | return true; 70 | } 71 | }; -------------------------------------------------------------------------------- /Web/movies.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Movie App 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Search Result > <%= searchQuery.toUpperCase() %>

12 | 13 | 14 | <% data["results"].forEach((movie)=> { %> 15 | 16 |
17 |
18 |
19 | " class="card-img img-fluid"> 20 |
21 | 22 |
23 |
24 |

<%= movie["original_title"] %>

25 |
26 |

<%= movie["overview"] %>

27 |
28 |
29 |

Date Published: <%= movie["release_date"] %>

30 |

Total Votes: <%= movie["vote_count"] %>

31 |

Average Rating: <%= movie["vote_average"] %>

32 |
33 |
34 | 35 |
36 |
37 | 38 | <% }) %> 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Web/City website/css/scrolling-nav.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - Scrolling Nav HTML Template (http://startbootstrap.com) 3 | * Code licensed under the Apache License v2.0. 4 | * For details, see http://www.apache.org/licenses/LICENSE-2.0. 5 | */ 6 | 7 | body { 8 | width: 100%; 9 | height: 100%; 10 | } 11 | 12 | html { 13 | width: 100%; 14 | height: 100%; 15 | } 16 | 17 | @media(min-width:767px) { 18 | .navbar { 19 | padding: 20px 0; 20 | -webkit-transition: background .5s ease-in-out,padding .5s ease-in-out; 21 | -moz-transition: background .5s ease-in-out,padding .5s ease-in-out; 22 | transition: background .5s ease-in-out,padding .5s ease-in-out; 23 | } 24 | 25 | .top-nav-collapse { 26 | padding: 0; 27 | } 28 | } 29 | 30 | /* Demo Sections - You can use these as guides or delete them - the scroller will work with any sort of height, fixed, undefined, or percentage based. 31 | The padding is very important to make sure the scrollspy picks up the right area when scrolled to. Adjust the margin and padding of sections and children 32 | of those sections to manage the look and feel of the site. */ 33 | 34 | .intro-section { 35 | height: 100%; 36 | padding-top: 150px; 37 | text-align: center; 38 | background: #fff; 39 | } 40 | 41 | .about-section { 42 | height: 100%; 43 | padding-top: 150px; 44 | text-align: center; 45 | background: #eee; 46 | } 47 | 48 | .services-section { 49 | height: 100%; 50 | padding-top: 150px; 51 | text-align: center; 52 | background: #fff; 53 | } 54 | 55 | .contact-section { 56 | height: 100%; 57 | padding-top: 150px; 58 | text-align: center; 59 | background: #eee; 60 | } -------------------------------------------------------------------------------- /C/Linked List.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void create(); 4 | void display(); 5 | struct Node{ 6 | int data; 7 | struct Node *next; 8 | } 9 | *Start =NULL; 10 | int main() 11 | { 12 | printf("This is my first link list program\n"); 13 | while(1) 14 | { 15 | int choice; 16 | printf("\nEnter your choice\n1.For creating\n2.For Displaying\n3.For exit\n"); 17 | scanf("%d",&choice); 18 | switch(choice) 19 | { 20 | case 1:create(); 21 | break; 22 | case 2:display(); 23 | break; 24 | case 3:exit(0); 25 | } 26 | } 27 | 28 | 29 | return 0; 30 | } 31 | 32 | void create() 33 | { 34 | 35 | int a; 36 | do{ 37 | 38 | struct Node *current,*newnode; 39 | newnode=(struct Node*)malloc(sizeof(struct Node)); 40 | printf("\nEnter the data to be entered in the node: "); 41 | scanf("%d",&newnode->data); 42 | newnode->next=NULL; 43 | if(Start==NULL) 44 | { 45 | current=newnode; 46 | Start=newnode; 47 | } 48 | else{ 49 | current->next=newnode; 50 | current=newnode; 51 | } 52 | printf("Do you want to continue creating nodes\n1. to continue\n0. to stop: "); 53 | scanf("%d",&a); 54 | } 55 | while(a!=0); 56 | } 57 | void display() 58 | { 59 | struct Node *temp; 60 | temp=Start; 61 | printf("The linked list is: "); 62 | if(Start==NULL) 63 | { 64 | printf("the list is empty\n"); 65 | } 66 | else{ 67 | while(temp!=NULL) 68 | { 69 | printf("%d ",temp->data); 70 | temp=temp->next; 71 | } 72 | printf("\n"); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /C++/zigzagbinary.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | struct Node { 5 | int data; 6 | struct Node *left, *right; 7 | }; 8 | void zizagtraversal(struct Node* root) 9 | { 10 | if (!root) 11 | return; 12 | stack currentlevel; 13 | stack nextlevel; 14 | currentlevel.push(root); 15 | bool lefttoright = true; 16 | while (!currentlevel.empty()) { 17 | 18 | struct Node* temp = currentlevel.top(); 19 | currentlevel.pop(); 20 | if (temp) { 21 | cout << temp->data << " "; 22 | if (lefttoright) { 23 | if (temp->left) 24 | nextlevel.push(temp->left); 25 | if (temp->right) 26 | nextlevel.push(temp->right); 27 | } 28 | else { 29 | if (temp->right) 30 | nextlevel.push(temp->right); 31 | if (temp->left) 32 | nextlevel.push(temp->left); 33 | } 34 | } 35 | 36 | if (currentlevel.empty()) { 37 | lefttoright = !lefttoright; 38 | swap(currentlevel, nextlevel); 39 | } 40 | } 41 | } 42 | struct Node* newNode(int data) 43 | { 44 | struct Node* node = new struct Node; 45 | node->data = data; 46 | node->left = node->right = NULL; 47 | return (node); 48 | } 49 | int main() 50 | { 51 | struct Node* root = newNode(1); 52 | root->left = newNode(2); 53 | root->right = newNode(3); 54 | root->left->left = newNode(7); 55 | root->left->right = newNode(6); 56 | root->right->left = newNode(5); 57 | root->right->right = newNode(4); 58 | cout << "ZigZag Order traversal of binary tree is \n"; 59 | 60 | zizagtraversal(root); 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /Java/SubsetSum.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | /* A Dynamic Programming solution for subset, 4 | This code solves the problem in 5 | Pseudo-polynomial time use the Dynamic programming. 6 | 7 | 8 | */ 9 | class SubsetSUm { 10 | 11 | 12 | static boolean isSubsetSum(int set[], 13 | int n, int sum) 14 | { 15 | 16 | boolean subset[][] = new boolean[sum + 1][n + 1]; 17 | 18 | for (int i = 0; i <= n; i++) 19 | subset[0][i] = true; 20 | 21 | 22 | for (int i = 1; i <= sum; i++) 23 | subset[i][0] = false; 24 | 25 | 26 | for (int i = 1; i <= sum; i++) { 27 | for (int j = 1; j <= n; j++) { 28 | subset[i][j] = subset[i][j - 1]; 29 | if (i >= set[j - 1]) 30 | subset[i][j] = subset[i][j] || subset[i - set[j - 1]][j - 1]; 31 | } 32 | } 33 | 34 | return subset[sum][n]; 35 | } 36 | 37 | /* Driver code */ 38 | public static void main(String args[]) 39 | { Scanner sc = new Scanner(System.in); 40 | System.out.print("Enter the size of your array:"); 41 | int n = sc.nextInt(); 42 | 43 | int set[] = new int [n]; 44 | 45 | System.out.println("Enter your array:"); 46 | for (int i = 0; i < n; i++) 47 | set[i] =sc.nextInt(); 48 | 49 | System.out.println("Enter the sum:"); 50 | int sum = sc.nextInt(); 51 | 52 | if (isSubsetSum(set, n, sum) == true) 53 | System.out.println("Found a subset" 54 | + " with given sum"); 55 | else 56 | System.out.println("No subset with" 57 | + " given sum"); 58 | 59 | sc.close(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /C++/MaxSubArrayKadane.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define IOS \ 4 | ios_base::sync_with_stdio(false); \ 5 | cin.tie(NULL); \ 6 | cout.tie(NULL); 7 | #define vi vector 8 | #define vp vector> 9 | #define vpp vector, int>> 10 | #define si set 11 | #define f(x, y, z) for (x = y; x < z; x++) 12 | #define pb push_back 13 | #define mp make_pair 14 | #define ld long double 15 | #define fb(x, y, z) for (x = y; x > z; x--) 16 | #define pqf priority_queue> 17 | #define pqb priority_queue, greater> 18 | #define ps(x, y) fixed << setprecision(y) << x 19 | #define MOD 1e9 20 | #define PI 3.1415926535 21 | 22 | 23 | void swap (int *a, int *b) 24 | { 25 | int temp = *a; 26 | *a = *b; 27 | *b = temp; 28 | } 29 | 30 | int MaxSubArrayKadane(int a[], int n) 31 | { 32 | int maxsum = INT_MIN; 33 | int sum = INT_MIN; 34 | for (size_t i = 0; i < n; i++) 35 | { 36 | sum = max(0,sum + a[i]); 37 | maxsum = max(sum,maxsum); 38 | } 39 | 40 | return maxsum; 41 | } 42 | 43 | int main() 44 | { 45 | IOS 46 | const int N = 1000; 47 | int n = N * 2 + 1; 48 | int a[N*2 + 1] = {0}; 49 | 50 | for (size_t i = 0; i < n; i++) 51 | { 52 | a[i] = -18 + i; 53 | } 54 | 55 | srand (time(NULL)); 56 | 57 | for (int i = n - 1; i > 0; i--) 58 | { 59 | int j = rand() % (i + 1); 60 | swap(&a[i], &a[j]); 61 | } 62 | 63 | auto start = chrono::steady_clock::now(); 64 | 65 | int ans = MaxSubArrayKadane(a, n); 66 | 67 | auto end = chrono::steady_clock::now(); 68 | 69 | // Store the time difference between start and end 70 | auto diff = end - start; 71 | 72 | cout << "Ans = " << ans << endl; 73 | cout << chrono::duration (diff).count() << " ns" << endl; 74 | 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /C++/MaxSubArrayNaive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define IOS \ 4 | ios_base::sync_with_stdio(false); \ 5 | cin.tie(NULL); \ 6 | cout.tie(NULL); 7 | #define vi vector 8 | #define vp vector> 9 | #define vpp vector, int>> 10 | #define si set 11 | #define f(x, y, z) for (x = y; x < z; x++) 12 | #define pb push_back 13 | #define mp make_pair 14 | #define ld long double 15 | #define fb(x, y, z) for (x = y; x > z; x--) 16 | #define pqf priority_queue> 17 | #define pqb priority_queue, greater> 18 | #define ps(x, y) fixed << setprecision(y) << x 19 | #define MOD 1e9 20 | #define PI 3.1415926535 21 | 22 | 23 | void swap (int *a, int *b) 24 | { 25 | int temp = *a; 26 | *a = *b; 27 | *b = temp; 28 | } 29 | 30 | int MaxSubArrayNaive(int a[], int n) 31 | { 32 | int maxsum = 0; 33 | for (size_t i = 0; i < n; i++) 34 | { 35 | int sum = 0; 36 | for (size_t j = i; j < n; j++) 37 | { 38 | sum += a[j]; 39 | maxsum = max(sum, maxsum); 40 | } 41 | } 42 | return maxsum; 43 | } 44 | 45 | int main() 46 | { 47 | IOS 48 | const int N = 1000; 49 | int n = N * 2 + 1; 50 | int a[N*2 + 1] = {0}; 51 | 52 | for (size_t i = 0; i < n; i++) 53 | { 54 | a[i] = -18 + i; 55 | } 56 | 57 | srand (time(NULL)); 58 | 59 | for (int i = n - 1; i > 0; i--) 60 | { 61 | int j = rand() % (i + 1); 62 | swap(&a[i], &a[j]); 63 | } 64 | 65 | auto start = chrono::steady_clock::now(); 66 | 67 | int ans = MaxSubArrayNaive(a, n); 68 | 69 | auto end = chrono::steady_clock::now(); 70 | 71 | // Store the time difference between start and end 72 | auto diff = end - start; 73 | 74 | cout << "Ans = " << ans << endl; 75 | cout << "Time = " << chrono::duration (diff).count() << " ns" << endl; 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /C++/BinaryShifting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long int 4 | 5 | vector>adj; 6 | vectorlevel; 7 | const ll lg = 20; 8 | const ll size = 1e5 + 2; 9 | ll up[200005][21]; 10 | 11 | ll dfs(ll child, ll parent) 12 | { 13 | 14 | up[child][0] = parent; 15 | 16 | for(int i=1; i level[b]) 46 | swap(a,b); 47 | 48 | ll d = level[b] - level[a]; 49 | 50 | while(d > 0) 51 | { 52 | ll i = log2l(d); 53 | b = up[b][i]; 54 | d -= (1<=0; i--) 60 | { 61 | if(up[a][i] !=0 && (up[a][i] != up[b][i])) 62 | { 63 | a = up[a][i] , b = up[b][i]; 64 | } 65 | } 66 | return up[a][0]; 67 | } 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | ll solve() 76 | { 77 | ll n,q; 78 | cin>>n>>q; 79 | adj.clear(); 80 | adj.resize(n+4); 81 | level.clear(); 82 | level.resize(n+4); 83 | for(int i=2; i<=n; i++) 84 | { 85 | ll u,v; 86 | cin>>u; 87 | v = i; 88 | adj[u].push_back(v); 89 | adj[v].push_back(u); 90 | 91 | } 92 | dfs(1,0); 93 | 94 | // ll q; 95 | //cin>>q; 96 | while(q--) 97 | { 98 | ll a,b,c; 99 | cin>>a>>b; 100 | 101 | ll ans = lca(a,b); 102 | 103 | cout<>ignore; 117 | while(ignore--) 118 | { 119 | solve(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Java/palindrome_partitioning.java: -------------------------------------------------------------------------------- 1 | //Initial Template for Java 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | class palindrome_partitioning{ 7 | public static void main(String args[])throws IOException 8 | { 9 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 10 | int t = Integer.parseInt(in.readLine()); 11 | while(t-- > 0){ 12 | String str = in.readLine(); 13 | Solution ob = new Solution(); 14 | System.out.println(ob.palindromicPartition(str)); 15 | } 16 | } 17 | }// } Driver Code Ends 18 | 19 | 20 | //User function Template for Java 21 | 22 | class Solution{ 23 | static int[][] dp = new int[501][501]; 24 | static int palindromicPartition(String s) 25 | { 26 | for(int [] rows:dp) 27 | Arrays.fill(rows,-1); 28 | return solve(s,0,s.length()-1); 29 | } 30 | public static int solve(String s,int i ,int j) 31 | { 32 | if(i>=j) 33 | return 0; 34 | if(palindrome(s,i,j)) 35 | return 0; 36 | if(dp[i][j]!=-1) 37 | return dp[i][j]; 38 | dp[i][j] = Integer.MAX_VALUE; 39 | for(int k = i;kj) 59 | return false; 60 | if(i==j) 61 | return true; 62 | while(i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Deserunt minim iis incurreret cohaerescant iis ab ab graviterque ne occaecat 17 | adipisicing ne occaecat id sint ne est legam laboris, de in labore quid quem, 18 | eram ita quamquam, id esse despicationes si et aut aliqua consequat. Cillum 19 | vidisse a occaecat. Fore eu deserunt. Sint pariatur aut offendit. Pariatur 20 | aliqua dolor proident multos, cupidatat malis expetendis senserit. Laboris 21 | reprehenderit non mandaremus. Do velit quibusdam coniunctione o ut qui quem 22 | appellat et laborum quid culpa eu quae, sed commodo tractavissent ex laboris 23 | quae possumus tempor ut o ut nisi enim sint, dolor o admodum non nisi, pariatur 24 | ea possumus.

25 |
26 | 35 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /EucladianTheorem.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Enter first number 2740\n", 13 | "Enter second number 1760\n", 14 | "GCD is 20\n", 15 | "s= 9\n", 16 | "t= -14\n" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "r1=int(input(\"Enter first number \"))\n", 22 | "r2=int(input(\"Enter second number \"))\n", 23 | "s1=1\n", 24 | "s2=0\n", 25 | "t1=0\n", 26 | "t2=1\n", 27 | "while(r2>0):\n", 28 | " q=r1//r2\n", 29 | " r=r1%r2\n", 30 | " r1=r2\n", 31 | " r2=r\n", 32 | " s=s1-(s2*q)\n", 33 | " t=t1-(t2*q)\n", 34 | " s1=s2\n", 35 | " s2=s\n", 36 | " t1=t2\n", 37 | " t2=t\n", 38 | " gcd=r1\n", 39 | "print(\"GCD is \"+str(gcd))\n", 40 | "print(\"s= \"+str(s1))\n", 41 | "print(\"t= \"+str(t1))\n", 42 | " \n", 43 | " " 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 2, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "Enter first number 788\n", 56 | "Enter second number 236\n", 57 | "GCD is 4\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "r1=int(input(\"Enter first number \"))\n", 63 | "r2=int(input(\"Enter second number \"))\n", 64 | "while(r2>0):\n", 65 | " q=r1//r2\n", 66 | " r=r1%r2\n", 67 | " r1=r2\n", 68 | " r2=r\n", 69 | " gcd=r1\n", 70 | "print(\"GCD is \"+str(gcd))" 71 | ] 72 | } 73 | ], 74 | "metadata": { 75 | "kernelspec": { 76 | "display_name": "Python 3", 77 | "language": "python", 78 | "name": "python3" 79 | }, 80 | "language_info": { 81 | "codemirror_mode": { 82 | "name": "ipython", 83 | "version": 3 84 | }, 85 | "file_extension": ".py", 86 | "mimetype": "text/x-python", 87 | "name": "python", 88 | "nbconvert_exporter": "python", 89 | "pygments_lexer": "ipython3", 90 | "version": "3.7.3" 91 | } 92 | }, 93 | "nbformat": 4, 94 | "nbformat_minor": 2 95 | } 96 | -------------------------------------------------------------------------------- /bootstrap_use/example8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 |
21 |

Normal

22 |

With supporting text below as a natural lead-in to additional content. 23 | And this card has a little more text to make the col taller 24 |

25 | Outline 26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |

Vertical Center

34 |

With supporting text below as a natural lead-in to additional content.

35 | Outline 36 |
37 |
38 |
39 |
40 |
41 |
42 | 43 | 46 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /C++/segmentTree.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define ll long long int 4 | const ll inf = 1e15; 5 | 6 | 7 | class segmentTree 8 | { 9 | private: 10 | vectorarr; 11 | public: vectort; 12 | private: ll n; 13 | 14 | public: segmentTree(vectorm,ll c) : arr(m),n(c) 15 | { 16 | 17 | t.resize(4*n); 18 | build(1,0,c-1); 19 | } 20 | 21 | private: void build(ll i, ll l, ll r) 22 | { 23 | if(l == r) 24 | { 25 | 26 | t[i] = arr[l]; 27 | return; 28 | } 29 | 30 | ll mid = (l+r)/2; 31 | build(2*i,l,mid); 32 | build((2*i) + 1, mid+1, r); 33 | t[i] = merge(t[lc(i)], t[rc(i)]); 34 | } 35 | public: void show() 36 | { 37 | for(int i=0; i qr) 73 | { 74 | return 0; 75 | } 76 | if(ql <= l && qr >= r) 77 | return t[i]; 78 | 79 | ll mid = (l+r)/2; 80 | 81 | ll resl = query(ql,qr,lc(i),l,mid); 82 | ll resr = query(ql,qr,rc(i),mid+1,r); 83 | t[i] = merge(resl,resr); 84 | } 85 | }; 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | int main() 94 | { 95 | ios_base::sync_with_stdio(0); 96 | cin.tie(0); 97 | cout.tie(0); 98 | 99 | int ignore = 1; 100 | //cin>>ignore; 101 | 102 | while(ignore--) 103 | { 104 | vectorarr(5); 105 | iota(arr.begin(),arr.end(),0); 106 | segmentTree d(arr,arr.size()); 107 | // d.show(); 108 | //d.modify(1,55); 109 | cout< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /bootstrap_use/example2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Deserunt minim iis incurreret cohaerescant iis ab ab graviterque ne occaecat 17 | adipisicing ne occaecat id sint ne est legam laboris, de in labore quid quem, 18 | eram ita quamquam, id esse despicationes si et aut aliqua consequat. Cillum 19 | vidisse a occaecat. Fore eu deserunt. Sint pariatur aut offendit. Pariatur 20 | aliqua dolor proident multos, cupidatat malis expetendis senserit. Laboris 21 | reprehenderit non mandaremus. Do velit quibusdam coniunctione o ut qui quem 22 | appellat et laborum quid culpa eu quae, sed commodo tractavissent ex laboris 23 | quae possumus tempor ut o ut nisi enim sint, dolor o admodum non nisi, pariatur 24 | ea possumus.

25 |
26 | 35 | 38 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Web/City website/js/custom.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | /* Intro */ 3 | $('.wp1').waypoint(function() { 4 | $('.wp1').addClass('animated fadeIn'); 5 | }, { 6 | offset: '75%' 7 | }); 8 | 9 | /* Features */ 10 | $('.wp2').waypoint(function() { 11 | $('.wp2').addClass('animated fadeIn'); 12 | }, { 13 | offset: '50%' 14 | }); 15 | 16 | /* Experience */ 17 | $('.wp3').waypoint(function() { 18 | $('.wp3').addClass('animated fadeIn'); 19 | $('.skills-bar-container').addClass('animated fadeIn'); 20 | $('.wp3-1').addClass('progress1-delay'); 21 | $('.wp3-2').addClass('progress2-delay'); 22 | $('.wp3-3').addClass('progress3-delay'); 23 | $('.wp3-4').addClass('progress4-delay'); 24 | $('.wp3-5').addClass('progress5-delay'); 25 | }, { 26 | offset: '50%' 27 | }); 28 | 29 | /* Resume Button */ 30 | $('.wp4').waypoint(function() { 31 | $('.wp4').addClass('animated bounceIn'); 32 | }, { 33 | offset: '75%' 34 | }); 35 | 36 | /* Portfolio */ 37 | $('.wp5').waypoint(function() { 38 | $('.wp5').addClass('animated fadeIn'); 39 | }, { 40 | offset: '75%' 41 | }); 42 | 43 | /* Paper Plane */ 44 | $('.wp6').waypoint(function() { 45 | $('.wp6').addClass('animated bounceInDown'); 46 | }, { 47 | offset: '75%' 48 | }); 49 | 50 | 51 | // for preloader 52 | // setTimeout(function(){ 53 | // $('body').addClass('loaded'); 54 | // }, 2800); 55 | 56 | // jQuery to collapse the navbar on scroll 57 | $(window).scroll(function() { 58 | if ($(".navbar").offset().top > 50) { 59 | $(".navbar-fixed-top").addClass("top-nav-collapse"); 60 | // $(".navbar").addClass("navbar-shadow"); 61 | } else { 62 | $(".navbar-fixed-top").removeClass("top-nav-collapse"); 63 | // $(".navbar").removeClass("navbar-shadow"); 64 | } 65 | }); 66 | 67 | $('a.page-scroll').bind('click', function(event) { 68 | var $anchor = $(this); 69 | $('html, body').stop().animate({ 70 | scrollTop: $($anchor.attr('href')).offset().top 71 | }, 1500, 'easeInOutExpo'); 72 | event.preventDefault(); 73 | }); 74 | 75 | 76 | // Closes the Responsive Menu on Menu Item Click 77 | $('.navbar-collapse ul li a').click(function() { 78 | $('.navbar-toggle:visible').click(); 79 | }); 80 | 81 | $("#to-top").mouseover(function() { 82 | $("#to-top-copy").animate({opacity: "1"}, "slow"); 83 | }); 84 | $("#to-top").mouseout(function() { 85 | $("#to-top-copy").animate({opacity: "0"}, "slow"); 86 | }); 87 | 88 | }); 89 | -------------------------------------------------------------------------------- /bootstrap_use/example3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |

Deserunt minim iis incurreret cohaerescant iis ab ab graviterque ne occaecat 20 | adipisicing ne occaecat id sint ne est legam laboris, de in labore quid quem, 21 | eram ita quamquam, id esse despicationes si et aut aliqua consequat. Cillum 22 | vidisse a occaecat. Fore eu deserunt. Sint pariatur aut offendit. Pariatur 23 | aliqua dolor proident multos, cupidatat malis expetendis senserit. Laboris 24 | reprehenderit non mandaremus. Do velit quibusdam coniunctione o ut qui quem 25 | appellat et laborum quid culpa eu quae, sed commodo tractavissent ex laboris 26 | quae possumus tempor ut o ut nisi enim sint, dolor o admodum non nisi, pariatur 27 | ea possumus.

28 |
29 | 38 |
39 |
40 | 41 | 44 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /bootstrap_use/example4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |

Deserunt minim iis incurreret cohaerescant iis ab ab graviterque ne occaecat 19 | adipisicing ne occaecat id sint ne est legam laboris, de in labore quid quem, 20 | eram ita quamquam, id esse despicationes si et aut aliqua consequat. Cillum 21 | vidisse a occaecat. Fore eu deserunt. Sint pariatur aut offendit. Pariatur 22 | aliqua dolor proident multos, cupidatat malis expetendis senserit. Laboris 23 | reprehenderit non mandaremus. Do velit quibusdam coniunctione o ut qui quem 24 | appellat et laborum quid culpa eu quae, sed commodo tractavissent ex laboris 25 | quae possumus tempor ut o ut nisi enim sint, dolor o admodum non nisi, pariatur 26 | ea possumus.

27 |
28 | 37 |
38 |
39 | 40 | 43 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Web/City website/js/jquery.scrollTo.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com 3 | * Licensed under MIT 4 | * @author Ariel Flesler 5 | * @version 2.1.0 6 | */ 7 | ;(function(l){'use strict';l(['jquery'],function($){var k=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};k.defaults={axis:'xy',duration:0,limit:true};function isWin(a){return!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!==-1}$.fn.scrollTo=function(f,g,h){if(typeof g==='object'){h=g;g=0}if(typeof h==='function'){h={onAfter:h}}if(f==='max'){f=9e9}h=$.extend({},k.defaults,h);g=g||h.duration;var j=h.queue&&h.axis.length>1;if(j){g/=2}h.offset=both(h.offset);h.over=both(h.over);return this.each(function(){if(f===null)return;var d=isWin(this),elem=d?this.contentWindow||window:this,$elem=$(elem),targ=f,attr={},toff;switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=d?$(targ):$(targ,elem);if(!targ.length)return;case'object':if(targ.is||targ.style){toff=(targ=$(targ)).offset()}}var e=$.isFunction(h.offset)&&h.offset(elem,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a==='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,prev=$elem[key](),max=k.max(elem,a);if(toff){attr[key]=toff[pos]+(d?0:prev-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b),10)||0;attr[key]-=parseInt(targ.css('border'+b+'Width'),10)||0}attr[key]+=e[pos]||0;if(h.over[pos]){attr[key]+=targ[a==='x'?'width':'height']()*h.over[pos]}}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)==='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key])){attr[key]=attr[key]<=0?0:Math.min(attr[key],max)}if(!i&&h.axis.length>1){if(prev===attr[key]){attr={}}else if(j){animate(h.onAfterFirst);attr={}}}});animate(h.onAfter);function animate(a){var b=$.extend({},h,{queue:true,duration:g,complete:a&&function(){a.call(elem,targ,h)}});$elem.animate(attr,b)}})};k.max=function(a,b){var c=b==='x'?'Width':'Height',scroll='scroll'+c;if(!isWin(a))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,doc=a.ownerDocument||a.document,html=doc.documentElement,body=doc.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(t){return $(t.elem)[t.prop]()},set:function(t){var a=this.get(t);if(t.options.interrupt&&t._last&&t._last!==a){return $(t.elem).stop()}var b=Math.round(t.now);if(a!==b){$(t.elem)[t.prop](b);t._last=this.get(t)}}};return k})}(typeof define==='function'&&define.amd?define:function(a,b){'use strict';if(typeof module!=='undefined'&&module.exports){module.exports=b(require('jquery'))}else{b(jQuery)}})); -------------------------------------------------------------------------------- /Guessing Number Game in Java/Guessing_Game_Human_vs_CPU.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.util.*; 3 | public class Guessing_Game_Human_vs_CPU 4 | { 5 | public static int computerGuess(int lower,int upper,int randnum,int count) 6 | { 7 | int guess=(lower+upper)/2; 8 | if(guess==randnum) 9 | return count; 10 | 11 | if(guessrandnum){ 17 | count++; 18 | return computerGuess(lower,guess,randnum,count); 19 | } 20 | return -1; 21 | } 22 | 23 | public static void main(String[] args) 24 | { 25 | final Scanner sc=new Scanner(System.in); 26 | char ch='Y'; 27 | //the game resets if select Y else exits 28 | while(ch=='Y') 29 | { 30 | //Generating a random integer number Between 1 to 100 31 | int randnum=(int)(Math.random()*100+1); 32 | //Math.random gives adouble between 0 and 1 so multiply by 100 so gives between 0 to 99 and 1 for 0 to 100 33 | 34 | int chances=10; 35 | while(chances>0) //while attempts are less than 10 36 | { 37 | System.out.print("Guesss A Number between 1 to 100:"); 38 | int guess=sc.nextInt(); 39 | //input the guessed Number 40 | 41 | if(guess==randnum){ 42 | System.out.println("Congrats you guessed the number !!\n"); 43 | break; 44 | } 45 | else if(guess>randnum){ 46 | System.out.println("Your guess is higher than the number.\n"); 47 | } 48 | else{ 49 | System.out.println("Your guess is lower than the number.\n"); 50 | } 51 | 52 | chances--; 53 | } 54 | 55 | if(chances!=0){ 56 | System.out.println("\nYou guessed the Number in "+(10-chances)+" attempts."); 57 | System.out.println("You scored "+(chances*10)+" points."); 58 | } 59 | else{ 60 | System.out.println("\nYou were not able to guess the number in 10 attempts.\n Better Luck next Time"); 61 | System.out.println("You scored 0 points."); 62 | } 63 | int steps=computerGuess(0,100,randnum,0); 64 | System.out.println("\nComputer solved it in "+steps+" attempts."); 65 | 66 | if((10-chances) 2 | using namespace std; 3 | 4 | int Adjacency_list(int type) 5 | { 6 | int n,m; 7 | cout << "Enter Number of vertices : "; 8 | cin >> n; 9 | cout << "\nEnter number of edge : "; 10 | cin >> m; 11 | list graph[n+1]; 12 | for(int i=0; i> a >> b; 16 | graph[a].push_back(b); 17 | if(type==2) graph[b].push_back(a); 18 | } 19 | cout << "Your Graph is : \n"; 20 | for(int node=1;node<=n;node++) 21 | { 22 | cout << node << " --> "; 23 | for(int &subnode: graph[node]) cout << subnode << " "; 24 | cout << "\n"; 25 | } 26 | return 0; 27 | } 28 | void Adjacency_matrix(int type) 29 | { 30 | cout << "Enter number of vertices: "; 31 | int n; 32 | cin >> n; 33 | cout << "Enter number of edge: "; 34 | int m; 35 | cin >> m; 36 | bool graph[n+1][n+1]; 37 | memset(graph,false,sizeof(graph)); 38 | for(int i=0;i> a >> b; 42 | graph[a][b]=true; 43 | if(type==2) graph[b][a]=true; 44 | } 45 | cout << "Your Graph is: \n"; 46 | for(int node=1;node<=n;node++) 47 | { 48 | for(int subnode=1; subnode<=n; subnode++) 49 | { 50 | if(graph[node][subnode]) cout << 1 << " "; 51 | else cout << 0 << " "; 52 | } 53 | cout << "\n"; 54 | } 55 | } 56 | void Incidence_matrix(int type) 57 | { 58 | int n,m; 59 | cout << "Enter number of vertices: "; 60 | cin >> n; 61 | cout << "\nEnter number of edge: "; 62 | cin >> m; 63 | int graph[n+1][m+1]; 64 | memset(graph, 0, sizeof(graph)); 65 | for(int i=1; i<=m; i++) 66 | { 67 | int a,b; 68 | cin >> a >> b; 69 | for(int node=1;node<=n;node++) 70 | { 71 | if(node==a) graph[node][i]=1; 72 | if(type==1 && node==b) graph[node][i]=-1; 73 | else if(type==2 && node==b) graph[node][i]=1; 74 | } 75 | } 76 | cout << "Your Graph is : \n"; 77 | for(int node=1;node<=n;node++) 78 | { 79 | cout << node << " --> "; 80 | for(int edge=1;edge<=m;edge++) 81 | { 82 | cout << graph[node][edge] << " "; 83 | } 84 | cout << "\n"; 85 | } 86 | } 87 | 88 | 89 | int main() { 90 | 91 | cout << "\nGraph:\n\n"; 92 | cout << "1 : Directed graph\n2 : Undirected graph\n"; 93 | int type; 94 | cin >> type; 95 | cout << "1 : Incidence matrix representation\n"; 96 | cout << "2 : Adjacency matrix representation\n"; 97 | cout << "3 : Adjacency list representation\n"; 98 | 99 | int graphType; 100 | cin >> graphType; 101 | if(graphType==1) Incidence_matrix(type); 102 | else if(graphType==2) Adjacency_matrix(type); 103 | else if(graphType==3) Adjacency_list(type); 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /Python/BST.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | #Given a #binarytree. Check whether it is a #BST or not. 3 | #Expected Time Complexity: O(N). 4 | #Expected Auxiliary Space: O(Height of the BST). 5 | 6 | #Code starts here 7 | result = True 8 | prev = 0 9 | 10 | 11 | def isValidBSTUtil(root): 12 | global result, prev 13 | if root != None and result: 14 | isValidBSTUtil(root.left) 15 | if root.data <= prev: 16 | result = False 17 | prev = root.data 18 | 19 | isValidBSTUtil(root.right) 20 | 21 | def isValidBST(root): 22 | global result, prev 23 | result = True 24 | prev = 0 25 | isValidBSTUtil(root) 26 | return result 27 | 28 | from collections import deque 29 | # Tree Node 30 | class Node: 31 | def __init__(self, val): 32 | self.right = None 33 | self.data = val 34 | self.left = None 35 | 36 | # Function to Build Tree 37 | def buildTree(s): 38 | #Corner Case 39 | if(len(s)==0 or s[0]=="N"): 40 | return None 41 | 42 | # Creating list of strings from input 43 | # string after spliting by space 44 | ip=list(map(str,s.split())) 45 | 46 | # Create the root of the tree 47 | root=Node(int(ip[0])) 48 | size=0 49 | q=deque() 50 | 51 | # Push the root to the queue 52 | q.append(root) 53 | size=size+1 54 | 55 | # Starting from the second element 56 | i=1 57 | while(size>0 and i=len(ip)): 78 | break 79 | currVal=ip[i] 80 | 81 | # If the right child is not null 82 | if(currVal!="N"): 83 | 84 | # Create the right child for the current node 85 | currNode.right=Node(int(currVal)) 86 | 87 | # Push it to the queue 88 | q.append(currNode.right) 89 | size=size+1 90 | i=i+1 91 | return root 92 | 93 | 94 | if __name__=="__main__": 95 | t=int(input("No. of testcases: ")) 96 | for _ in range(0,t): 97 | s=input("Tree list(level-order): ") 98 | root=buildTree(s) 99 | if isValidBST(root): 100 | print("Valid BST\n") 101 | else: 102 | print("Not a BST\n") 103 | 104 | # } Driver Code Ends 105 | -------------------------------------------------------------------------------- /bootstrap_use/example5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |

Deserunt minim iis incurreret cohaerescant iis ab ab graviterque ne occaecat 20 | adipisicing ne occaecat id sint ne est legam laboris, de in labore quid quem, 21 | eram ita quamquam, id esse despicationes si et aut aliqua consequat. Cillum 22 | vidisse a occaecat. Fore eu deserunt. Sint pariatur aut offendit. Pariatur 23 | aliqua dolor proident multos, cupidatat malis expetendis senserit. Laboris 24 | reprehenderit non mandaremus. Do velit quibusdam coniunctione o ut qui quem 25 | appellat et laborum quid culpa eu quae, sed commodo tractavissent ex laboris 26 | quae possumus tempor ut o ut nisi enim sint, dolor o admodum non nisi, pariatur 27 | ea possumus.

28 |
29 |
30 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam porttitor tortor at ullamcorper suscipit. Sed nunc ante, venenatis eget orci ac, iaculis elementum diam. Nam sem dolor, egestas porta sagittis et, interdum in nibh. Morbi odio odio, euismod sit amet metus id, lacinia faucibus lacus. Nullam ut lobortis leo. Phasellus semper libero at justo posuere, sit amet mollis magna convallis. Nulla eu metus tempus, mollis metus vel, fringilla augue. 31 |
32 | 41 |
42 |
43 | 44 |
47 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /C++/MaxSubArrayMerge.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define IOS \ 4 | ios_base::sync_with_stdio(false); \ 5 | cin.tie(NULL); \ 6 | cout.tie(NULL); 7 | #define vi vector 8 | #define vp vector> 9 | #define vpp vector, int>> 10 | #define si set 11 | #define f(x, y, z) for (x = y; x < z; x++) 12 | #define pb push_back 13 | #define mp make_pair 14 | #define ld long double 15 | #define fb(x, y, z) for (x = y; x > z; x--) 16 | #define pqf priority_queue> 17 | #define pqb priority_queue, greater> 18 | #define ps(x, y) fixed << setprecision(y) << x 19 | #define MOD 1e9 20 | #define PI 3.1415926535 21 | 22 | void swap(int *a, int *b) 23 | { 24 | int temp = *a; 25 | *a = *b; 26 | *b = temp; 27 | } 28 | 29 | tuple MaxSubArrayMerge(int a[], int l, int r); 30 | 31 | tuple MaximumMiddleArray(int a[], int l, int m, int r); 32 | 33 | int main() 34 | { 35 | IOS 36 | const int N = 1000; 37 | int n = N * 2 + 1; 38 | int a[N*2 + 1] = {0}; 39 | 40 | for (size_t i = 0; i < n; i++) 41 | { 42 | a[i] = -1 * N + i; 43 | } 44 | 45 | srand(time(NULL)); 46 | 47 | for (int i = n - 1; i > 0; i--) 48 | { 49 | int j = rand() % (i + 1); 50 | swap(&a[i], &a[j]); 51 | } 52 | 53 | auto start = chrono::steady_clock::now(); 54 | 55 | tuple ans = MaxSubArrayMerge(a, 0, n - 1); 56 | 57 | auto end = chrono::steady_clock::now(); 58 | 59 | // Store the time difference between start and end 60 | auto diff = end - start; 61 | 62 | cout << "Ans = " << get<2>(ans) << endl; 63 | cout << chrono::duration(diff).count() << " ns" << endl; 64 | 65 | return 0; 66 | } 67 | 68 | tuple MaxSubArrayMerge(int a[], int l, int r) 69 | { 70 | if (l == r) 71 | { 72 | return {l, r, a[l]}; 73 | } 74 | int m = (l + r) / 2; 75 | tuple left = MaxSubArrayMerge(a, l, m); 76 | 77 | tuple right = MaxSubArrayMerge(a, m + 1, r); 78 | 79 | tuple cont = MaximumMiddleArray(a, l, m, r); 80 | 81 | if (get<2>(left) >= get<2>(right) && get<2>(left) >= get<2>(cont)) 82 | { 83 | return left; 84 | } 85 | else if (get<2>(right) >= get<2>(left) && get<2>(right) >= get<2>(cont)) 86 | { 87 | return right; 88 | } 89 | else 90 | { 91 | return cont; 92 | } 93 | } 94 | 95 | tuple MaximumMiddleArray(int a[], int l, int m, int r) 96 | { 97 | int left = 0, right = 0, left_sum = INT_MIN, right_sum = INT_MIN, sum = 0; 98 | for (int i = m; i >= l; i--) 99 | { 100 | sum += a[i]; 101 | if (sum > left_sum) 102 | { 103 | left_sum = sum; 104 | left = i; 105 | } 106 | } 107 | for (int i = m + 1; i <= r; i++) 108 | { 109 | sum += a[i]; 110 | if (sum > right_sum) 111 | { 112 | right_sum = sum; 113 | right = i; 114 | } 115 | } 116 | 117 | return {left, right, left_sum + right_sum}; 118 | } 119 | -------------------------------------------------------------------------------- /reverseproxy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | string read(string s){ 5 | int i=0; 6 | string domain=""; 7 | while(s[i]!='/'){ 8 | domain+=s[i]; 9 | i++; 10 | } 11 | return domain; 12 | } 13 | 14 | string read_up(string s){ 15 | int i=0; 16 | string ip=""; 17 | string up=""; 18 | while(s[i]!='/'){ 19 | i++; 20 | } 21 | i++; 22 | while(i>mp; 69 | map>mp1; 70 | cin>>n; 71 | for(int i=0;i>p; 73 | } 74 | 75 | cin>>urlcnt; 76 | for(int i=0;i>url_s; 78 | cin>>count; 79 | queueq; 80 | for(int j=0;j>s; 82 | q.push(s); 83 | } 84 | mp1[url_s]=q; 85 | } 86 | cin>>queries; 87 | for(int i=0;i>s; 89 | 90 | string domain=read(s); 91 | string up=read_up(s); 92 | string down=read_down(s); 93 | if(up==""&& down==""){ 94 | 95 | queue q=mp1[domain]; 96 | 97 | string machine=q.front(); 98 | q.pop(); 99 | 100 | mp[machine].push_back(s); 101 | q.push(machine); 102 | mp1[domain]=q; 103 | } 104 | else if(up!=""){ 105 | queue q=mp1[domain]; 106 | q.push(up); 107 | string temp=q.front(); 108 | q.pop(); 109 | q.push(temp); 110 | mp1[domain]=q; 111 | } 112 | else if(down!=""){ 113 | queue modified; 114 | queue q=mp1[domain]; 115 | while(!q.empty() && q.front()!=down){ 116 | modified.push(q.front()); 117 | q.pop(); 118 | } 119 | q.pop(); 120 | while(!q.empty()){ 121 | modified.push(q.front()); 122 | q.pop(); 123 | } 124 | mp1[domain]=modified; 125 | } 126 | 127 | } 128 | 129 | for(auto it:mp){ 130 | cout< vec=it.second; 132 | for(auto it1:vec) 133 | cout< 2 | using namespace std; 3 | 4 | string read(string s){ 5 | int i=0; 6 | string domain=""; 7 | while(s[i]!='/'){ 8 | domain+=s[i]; 9 | i++; 10 | } 11 | return domain; 12 | } 13 | 14 | string read_up(string s){ 15 | int i=0; 16 | string ip=""; 17 | string up=""; 18 | while(s[i]!='/'){ 19 | i++; 20 | } 21 | i++; 22 | while(i>mp; 69 | map>mp1; 70 | cin>>n; 71 | for(int i=0;i>p; 73 | } 74 | 75 | cin>>urlcnt; 76 | for(int i=0;i>url_s; 78 | cin>>count; 79 | queueq; 80 | for(int j=0;j>s; 82 | q.push(s); 83 | } 84 | mp1[url_s]=q; 85 | } 86 | cin>>queries; 87 | for(int i=0;i>s; 89 | 90 | string domain=read(s); 91 | string up=read_up(s); 92 | string down=read_down(s); 93 | if(up==""&& down==""){ 94 | 95 | queue q=mp1[domain]; 96 | 97 | string machine=q.front(); 98 | q.pop(); 99 | 100 | mp[machine].push_back(s); 101 | q.push(machine); 102 | mp1[domain]=q; 103 | } 104 | else if(up!=""){ 105 | queue q=mp1[domain]; 106 | q.push(up); 107 | string temp=q.front(); 108 | q.pop(); 109 | q.push(temp); 110 | mp1[domain]=q; 111 | } 112 | else if(down!=""){ 113 | queue modified; 114 | queue q=mp1[domain]; 115 | while(!q.empty() && q.front()!=down){ 116 | modified.push(q.front()); 117 | q.pop(); 118 | } 119 | q.pop(); 120 | while(!q.empty()){ 121 | modified.push(q.front()); 122 | q.pop(); 123 | } 124 | mp1[domain]=modified; 125 | } 126 | 127 | } 128 | 129 | for(auto it:mp){ 130 | cout< vec=it.second; 132 | for(auto it1:vec) 133 | cout<