diff --git a/Task1/img/AmitDutta.jpeg b/Task1/img/AmitDutta.jpeg new file mode 100644 index 00000000..4f4afad3 Binary files /dev/null and b/Task1/img/AmitDutta.jpeg differ diff --git a/Task1/img/Dharmick.jpg b/Task1/img/Dharmick.jpg new file mode 100644 index 00000000..c9997647 Binary files /dev/null and b/Task1/img/Dharmick.jpg differ diff --git a/Task1/img/IMG_20190209_000932.jpg b/Task1/img/IMG_20190209_000932.jpg new file mode 100644 index 00000000..998cd4d9 Binary files /dev/null and b/Task1/img/IMG_20190209_000932.jpg differ diff --git a/Task1/img/marciokuroki.jpg b/Task1/img/marciokuroki.jpg new file mode 100644 index 00000000..2823dcde Binary files /dev/null and b/Task1/img/marciokuroki.jpg differ diff --git a/Task1/img/rahulharlalka.jpeg b/Task1/img/rahulharlalka.jpeg new file mode 100644 index 00000000..79ec56a5 Binary files /dev/null and b/Task1/img/rahulharlalka.jpeg differ diff --git a/Task1/img/risheekjain.JPG b/Task1/img/risheekjain.JPG new file mode 100644 index 00000000..0bb30cf5 Binary files /dev/null and b/Task1/img/risheekjain.JPG differ diff --git a/Task1/img/satyam.jpg b/Task1/img/satyam.jpg new file mode 100644 index 00000000..314a658a Binary files /dev/null and b/Task1/img/satyam.jpg differ diff --git a/Task1/img/scheleon.jpg b/Task1/img/scheleon.jpg new file mode 100644 index 00000000..e038d0f1 Binary files /dev/null and b/Task1/img/scheleon.jpg differ diff --git a/Task1/img/shubhayans.jpeg b/Task1/img/shubhayans.jpeg new file mode 100644 index 00000000..7d3feebb Binary files /dev/null and b/Task1/img/shubhayans.jpeg differ diff --git a/Task1/img/soumyaukil.png b/Task1/img/soumyaukil.png new file mode 100644 index 00000000..4405fe85 Binary files /dev/null and b/Task1/img/soumyaukil.png differ diff --git a/Task1/img/sudeepta.jpeg b/Task1/img/sudeepta.jpeg new file mode 100644 index 00000000..642c38bd Binary files /dev/null and b/Task1/img/sudeepta.jpeg differ diff --git a/Task1/index.html b/Task1/index.html index 3850f558..fc89b44e 100644 --- a/Task1/index.html +++ b/Task1/index.html @@ -5,8 +5,15 @@ - + + + + + + + Hacktoberfest'19 | BIT MESRA + @@ -18,21 +25,20 @@ Hacktoberfest'19 | BIT MESRA + - -
-
-

HACKTOBERFEST 2019 | BIT MESRA

-

The Open-Source Community Welcomes You!

-
-
- +
+
+

HACKTOBERFEST 2019 | BIT MESRA

+

The Open-Source Community Welcomes You!

