Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ambujraj authored Oct 2, 2018
2 parents 6832764 + 39b3f78 commit ef2c6b5
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Name: Jillian Keenan
Place: Belfast, N.Ireland
About: I'm a final year computing science student.
Programming Languages: Java, C#, Javascript
Email: [email protected]


Name: [Aditya Agarwal](https://github.com/aditya81070)<br/>
Place: Jaipur, Rajasthan<br/>
About: I am 3rd year computer science student at Jecrc foundation, Jaipur. I am a front end developer.<br/>
Expand Down Expand Up @@ -31,6 +38,16 @@ Programming Language: Cpp, C, R, PHP, HTML, CSS <br/>
Email: [email protected]


Name: [Mohit Uniyal](https://github.com/mohit2016)
About: I am currently pursuing BSc (H) Computer Science from Delhi University, and i'm in final year. I have some experience in frontend development, and android app development. I have knowledge of MEAN stack. Also, I'm in the field of Machine Learning these days.
Programming Language: C++, JavaScript, Java, Python<br/>
Email: [email protected]

Name:[Michael Loftus](https://github.com/destoer/)
About: currently a student studying cs and maths
Programming Language: C, C++, Rust
Email: [email protected]

Name: [Bernard Joseph Jean Bruno](https://github.com/theArtechnology)
About: Computer Science student as an undergraduate at Université des Mascareignes, Mauritius.
Programming Language: C, C++, Javascript, Python <br/>
Expand Down Expand Up @@ -64,7 +81,9 @@ About: I am currently a NUS undergraduate Year 2 Computer Science Student. My fi
Programming Language: Java, C, HTML, CSS, Kotlin
Email: [email protected]


Name: [John Braun](https://github.com/jhnbrn90)
About: I am doing a PhD in organic chemistry and really like programming. Used Laravel to create some useful tools for our research group, amongst others a chemicals inventory, booking system and supporting information manager.
Programming Language: PHP, JavaScript
Email: [email protected]

5 changes: 5 additions & 0 deletions fibonacci/fibonacci.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fibonacci :: Int -> Int

fibonacci 1 = 1
fibonacci 2 = 1
fibonacci x = fibonacci (x-1) + fibonacci (x-2)
5 changes: 5 additions & 0 deletions hello-world/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print("Hello, World!")


main()
22 changes: 22 additions & 0 deletions palindrome/palindrome.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
if (argc < 2)
return 1;

int len = strlen(argv[1]), i, palindrome = 1;
for (i = 0; i < (len + (len % 2) / 2); i++) {
if (argv[1][i] != argv[1][(len - 1) - i]) {
palindrome = 0;
break;
}
}

printf("%s is ", argv[1]);
if (!palindrome)
printf("not ");
printf("a palindrome.\n");

return 0;
}
2 changes: 2 additions & 0 deletions palindrome/palindrome.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
isPalindrom :: String -> Bool
isPalindrom x = x == (reverse x)
7 changes: 7 additions & 0 deletions perfect-square/perfect-square.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
perfectSquare :: [Int]
perfectSquare = [x*x | x <- [1..]]

listNPerfectSquare :: Int -> [Int]
listNPerfectSquare n = take n perfectSquare


33 changes: 33 additions & 0 deletions phone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int stringdigit(string str)
{
for(int i = 0; i < str.length(); i++)
{
if(isdigit(str[i]) == 0)
{
return 1;
}
}
return 0;
}


int main(void)
{
cout << "Please enter a phone number: ";
string number;
cin >> number;

if(number.length() != 10 || stringdigit(number) == 1)
{
cout << "Not a valid phone number" << endl;
return 1;
}


cout << "is a valid phone number" << endl;
}
75 changes: 75 additions & 0 deletions sorting/HeapSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

// Java program for implementation of Heap Sort
public class HeapSort
{
public void sort(int arr[])
{
int n = arr.length;

// Build heap (rearrange array)
for (int i = n / 2 - 1; i >= 0; i--)
heapify(arr, n, i);

// One by one extract an element from heap
for (int i=n-1; i>=0; i--)
{
// Move current root to end
int temp = arr[0];
arr[0] = arr[i];
arr[i] = temp;

// call max heapify on the reduced heap
heapify(arr, i, 0);
}
}

// To heapify a subtree rooted with node i which is
// an index in arr[]. n is size of heap
void heapify(int arr[], int n, int i)
{
int largest = i; // Initialize largest as root
int l = 2*i + 1; // left = 2*i + 1
int r = 2*i + 2; // right = 2*i + 2

// If left child is larger than root
if (l < n && arr[l] > arr[largest])
largest = l;

// If right child is larger than largest so far
if (r < n && arr[r] > arr[largest])
largest = r;

// If largest is not root
if (largest != i)
{
int swap = arr[i];
arr[i] = arr[largest];
arr[largest] = swap;

// Recursively heapify the affected sub-tree
heapify(arr, n, largest);
}
}

/* A utility function to print array of size n */
static void printArray(int arr[])
{
int n = arr.length;
for (int i=0; i<n; ++i)
System.out.print(arr[i]+" ");
System.out.println();
}

// Driver program
public static void main(String args[])
{
int arr[] = {12, 11, 13, 5, 6, 7};
int n = arr.length;

HeapSort ob = new HeapSort();
ob.sort(arr);

System.out.println("Sorted array is");
printArray(arr);
}
}
29 changes: 29 additions & 0 deletions telephoneValidator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*JAVA program to find if a number is in a valid Indian mobile number format*/

import java.util.*;
import java.lang.String;
public class telephoneValidator{

//Main Driver method
public static void main(String []args){
//num can be replaced with any mobile number
String num = "5845218987";
if(validateNumber(num)){
System.out.println("Valid mobile number");
}else{
System.out.println("Invalid mobile number");
}
}

//checks if it is a valid Indian mobile number format
private static boolean validateNumber(String num){
if(num.length()==11){
char start = num.charAt(0);
if(start!='9'||start!='8'||start!='7'||start!='6'){ //Indian mobile number generally starts with 9,8,7 or 6
return true;
}
}
return false;

}
}
28 changes: 28 additions & 0 deletions telephone_number_validator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<bits/stdc++.h>

using namespace std;
int main()
{
string number;
cout<<"Enter Mobile Number: ";
cin>>number;

bool flag = 0;
int i = 0;
while(number[i])
{
if(number[i] < 48 || number[i] > 57) //check if all the characters are numeric if not we set flag = 1
{
flag = 1;
break;
}
i++;
}

if(!flag && number.length() == 10) //check if flag is not set and length is 10.
cout<<"Phone Number Valid";
else
cout<<"Phone Number NOT Valid";

return 0;
}

0 comments on commit ef2c6b5

Please sign in to comment.