max)
15 | max=a[i];
16 | }
17 | System.out.println(max);
18 | int p=max+1;
19 | //create count array
20 |
21 | int b[]=new int[n];
22 | int count[]=new int[p];
23 | for (int i=0; i=0; i--)
30 | {
31 | b[count[a[i]]-1] = a[i];
32 | count[a[i]]--;
33 | }
34 | for (int i = 0; i
2 | using namespace std;
3 |
4 | void heapify(int arr[], int n, int root){
5 | int largest = root;
6 | int l = 2*root + 1;
7 | int r = 2*root + 2;
8 | if (l < n && arr[l] > arr[largest])
9 | largest = l;
10 | if (r < n && arr[r] > arr[largest])
11 | largest = r;
12 | if (largest != root){
13 | swap(arr[root], arr[largest]);
14 | heapify(arr, n, largest);
15 | }
16 | }
17 | void heapSort(int arr[], int n){
18 | for (int i = n / 2 - 1; i >= 0; i--)
19 | heapify(arr, n, i);
20 | for (int i=n-1; i>=0; i--){
21 | swap(arr[0], arr[i]);
22 | heapify(arr, i, 0);
23 | }
24 | }
25 | void displayArray(int arr[], int n){
26 | for (int i=0; iA[j+1]){
16 | int temp=A[j];
17 | A[j]=A[j+1];
18 | A[j+1]=temp;
19 | }
20 | }
21 |
22 | }
23 | }
24 | public void print(){
25 | for(int i=0;inum) {
29 | l=mid-1;
30 | }else {
31 | if(ar[mid]==num) {
32 | System.out.print("Element found AT position - "+mid);
33 | b=true;
34 | break;
35 | }
36 | }
37 | }
38 | mid=(f+l)/2;
39 |
40 |
41 | }
42 | if(b==false) System.out.print("Element not found!");
43 |
44 |
45 |
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/contributions/Nirmal Giri/insertion_sort.java:
--------------------------------------------------------------------------------
1 | package javaapplication193;
2 | import java.util.Scanner;
3 |
4 | class insertionop{
5 | int []B;
6 | int m;
7 | public insertionop(int []A,int n){
8 | B=A;
9 | m=n;
10 | }
11 | public void sort(){
12 | for(int i=1;i0 && B[hole-1]>value){
16 | B[hole]=B[hole-1];
17 | hole=hole-1;
18 | }
19 | B[hole]=value;
20 | }
21 | }
22 | public void display(){
23 | for(int i=0;i
2 | #include
3 | using namespace std;
4 | class Node{
5 | public:
6 | int data;
7 | Node* next;
8 | Node(int data){
9 | this->data=data;
10 | next=NULL;
11 | }
12 | };
13 | void createNode(Node** head,int data){
14 | Node* newNode=new Node(data);
15 | if(*head==NULL){
16 | *head=newNode;
17 | return;
18 | }
19 | newNode->next=*head;
20 | *head=newNode;
21 | }
22 | void display(Node** head){
23 | Node* temp=*head;
24 | while(temp!=NULL){
25 | cout<data<<" ";
26 | temp=temp->next;
27 | }
28 | }
29 |
30 | void recursiveDisplay(Node* head){
31 | if(head==NULL) return;
32 |
33 | recursiveDisplay(head->next);
34 | cout<data<<" ";
35 |
36 | }
37 | int main(){
38 | int T;
39 | cout<<"Enter Number of Nodes: "<>T;
41 | Node* head=NULL;
42 | while(T--){
43 | int data;
44 | cout<<"enter data of Node"<>data;
46 | createNode(&head,data);
47 | }
48 | cout<<"Linked List is: "<
2 | using namespace std;
3 |
4 | void swap(int* a, int* b){
5 | int t = *a;
6 | *a = *b;
7 | *b = t;
8 | }
9 | int partition (int arr[], int low, int high){
10 | int pivot = arr[high];
11 | int i = (low - 1);
12 | for (int j = low; j <= high - 1; j++){
13 | if (arr[j] < pivot){
14 | i++;
15 | swap(&arr[i], &arr[j]);
16 | }
17 | }
18 | swap(&arr[i + 1], &arr[high]);
19 | return (i + 1);
20 | }
21 | void quickSort(int arr[], int low, int high){
22 | if (low < high){
23 | int pi = partition(arr, low, high);
24 | quickSort(arr, low, pi - 1);
25 | quickSort(arr, pi + 1, high);
26 | }
27 | }
28 | void print(int arr[], int n){
29 | for (int i = 0; i < n; i++)
30 | cout << arr[i] << " ";
31 | }
32 | int main(){
33 | int n;
34 | cout<<"Enter total number of array elements: ";
35 | cin >> n;
36 | int a[n];
37 | cout<<"Enter array elements: ";
38 | for(int i = 0; i < n; i++)
39 | cin >> a[i];
40 | cout<<"\nArray elements after Quick Sorting:\n";
41 | quickSort(a, 0, n - 1);
42 | print(a, n);
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/contributions/nilesh_choudhary/gcd_lcm_recursive.py:
--------------------------------------------------------------------------------
1 | """
2 | Recursion program for:
3 | GCD: Greatest Common Divider
4 | LCM: Least Common Multiple
5 | """
6 |
7 | # Recursive Function for GCD
8 |
9 |
10 | def gcd(a, b):
11 | if(b == 0):
12 | return a
13 | else:
14 | return gcd(b, a % b)
15 |
16 | # Recursive Function for LCM
17 |
18 |
19 | def lcm(a, b):
20 | return int((a / gcd(a, b)) * b)
21 |
22 | # main function for getting inputs
23 |
24 |
25 | def main():
26 | # GCD input Code
27 | a = int(input("Enter first number:"))
28 | b = int(input("Enter second number:"))
29 | GCD = gcd(a, b)
30 | print("GCD is: ")
31 | print(GCD)
32 | # LCM input Code
33 | lcm.multiple = 0
34 | a = int(input("Enter first number:"))
35 | b = int(input("Enter second number:"))
36 | if(a > b):
37 | LCM = lcm(b, a)
38 | else:
39 | LCM = lcm(a, b)
40 | print(LCM)
41 |
42 |
43 | # Executing the main function
44 | if __name__ == "__main__":
45 | main()
46 |
47 |
48 | """
49 | Input/Output:
50 |
51 | Enter first number:15
52 | Enter second number:20
53 | GCD is:
54 | 5
55 | Enter first number:15
56 | Enter second number:20
57 | 60
58 |
59 | """
60 |
--------------------------------------------------------------------------------
/contributions/queue.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | class queue{
4 |
5 | public Queue queue;
6 |
7 | public Q()
8 | {
9 | this.queue = new LinkedList();
10 | }
11 |
12 | public void push(int data) {
13 | this.queue.add(data);
14 | }
15 |
16 | public void pop() {
17 | this.queue.remove();
18 | }
19 |
20 | public void peek() {
21 | System.out.println("Element on top: " + this.queue.element());
22 | }
23 |
24 | public void reverse(){
25 |
26 | Integer temp;
27 | if(!queue.isEmpty()) {
28 | temp = this.queue.remove();
29 | this.reverse();
30 | this.queue.add(temp);
31 | }
32 | }
33 |
34 | public void printQueue()
35 | {
36 | System.out.println(this.queue.toString());
37 | }
38 | }
39 |
40 | class Question1 {
41 | public static void main(String[] args) {
42 | Q obj = new Q();
43 | Scanner s = new Scanner(System.in);
44 | System.out.println(" enter size of queue : ");
45 | int n = s.nextInt();
46 | System.out.println(" enter elements of queue : ");
47 | for(int i=0;i0.2%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 1 chrome version",
39 | "last 1 firefox version",
40 | "last 1 safari version"
41 | ]
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/contributions/AnmolSingh/Skin:
--------------------------------------------------------------------------------
1 | Lead was a common additive they used to put into gasoline to avoid spontaneous combustion when the fuel is put under pressure. Repeated exposition to high concentrations of lead produce permanent IQ loss and mood changes. My theory is that GoT dragons use some sort of fuel or hydrocarbon they naturally produce (magic creatures), and they add lead into it, maybe by ingesting it from an external source, to avoid the fuel exploding inside them when they pump it out and ignite it to burn some guy.
2 |
3 | My theory is that all the people who we see in the show,
4 | who apparently become idiots due to bad and lazy writing, are actually getting their IQs constantly and progressively lowered by the fumes from the dragonfire.
5 | Cersei, who has never been in contact with a dragon, has been in contact with the fumes from valyrian fire,
6 | which probably has lead in it, so she become dumber in the battle in the river, and dumber when she burnt the church. Finally,
7 | they all are poisoned again in the final battle of King's landing (a lot of dragonfire there), originating the dumbest scene, at the end of the series, when they all talk and choose king. But it's not bad writing.
8 | They are just a lot of sick people from an era without any actual medical knowledge.
9 |
--------------------------------------------------------------------------------
/contributions/q1.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | class q1{
4 |
5 | public Queue queue;
6 |
7 | public Q()
8 | {
9 | this.queue = new LinkedList();
10 | }
11 |
12 | public void push(int data) {
13 | this.queue.add(data);
14 | }
15 |
16 | public void pop() {
17 | this.queue.remove();
18 | }
19 |
20 | public void peek() {
21 | System.out.println("Element on top: " + this.queue.element());
22 | }
23 |
24 | public void reverse(){
25 |
26 | Integer temp;
27 | if(!queue.isEmpty()) {
28 | temp = this.queue.remove();
29 | this.reverse();
30 | this.queue.add(temp);
31 | }
32 | }
33 |
34 | public void printQueue()
35 | {
36 | System.out.println(this.queue.toString());
37 | }
38 | }
39 |
40 | class Question1 {
41 | public static void main(String[] args) {
42 | Q obj = new Q();
43 | Scanner s = new Scanner(System.in);
44 | System.out.println(" enter size of queue : ");
45 | int n = s.nextInt();
46 | System.out.println(" enter elements of queue : ");
47 | for(int i=0;i [[int]]:
11 | """
12 | >>> generate_all_combinations(n=4, k=2)
13 | [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
14 | """
15 |
16 | result = []
17 | create_all_state(1, n, k, [], result)
18 | return result
19 |
20 |
21 | def create_all_state(increment, total_number, level, current_list, total_list):
22 | if level == 0:
23 | total_list.append(current_list[:])
24 | return
25 |
26 | for i in range(increment, total_number - level + 2):
27 | current_list.append(i)
28 | create_all_state(i + 1, total_number, level - 1, current_list, total_list)
29 | current_list.pop()
30 |
31 |
32 | def print_all_state(total_list):
33 | for i in total_list:
34 | print(*i)
35 |
36 |
37 | if __name__ == "__main__":
38 | n = 4
39 | k = 2
40 | total_list = generate_all_combinations(n, k)
41 | print_all_state(total_list)
42 |
--------------------------------------------------------------------------------
/contributions/samyak-ds/q1.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | class q1{
4 |
5 | public Queue queue;
6 |
7 | public Q()
8 | {
9 | this.queue = new LinkedList();
10 | }
11 |
12 | public void push(int data) {
13 | this.queue.add(data);
14 | }
15 |
16 | public void pop() {
17 | this.queue.remove();
18 | }
19 |
20 | public void peek() {
21 | System.out.println("Element on top: " + this.queue.element());
22 | }
23 |
24 | public void reverse(){
25 |
26 | Integer temp;
27 | if(!queue.isEmpty()) {
28 | temp = this.queue.remove();
29 | this.reverse();
30 | this.queue.add(temp);
31 | }
32 | }
33 |
34 | public void printQueue()
35 | {
36 | System.out.println(this.queue.toString());
37 | }
38 | }
39 |
40 | class Question1 {
41 | public static void main(String[] args) {
42 | Q obj = new Q();
43 | Scanner s = new Scanner(System.in);
44 | System.out.println(" enter size of queue : ");
45 | int n = s.nextInt();
46 | System.out.println(" enter elements of queue : ");
47 | for(int i=0;i queue;
6 |
7 | public Q()
8 | {
9 | this.queue = new LinkedList();
10 | }
11 |
12 | public void push(int data) {
13 | this.queue.add(data);
14 | }
15 |
16 | public void pop() {
17 | this.queue.remove();
18 | }
19 |
20 | public void peek() {
21 | System.out.println("Element on top: " + this.queue.element());
22 | }
23 |
24 | public void reverse(){
25 |
26 | Integer temp;
27 | if(!queue.isEmpty()) {
28 | temp = this.queue.remove();
29 | this.reverse();
30 | this.queue.add(temp);
31 | }
32 | }
33 |
34 | public void printQueue()
35 | {
36 | System.out.println(this.queue.toString());
37 | }
38 | }
39 |
40 | class Question1 {
41 | public static void main(String[] args) {
42 | Q obj = new Q();
43 | Scanner s = new Scanner(System.in);
44 | System.out.println(" enter size of queue : ");
45 | int n = s.nextInt();
46 | System.out.println(" enter elements of queue : ");
47 | for(int i=0;i 0) {
22 | int rem = n % 10;
23 | val += rem * Math.pow(b,exp);
24 | exp++;
25 | n = n / 10;
26 | }
27 |
28 | return val;
29 | }
30 |
31 | public static int DecimaltoanyBase(int n, int b) {
32 | int exp = 0;
33 | int val = 0;
34 |
35 | while (n > 0) {
36 | int rem = n % b;
37 | val += rem * Math.pow(10,exp);
38 | exp++;
39 | n = n / b;
40 | }
41 |
42 | return val;
43 | }
44 |
45 | }
46 |
47 | //Input
48 | //111001
49 | //2
50 | //3
51 |
52 | //Output
53 | //2010
54 |
--------------------------------------------------------------------------------
/contributions/Pavan Kalyan Konudula/Palindrome.java:
--------------------------------------------------------------------------------
1 |
2 | //String Palindrome Checker
3 |
4 | import java.io.*;
5 |
6 | public class Palindrome
7 | {
8 | public static void main(String args[])throws Exception
9 | {
10 | BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
11 |
12 | System.out.println("Enter a String to check for Palindrome");
13 |
14 | String input=br.readLine(); //reading input
15 |
16 | int left=0;
17 | int right=input.length()-1;
18 |
19 | int flag=0; //set to 1 for not valid palindrome string and 0 for valid palindrome string
20 |
21 | //using two pointer approach to check for palindrome
22 | while(leftA[mid]){
26 | i=mid+1;
27 | }
28 | if(find>A[j]){
29 | System.out.println("Not in array or not found");
30 | break;
31 | }
32 | }
33 | }
34 |
35 | }
36 |
37 |
38 |
39 |
40 | public class binary_search {
41 | public static void main(String[] args) {
42 | Scanner sc=new Scanner(System.in);
43 | int n=sc.nextInt();
44 | int A[]=new int[n];
45 | for(int i=0;iarray[mid])
30 | {
31 | beg=mid+1;
32 | }
33 | else if (element==array[mid])
34 | {
35 | flag=true;
36 | System.out.println("Element found at position= "+ (mid+1));
37 | break;
38 | }
39 | else
40 | {
41 | end=mid-1;
42 | }
43 |
44 | mid=(beg+end)/2;
45 | }
46 | if (!flag)
47 | {
48 | System.out.println("Elemnt not found!!");
49 | }
50 | System.out.println("\nDo you want to continue (Type y or n) \n");
51 | ch = ip.next().charAt(0);
52 | }while (ch == 'Y'|| ch == 'y');
53 |
54 | ip.close();}
55 | }
56 |
--------------------------------------------------------------------------------
/contributions/Nirmal Giri/arrayinsertion.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class arrayinsertion {
4 | public static void main(String[] args) {
5 | Scanner ip = new Scanner(System.in);
6 | int n ,e , num, pos;
7 |
8 | System.out.print("Enter size: ");
9 | e = ip.nextInt();
10 |
11 | System.out.print("Enter number? ");
12 | n = ip.nextInt();
13 |
14 | int a[] = new int[e];
15 |
16 | int i=0;
17 | while (i=pos; j2--) {
36 | a[j2+1]=a[j2];
37 | }
38 | a[pos]=num;
39 | n=n+1;
40 |
41 | System.out.print("\nNew Array: ");
42 | for (int j2 = 0; j2 < n; j2++) {
43 | System.out.print(a[j2]+" ");
44 | }
45 |
46 | } else {
47 | System.out.println("\nInvalid position");
48 | }
49 |
50 | ip.close();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/contributions/Pavan Kalyan Konudula/Permutations.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Program to print all Possible Permutations of given String
4 |
5 | Ex : ABC
6 |
7 | ABC
8 | ACB
9 | BAC
10 | BCA
11 | CBA
12 | CAB
13 |
14 | are possible Permutations
15 | */
16 |
17 |
18 | import java.util.*;
19 | import java.io.*;
20 |
21 | public class Permutations {
22 |
23 | static void per(String s,int left,int right)
24 | {
25 | if(left==s.length()-1)
26 | {
27 | System.out.println(s);
28 | return;
29 | }
30 |
31 | if(left= self.lim_charge
35 | else None
36 | )
37 | if new_key is None:
38 | break
39 | else:
40 | i += 1
41 |
42 | return new_key
43 |
--------------------------------------------------------------------------------
/contributions/Ritik_Ranjan/bubble_sort.py:
--------------------------------------------------------------------------------
1 | def bubble_sort(collection):
2 | """Pure implementation of bubble sort algorithm in Python
3 |
4 | :param collection: some mutable ordered collection with heterogeneous
5 | comparable items inside
6 | :return: the same collection ordered by ascending
7 |
8 | Examples:
9 | >>> bubble_sort([0, 5, 2, 3, 2])
10 | [0, 2, 2, 3, 5]
11 |
12 | >>> bubble_sort([])
13 | []
14 |
15 | >>> bubble_sort([-2, -45, -5])
16 | [-45, -5, -2]
17 |
18 | >>> bubble_sort([-23, 0, 6, -4, 34])
19 | [-23, -4, 0, 6, 34]
20 |
21 | >>> bubble_sort([-23, 0, 6, -4, 34]) == sorted([-23, 0, 6, -4, 34])
22 | True
23 | """
24 | length = len(collection)
25 | for i in range(length - 1):
26 | swapped = False
27 | for j in range(length - 1 - i):
28 | if collection[j] > collection[j + 1]:
29 | swapped = True
30 | collection[j], collection[j + 1] = collection[j + 1], collection[j]
31 | if not swapped:
32 | break # Stop iteration if the collection is sorted.
33 | return collection
34 |
35 |
36 | if __name__ == "__main__":
37 | import time
38 |
39 | user_input = input("Enter numbers separated by a comma:").strip()
40 | unsorted = [int(item) for item in user_input.split(",")]
41 | start = time.process_time()
42 | print(*bubble_sort(unsorted), sep=",")
43 | print(f"Processing time: {time.process_time() - start}")
44 |
--------------------------------------------------------------------------------
/contributions/stack.java:
--------------------------------------------------------------------------------
1 |
2 | class Stack {
3 | static final int MAX = 1000;
4 | int top;
5 | int a[] = new int[MAX]; // Maximum size of Stack
6 |
7 | boolean isEmpty()
8 | {
9 | return (top < 0);
10 | }
11 | Stack()
12 | {
13 | top = -1;
14 | }
15 |
16 | boolean push(int x)
17 | {
18 | if (top >= (MAX - 1)) {
19 | System.out.println("Stack Overflow");
20 | return false;
21 | }
22 | else {
23 | a[++top] = x;
24 | System.out.println(x + " pushed into stack");
25 | return true;
26 | }
27 | }
28 |
29 | int pop()
30 | {
31 | if (top < 0) {
32 | System.out.println("Stack Underflow");
33 | return 0;
34 | }
35 | else {
36 | int x = a[top--];
37 | return x;
38 | }
39 | }
40 |
41 | int peek()
42 | {
43 | if (top < 0) {
44 | System.out.println("Stack Underflow");
45 | return 0;
46 | }
47 | else {
48 | int x = a[top];
49 | return x;
50 | }
51 | }
52 | }
53 |
54 | class Main {
55 | public static void main(String args[])
56 | {
57 | Stack s = new Stack();
58 | s.push(10);
59 | s.push(20);
60 | s.push(30);
61 | System.out.println(s.pop() + " Popped from stack");
62 | }
63 | }
--------------------------------------------------------------------------------
/contributions/Ishita Jain/all_permutations.py:
--------------------------------------------------------------------------------
1 | """
2 | In this problem, we want to determine all possible permutations
3 | of the given sequence. We use backtracking to solve this problem.
4 |
5 | Time complexity: O(n! * n),
6 | where n denotes the length of the given sequence.
7 | """
8 |
9 |
10 | def generate_all_permutations(sequence):
11 | create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])
12 |
13 |
14 | def create_state_space_tree(sequence, current_sequence, index, index_used):
15 | """
16 | Creates a state space tree to iterate through each branch using DFS.
17 | We know that each state has exactly len(sequence) - index children.
18 | It terminates when it reaches the end of the given sequence.
19 | """
20 |
21 | if index == len(sequence):
22 | print(current_sequence)
23 | return
24 |
25 | for i in range(len(sequence)):
26 | if not index_used[i]:
27 | current_sequence.append(sequence[i])
28 | index_used[i] = True
29 | create_state_space_tree(sequence, current_sequence, index + 1, index_used)
30 | current_sequence.pop()
31 | index_used[i] = False
32 |
33 |
34 | """
35 | remove the comment to take an input from the user
36 |
37 | print("Enter the elements")
38 | sequence = list(map(int, input().split()))
39 | """
40 |
41 | sequence = [3, 1, 2, 4]
42 | generate_all_permutations(sequence)
43 |
44 | sequence = ["A", "B", "C"]
45 | generate_all_permutations(sequence)
46 |
--------------------------------------------------------------------------------
/contributions/Ritika-Roongta/countBST.txt:
--------------------------------------------------------------------------------
1 | class Node:
2 |
3 | def __init__(self, data):
4 | self.left = None
5 | self.right = None
6 | self.data = data
7 |
8 | def getCountOfNode(root, low, high):
9 | if root == None:
10 | return 0
11 |
12 | if root.data == high and root.data == low:
13 | return 1
14 |
15 | if root.data <= high and root.data >= low:
16 | return (1 + getCountOfNode(root.left, low, high) + getCountOfNode(root.right, low, high))
17 |
18 | elif root.data < low:
19 | return getCount(root.right, low, high)
20 |
21 | else:
22 | return getCount(root.left, low, high)
23 |
24 | def insert(root,data):
25 | if root is None:
26 | return Node(data)
27 | else:
28 | if root.data == data:
29 | return root
30 | elif root.data < data:
31 | root.right = insert(root.right, data)
32 | else:
33 | root.left = insert(root.left, data)
34 | return root
35 |
36 | if __name__ == '__main__':
37 | print("Enter number of test cases: ")
38 | T = input()
39 | while (T!=0):
40 | N = input("Enter number of nodes in BST: ")
41 | y = input("Enter root value: ")
42 | r = Node(y)
43 | while(N!=1):
44 | x = input("Enter the node values")
45 | r = insert(r, x)
46 | N = N - 1
47 | l = input("Enter the starting value: ")
48 | h = input("Enter the ending range value: ")
49 | count = getCountOfNode(r, l, h)
50 | print(count)
51 | T -=1
52 |
--------------------------------------------------------------------------------
/contributions/Ritik_Ranjan/quick_sort.py:
--------------------------------------------------------------------------------
1 | """
2 | This is a pure python implementation of the quick sort algorithm
3 |
4 | For doctests run following command:
5 | python -m doctest -v quick_sort.py
6 | or
7 | python3 -m doctest -v quick_sort.py
8 |
9 | For manual testing run:
10 | python quick_sort.py
11 | """
12 |
13 |
14 | def quick_sort(collection):
15 | """Pure implementation of quick sort algorithm in Python
16 |
17 | :param collection: some mutable ordered collection with heterogeneous
18 | comparable items inside
19 | :return: the same collection ordered by ascending
20 |
21 | Examples:
22 | >>> quick_sort([0, 5, 3, 2, 2])
23 | [0, 2, 2, 3, 5]
24 |
25 | >>> quick_sort([])
26 | []
27 |
28 | >>> quick_sort([-2, -5, -45])
29 | [-45, -5, -2]
30 | """
31 | length = len(collection)
32 | if length <= 1:
33 | return collection
34 | else:
35 | # Use the last element as the first pivot
36 | pivot = collection.pop()
37 | # Put elements greater than pivot in greater list
38 | # Put elements lesser than pivot in lesser list
39 | greater, lesser = [], []
40 | for element in collection:
41 | if element > pivot:
42 | greater.append(element)
43 | else:
44 | lesser.append(element)
45 | return quick_sort(lesser) + [pivot] + quick_sort(greater)
46 |
47 |
48 | if __name__ == "__main__":
49 | user_input = input("Enter numbers separated by a comma:\n").strip()
50 | unsorted = [int(item) for item in user_input.split(",")]
51 | print(quick_sort(unsorted))
52 |
--------------------------------------------------------------------------------
/contributions/Atul/Binary Search.kt:
--------------------------------------------------------------------------------
1 | import java.util.*
2 |
3 | /**
4 | * Created by gazollajunior on 03/04/16.
5 | */
6 |
7 | fun > binarySearch(list: List, key: T): Int? {
8 | var rangeStart = 0
9 | var rangeEnd = list.count()
10 | while (rangeStart < rangeEnd) {
11 | val midIndex = rangeStart + (rangeEnd - rangeStart)/2
12 | if (list[midIndex] == key) {
13 | return midIndex
14 | } else if (list[midIndex] < key) {
15 | rangeStart = midIndex + 1
16 | } else {
17 | rangeEnd = midIndex
18 | }
19 | }
20 | return null
21 | }
22 |
23 | fun > binarySearchRec(list: List, key: T): Optional {
24 | require(list == list.sorted())
25 |
26 | fun helper(start: Int, end: Int): Optional {
27 | val mid: Int = start + (end - start) / 2
28 | if (end < start) return Optional.empty()
29 |
30 | if (key == list[mid]) {
31 | return Optional.of(mid)
32 | } else if (key < list[mid]) {
33 | return helper(start, mid - 1)
34 | } else {
35 | return helper(mid + 1, end)
36 | }
37 | }
38 |
39 | return helper(0, list.count())
40 | }
41 |
42 | fun main(args: Array) {
43 | println("\nOrdered list:")
44 | val ordered = listOf("Adam", "Clark", "John", "Tim", "Zack")
45 | println(ordered)
46 | val name = "John"
47 | println("\n$name is in the position ${binarySearch(ordered, name)} in the ordered List.")
48 | println("\n$name is in the position ${binarySearchRec(ordered, name)} in the ordered List.")
49 | }
50 |
--------------------------------------------------------------------------------
/contributions/Nirmal Giri/arraymerging.java:
--------------------------------------------------------------------------------
1 | /**
2 | * arraymerging
3 | */
4 | import java.util.Scanner;
5 |
6 | public class arraymerging {
7 |
8 | public static void main(String[] args) {
9 | Scanner ip = new Scanner(System.in);
10 | System.out.print("Enter size 1st: ");
11 | int n = ip.nextInt();
12 | System.out.print("Enter size 2nd: ");
13 | int m=ip.nextInt();
14 |
15 | int[] a = new int[n];
16 | int[] b = new int[m];
17 |
18 | System.out.print("Enter numbers: ");
19 | for (int i = 0; i < a.length ; i++) {
20 | a[i] = ip.nextInt();
21 | }
22 | System.out.print("Array: ");
23 | for (int i = 0; i < a.length; i++) {
24 | System.out.print(a[i]+" ");
25 | }
26 |
27 | System.out.print("\nEnter numbers: ");
28 | for (int i = 0; i < b.length ; i++) {
29 | b[i] = ip.nextInt();
30 | }
31 | System.out.print("Array: ");
32 | for (int i = 0; i < b.length; i++) {
33 | System.out.print(b[i]+" ");
34 | }
35 |
36 | int[] c = new int[n+m];
37 | int i=0;
38 | while (i
2 | Binary search tree implementation in PHP
3 |
4 | Example: Array data:
5 | [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]
6 |
7 | Result:
8 |
48 |
49 |
--------------------------------------------------------------------------------
/webapp/src/Components/UserForm.css:
--------------------------------------------------------------------------------
1 | .text{
2 | text-align: center;
3 | font-size: 210%;
4 | padding-bottom: 10px;
5 | }
6 | .starter{
7 |
8 |
9 | }
10 | .align-part1{
11 | margin-top: 10px;
12 | }
13 | .register-text{
14 | position: relative;
15 | top:11px;
16 | }
17 | .subtext{
18 | padding-top: -50px;
19 | text-align: center;
20 | font-size: 130%;
21 | margin-bottom: -15px;
22 | }
23 |
24 | .form-style{
25 | display: flex;
26 | justify-content: center;
27 | flex-wrap: wrap;
28 | margin-bottom: -60px;
29 | }
30 | .textarea-1{
31 | width: 30ch;
32 | }
33 | .designform{
34 | margin: 30px;
35 | text-align: center;
36 | }
37 | .designform1{
38 | margin: 30px;
39 | text-align: center;
40 | margin-bottom: -20px;
41 | }
42 | .button-design{
43 | margin-top: 50px;
44 | text-align: center;
45 | }
46 | .text-design{
47 | font-size: 140%;
48 | }
49 | .Button-align{
50 | padding-top: 30px;
51 | float: right;
52 | }
53 | .button1{
54 | position: relative;
55 | left:10px;
56 |
57 |
58 | }
59 | .button2{
60 | position: relative;
61 | left:20px;
62 | }
63 | @media only screen and (max-width: 600px) {
64 | body{
65 | width: 100%;
66 | height: 100%;
67 | justify-content: center;
68 | flex-wrap: wrap;
69 | }
70 | .text{
71 | padding-top: 45px;
72 | }
73 | .textarea-1{
74 | width: auto;
75 | }
76 | .paper-respo{
77 | width: 100%;
78 | }
79 |
80 | }
81 |
82 |
83 | .tf-comp{
84 | margin: 10px;
85 |
86 | }
87 | .paper-respo{
88 | padding: 20px;
89 |
90 | }
91 | .paper-respo-1{
92 | padding: 0px;
93 | }
--------------------------------------------------------------------------------
/contributions/Prachika-Kanodia/Hacktoberfest2020.py:
--------------------------------------------------------------------------------
1 | # Python program to find largest
2 | # number in a list
3 |
4 | # list of numbers
5 | list1 = [10, 20, 4, 45, 99]
6 |
7 | # sorting the list
8 | list1.sort()
9 |
10 | # printing the last element
11 | print("Largest element is:", list1[-1])
12 |
13 |
14 | # Python3 program to add two numbers
15 |
16 | num1 = 15
17 | num2 = 12
18 |
19 | # Adding two nos
20 | sum = num1 + num2
21 |
22 | # printing values
23 | print("Sum of {0} and {1} is {2}" .format(num1, num2, sum))
24 |
25 |
26 | # Python program to find the factorial of a number provided by the user.
27 |
28 | # change the value for a different result
29 | num = 7
30 |
31 | # To take input from the user
32 | #num = int(input("Enter a number: "))
33 |
34 | factorial = 1
35 |
36 | # check if the number is negative, positive or zero
37 | if num < 0:
38 | print("Sorry, factorial does not exist for negative numbers")
39 | elif num == 0:
40 | print("The factorial of 0 is 1")
41 | else:
42 | for i in range(1,num + 1):
43 | factorial = factorial*i
44 | print("The factorial of",num,"is",factorial)
45 |
46 | # Program to display the Fibonacci sequence up to n-th term
47 |
48 | nterms = int(input("How many terms? "))
49 |
50 | # first two terms
51 | n1, n2 = 0, 1
52 | count = 0
53 |
54 | # check if the number of terms is valid
55 | if nterms <= 0:
56 | print("Please enter a positive integer")
57 | elif nterms == 1:
58 | print("Fibonacci sequence upto",nterms,":")
59 | print(n1)
60 | else:
61 | print("Fibonacci sequence:")
62 | while count < nterms:
63 | print(n1)
64 | nth = n1 + n2
65 | # update values
66 | n1 = n2
67 | n2 = nth
68 | count += 1
69 |
70 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 | firebase.js
3 | # dependencies
4 | **/node_modules
5 | /.pnp
6 | **/build
7 | .pnp.js
8 | settings.json
9 | # testing
10 | /coverage
11 | **/build
12 | # production
13 | **/build/
14 | **/.idea
15 | cloud-function/public
16 | # misc
17 | .DS_Store
18 | .env.local
19 | .env.development.local
20 | .env.test.local
21 | .env.production.local
22 |
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 | *.code-workspace
33 |
34 | # Local History for Visual Studio Code
35 | .history/
36 |
37 | # User-specific stuff
38 | .idea/**/workspace.xml
39 | .idea/**/tasks.xml
40 | .idea/**/usage.statistics.xml
41 | .idea/**/dictionaries
42 | .idea/**/shelf
43 |
44 | # Generated files
45 | .idea/**/contentModel.xml
46 |
47 | # Sensitive or high-churn files
48 | .idea/**/dataSources/
49 | .idea/**/dataSources.ids
50 | .idea/**/dataSources.local.xml
51 | .idea/**/sqlDataSources.xml
52 | .idea/**/dynamic.xml
53 | .idea/**/uiDesigner.xml
54 | .idea/**/dbnavigator.xml
55 |
56 |
57 | # CMake
58 | cmake-build-*/
59 |
60 | # Mongo Explorer plugin
61 | .idea/**/mongoSettings.xml
62 |
63 | # File-based project format
64 | *.iws
65 |
66 | # IntelliJ
67 | out/
68 |
69 | # mpeltonen/sbt-idea plugin
70 | .idea_modules/
71 |
72 | # JIRA plugin
73 | atlassian-ide-plugin.xml
74 |
75 | # Cursive Clojure plugin
76 | .idea/replstate.xml
77 |
78 | # Crashlytics plugin (for Android Studio and IntelliJ)
79 | com_crashlytics_export_strings.xml
80 | crashlytics.properties
81 | crashlytics-build.properties
82 | fabric.properties
83 |
84 | # Editor-based Rest Client
85 | .idea/httpRequests
86 |
87 |
--------------------------------------------------------------------------------
/contributions/Create Stack data structure implementation. #17ANUJ SRIVASTAVA:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace std;
6 |
7 | typedef struct
8 | {
9 | int *elems;
10 | int logLength;
11 | int allocLength;
12 | } Stack;
13 |
14 | void createStack(Stack *s)
15 | {
16 | s->logLength = 0;
17 | s->allocLength = 4;
18 | s->elems = (int *)malloc(4 * sizeof(int));
19 | assert(s->elems != NULL);
20 | }
21 |
22 | void deleteStack(Stack *s)
23 | {
24 | free(s->elems);
25 | s->logLength = 0;
26 | /* free(s) - Don't do this.
27 | The structure is not dynamically allocated */
28 | }
29 |
30 | void pushStack(Stack *s, int value)
31 | {
32 | if(s->logLength == s->allocLength) {
33 | /* doubling stratege */
34 | s->allocLength *= 2;
35 | s->elems = (int *)realloc(s->elems,s->allocLength * sizeof(int));
36 | assert(s->elems != NULL);
37 | }
38 |
39 | s->elems[s->logLength] = value;
40 | s->logLength++;
41 | }
42 |
43 | int popStack(Stack *s)
44 | {
45 | assert(s->logLength > 0);
46 | s->logLength--;
47 | return s->elems[s->logLength];
48 | }
49 |
50 | void printStack(Stack *s)
51 | {
52 | for(int i = 0; i < s->logLength; i++) {
53 | cout << s->elems[i] << " ";
54 | }
55 | cout << endl;
56 | return;
57 | }
58 |
59 | int main()
60 | {
61 | Stack s;
62 | createStack(&s;);
63 | for(int i = 0; i < 10; i++) {
64 | pushStack(&s;,i);
65 | }
66 | printStack(&s;);
67 | cout << "Pop: " << popStack(&s;) << endl;
68 | printStack(&s;);
69 | cout << "Pop: " << popStack(&s;) << endl;
70 | printStack(&s;);
71 |
72 | cout << "Stack disposed" << endl;
73 | deleteStack(&s;);
74 | printStack(&s;);
75 | }
76 | //output
77 | 0 1 2 3 4 5 6 7 8 9
78 | Pop: 9
79 | 0 1 2 3 4 5 6 7 8
80 | Pop: 8
81 | 0 1 2 3 4 5 6 7
82 | Stack disposed
83 |
--------------------------------------------------------------------------------
/cloud-function/index.js:
--------------------------------------------------------------------------------
1 | const crypto = require('crypto');
2 | const db = require('./firebase');
3 | const settings = require('./settings');
4 |
5 | exports.handleNewMergedPullRequest = (req, res) => {
6 | return validatePullRequest(req)
7 | .then(() => {
8 | console.log('in');
9 | if (req.body.action === 'closed' && req.body.pull_request.merged === true) {
10 | console.log('user validated, about to save');
11 | return saveToDatabase(req.body.pull_request.user.login);
12 | } else {
13 | console.log('not saved');
14 | }
15 | }).then(() => {
16 | console.log('exit');
17 | res.status(200).end();
18 | })
19 | .catch((err) => {
20 | console.error(err.stack);
21 | res.status(err.statusCode ? err.statusCode : 500)
22 | .send(err.message)
23 | .end();
24 | });
25 | };
26 |
27 | function saveToDatabase(githubId) {
28 | return db.collection('users').doc(githubId.toLowerCase()).update({
29 | verified: true
30 | }).then(() => {
31 | console.log('saved')
32 | }).catch(error => {
33 | console.error(error)
34 | });
35 | }
36 |
37 | function validatePullRequest(req) {
38 | return Promise.resolve()
39 | .then(() => {
40 | const digest = crypto
41 | .createHmac('sha1', settings.secretToken)
42 | .update(JSON.stringify(req.body))
43 | .digest('hex');
44 | if (req.headers['x-hub-signature'] !== `sha1=${digest}`) {
45 | const error = new Error('Unauthorized');
46 | error.statusCode = 403;
47 | throw error;
48 | } else {
49 | console.log('Request validated.');
50 |
51 | }
52 | });
53 | }
54 |
--------------------------------------------------------------------------------
/contributions/Rishabh Singhal/DFS.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class DFS{
3 | Stack S=new Stack<>();
4 | static class Node{
5 | int data;
6 | ArrayList neighbour=new ArrayList<>();
7 | boolean visit;
8 | public Node(int v){
9 | data=v;
10 | }
11 | public class Graph {
12 | private int[][] nodes; // all nodes; e.g. int[][] nodes = {{1,2,3}, {3,2,1,5,6}...};
13 | public int[] getAdjacentNodes(int v) {
14 | return nodes[v];
15 | }
16 | // number of vertices in a graph
17 | public int vSize() {
18 | return nodes.length;
19 | }
20 | }
21 | public void addneighbour(Node n){
22 | neighbour.add(n);
23 | }
24 | public ArrayList getneighbour(Node n){
25 | return n.neighbour;
26 | }
27 | public void printneighbour(Node n){
28 | ArrayList nn =getneighbour(n);
29 | for(int i=0;i E = ex.getneighbour(ex);//getting nei and adding to queue
41 | for(int i=0;i
11 |
12 |
13 |
14 |
Designed & Developed by
15 |
16 |
17 |
18 |
19 |
20 |
24 |
28 |
32 |
36 |
37 |
38 | );
39 | }
40 | }
41 |
42 | export default Contributors;
43 |
--------------------------------------------------------------------------------
/webapp/src/Components/Navigation.css:
--------------------------------------------------------------------------------
1 | .bm-burger-button {
2 | position: fixed;
3 | width: 30px;
4 | height: 25px;
5 | left: 26px;
6 | top: 26px;
7 | }
8 | /*todo: change color of burger button*/
9 | /* Color/shape of burger icon bars */
10 | .bm-burger-bars {
11 | background: #17202A;
12 | }
13 |
14 | /* Color/shape of burger icon bars on hover*/
15 | /*todo: change color to theme color*/
16 | .bm-burger-bars-hover {
17 | background: #0091EA;
18 |
19 | }
20 |
21 | /* Position and sizing of clickable cross button */
22 | /*todo change h and w of cross*/
23 | .bm-cross-button {
24 | height: 24px;
25 | width: 24px;
26 | }
27 |
28 | /* Color/shape of close button cross */
29 | /*todo change color according to text*/
30 | .bm-cross {
31 | background: #bdc3c7;
32 | }
33 |
34 | /*
35 | Sidebar wrapper styles
36 | Note: Beware of modifying this element as it can break the animations - you should not need to touch it in most cases
37 | */
38 | .bm-menu-wrap {
39 | position: fixed;
40 | height: 100%;
41 | }
42 |
43 | /* General sidebar styles */
44 | /*todo: change background color according to theme*/
45 | .bm-menu {
46 | background: #2980b9;
47 | padding: 2.5em 0.2em 0;
48 | font-size: 1.15em;
49 | }
50 |
51 | /* Morph shape necessary with bubble or elastic */
52 | .bm-morph-shape {
53 | fill: #373a47;
54 | }
55 |
56 | /* Wrapper for item list */
57 | .bm-item-list {
58 | color: #b8b7ad;
59 | padding: 0.8em;
60 | }
61 |
62 | /* Individual item */
63 | .bm-item {
64 | display: inline-block;
65 | }
66 |
67 | /* Styling of overlay */
68 | .bm-overlay {
69 | background: rgba(0, 0, 0, 0.3);
70 | }
71 | /*todo change color of text*/
72 | .menu-item{
73 | color: white;
74 | outline: none;
75 | font-size: 120%;
76 | margin: 30px;
77 | }
78 | /*todo change hover color*/
79 | .menu-item:hover{
80 | color: #00203FFF;
81 | text-decoration: none;
82 | }
83 | a:hover{
84 | cursor: pointer;
85 | }
86 | .jk-tag{
87 | padding-left: 2px;
88 | font-size: 150%;
89 | color: white;
90 | outline: none;
91 | }
92 |
--------------------------------------------------------------------------------
/contributions/Suhas/InstCrawler.py:
--------------------------------------------------------------------------------
1 | # Requirements to be installed:
2 | # pip install requests
3 | # pip install BeautifulSoup4
4 | # pip install prettytable
5 |
6 | import json
7 | import requests
8 | from bs4 import BeautifulSoup
9 | import sys
10 | import datetime as dt
11 | from prettytable import PrettyTable
12 |
13 | URL = "https://www.instagram.com/{}/"
14 |
15 |
16 | def scrape_data(username):
17 | r = requests.get(URL.format(username))
18 | soup= BeautifulSoup(r.text, "html.parser")
19 |
20 | script = soup.find('script', text=lambda t: t.startswith('window._sharedData'))
21 | page_json = script.text.split(' = ', 1)[1].rstrip(';')
22 | data = json.loads(page_json)
23 | non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
24 | raw_posts = data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']
25 |
26 | profile = soup.find("meta", property = "og:description")
27 | posts = []
28 |
29 | for i in range(len(raw_posts)):
30 | link = raw_posts[i]['node']['display_url']
31 | date = dt.datetime.fromtimestamp(raw_posts[i]['node']['taken_at_timestamp']).strftime('%Y-%m-%d %H:%M:%S')
32 | likes = raw_posts[i]['node']['edge_liked_by']['count']
33 | comments = raw_posts[i]['node']['edge_media_to_comment']['count']
34 | type = "Video" if raw_posts[i]['node']['is_video'] else "Image"
35 | posts.append({"id": i, "link": link, "type": type, "date": date, "likes": likes, "comments": comments})
36 |
37 | return posts
38 |
39 |
40 | def printTable(data):
41 | t = PrettyTable(["S.No", "Date", "Post Type", "No. likes", "No. Comments"])
42 | for row in data:
43 | t.add_row([row["id"], row["date"], row["type"], row["likes"], row["comments"]])
44 |
45 | print(t)
46 |
47 |
48 | if __name__ == "__main__":
49 |
50 | print("Enter your Instagram UserName: ")
51 | username = input()
52 |
53 | data = scrape_data(username)
54 |
55 | print("\n\tRecent Instagram Posts Data of ", username)
56 | printTable(data);
57 |
58 |
--------------------------------------------------------------------------------
/contributions/gauravbisht005/MergeSort.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | void merge(int A[], int l, int m, int r){
5 | int i = 0;
6 | int j = 0;
7 | int k = l;
8 | int sizeOfRight = r - m;
9 | int sizeOfLeft = m - l + 1;
10 | int leftArray[sizeOfLeft];
11 | int rightArray[sizeOfRight];
12 | for(i; i < sizeOfLeft; i++){
13 | leftArray[i] = A[k];
14 | k++;
15 | }
16 | for(j; j < sizeOfRight; j++){
17 | rightArray[j] = A[k];
18 | k++;
19 | }
20 | i = 0;
21 | j = 0;
22 | k = l;
23 | while(i < sizeOfLeft && j < sizeOfRight){
24 | if(leftArray[i] <= rightArray[j]){
25 | A[k] = leftArray[i];
26 | i++;
27 | k++;
28 | }
29 | else{
30 | A[k] = rightArray[j];
31 | j++;
32 | k++;
33 | }
34 | }
35 | while(i < sizeOfLeft){
36 | A[k] = leftArray[i];
37 | i++;
38 | k++;
39 | }
40 | while(j < sizeOfRight){
41 | A[k] = rightArray[j];
42 | j++;
43 | k++;
44 | }
45 | }
46 | void mergeSort(int A[], int l, int r){
47 | int first = l;
48 | int last = r;
49 | if(first == last)
50 | return;
51 | else {
52 | int middle = (first + last) / 2;
53 | mergeSort(A,first, middle);
54 | mergeSort(A, middle + 1, last);
55 | merge(A, first, middle, last);
56 | }
57 | }
58 | int main(){
59 | cout << "Please enter the length (number of elements) of the input array: ";
60 | int n;
61 | cin >> n;
62 | if(n <= 0){
63 | cout << "Illegal input array length!" << endl;
64 | return 0;
65 | }
66 | int* A = new int [n];
67 | cout << "Please enter each element in the array" << endl;
68 | cout << "(each element must be an integer within the range of int type)." << endl;
69 | for(int i=0; i> A[i];
72 | }
73 | cout << "Given array A[] is: ";
74 | for(int i=0; i 0]
48 | print(bucket_sort(unsorted))
49 |
--------------------------------------------------------------------------------
/contributions/linked list:
--------------------------------------------------------------------------------
1 | // A complete working Java program to demonstrate deletion in singly
2 | // linked list
3 | class LinkedList
4 | {
5 | Node head; // head of list
6 |
7 | /* Linked list Node*/
8 | class Node
9 | {
10 | int data;
11 | Node next;
12 | Node(int d)
13 | {
14 | data = d;
15 | next = null;
16 | }
17 | }
18 |
19 | /* Given a key, deletes the first occurrence of key in linked list */
20 | void deleteNode(int key)
21 | {
22 | // Store head node
23 | Node temp = head, prev = null;
24 |
25 | // If head node itself holds the key to be deleted
26 | if (temp != null && temp.data == key)
27 | {
28 | head = temp.next; // Changed head
29 | return;
30 | }
31 |
32 | // Search for the key to be deleted, keep track of the
33 | // previous node as we need to change temp.next
34 | while (temp != null && temp.data != key)
35 | {
36 | prev = temp;
37 | temp = temp.next;
38 | }
39 |
40 | // If key was not present in linked list
41 | if (temp == null) return;
42 |
43 | // Unlink the node from linked list
44 | prev.next = temp.next;
45 | }
46 |
47 | /* Inserts a new Node at front of the list. */
48 | public void push(int new_data)
49 | {
50 | Node new_node = new Node(new_data);
51 | new_node.next = head;
52 | head = new_node;
53 | }
54 |
55 | /* This function prints contents of linked list starting from
56 | the given node */
57 | public void printList()
58 | {
59 | Node tnode = head;
60 | while (tnode != null)
61 | {
62 | System.out.print(tnode.data+" ");
63 | tnode = tnode.next;
64 | }
65 | }
66 |
67 | /* Drier program to test above functions. Ideally this function
68 | should be in a separate user class. It is kept here to keep
69 | code compact */
70 | public static void main(String[] args)
71 | {
72 | LinkedList llist = new LinkedList();
73 |
74 | llist.push(7);
75 | llist.push(1);
76 | llist.push(3);
77 | llist.push(2);
78 |
79 | System.out.println("\nCreated Linked list is:");
80 | llist.printList();
81 |
82 | llist.deleteNode(1); // Delete node with data 1
83 |
84 | System.out.println("\nLinked List after Deletion of 1:");
85 | llist.printList();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/contributions/Atul/Depth First Search (DFS).kt:
--------------------------------------------------------------------------------
1 | fun main(args: Array) {
2 |
3 | val adjacencyList = AdjacencyList()
4 |
5 | val s = adjacencyList.createVertex("S")
6 | val a = adjacencyList.createVertex("A")
7 | val b = adjacencyList.createVertex("B")
8 | val c = adjacencyList.createVertex("C")
9 | val d = adjacencyList.createVertex("D")
10 | val f = adjacencyList.createVertex("F")
11 | val g = adjacencyList.createVertex("G")
12 | val e = adjacencyList.createVertex("E")
13 |
14 | adjacencyList.add(Undirected(), s, a)
15 | adjacencyList.add(Undirected(), a, b)
16 | adjacencyList.add(Undirected(), a, d)
17 | adjacencyList.add(Undirected(), a, c)
18 | adjacencyList.add(Undirected(), b, d)
19 | adjacencyList.add(Undirected(), d, g)
20 | adjacencyList.add(Undirected(), d, f)
21 | adjacencyList.add(Undirected(), f, e)
22 |
23 | print(adjacencyList)
24 | print(depthFirstSearch(s, e, adjacencyList))
25 |
26 | }
27 |
28 | fun depthFirstSearch(start: VertexString, end: VertexString, graph: AdjacencyList): Stack {
29 | val visited: MutableSet = mutableSetOf()
30 | val stack = Stack()
31 |
32 | stack.push(start)
33 | visited.add(start)
34 |
35 | var vertex = stack.peek()
36 |
37 | loop@while (vertex != null && vertex != end) {
38 |
39 | val neighbors = graph.edges(vertex)
40 | if (neighbors != null && neighbors.count() > 0) {
41 |
42 | for (edge in neighbors) {
43 | if (!visited.contains(edge.destination)) {
44 | visited.add(edge.destination)
45 | stack.push(edge.destination)
46 | print("$stack")
47 | vertex = stack.peek()
48 | continue@loop
49 | }
50 | }
51 |
52 | } else {
53 | print("backtrack from $vertex")
54 | stack.pop()
55 | vertex = stack.peek()
56 | continue
57 | }
58 |
59 | print("backtrack from $vertex")
60 | stack.pop()
61 | vertex = stack.peek()
62 | }
63 |
64 | return stack
65 | }
--------------------------------------------------------------------------------
/contributions/AnmolSingh/Art:
--------------------------------------------------------------------------------
1 | Fax Machines be like: "OOOO oo 0000000 ᵒᵒᴼᵒ⁰ᵒᴼᴼᴼ⁰ᵒᴼᴼᴼᴼᵒᵒᵒ ⁰⁰⁰ᵒ⁰ᵒᵒᵒ⁰ᵒ⁰ᵒ⁰ᵒᴼᴼ⁰ᵒ⁰ᴼ⁰ᴼ⁰ᵒᵒ⁰ᴼ⁰ᴼᵒᴼᴼᴼᵒ DoOOOOOOODOOOOOOOODOOOOOOOOODOOOOOOOOOo
2 |
3 | ⁰⁰⁰ᵒ⁰ᵒᵒᵒ⁰ᵒ⁰ᵒ⁰ᵒᴼᴼ⁰ᵒ⁰ᴼ⁰ᴼ⁰ᵒᵒ⁰ᴼ⁰ᴼᵒᴼᴼᴼᵒ AAAAAAAAAAAAA RRR AAAAARRRR AAAAARRRA̸̤̰̯͙̳̦͓̪͖̖̤̭̎̃̈́̿͛̀̅͆̾̓͗͝ͅŞ̸̲̟̬̝̟̜̺̪͎̭̅S̷̯̥̭̪̘̟̹̱̘̫͚̦̘͋̊́̅͂Ș̵̢̛͎̩͎̩̩̖̲̪͓̱͈̦̱̿͂͑̅̑́͗̓̏̋͘͝͝S̴͕̀̎͆͐̋̊͘͠S̶̖̈́͐͂̒͋̍̃͒͑̈́̀̈͠S̸̡̡̡̬̗̲͈͌̐̃̐̒̏̀̈́͝S̸̨͎̙͕̩̠̳͙̠̬̜̯̩̏̒̓̀̈́̀͂̎͗̀̋́̕͠Ş̶̪̹͙̕S̴̮̝̮̣̙͇̈́̋D̷̡͚̦̊̆͌̂̃G̷̢̞͍͒̅̈͐̈́͗͌̅̀̀̄͂̀̿̚A̶̟͖͚̦̤̍̉̎͝S̷̡̪̣̪͈̱͔̪͇̫̹̈͑̎͌̄͐͊̔́̈́͜͜͠J̵̨̩̮̪͑̑̀͝H̶̨̞̜͍̥̻̎́ͅD̸̟̮̺͔͉̆͂͝F̵̛̫̀̈̕G̸̨̟̭͇̿̔̕ͅJ̴̛̲͂̎̏̋̈́̓͗̇̏̉͠Å̶̤̓̽̆̈́͐̀͒̓͆̃͆͗͌H̶͉͔̟̙̊̃̀͊̓͠͠Š̸̢̧̧̥̤͎̻̭̩̞̱̯͉̞̗̈́̾͝D̶̡̻̰͕̭͍̠͉̫̖̤͂͝Ģ̷̯̳̥̳͓̼̹͒̌̈͜͠F̸̧̭̟̦̺̭̻̣̗̭̭̱̜̠̬̽͗͐͗̈̈͋̓͆͆̉Ḧ̸̨̱͈͚̰̤͕̲̲̪̺̪̾̾̎͌͗̀̂̓͋͊̾̇Ấ̵̡͖̥̤̖̪͖̱̫̟͖̅̇̆͋̐̆́̅̏͠S̵̨̨͈̗̪̲͙̞̤̲̗̳̺̓̃̀͊͊̀͐̾͛̉̽͌̚̚͝Ḑ̶̧̫̞̳̽̊͒̔̋͑̏̅̌͛̚͝F̴̦̤̝̖̗̦̗̠͈̝̀̌͗́̄͂̋̆̇͛͐́͒̈́̃J̵̨̧̝̭̳̬̣̣̬̩̬̬͙̺̈̀H̸̢̰̣̦̙͔͍̃̔̋͌̉̓̾̚Ą̶̨̳̂S̸͓̫͒̇̊͒̄̎͆D̴̰̻̊̂͐̐̎̏́̏̏͘̕F̶̧̣̘̦̪̮̰̫̯̞͓̀̓̀̆͐͂̈̕͜͠͝͠H̶̢̨̢͕̰̩̯͍̜̳͕̓́̍̈́͑͗̍̌̓̑̈́͐̕̚Ā̴̧̤̰͓̝̑̆̿̑͛̾̀̒͘J̸̗̈́́̈́Ŝ̴̢͕̖̰͚̗̥͑͊̓̈̌̇̆͒͑͗̂̇D̸̨̛͕̬̩̤̱͗͊̽̍͂̋͠F̴̡̥̌̃̃͆̑͝͝͝J̷̧̢̩̱̥̺̝̖̤̣̎̌͑̀͋̍̔͋̀̃̚A̸̲͗͆̋̌͆̓́̔̌̍̇̂͊̑͑͜H̶̛͕̑̂̐̚̚S̵̺͔͍̼̐̈́̈̆͐̄͑̋̈́̕͝͝Ḑ̶͎̜̌͒̅̈́̈̔̃̔̋F̶͚̼͋̈́̋̈́͜Ģ̷̨̯̫̭͉͇͔͎̙͆̐͆̓̐̀͑́͌̈̎̋̕A̶̧̢̹̟͈̔̾͑̏̈́͂̇̿̄̄̉͝J̸̡͕̜̼̠͔̝̹͈̦̏̊S̵͇͔̤̻̩͚̖͙̰͍̘͚̃͗̎̊̓̓̈́̈́̃̐̕͜ͅȞ̶̢̲̰̩̮͙̪͎̲̝̠͙̃͐̐̅̈́̓͑̚͝͝D̸̢̤̥̘͙͖͍̟͒͛͂̇͐̌͊̇̊͂͌͘̕͠F̷̡̩̞̯̝͕̝̩̝̦̫̜̻͖̒̅̑̓̎́̄͑̏̔͝ͅG̸̢͍̝̝͈͍͙̦̝͇̺̽͗̓͑̊́̈͊̆̂̽̂͘̚Ḁ̷͕̩̰͎̽̑͌͌̓͐̓̈̾̓̍̚̕K̶͚̳̖̭͙̬̖͌̈́̈́͆̋̎J̷̛̗̉̆̎͌͋̽͆̍̄̆̕͘͝͝S̶̨̱̪̖̘̥̺̙̦̖̙̠͓͌̊Ḩ̷̖̼̹̠̞̜̙͇̤̹̝͇̭́̓̚ͅD̵̡̻͇̰͚̦̰̐͂͋̅͑̾̕͝ͅF̷̢̨͍̳͇̘͍̠̠̜̓̆̿͆͛̀́͐͂̚͝ͅĢ̶͓͈̠̖̬̮̞̪̺͇̆͂̈̈́̕ͅA̶̢̙̟͇̗̭̭̹̥͔̹͇͚̻̎̀̀͜Ḱ̷͚̼͔̜͔͓͖̲̟̺͉̻͔̠̽̑̂̄͂͊̌̔̏͘̕͝͝S̷̟̗͚͓̮͕̺̝͍̬͇̩͗́̿͊̓͒̐̐͝J̸̡͈̩̤͇͚͎͔̹͔͋̑͝D̸̨̢̨̻̬̜̥̭͖̬̺̦̯̽̋́̀̊̈́̊̈́͑̌͗͐͛̕͜͜H̵̯̮̔͑̃͛̅̐̆̐͂̈͋̐̾̚G̵͙̝̗̼͚̳͇͓̣͆̂͜A̵̛̛̻̰͍̅̎͛́̄͗̓̾́Ş̶̛͙̠͈̱̬͚̳̪̹͕̤̭̔́̈̀̈́͗͗̑̈L̵̠̟̪͚͚̠͇̗̿̈́̉͂̃͂F̵͓͉̬̺̘͈̣̝͗̈͂͋̓̚͠K̴̟̋̐̃̏͆̊͛̓͆͠J̵̢̛̪̫̫̬̹͔̖͙͓̲̻͌̈́̾̎́̊̾̆̓̍́̍̕͜H̶̡̛̺̖̖͈̙̹̱͖̕͜Ȧ̵̡̯͕̭̳͍̩̙̩̰̫͕̀́̈́͂̊̎̈̑́͌̾͛ͅͅS̵̡̪̫̫̠̗͍̭͓̥̎̉͆̒̋́̓͜͝L̶̢̥̯̮̫̠̫̼̲̝͍̯̯̮̭̀̐͆͆͋̇̇̈́͗̊͠J̶̡̬̲̟̹͚̟̣̬̦͒́̂̔̌̿͘͝͠K̶̡̼̱̙̱̦̼̜͉͉͉̦̉̿̕͝͝ͅD̷̢̨͎̖̘̰͓̜̞͇͙̱̍́͋̍͑͜͠F̸̧̧̥̳̙͇͖͉̳̲̺͙̗͎̑̃͌̑̐͋ͅĜ̴̢͔̠̺͚̘̎̓̒̇̾͝H̶̡̲͚̥̘̹͓̻̳̥͎̦̾͋̔̋̋͑͊̈͛̚͘͜͝J̴̢̨̬̙͔̜̟͉̮̃̾̃̋̓̉̂̒͋̇Ș̷̡̛̹̪̪̤̖̜͙͓̾̇̌̇̆̈́͘͜D̴͙͔͚͓̪̮̰̞̭̎̈̏̾̌́͆̄̕̕͜͝ͅG̴̨̲͙̰͈̖̠̝̠̒̈́͂̑̎̈͑̓̕̚͝F̵̝͇̮̺̮̦͔̈̓͂̿̇̌̓̊̂̿̔͘̕͘Ą̵̨̨̨̛̣̯͕̼͓̯̗̠͇͍̉̔̈̿̈́̀̔̊̚̕͠J̸̨̟̺̭͓̠̄K̸̨̪͔̤͌͝S̸̢͙͕̖̻͑̄̊̄̇̉̍̃͗̀̾́̍͗͘D̴̨̡̟͍̰̜͚͇̙͙̣̹̜̈́̒̿̾̒͘͝F̸̘̥̖͐Ġ̴̱̙
4 |
5 | chhk chk chk chk ch chk chk chhkk chkchk chcchkchkchkc. hkccccchk cchk chkchc ckhc krkrkrhckchk chchkck hkkchrkchckr chkrkrchk ch chhhhhhhhhhhhhkrdk"
6 |
--------------------------------------------------------------------------------
/contributions/Dhruv Khatri/Beale_1.txt:
--------------------------------------------------------------------------------
1 | 71, 194, 38, 1701, 89, 76, 11, 83, 1629, 48, 94, 63, 132, 16, 111, 95, 84, 341, 975,14, 40, 64, 27, 81, 139, 213, 63, 90, 1120, 8, 15, 3, 126, 2018, 40, 74, 758, 485,604, 230, 436, 664, 582, 150, 251, 284, 308, 231, 124, 211, 486, 225, 401, 370,11, 101, 305, 139, 189, 17, 33, 88, 208, 193, 145, 1, 94, 73, 416, 918, 263, 28, 500,538, 356, 117, 136, 219, 27, 176, 130, 10, 460, 25, 485, 18, 436, 65, 84, 200, 283,118, 320, 138, 36, 416, 280, 15, 71, 224, 961, 44, 16, 401, 39, 88, 61, 304, 12, 21,24, 283, 134, 92, 63, 246, 486, 682, 7, 219, 184, 360, 780, 18, 64, 463, 474, 131,160, 79, 73, 440, 95, 18, 64, 581, 34, 69, 128, 367, 460, 17, 81, 12, 103, 820, 62,116, 97, 103, 862, 70, 60, 1317, 471, 540, 208, 121, 890, 346, 36, 150, 59, 568,614, 13, 120, 63, 219, 812, 2160, 1780, 99, 35, 18, 21, 136, 872, 15, 28, 170, 88, 4,30, 44, 112, 18, 147, 436, 195, 320, 37, 122, 113, 6, 140, 8, 120, 305, 42, 58, 461,44, 106, 301, 13, 408, 680, 93, 86, 116, 530, 82, 568, 9, 102, 38, 416, 89, 71, 216,728, 965, 818, 2, 38, 121, 195, 14, 326, 148, 234, 18, 55, 131, 234, 361, 824, 5,81, 623, 48, 961, 19, 26, 33, 10, 1101, 365, 92, 88, 181, 275, 346, 201, 206, 86,36, 219, 324, 829, 840, 64, 326, 19, 48, 122, 85, 216, 284, 919, 861, 326, 985,233, 64, 68, 232, 431, 960, 50, 29, 81, 216, 321, 603, 14, 612, 81, 360, 36, 51, 62,194, 78, 60, 200, 314, 676, 112, 4, 28, 18, 61, 136, 247, 819, 921, 1060, 464, 895,10, 6, 66, 119, 38, 41, 49, 602, 423, 962, 302, 294, 875, 78, 14, 23, 111, 109, 62,31, 501, 823, 216, 280, 34, 24, 150, 1000, 162, 286, 19, 21, 17, 340, 19, 242, 31,86, 234, 140, 607, 115, 33, 191, 67, 104, 86, 52, 88, 16, 80, 121, 67, 95, 122, 216,548, 96, 11, 201, 77, 364, 218, 65, 667, 890, 236, 154, 211, 10, 98, 34, 119, 56,216, 119, 71, 218, 1164, 1496, 1817, 51, 39, 210, 36, 3, 19, 540, 232, 22, 141, 617,84, 290, 80, 46, 207, 411, 150, 29, 38, 46, 172, 85, 194, 39, 261, 543, 897, 624, 18,212, 416, 127, 931, 19, 4, 63, 96, 12, 101, 418, 16, 140, 230, 460, 538, 19, 27, 88,612, 1431, 90, 716, 275, 74, 83, 11, 426, 89, 72, 84, 1300, 1706, 814, 221, 132,40, 102, 34, 868, 975, 1101, 84, 16, 79, 23, 16, 81, 122, 324, 403, 912, 227, 936,447, 55, 86, 34, 43, 212, 107, 96, 314, 264, 1065, 323, 428, 601, 203, 124, 95, 216,814, 2906, 654, 820, 2, 301, 112, 176, 213, 71, 87, 96, 202, 35, 10, 2, 41, 17, 84,221, 736, 820, 214, 11, 60, 760.
2 |
--------------------------------------------------------------------------------
/contributions/Shubham-Bhandari/restart-router.py:
--------------------------------------------------------------------------------
1 |
2 | from selenium import webdriver
3 | from selenium.webdriver.chrome.options import Options
4 | from selenium.common.exceptions import WebDriverException
5 |
6 | # function to update chrome driver
7 | def update_chrome_driver(n):
8 | import subprocess
9 | try:
10 | print('Need to update the Chromedriver')
11 | rc = subprocess.run('/home/sb/dev/Projects-Python/automate-boring-stuff/update-chrome-driver.sh')
12 | rc.check_returncode()
13 | print('Chrome driver updated successfully')
14 | main(n + 1)
15 | except subprocess.CalledProcessError:
16 | print('Error in updating Chrome driver, please do it manually')
17 | return
18 |
19 |
20 | def main(n):
21 | if n <= 1:
22 | try:
23 | opt = Options()
24 | opt.headless = True
25 | global browser
26 | browser = webdriver.Chrome(chrome_options=opt)
27 | print('Rebooting router')
28 | browser.get('http://192.168.1.254')
29 | browser.find_element_by_xpath(r'//*[(@id = "username")]').send_keys('') #Enter your user id here.
30 | browser.find_element_by_xpath(r'//*[(@id = "password")]').send_keys('') #enter your password here
31 | browser.find_element_by_xpath(
32 | '//td//td[(((count(preceding-sibling::*) + 1) = 1) and parent::*)]//input').click()
33 | browser.find_element_by_xpath('//*[contains(concat( " ", @class, " " ),'
34 | ' concat( " ", "x_main_menu", " " )) '
35 | 'and (((count(preceding-sibling::*) + 1) = 5) and parent::*)]//a').click()
36 | browser.find_element_by_xpath('/html/body/div/section/div[1]/div[1]/div[1]/ul[5]/li[5]').click()
37 | browser.switch_to.frame(browser.find_element_by_id('mainFrame'))
38 | browser.find_element_by_id('do_reboot').click()
39 | alert = browser.switch_to.alert
40 | alert.accept()
41 | import time
42 | time.sleep(2)
43 | browser.close()
44 | print('Successfully Rebooted')
45 | except WebDriverException:
46 | update_chrome_driver(n)
47 | else:
48 | print("Error in rebooting router")
49 |
50 |
51 | main(0)
52 |
--------------------------------------------------------------------------------
/webapp/src/BaseComponents/InfoAccordion.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {makeStyles} from '@material-ui/core/styles';
3 | import Accordion from '@material-ui/core/Accordion';
4 | import AccordionSummary from '@material-ui/core/AccordionSummary';
5 | import AccordionDetails from '@material-ui/core/AccordionDetails';
6 | import Typography from '@material-ui/core/Typography';
7 | import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
8 | import './InfoAccordion.css';
9 | import Pic from '../media/hack.png';
10 |
11 |
12 | const useStyles = makeStyles((theme) => ({
13 | heading: {
14 | fontSize: theme.typography.pxToRem(15),
15 | fontWeight: theme.typography.fontWeightRegular,
16 | color: 'white'
17 | },
18 | coloring: {
19 | backgroundColor: '#2980B9',
20 | },
21 | text: {
22 | color: 'white'
23 | }
24 | }));
25 |
26 | export default function InfoAccordion(props) {
27 | const classes = useStyles();
28 | const [expanded, setExpanded] = React.useState(false);
29 | // const image =[Pic,Git];
30 |
31 | const handleChange = (panel) => (event, isExpanded) => {
32 | console.log(panel);
33 | setExpanded(isExpanded ? panel : false);
34 | };
35 | return (
36 |
37 | }
39 | aria-controls={props.controls}
40 | id={props.id}
41 | >
42 | {props.heading}
43 |
44 |
45 | {props.isImage ?
: null}
46 |
47 |
48 | {props.content}
49 |
50 |
51 |
52 |
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/contributions/Megha khangarot/end & print.txt:
--------------------------------------------------------------------------------
1 | Print - itself carries the meaning of new line character and
2 | "end" in Python is behaving like a variable to display any value - Hi/space,
3 | otherwise end behaves like new line, we need to stick it to same line until all stars are printed
4 |
5 | Python's print() function comes with a parameter called 'end'. By default,
6 | the value of this parameter is '\n', i.e. the new line character.
7 |
8 | The end key of print function will set the string that needs
9 | to be appended when printing is done.
10 |
11 | By default the end key is set by newline character.
12 | So after finishing printing all the variables,
13 | a newline character is appended.
14 | Hence, we get the output of each print statement in different line.
15 | But we will now overwrite the newline character by a hyphen(-)
16 | at the end of the print statement. See the following example.
17 |
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19 |
20 | # initialize a list
21 | initList = ['camel', 'case', 'stop']
22 |
23 | # print each words using loop
24 | print('Printing using default print function')
25 | for item in initList:
26 | print(item) # default print function. newline is appended after each item.
27 |
28 | print() # another newline
29 |
30 | # print each words using modified print function
31 | print('Printing using modified print function')
32 | for item in initList:
33 | print(item, end='-')
34 |
35 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36 | Output
37 |
38 | Printing using default print function
39 | camel
40 | case
41 | stop
42 |
43 | Printing using modified print function
44 | camel-case-stop-
45 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46 |
47 | Another example
48 |
49 | for i in range(0, 5):
50 | for j in range(0, i+1):
51 | print("*",end="")
52 | print()
53 |
54 | *
55 | **
56 | ***
57 | ****
58 | *****
59 |
60 |
61 | for i in range(0, 5):
62 | for j in range(0, i+1):
63 | print("* ",end="")
64 | print()
65 |
66 | *
67 | * *
68 | * * *
69 | * * * *
70 | * * * * *
71 |
72 | for i in range(0, 5):
73 | for j in range(0, i+1):
74 | print("* ",end="Hi")
75 | print()
76 |
77 | * Hi
78 | * Hi* Hi
79 | * Hi* Hi* Hi
80 | * Hi* Hi* Hi* Hi
81 | * Hi* Hi* Hi* Hi* Hi
--------------------------------------------------------------------------------
/webapp/src/util/FormValidation.js:
--------------------------------------------------------------------------------
1 | import {AddUser} from './FormDb';
2 | import {Octokit} from '@octokit/core'
3 |
4 |
5 | import pat from '../settings';
6 |
7 |
8 | async function validateGithubId(id) {
9 | const kit = new Octokit({auth: pat.pat, userAgent: 'network-jklu-webapp'});
10 | return await kit.request('GET /users/' + id, {});
11 | }
12 |
13 | function getRequiredFields(result) {
14 |
15 | return {
16 | 'gitId': result.data.login,
17 | 'avatar': result.data.avatar_url,
18 | 'pubRepo': result.data.public_repos
19 | }
20 | }
21 |
22 | export default function FormValidation(gitId, clg, frndOne, frndTwo, frndThree, frndFour, loc, name) {
23 | let friends = [];
24 | let unqFriends = new Set();
25 | unqFriends.add(frndOne);
26 | unqFriends.add(frndTwo);
27 | unqFriends.add(frndThree);
28 | unqFriends.add(frndFour);
29 | unqFriends.delete('');
30 | unqFriends = Array.from(unqFriends);
31 | let mainUser = {};
32 | return validateGithubId(gitId).then(res => {
33 | mainUser = getRequiredFields(res);
34 | if (unqFriends.includes(gitId) || unqFriends.length < 2) {
35 | return false
36 | }
37 | return validateGithubId(unqFriends[0]);
38 | }).then(res => {
39 | if (res) {
40 | friends.push(getRequiredFields(res));
41 | return validateGithubId(unqFriends[1]);
42 | }
43 | return false
44 | }).then(res => {
45 | if (res) {
46 | friends.push(getRequiredFields(res));
47 | if (unqFriends.length >= 3) {
48 | return validateGithubId(unqFriends[2]);
49 | } else {
50 | return true
51 | }
52 | }
53 | return false
54 | }).then(res => {
55 | if (res === false) {
56 | return false
57 | }
58 | if (res !== true) {
59 | friends.push(getRequiredFields(res));
60 | if (unqFriends.length === 4) {
61 | return validateGithubId(unqFriends[3])
62 | }
63 | }
64 | return true
65 | }).then(res => {
66 |
67 | if (res === false) {
68 | return false
69 | }
70 | if (res !== true) {
71 | friends.push(getRequiredFields(res));
72 | }
73 | return AddUser(mainUser, clg, friends, loc, name);
74 | })
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/contributions/Saumya-Patel/Snowball_Numbers.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | # In[ ]:
5 |
6 |
7 | def letter_distribution(sentence):
8 | all_freq = {}
9 | for i in sentence: #loop through characters of sentence
10 | if i.isalpha():
11 | if i in all_freq: # characters is not a key in all_freq
12 | all_freq[i] += 1
13 | else:
14 | all_freq[i] = 1
15 | return (all_freq)
16 |
17 |
18 | # In[ ]:
19 |
20 |
21 | def snowball(sentence):
22 | freq = letter_distribution(sentence)
23 | frequency = []
24 | for v in freq.values():
25 | frequency.append(v) # making a list of values of freq
26 | freq_1 = []
27 | for i in frequency:
28 | if(i not in freq_1):
29 | freq_1.append(i) # making a unique list of all elements in frequency
30 | if(len(freq_1) < len(frequency)): # elemnts in frequency were duplicate
31 | return False
32 | else:
33 | return True
34 |
35 |
36 | # In[ ]:
37 |
38 |
39 | def pyramid(sentence):
40 | freq = letter_distribution(sentence)
41 | frequency = []
42 | for v in freq.values():
43 | frequency.append(v) # making a list of values of freq
44 | freq_1 = []
45 | for i in range(len(frequency)):
46 | count =0
47 | for j in range(i+1,len(frequency)):
48 | if(frequency[i]==frequency[j]): # if the element occurs again in list
49 | count+=1
50 | freq_1.append(count)
51 | flag=0
52 | for i in freq_1:
53 | if(i==1): # if 1 occurs in freq_1
54 | flag =1
55 | if(flag==1):
56 | return True
57 | else:
58 | return False
59 |
60 |
61 | # In[ ]:
62 |
63 |
64 | def pi(sentence):
65 | from mpmath import mp
66 | freq = letter_distribution(sentence)
67 | frequency = []
68 | for v in freq.values():
69 | frequency.append(str(v)) # making a list of values of freq
70 | string = ""
71 | for i in frequency:
72 | string += i
73 | sort_string = sorted(string) #sorting string elements
74 | mp.dps = len(frequency)
75 | pi_num = mp.pi #to get value of pi till 50 decimal places
76 | pi_num = str(pi_num)
77 | PI_n = ""
78 | for i in pi_num:
79 | if(i == "."):
80 | pass
81 | else:
82 | PI_n += i
83 | sort_pi = sorted(PI_n)
84 | if(sort_string == sort_pi):
85 | return True
86 | else:
87 | return False
88 |
89 |
--------------------------------------------------------------------------------
/contributions/Shruti Solani/Stack in C.c:
--------------------------------------------------------------------------------
1 | //Implementing Stacks using array
2 | //using a menu-driven program
3 | #include
4 | #define MAX 10 //defining size of stack
5 |
6 | int stack[MAX] , top = -1;
7 | void push(int st[], int value); //push value into stack
8 | int pop(int st[]); //pop element from stack
9 | int peek(int st[]); //returns top element in stack
10 | void display(int st[]); //displays stack
11 |
12 | int main()
13 | {
14 | int value,choice,popped,peeked;
15 | do
16 | {
17 | printf("\n1) Push");
18 | printf("\n2) Pop");
19 | printf("\n3) Peek");
20 | printf("\n4) Display");
21 | printf("\n5) Exit");
22 | printf("\nEnter your choice : ");
23 | scanf("%d",&choice);
24 | switch(choice)
25 | {
26 | case 1:
27 | printf("\nEnter value to push : ");
28 | scanf("%d",&value);
29 | push(stack,value);
30 | break;
31 | case 2:
32 | popped = pop(stack);
33 | if(popped != -1)
34 | printf("%d is popped",popped);
35 | break;
36 | case 3:
37 | peeked = peek(stack);
38 | if(peeked != -1)
39 | printf("%d is at the top of stack",peeked);
40 | break;
41 | case 4:
42 | display(stack);
43 | break;
44 | }
45 | }while(choice != 5);
46 | return 0;
47 | }
48 |
49 | void push(int st[],int value)
50 | {
51 | if(top == MAX - 1)
52 | {
53 | printf("\nStack is full");
54 | }
55 | else
56 | {
57 | top++;
58 | st[top] = value;
59 | }
60 | }
61 |
62 | int pop(int st[])
63 | {
64 | int popped;
65 | if(top == -1)
66 | {
67 | printf("\nStack is empty.");
68 | }
69 | else
70 | {
71 | popped = st[top];
72 | top--;
73 | return popped;
74 | }
75 | }
76 |
77 | int peek(int st[])
78 | {
79 | if(top == -1)
80 | {
81 | printf("\nStack is Empty");
82 | }
83 | else
84 | {
85 | int peeked = st[top];
86 | return peeked;
87 | }
88 | }
89 |
90 | void display(int st[])
91 | {
92 | int i;
93 | if(top == -1)
94 | {
95 | printf("\nStack is Empty.");
96 | }
97 | else
98 | {
99 | for(i = top; i>=0; i--)
100 | {
101 | printf("\n%d",st[i]);
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/webapp/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/contributions/activity-logger:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import pickle
3 | import os.path
4 | from googleapiclient.discovery import build
5 | from google_auth_oauthlib.flow import InstalledAppFlow
6 | from google.auth.transport.requests import Request
7 | import datetime
8 | import argparse
9 |
10 | parser = argparse.ArgumentParser()
11 | parser.add_argument('act', help='Name of the activity')
12 | parser.add_argument('-d', '--desc', help='Description of the activity')
13 | args = parser.parse_args()
14 | # If modifying these scopes, delete the file token.pickle.
15 | SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
16 | base = '' # file directory location
17 |
18 |
19 | def main(act='-', desc='-'):
20 | creds = None
21 | # The file token.pickle stores the user's access and refresh tokens, and is
22 | # created automatically when the authorization flow completes for the first
23 | # time.
24 | if os.path.exists(base + 'token.pickle'):
25 | with open(base + 'token.pickle', 'rb') as token:
26 | creds = pickle.load(token)
27 | # If there are no (valid) credentials available, let the user log in.
28 | if not creds or not creds.valid:
29 | if creds and creds.expired and creds.refresh_token:
30 | creds.refresh(Request())
31 | else:
32 | flow = InstalledAppFlow.from_client_secrets_file(
33 | base + 'client_secret.json', SCOPES)
34 | creds = flow.run_local_server(port=0)
35 | # Save the credentials for the next run
36 | with open(base + 'token.pickle', 'wb') as token:
37 | pickle.dump(creds, token)
38 |
39 | service = build('sheets', 'v4', credentials=creds)
40 |
41 | spreadsheet_id = '' #Id for the spreadsheet
42 | range_name = 'Sheet1'
43 | value_input_option = 'RAW'
44 | date = datetime.date.today()
45 | time = datetime.datetime.now()
46 | print('{0}: {1}/{2}/{3}::{4}:{5}:{6}'.format(act, date.day, date.month, date.year, time.hour, time.minute,
47 | time.second))
48 | values = {'values': [[act, desc, date.day, date.month, date.year, time.hour, time.minute, time.second]]}
49 | # Call the Sheets API
50 | sheet = service.spreadsheets()
51 | result = sheet.values().append(
52 | spreadsheetId=spreadsheet_id, range=range_name,
53 | valueInputOption=value_input_option, insertDataOption='INSERT_ROWS',
54 | body=values
55 | ).execute()
56 | print('{0} cells updated.'.format(result['updates'].get('updatedCells')))
57 |
58 |
59 | if __name__ == '__main__':
60 | main(args.act, args.desc)
61 |
--------------------------------------------------------------------------------
/contributions/Vanshika Sharma/queue.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | public class queue
3 | {
4 | public static void main(String args[])
5 | {
6 | Scanner sc = new Scanner(System.in);
7 | System.out.print("Size of queue: ");
8 | int size = sc.nextInt(), choice=0;
9 | queue_methods ob = new queue_methods(size);
10 | System.out.println("Menu:\n1. Push \n2. Pop \n3. Peep \n4. Exit");
11 | System.out.print("\nEnter your choice (number): ");
12 | choice = sc.nextInt();
13 | while(choice != 4)
14 | {
15 | switch(choice)
16 | {
17 | case 1: System.out.print("Enter value: ");
18 | int n= sc.nextInt();
19 | ob.push(n);
20 | ob.display();
21 | break;
22 | case 2: ob.pop();
23 | ob.display();
24 | break;
25 | case 3: ob.peep();
26 | break;
27 | default: System.out.println("Wrong choice");
28 | break;
29 | }
30 | System.out.print("\nEnter your choice (number): ");
31 | choice = sc.nextInt();
32 | }
33 | }
34 | }
35 |
36 | class queue_methods
37 | {
38 | int arr[], front, rear, size;
39 | public queue_methods(int s)
40 | {
41 | size =s;
42 | arr = new int[size];
43 | front = -1;
44 | rear=-1;
45 | }
46 | public void push(int n)
47 | {
48 | if(rear == size-1)
49 | System.out.println("**Queue is Overflowing**");
50 | else
51 | {
52 | rear++;
53 | arr[rear] = n;
54 | System.out.println("--Item is pushed--");
55 | }
56 | if(rear == 0) //condition of first element getting pushed
57 | front = 0;
58 | }
59 | public void pop()
60 | {
61 | if(front == -1)
62 | System.out.println("**Underflow**");
63 | else if (front == rear)
64 | {
65 | front = rear = -1;
66 | System.out.println("---Item Popped---");
67 | }
68 | else
69 | {
70 | System.out.println("---Item Popped---");
71 | front++;
72 | }
73 | }
74 | public void peep()
75 | {
76 | if(rear==-1)
77 | System.out.println("---Queue is Empty---");
78 | else
79 | System.out.println("-- Queue has following value on rear: --\n "+arr[rear]);
80 | }
81 | public void display()
82 | {
83 | if(rear == -1)
84 | System.out.println("---Queue is Empty---");
85 | else
86 | {
87 | System.out.println("Your Queue contains: ");
88 | for(int x=rear; x>=front; x--)
89 | System.out.println(arr[x]);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/contributions/Ritika-Roongta/ANN.txt:
--------------------------------------------------------------------------------
1 | For creating an Artificial Neural Network (ANN), I have used the Pima-Indian-Diabetes data set which was freeley available on Kaggle.
2 | The result obtained will show a prediction of whether a person has diabetes or not.
3 | If the predicted values comes out to be '1', it means the person has diabetes and if it comes out to be '0', he/she does not has diabetes.
4 | Firsty I imported fifferent libraries like pandas, sklearn's model selection & the dataset and then the dataset was converted into an array.
5 | Then data was split into independent set 'X' and dependent set 'y'. Then, the dataset values were processed so that they contain values between 0 and 1.
6 | Then data was again splitted into training and testing data.
7 | Then processing for ANN was done. Here data was divided into three layers using "Sequential model" and "reLu, sigmoid" activations. After the above data is compiled, 'binary_crossentropy' loss function was done to measure how well training was done and then Stochastic Gradient Descent ‘sgd’ optimizer was used to improve upon the loss. Accuracy on each step was also calculated using 'accuracy' metrics. The model was trained by using the fit method on the training data, and in batch sizes of 57, with 1000 epochs. To see how well the model is performing, validation data was given to the model by splitting the training data into 20% validation. Then model performance was visualized using graphs. Lastly, predictrion was done using X_test data set. A threshold was created where values .5 and above classify the target data as (1) and values less then that as (0). Then, the model was evaluated on training and testing data set and corresponding accuracy was calculated.
8 |
9 |
10 |
11 |
12 | data1 = json.load(inputFile1)
13 | inputFile1.close()
14 | data2 = json.load(inputFile2)
15 | inputFile2.close()
16 | data3 = json.load(inputFile3)
17 | inputFile3.close()
18 | data4 = json.load(inputFile4)
19 | inputFile4.close()
20 | data5 = json.load(inputFile5)
21 | inputFile5.close()
22 | output1 = csv.writer(outputFile1)
23 | output2 = csv.writer(outputFile2)
24 | output3 = csv.writer(outputFile3)
25 | output4 = csv.writer(outputFile4)
26 | output5 = csv.writer(outputFile5)
27 |
28 |
29 |
30 |
31 | inputFile4 = pd.read_json("/content/yelp_academic_dataset_tip.json", lines=True)
32 | inputFile5 = pd.read_json("/content/yelp_academic_dataset_user.json", lines=True)
33 |
34 |
35 |
36 | outputFile4 = inputFile4.to_csv("/content/tip.csv")
37 | outputFile5 = inputFile5.to_csv("/content/user.csv")
38 |
39 |
40 | inputFile3 = pd.read_json("/content/yelp_academic_dataset_review.json", lines=True)
41 | outputFile3 = inputFile3.to_csv("/content/review.csv")
42 |
43 |
44 |
45 | LOAD CSV FROM "file:////content/checkin.csv"
46 | LOAD CSV FROM "file:////content/tip.csv"
47 |
--------------------------------------------------------------------------------
/contributions/SwatiTripathi/Pattern_In_C.c:
--------------------------------------------------------------------------------
1 | #include
2 | void fullpyramidofStars(int rows){
3 | int i, blank, k = 0;
4 | for (i = 1; i <= rows; ++i, k = 0) {
5 | for (blank = 1; blank <= rows - i; ++blank) {
6 | printf(" ");
7 | }
8 | while (k != 2 * i - 1) {
9 | printf("* ");
10 | ++k;
11 | }
12 | printf("\n");
13 | }
14 | }
15 | void FullPyramidOfNumbers(int rows)
16 | {
17 | int i, space, k = 0, count = 0, count1 = 0;
18 | for (i = 1; i <= rows; ++i) {
19 | for (space = 1; space <= rows - i; ++space) {
20 | printf(" ");
21 | ++count;
22 | }
23 | while (k != 2 * i - 1) {
24 | if (count <= rows - 1) {
25 | printf("%d ", i + k);
26 | ++count;
27 | } else {
28 | ++count1;
29 | printf("%d ", (i + k - 2 * count1));
30 | }
31 | ++k;
32 | }
33 | count1 = count = k = 0;
34 | printf("\n");
35 | }
36 | }
37 | void InvertedPyramidofStars(int rows)
38 | {
39 | int i, j, space;
40 | for (i = rows; i >= 1; --i) {
41 | for (space = 0; space < rows - i; ++space)
42 | printf(" ");
43 | for (j = i; j <= 2 * i - 1; ++j)
44 | printf("* ");
45 | for (j = 0; j < i - 1; ++j)
46 | printf("* ");
47 | printf("\n");
48 | }
49 | }
50 | void HalfPyramidofStars(int rows)
51 | {
52 | int i, j;
53 | for (i = 1; i <= rows; ++i) {
54 | for (j = 1; j <= i; ++j) {
55 | printf("* ");
56 | }
57 | printf("\n");
58 | }
59 | }
60 | int main() {
61 | int rows,choice =0;
62 | printf("Enter the number of rows: ");
63 | scanf("%d", &rows);
64 | printf("List of Patterns this program can print ");
65 | printf("\n1)Full Pyramid of stars \n2)Full Pyramid of Numbers");
66 | printf("\n3)Inverted Pyramid of stars \n4)Half Pyramid of Stars\n");
67 | printf("5)Quit program ");
68 | printf("\nEnter your choice no(1-5) from list below:\n");
69 | scanf("%d", &choice);
70 | switch(choice)
71 | {
72 | case 1: fullpyramidofStars(rows);break;
73 | case 2: FullPyramidOfNumbers(rows);break;
74 | case 3: InvertedPyramidofStars(rows);break;
75 | case 4: HalfPyramidofStars(rows);break;
76 | case 5: printf("Quiting\n");return 0;
77 | default: printf("wrong choice"); break;
78 | }
79 | return 0;
80 | }
81 | /* Output looks like below:
82 | Enter the number of rows: 5
83 | List of Patterns this program can print
84 | 1)Full Pyramid of stars
85 | 2)Full Pyramid of Numbers
86 | 3)Inverted Pyramid of stars
87 | 4)Half Pyramid of Stars
88 | 5)Quit program
89 | Enter your choice no(1-5) from list below:
90 | 1
91 | *
92 | * * *
93 | * * * * *
94 | * * * * * * *
95 | * * * * * * * * *
96 |
97 |
98 | */
--------------------------------------------------------------------------------
/contributions/Adarsh_Sengar/heap.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | # This heap class start from here.
4 | class Heap:
5 | def __init__(self): # Default constructor of heap class.
6 | self.h = []
7 | self.currsize = 0
8 |
9 | def leftChild(self, i):
10 | if 2 * i + 1 < self.currsize:
11 | return 2 * i + 1
12 | return None
13 |
14 | def rightChild(self, i):
15 | if 2 * i + 2 < self.currsize:
16 | return 2 * i + 2
17 | return None
18 |
19 | def maxHeapify(self, node):
20 | if node < self.currsize:
21 | m = node
22 | lc = self.leftChild(node)
23 | rc = self.rightChild(node)
24 | if lc is not None and self.h[lc] > self.h[m]:
25 | m = lc
26 | if rc is not None and self.h[rc] > self.h[m]:
27 | m = rc
28 | if m != node:
29 | temp = self.h[node]
30 | self.h[node] = self.h[m]
31 | self.h[m] = temp
32 | self.maxHeapify(m)
33 |
34 | def buildHeap(
35 | self, a
36 | ): # This function is used to build the heap from the data container 'a'.
37 | self.currsize = len(a)
38 | self.h = list(a)
39 | for i in range(self.currsize // 2, -1, -1):
40 | self.maxHeapify(i)
41 |
42 | def getMax(self): # This function is used to get maximum value from the heap.
43 | if self.currsize >= 1:
44 | me = self.h[0]
45 | temp = self.h[0]
46 | self.h[0] = self.h[self.currsize - 1]
47 | self.h[self.currsize - 1] = temp
48 | self.currsize -= 1
49 | self.maxHeapify(0)
50 | return me
51 | return None
52 |
53 | def heapSort(self): # This function is used to sort the heap.
54 | size = self.currsize
55 | while self.currsize - 1 >= 0:
56 | temp = self.h[0]
57 | self.h[0] = self.h[self.currsize - 1]
58 | self.h[self.currsize - 1] = temp
59 | self.currsize -= 1
60 | self.maxHeapify(0)
61 | self.currsize = size
62 |
63 | def insert(self, data): # This function is used to insert data in the heap.
64 | self.h.append(data)
65 | curr = self.currsize
66 | self.currsize += 1
67 | while self.h[curr] > self.h[curr / 2]:
68 | temp = self.h[curr / 2]
69 | self.h[curr / 2] = self.h[curr]
70 | self.h[curr] = temp
71 | curr = curr / 2
72 |
73 | def display(self): # This function is used to print the heap.
74 | print(self.h)
75 |
76 |
77 | def main():
78 | l = list(map(int, input().split()))
79 | h = Heap()
80 | h.buildHeap(l)
81 | h.heapSort()
82 | h.display()
83 |
84 |
85 | if __name__ == "__main__":
86 | main()
87 |
--------------------------------------------------------------------------------
/contributions/namanagarwal/Array_Implementation.py:
--------------------------------------------------------------------------------
1 | #Stacks can be implemented with th ehelp of arrays as well.
2 | #We can insert and delete elements only at the end of the array(the top of the stack)
3 | #Python comes built-in with lists which are basically arrays.
4 | #They contain functionalities like append and pop which correspond to the push and pop methods of stacks respectively
5 | #So implementing stacks using arrays is pretty simple in Python
6 | #The time complexities of different operations are same as that for the inked list implementation of stacks
7 |
8 |
9 | #We define a class Stack with the array which will store the elements and the methods we require for a stack
10 | class Stack():
11 |
12 | #The constructor consists of only an empty array as length comes built-in with arrays(lists)
13 | def __init__(self):
14 | self.array = []
15 |
16 | #In the peek method we access the last element of the array(top element of the stack) by using the built-in length functionality of arrays
17 | def peek(self):
18 | return self.array[len(self.array)-1]
19 |
20 | #For push operation, we use the built-in append method of lists, which appends/pushes/inserts an element at the end of the list(top of the stack)
21 | def push(self, data):
22 | self.array.append(data)
23 | return
24 |
25 | #For pop operation, we use thebuilt-in pop method of lists, which removes the last element of the list(top element of the stack)
26 | #Time complexity of pop operation for the last element of the list is O(1).
27 | def pop(self):
28 | if len(self.array)!= 0:
29 | self.array.pop()
30 | return
31 | else:
32 | print("Stack Empty")
33 | return
34 |
35 | #Stack follows LIFO, so for the print operation, we have to print the last element of the list first.
36 | #This will require a loop traversing the entire array, so the complexity is O(n)
37 | def print_stack(self):
38 | for i in range(len(self.array)-1, -1, -1):
39 | print(self.array[i])
40 | return
41 |
42 |
43 |
44 | my_stack = Stack()
45 | my_stack.push("Andrei's")
46 | my_stack.push("Courses")
47 | my_stack.push("Are")
48 | my_stack.push("Awesome")
49 | my_stack.print_stack()
50 | #Awesome
51 | #Are
52 | #Courses
53 | #Andrei's
54 |
55 | my_stack.pop()
56 | my_stack.pop()
57 | my_stack.print_stack()
58 | #Courses
59 | #Andrei's
60 |
61 | print(my_stack.peek())
62 | #Courses
63 |
64 | print(my_stack.__dict__)
65 | #{'array': ["Andrei's", 'Courses']}
66 |
67 |
68 | '''Stacks can be implemented in Python in two more ways.
69 | 1. Using the 'deque' class from 'collections' module. Same methods used in lists, append and pop are used in deques
70 | 2. Using 'LifoQueue' from the 'queue' module . 'put()' and 'get()' methods are used for pushing and popping. It comes with some other useful metjods async well.
71 | '''
--------------------------------------------------------------------------------