+
+
- +
@@ -48,82 +54,86 @@
(Collaborator)
class="fa fa-linkedin-square fa-3x">
- - -
- -
-
Aman Agarwal
-
(Collaborator)
-
- - -
-
-
+
-
-
Vishal Gorai
-
(Collaborator)
-
- - -
-
-
- +
+
Vishal Gorai
+
(Collaborator)
+
+ + +
+
+ -
+
+
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Nandom Alfred Mamdam
- + +
+
+
+ +
+ +
+
Aman Agarwal
+
+ +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Muskan Sharma
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;"> +
Shivam Goyal
- + + +
-
+
+ + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Kiel H. Byrne
@@ -131,38 +141,55 @@
Kiel H. Byrne
+
-
+ +
+ +
+
Márcio Kuroki Gonçalves
+
+ + +
+
+
+
I Putu Jaya Adi Pranata
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Dreamer01
- - + + + + + +
+
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Utkarsh Singh
@@ -171,23 +198,25 @@
Utkarsh Singh
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Tanmay Kumar Bisoi
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Emmanuel Dylan
@@ -199,59 +228,66 @@
Emmanuel Dylan
+ style="width: 360px; overflow: hidden; border-radius: 1px;"> +
Arpit Anand
- + + +
+
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Chris Ellis
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Saksham Kapoor
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Anirudh Jwala
- + + +
-
+
+
-
+
Sayantan
@@ -262,60 +298,71 @@
Sayantan
+
+ +
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Abednego Edet
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Utkarsh Gupta
- Github - LinkedIn + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Baecon
- Github - LinkedIn + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Romain Guillemot
- - + + + + + +
+
+ +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Aniket Anand
@@ -327,180 +374,215 @@
Aniket Anand
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Nikita Namdev
- - + + + + + + +
+
+
+ +
+ +
+
Satyam Mishra
+
+ +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Muskan Gupta
- + + +
+
+ +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Hemanth Kumar
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Anchal Agarwal
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Aditya Raj Singh
- Github - LinkedIn + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Suchismita Sarkar
- + + +
+
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Bradley Jordan
- Github - LinkedIn + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Ritul Jain
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Davi Cardoso
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Udai Agarwal
- + + +
- +
+
+ +
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Vaibhav Vijay
- +
- +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Izabella Melo
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Rishabh Choudhary
- - + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
slothy
@@ -510,102 +592,117 @@
slothy
+
+ +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Moin Shaikh
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Sean Kerwin
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Trapta Singh
- Github - LinkedIn + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Chris Ellis
- + + +
+
+ + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Priyanshu Kumar
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Joel Bernasky
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Alan Saputra Lengkoan
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Krishna Desabhotla
@@ -616,60 +713,73 @@
Krishna Desabhotla
+
+ + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Nikhil Shrivastava
- - + + + + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Aayush Garg
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Mateo Hoxha
- + + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Dhruv Bhatia
- + + +
+
+ + +
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Kanishk Gupta
@@ -681,7 +791,7 @@
Kanishk Gupta
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Krishna Desabhotla
@@ -691,8 +801,9 @@
Krishna Desabhotla
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Divyansh Tripathi
@@ -702,20 +813,158 @@
Divyansh Tripathi
+
+ style="width: 360px; overflow: hidden; border-radius: 1px;">
Mohsin Rasool
- + + +
+ - +
+
+ +
+
Dharmick Sai
+
+ + +
+
+
+ +
+ +
+
Amit Dutta
+
+ + +
+
+
+ +
+ +
+
Rahul Harlalka
+
+ + +
+
+
+ +
+ +
+
Shekhar Kumar
+
+ + +
+
+
+
+ +
+ +
+ +
+
Risheek Jain
+
+ + +
+
+
+ + +
+ +
+
Shubham Kumar
+
+ + +
+
+
+ + + +
+ +
+
Shubhayan Saha
+
+ + +
+
+
+ + +
+ +
+
Sudeepta Das
+
+ + +
+
+ +
+
+
+
+ +
+
Suchismita Sarkar
+
+ + +
+
+
+
+ +
+
Sergi Oca
+
+ + +
+
+
+
+ +
+ +
+
Soumya Prasad Ukil
+
+ + +
+
+
+ + @@ -733,13 +982,11 @@
BIT MESRA | Institution of Electronics and Telecommunication Engineers (IETE - - - \ No newline at end of file + diff --git a/Task2/contributors.md b/Task2/contributors.md index 38005526..b12aea95 100644 --- a/Task2/contributors.md +++ b/Task2/contributors.md @@ -12,3 +12,10 @@ Start adding Your Names with hosted portfolio. 7. Dureksha Wasala - dcjc29.github.io 8. Vaibhav Vijay - [vaibhavvijay.me](https://vaibhavvijay.me) 9. Baecon - baecon.github.io +10. Muskan Sharma - muskan077.github.io +11. Aniket Anand - aanand2300.github.io +12. Hilmi Biya - hilmibiya.github.io +13. Márcio Kuroki - marciokuroki.github.io +14. Nihal Murmu - nihalmurmu.me +15. Aayush Garg - aayushgarg-03.github.io +16. Shubhayan Saha - https://shubhayans.github.io/ diff --git a/Task3/JavaScript/hello-world.js b/Task3/JavaScript/hello-world.js new file mode 100644 index 00000000..7bc4a71d --- /dev/null +++ b/Task3/JavaScript/hello-world.js @@ -0,0 +1 @@ +console.log('Hello world'); diff --git a/Task3/Objective-c/sieveExample.m b/Task3/Objective-c/sieveExample.m new file mode 100644 index 00000000..fd2c094b --- /dev/null +++ b/Task3/Objective-c/sieveExample.m @@ -0,0 +1,33 @@ +#import + +int main (int argc, const char * argv[]) +{ + int i, j, n = 150, P[151] = { 0, 1 }, prime = 1; + + for ( i = 2; i <= n; ++i ) { + P[i] = prime; + for ( j = 2; j < i ; ++j ) { + if ( i % j == 0 ) + P[i] = 0; + } + } + printf("Print prime numbers results:\n\n"); + for (i = 2; i <= n ; ++i) { + if ( P[i] != 0 ) + printf("%i\n", i); + } + + printf(" \n"); + printf("Print prime numbers original program #results:\n\n"); + //Original program referenced. + int p, d, isPrime; + for ( p = 2; p <= 150; ++p ) { + isPrime = 1; + for ( d = 2; d < p; ++d ) + if ( p % d == 0 ) + isPrime = 0; + if ( isPrime != 0 ) + NSLog (@"%i ", p); + } + return 0; +} diff --git a/Task3/cpp/Binary Search.cpp b/Task3/cpp/Binary Search.cpp new file mode 100644 index 00000000..63a31181 --- /dev/null +++ b/Task3/cpp/Binary Search.cpp @@ -0,0 +1,43 @@ +#include +using namespace std; + +// A recursive binary search function. It returns +// location of x in given array arr[l..r] is present, +// otherwise -1 +int binarySearch(int arr[], int l, int r, int x) +{ + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the middle + // itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then + // it can only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present + // in right subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not + // present in array + return -1; +} + +int main(void) +{ + int arr[] = { 2, 3, 4, 10, 40 }; + int x = 10; + int n = sizeof(arr) / sizeof(arr[0]); + int result = binarySearch(arr, 0, n - 1, x); + if(result!=-1) + cout<<"Element is present at index " << result < + +using namespace std; + +// Function to return gcd of two numbers a and b +int gcd(int a, int b) +{ + if (a == 0) + return b; + return gcd(b % a, a); +} + +// Driver Code +int main() +{ + int a, b; + cout<<"Enter any 2 numbers to find their gcd: "; + cin>>a>>b; + + cout << "GCD(" << a << ", " << b << ") = " << gcd(a, b) << endl; + return 0; +} diff --git a/Task3/cpp/FloydCycleLL b/Task3/cpp/FloydCycleLL new file mode 100644 index 00000000..da66fca3 --- /dev/null +++ b/Task3/cpp/FloydCycleLL @@ -0,0 +1,75 @@ +// C++ program to detect and remove loop +#include +using namespace std; + +struct Node { + int key; + struct Node* next; +}; + +Node* newNode(int key) +{ + Node* temp = new Node; + temp->key = key; + temp->next = NULL; + return temp; +} + +void printList(Node* head) +{ + while (head != NULL) { + cout << head->key << " "; + head = head->next; + } + cout << endl; +} + + +void detectAndRemoveLoop(Node* head) +{ + // If list is empty or has only one node + // without loop + if (head == NULL || head->next == NULL) + return; + + Node *slow = head, *fast = head; + + slow = slow->next; + fast = fast->next->next; + + while (fast && fast->next) { + if (slow == fast) + break; + slow = slow->next; + fast = fast->next->next; + } + + if (slow == fast) { + slow = head; + while (slow->next != fast->next) { + slow = slow->next; + fast = fast->next; + } + + fast->next = NULL; /* remove loop */ + } +} + +int main() +{ + Node* head = newNode(50); + head->next = head; + head->next = newNode(20); + head->next->next = newNode(15); + head->next->next->next = newNode(4); + head->next->next->next->next = newNode(10); + + head->next->next->next->next->next = head->next->next; + + detectAndRemoveLoop(head); + + printf("Linked List after removing loop \n"); + printList(head); + + return 0; +} diff --git a/Task3/cpp/MenuDrivenFileManipulation.cpp b/Task3/cpp/MenuDrivenFileManipulation.cpp new file mode 100644 index 00000000..4176ad1c --- /dev/null +++ b/Task3/cpp/MenuDrivenFileManipulation.cpp @@ -0,0 +1,179 @@ +#include +#include +#include + +using namespace std; + + +class Stud; +class MyException +{ + char str1[50]; + int what; + + public: + MyException() + { + *str1 =0; + what =0; +} + MyException (const char s[], int x) + { + strcpy(str1,s); + what = x; + + } +void printInfo(MyException e) + { + cout<>opt; + + } + out.close(); + +} + +Stud createRecord() +{ + int a,b,c; + int flag=0; + Stud s; + while(!flag) + { + try + { + flag=1; + cout<<" enter values for roll no and age and yob: "<>a; + cin>>b; + cin>>c; + + if (a<=0) + throw MyException("Roll No cannot be negative....",a); + if (b<15) + throw MyException("Age cannot be less than 15::", b); + + if (c >2019) + throw MyException("jOINING Year Cannot be greater than current year :: ",c); + } + catch(MyException e) + { + e.printInfo(e); + flag =0; + } + if (flag==1){ + s.setInfo(a,b,c); + return s; + } + } +} + +void displayFile() +{ + Stud s; + ifstream in; + in.open("stud.dat",ios::in|ios::binary); + + in.read((char *)&s,sizeof(s)); + while(!in.eof()) + { + s.displayInfo(); + in.read((char *)&s,sizeof(s)); + } +} + +void appendRecord() +{ + Stud s; + fstream out; + out.open("stud.dat",ios::app|ios::out|ios::binary); + s=createRecord(); + out.write((char *)&s,sizeof(s)); + out.close(); +} + + +int main() +{ + + int opt=1; + while(opt) + { + menu(); + cout<<"Enter ur option..."; + cin>>opt; + if (opt==1) + { + createFile(); + cout<<"File created successfully ....."< +//#include +using namespace std; +//using namespace boost::multiprecision; +//cpp_int +typedef long long int ll; +#define pb push_back +#define MOD 1000000007 +#define vec vector + +//sort(v.begin(), v.end()); +//sort(v.begin(), v.end(),greater()); +//reverse(v.begin(), v.end()); +//*max_element(v.begin(), v.end()); +//*min_element(v.begin(), v.end()); +//accumulate(v.begin(), v.end(), 0); +//count(v.begin(), v.end(), 20); +//find(first_iterator, last_iterator, x); +//lower_bound(first_iterator, last_iterator, x); +//upper_bound(first_iterator, last_iterator, x); +//distance(first_iterator,desired_position) +bool pairsum(ll a[],ll d) +{ + ll i=0; + ll j=d-1; + while(i + +void swap(int *xp, int *yp) +{ + int temp = *xp; + *xp = *yp; + *yp = temp; +} + +// An optimized version of Bubble Sort +void bubbleSort(int arr[], int n) +{ +int i, j; +bool swapped; +for (i = 0; i < n-1; i++) +{ + swapped = false; + for (j = 0; j < n-i-1; j++) + { + if (arr[j] > arr[j+1]) + { + swap(&arr[j], &arr[j+1]); + swapped = true; + } + } + + // IF no two elements were swapped by inner loop, then break + if (swapped == false) + break; +} +} + +/* Function to print an array */ +void printArray(int arr[], int size) +{ + int i; + for (i=0; i < size; i++) + printf("%d ", arr[i]); + printf("n"); +} + +// Driver program to test above functions +int main() +{ + int arr[] = {64, 34, 25, 12, 22, 11, 90}; + int n = sizeof(arr)/sizeof(arr[0]); + bubbleSort(arr, n); + printf("Sorted array: \n"); + printArray(arr, n); + return 0; +} diff --git a/Task3/cpp/quickSort.cpp b/Task3/cpp/quickSort.cpp new file mode 100644 index 00000000..d8ad27a8 --- /dev/null +++ b/Task3/cpp/quickSort.cpp @@ -0,0 +1,70 @@ +#include +#include +using namespace std; + +/* this function returns the partition index to the quicksort function*/ +int partitionMy(int a[],int p,int r) +{ + int x=a[r]; /* this is the pivot element,in this case it is the last one */ + int i=p-1; + int j=0; + + /* this brings all smaller elements to the left of the pivot + and larger elements to the right of the pivot*/ + + for(j=p;j<=r-1;j++) + { + if(a[j]<=x) + { + i++; + swap(a[j],a[i]); + + } + + } + swap(a[i+1],a[r]); + return i+1; + +} +void quickSort(int a[],int p,int r) +{ + /* we recursively call quicksort on the two parts of the array + after receiving the partition from partitionMy function*/ + + if(p>n; + a=new int[n]; + /* taking input of the array */ + + cout<<"Enter the elements of an array"<>a[i]; + } + + /* quicksort function for sorting the array*/ + + quickSort(a,1,n); + cout<<"The sorted array is: "< +//#include +using namespace std; +//using namespace boost::multiprecision; +//cpp_int +typedef long long int ll; +#define pb push_back +#define MOD 1000000007 +#define vec vector + +//sort(v.begin(), v.end()); +//sort(v.begin(), v.end(),greater()); +//reverse(v.begin(), v.end()); +//*max_element(v.begin(), v.end()); +//*min_element(v.begin(), v.end()); +//accumulate(v.begin(), v.end(), 0); +//count(v.begin(), v.end(), 20); +//find(first_iterator, last_iterator, x); +//lower_bound(first_iterator, last_iterator, x); +//upper_bound(first_iterator, last_iterator, x); +//distance(first_iterator,desired_position) +ll maxsum(ll a[],ll d,ll k) +{ + ll sum=0; + for(ll i=0;i Bool +isHappyNumber x + | l == 1 && n == 1 = True + | l == 1 && n /= 1 = False + | l > 1 = isHappyNumber n + where + !l = length $ show $ n + !n = happyParser x + +-- Helper which is does the actual calculating +happyParser :: Int -> Int +happyParser = sum . map (join (*)) . map digitToInt . show + +-- Generates the happy numbers below n +belowNHappyNumber :: Int -> [Int] +belowNHappyNumber n = [ x | x <- [1..n], isHappyNumber x] \ No newline at end of file diff --git a/Task3/haskell/SOS.hs b/Task3/haskell/SOS.hs new file mode 100644 index 00000000..4517a00d --- /dev/null +++ b/Task3/haskell/SOS.hs @@ -0,0 +1,23 @@ +Q. Calculate prime numbers using Sieve of Sundaram + +Sol. +module SOS where + +main :: IO () +main = do + putStrLn "Use Sieve of Sundaram with the starting value of: " + line1 <- getLine + let num = (read line1 :: Int) + print $ sieveOfSundaram num + +-- Adds the first prime and calls a list eliminating method +sieveOfSundaram :: Int -> [Int] +sieveOfSundaram n = 2 : (writeSOS $ [1..n] \\ elimList n) + +-- Uses the final transformations +writeSOS :: [Int] -> [Int] +writeSOS xs = map (\x -> 2 * x + 1) xs + +-- Creates the list of eliminations +elimList :: Int -> [Int] +elimList n = filter (<=n) [i + j + 2 * i * j | i<-[1..n], j<-[i..n]] \ No newline at end of file diff --git a/Task3/haskell/SieveOfEratosthenes.hs b/Task3/haskell/SieveOfEratosthenes.hs new file mode 100644 index 00000000..38638225 --- /dev/null +++ b/Task3/haskell/SieveOfEratosthenes.hs @@ -0,0 +1,20 @@ +Q. Calculate prime numbers up to n + +Sol. +module SieveOfEratosthenes where + +main :: IO () +main = do + putStrLn "Number to search primes up to: " + line1 <- getLine + let num = (read line1 :: Int) + print $ sieve num + +-- Calling the tail recursive function +sieve :: Int -> [Int] +sieve n = sieveRec [2..n] [] + +-- Tail recursive function, that uses the Sieve of Erastosthenes +sieveRec :: [Int] -> [Int] -> [Int] +sieveRec [] acc = reverse acc +sieveRec (n:xs) acc = sieveRec (filter (\x-> x `mod` n /= 0) xs) (n:acc) diff --git a/Task3/java/BubbleSort.java b/Task3/java/BubbleSort.java new file mode 100644 index 00000000..9c98b7bf --- /dev/null +++ b/Task3/java/BubbleSort.java @@ -0,0 +1,50 @@ +import java.util.Scanner; + +public class BubbleSort { + public static int[] takeInput() + { + Scanner s = new Scanner(System.in); + System.out.println("Enter the number of elements in the array"); + int n=s.nextInt(); + System.out.println("Enter the array Elements"); + int input[]=new int [n]; + for(int i=0;iarr[j+1]) + { + int temp=arr[j]; + arr[j]=arr[j+1]; + arr[j+1]=temp; + } + } + } + } + + public static void main(String[] args) { + int input[]=takeInput(); + printArray(input); + bubbleSort(input); + System.out.println(); + printArray(input); + + } + +} diff --git a/Task3/javascript/hello-world.js b/Task3/javascript/hello-world.js index 56d8e6e0..7bc4a71d 100644 --- a/Task3/javascript/hello-world.js +++ b/Task3/javascript/hello-world.js @@ -1,2 +1 @@ -console.log('Hello world!') - +console.log('Hello world'); diff --git a/Task3/kotlin/task3.kt b/Task3/kotlin/task3.kt new file mode 100644 index 00000000..0705feb2 --- /dev/null +++ b/Task3/kotlin/task3.kt @@ -0,0 +1,10 @@ +fun fibonacci(n: Int): Int { + var previous = 0 + var current = 1 + for (i: Int in 2..n) { + val temp = current + previous + previous = current + current = temp + } + return current +} \ No newline at end of file diff --git a/Task3/python/automatic examination invigilation using face detection.py b/Task3/python/automatic examination invigilation using face detection.py new file mode 100644 index 00000000..2f187094 --- /dev/null +++ b/Task3/python/automatic examination invigilation using face detection.py @@ -0,0 +1,113 @@ + +# coding: utf-8 + +# In[5]: + +#This is a examaination cheating detector for online exams!!! + + +# In[1]: + +#impoting all libraries + +import cv2 +import numpy as np +import pandas as pd +import datetime + + +# In[2]: + +#taking examinees logn details + +print("PLEASE ENTER LOGIN DETAILS TO LOG INTO THE EXAMINTION PORTAL") +print("ENTER NAME") +name=input() +print("ENTER ROLL NUMBER") +roll=input() + + +# In[3]: + +#imoprting face clasiifiers + +face_cascade=cv2.CascadeClassifier('C:/Users/rahul/OneDrive/Documents/new mega project files/cascades/data/haarcascade_frontalface_alt.xml') +cap=cv2.VideoCapture(0) +cap.set(3,1280) +cap.set(4,720) + + +# In[4]: + +#face and cheating detector during exam + +cheating=0 +cheating2=0 +while(True): + ret,frame=cap.read() + blurred=cv2.GaussianBlur(frame,(21,21),0) + weight_frame=cv2.addWeighted(frame,1.75,blurred,-0.5,0) + + yuv=cv2.cvtColor(frame,cv2.COLOR_BGR2YUV) + yuv[:,:,0]=cv2.equalizeHist(yuv[:,:,0]) + + bgr_frame = cv2.cvtColor(yuv, cv2.COLOR_YUV2BGR) + gray = cv2.cvtColor(bgr_frame, cv2.COLOR_BGR2GRAY) + + clahe = cv2.createCLAHE(clipLimit=40.0, tileGridSize=(8, 8)) + gray = clahe.apply(gray) + + faces=face_cascade.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5) + + for(x,y,w,h) in faces: + roi_gray=gray[x:x+w,y:y+h] + roi_frame=frame[x:x+w,y:y+h] + cv2.rectangle(frame,(x,y),(x+w,y+h),color=(255,0,0),thickness=2,lineType=cv2.LINE_AA) + + if len(faces)==0: + cheating=cheating+1 + if cheating==1: + now=datetime.datetime.now().second + if cheating>0: + if (datetime.datetime.now().second-now) > 10: + print("CHEATING",datetime.datetime.now().hour,":",datetime.datetime.now().minute,":",datetime.datetime.now().second) + if cheating >20: + print("EXAM TERMINATED AND PAPER CANCELLED!!","\n",name,roll,"CAUGHT CHEATING") + break + + + if len(faces)==0: + cheating2=cheating2+1 + count=0 + if cheating2==1: + now1=datetime.datetime.now().second + if cheating2>0: + + if (datetime.datetime.now().second-now1)>2: + count=count+1 + if count>=6: + print("cheating !! exam terminated,endl=\n") + break + if count <6 : + print("cheating warning \n") + + + + + + + + cv2.imshow('frame',frame) + + if cv2.waitKey(20) & 0xFF==ord('q'): + break + +cap.release() +cv2.destroyAllWindows() + + + +# In[ ]: + + + diff --git a/Task3/python/iris-species-classification-logistic-regression.py b/Task3/python/iris-species-classification-logistic-regression.py new file mode 100644 index 00000000..21cf8276 --- /dev/null +++ b/Task3/python/iris-species-classification-logistic-regression.py @@ -0,0 +1,249 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[1]: + + +import numpy as np +import pandas as pd +import os + + +# In[2]: + + +import seaborn as sns +import matplotlib.pyplot as plt +get_ipython().run_line_magic('matplotlib', 'inline') + + +# In[3]: + + +dataset=pd.read_csv("./Iris.csv") + + +# In[4]: + + +dataset.head() + + +# In[5]: + + +dataset.head() + + +# the different types of the iris species and their respective numbers in the dataset is shown below + +# In[6]: + + +dataset['Species'].value_counts() + + +# In[7]: + + +sns.countplot(x='Species',data=dataset) +plt.savefig('count sprecied in train data.png') + + +# now since we have to fit the model to the logistic regression model we will have to convert the different species into labels for them to fit into the model other wise the model will cause an error + +# In[8]: + + +species={'Iris-setosa':1,'Iris-versicolor':2,'Iris-virginica':3} + + +# In[9]: + + +dataset=dataset.replace({'Species':species}) + + +# In[10]: + + +dataset.head() + + +# we can now see that the statistics of our dataset + +# In[11]: + + +dataset.info() + + +# In[12]: + + +dataset.describe() + + +# ## Some features engineering + +# # we will now see which of the columns contain the most variance in the species prediction + +# In[13]: + + +dataset.corr()[['Species']].sort_values(by='Species',ascending=False) + + +# we will remove our ID column column as it is only the serial number and does not convey any relevant information about the prediction + +# In[14]: + + +dataset.drop('Id',axis=1,inplace=True) + + +# In[15]: + + +dataset.head() + + +# again finding the variance of the dataset + +# In[16]: + + +dataset.corr()[['Species']].sort_values(by='Species',ascending=False) + + +# we can see that the petal width and petal length convey more than 95 percent of the information for prediction of the species. sepal width convey negetive relation + +# In[17]: + + +sns.regplot(x='PetalLengthCm',y='Species',data=dataset) +plt.savefig('dependance of petal length of iris flowers on prediction.png') + + +# In[18]: + + +sns.regplot(x='PetalWidthCm',y='Species',data=dataset) +plt.savefig('dependance of petal width of iris flowers on prediction.png') + + +# In[19]: + + +sns.regplot(x='SepalLengthCm',y='Species',data=dataset) +plt.savefig('dependance of sepal length of iris flowers on prediction.png') + + +# In[20]: + + +sns.regplot(x='SepalWidthCm',y='Species',data=dataset) +plt.savefig('dependance of sepal width of iris flowers on prediction.png') + + +# now we split the dataset into our independant feature matrix and depeandant feature matrix + +# In[21]: + + +x_train=dataset.drop('Species',axis=1) +y_train=dataset[['Species']] + + +# now we split our dataset into training and test set for training and predicting respectively + +# In[22]: + + +from sklearn.model_selection import train_test_split as tts +x_train,x_test,y_train,y_test=tts(x_train,y_train,test_size=0.2,random_state=18) + + +# In[23]: + + +x_train.shape + + +# In[24]: + + +x_test.shape + + +# In[25]: + + +y_train.shape + + +# In[26]: + + +y_test.shape + + +# > **now we build our logistic regression classifier**** + +# In[27]: + + +from sklearn.linear_model import LogisticRegression +clf=LogisticRegression(C=112,max_iter=50) + + +# **logistic regression object/instance craeted +# now we will fit the object to the training data ** + +# In[28]: + + +clf.fit(x_train,np.array(y_train).ravel()) + + +# predicting values from the fitted classifier for the test data + +# In[29]: + + +y_predict=clf.predict(x_test) + + +# checking accuracy :- + +# In[30]: + + +from sklearn.metrics import confusion_matrix +confusion_matrix(y_test,y_predict) + + +# all the samples of the test data have been classified correctly + +# In[31]: + + +from sklearn.metrics import accuracy_score +accuracy_score(y_test,y_predict)*100 + + +# **accuracy of the model is 100 percent** + +# In[32]: + + +y_predict=pd.DataFrame(y_predict) +sns.countplot(x=0,data=y_predict) +plt.savefig('y_predict data.png') + + +# In[ ]: + + + + diff --git a/Task3/python/new_pima_indians_dataset .py b/Task3/python/new_pima_indians_dataset .py new file mode 100644 index 00000000..520d70b6 --- /dev/null +++ b/Task3/python/new_pima_indians_dataset .py @@ -0,0 +1,162 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[1]: + + +import numpy as np +import pandas as pd + + +# In[2]: + + +dataset=pd.read_csv("E:/kaggle/pima indian diabetes dataset aveon task 2/diabetes.csv") + + +# In[3]: + + +x_train=dataset.iloc[:,:-1].values + + +# In[4]: + + +y_train=dataset.iloc[:,-1].values + + +# In[5]: + + +x_train=pd.DataFrame(x_train) +y_train=pd.DataFrame(y_train) + + +# In[6]: + + +for i in range(2,8): + x_train=x_train.replace(0,x_train[i].mean()) + + +# In[7]: + + +from sklearn.preprocessing import MinMaxScaler +scaler=MinMaxScaler() +x_train=scaler.fit_transform(x_train) + + +# In[8]: + + +x_train=pd.DataFrame(x_train) + + +# In[9]: + + +from sklearn.cross_validation import train_test_split +x_train,x_test,y_train,y_test=train_test_split(x_train,y_train,test_size=0.22,random_state=57) + + +# In[10]: + + +y_train=np.array(y_train).ravel() + + +# In[11]: + + + +from sklearn.naive_bayes import GaussianNB +clf=GaussianNB() +clf.fit(x_train,y_train) + + +# In[12]: + + +y_predict=clf.predict(x_test) + + +# In[13]: + + +from sklearn.metrics import accuracy_score +accuracy_score(y_test,y_predict)*100 + + +# In[14]: + + +from sklearn.naive_bayes import GaussianNB +clf2=GaussianNB() +clf2.partial_fit(x_train,y_train,classes=[0,1,2,3,4,5,6,7]) + + +# In[15]: + + +y_predict2=clf2.predict(x_test) + + +# In[16]: + + +from sklearn.metrics import accuracy_score +accuracy_score(y_test,y_predict2)*100 + + +# In[84]: + + +from sklearn.linear_model import LogisticRegression +lr=LogisticRegression(C=1000000,max_iter=1000000,penalty='l1') +lr.fit(x_train,y_train) + + +# In[85]: + + +y_predict_lr=lr.predict(x_test) + + +# In[86]: + + +from sklearn.metrics import confusion_matrix +confusion_matrix(y_test,y_predict_lr) + + +# In[87]: + + +accuracy_score(y_test,y_predict) + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + + + +# In[ ]: + + + +