Skip to content

Commit

Permalink
Merge pull request #1 from ows-ali/master
Browse files Browse the repository at this point in the history
Update repository
  • Loading branch information
Shashwat-Garg authored Oct 19, 2018
2 parents 160f1f0 + 92fa5f1 commit da90c52
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ it will be redirected to the actual problem page)
- Place your source code file in respective folder (you can create a new folder if it is not present)
- Optional - You can add comments at the start of the file, if you want to share something, like steps to run the code etc
- Add and commit the changes. (Please do not make changes in any other file, but if you want to work on bug/improvement then add an issue first)
- Don't forget to add your name, country and the language used in contributors table in the README.md file
- Don't forget to add your name, image url, country and the language used in contributors table in the README.md file
- Generate a Pull Request (Optional: add problem name in the title and url to the problem in description)
- That's it, you have successfully completed your 1 out of 5 PRs. Well Done!
21 changes: 21 additions & 0 deletions Codechef/FLOW009.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.io.*;
class FLOW009 {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out, true);

int t = Integer.parseInt(br.readLine().trim());

while (t-- > 0) {
String[] tok = br.readLine().split(" ");

double quan = Double.parseDouble(tok[0]);
double price = Double.parseDouble(tok[1]);

double cost = quan * price;
if (quan > 1000) cost -= ((quan * price) / 100 * 10);

out.printf("%.6f\n", cost);
}
}
}
25 changes: 25 additions & 0 deletions Codechef/INTEST.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <bits/stdc++.h>

using namespace std;

void readInt(int &n) {
static char c;
while ((c = getchar_unlocked()) && c <= ' ');
n = c - '0';

while ((c = getchar_unlocked()) && c > ' ') n = (n << 3) + (n << 1) + c - '0';
}

int main() {
int n, k;
readInt(n); readInt(k);

int ans = 0;
while (n--) {
int foo; readInt(foo);
ans += foo % k == 0;
}

printf("%d\n", ans);
return 0;
}
53 changes: 53 additions & 0 deletions Codechef/LADDU.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.io.*;
import java.util.*;
class Laddu {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out, true);

int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");

int numAct = Integer.parseInt(st.nextToken());
int national = 0;

if (st.nextToken().equals("INDIAN")) national = 1;

int score = 0;
while (numAct-- > 0) {
score += laddus(br.readLine());
}

int perMonth = national == 0 ? 400 : 200;
out.println((score - (score % perMonth)) / perMonth);
}

out.close();
}
public static int laddus(String str) {
String[] arr = str.split(" ");

if (arr.length == 1) {
switch (arr[0]) {
case "TOP_CONTRIBUTOR" :
return 300;
case "CONTEST_HOSTED" :
return 50;
default :
return 0;
}
} else {
switch (arr[0]) {
case "BUG_FOUND" :
return Integer.parseInt(arr[1]);
case "CONTEST_WON" :
if (Integer.parseInt(arr[1]) <= 20) {
return 300 + 20 - Integer.parseInt(arr[1]);
} else return 300;
default :
return 0;
}
}
}
}
38 changes: 38 additions & 0 deletions Codechef/MAXDIFF.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
int t;
scanf("%d", &t);

while (t-- > 0) {
int n, k;
scanf("%d %d", &n, &k);

int arr[n];
int totalSum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];

totalSum += arr[i];
}

sort(arr, arr + n);

if (k > n / 2)
k = n - k;
int sumSon = 0, sumFather = 0;
for (int i = 0; i < k; i++)
sumSon += arr[i];

sumFather = totalSum - sumSon;

int diff = sumFather - sumSon;

printf("%d\n", diff);
}

return 0;
}
19 changes: 19 additions & 0 deletions Codechef/SPCANDY.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>

using namespace std;

int main() {
int t;
cin >> t;

while (t-- > 0) {
long n, k;
cin >> n >> k;

if (k == 0)
cout << "0 " << n << endl;
else
cout << n / k << " " << n % k << endl;
}
return 0;
}
39 changes: 39 additions & 0 deletions Codechef/SUMTRIAN.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import java.util.Scanner;

public class SumTrain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int notc = scanner.nextInt();
int nol;
short[][] arr;
for (int i = 0; i < notc; i++) {

nol = scanner.nextInt();
arr = new short[nol][nol];
for (int j = 0; j < nol; j++)
for (int k = 0; k <= j; k++)
arr[j][k] = scanner.nextByte();

for (int j = 1; j < nol; j++)
for (int k = 0; k <= j; k++)
if (k == 0)
arr[j][k] += arr[j - 1][k];
else if (j == k)
arr[j][k] += arr[j - 1][k - 1];
else
arr[j][k] += max(arr[j - 1][k], arr[j - 1][k - 1]);

long maxNum = arr[nol - 1][0];
for (int j = 1; j < nol; j++)
if (maxNum < arr[nol - 1][j])
maxNum = arr[nol - 1][j];
System.out.println(maxNum);
}
}

public static short max(short a, short b) {

return a > b ? a : b;
}
}
34 changes: 34 additions & 0 deletions Codechef/VOTERS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <cstdio>
#include <iostream>
#include <map>
#include <iterator>

using namespace std;

int main() {
map <int, int> m;

int a, b, c;
scanf("%d %d %d", &a, &b, &c);

int temp;
for (int i = 0; i < a + b + c; i++) {
scanf("%d", &temp);
m.insert(pair<int, int>(temp, m[temp]++));
}

map <int, int> :: iterator itr;
int counter = 0;
for (itr = m.begin(); itr != m.end(); ++itr) {
if (itr->second >= 2)
counter++;
}

printf("%d\n", counter);
for (itr = m.begin(); itr != m.end(); ++itr) {
if (itr->second >= 2)
printf("%d\n", itr->first);
}

return 0;
}
20 changes: 20 additions & 0 deletions Hackerrank/array-left-rotation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>

using namespace std;

int main() {
int n, k;
scanf("%d %d", &n, &k);

int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];

for (int j = k; j < n; j++)
cout << arr[j] << " ";

for (int p = 0; p < k; p++)
cout << arr[p] << " ";

return 0;
}
22 changes: 22 additions & 0 deletions Hackerrank/detect-whether-a-linked-list-contains-a-cycle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle/problem

bool has_cycle(Node* head) {

if (head == NULL || head->next == NULL){
return false;
}
else{
Node *runner = head->next->next;

while (runner != NULL && runner != head){
runner = runner->next->next;
head = head->next;
}
if (runner == NULL){
return false;
}
else{
return true;
}
}
}
27 changes: 27 additions & 0 deletions Hackerrank/staircase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the staircase function below.
static void staircase(int n) {
int m=n;

while(n!=0){
n--;
for(int i=0;i<n;i++) System.out.print(" ");
for(int i=0;i<m-n;i++) System.out.print("#");
System.out.println();
}
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
staircase(n);
scanner.close();
}
}
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
[![GitHub issues by-label](https://img.shields.io/github/issues-pr-closed-raw/ows-ali/Hacktoberfest.svg)](https://github.com/ows-ali/Hacktoberfest/pulls?q=is%3Apr+is%3Aclosed)
[![GitHub issues by-label](https://img.shields.io/github/issues-pr/ows-ali/Hacktoberfest.svg)](https://github.com/ows-ali/Hacktoberfest/pulls?q=is%3Aopen+is%3Apr)

This repositry is mainly open to those who are willing to generate PR for Hacktoberfest to get started with GitHub and open source world.
In this repository, you can find the solution code of problems from [Hackerrank](https://hackerrank.com).
This repository is mainly open to those who are looking to make some PR for the Hacktoberfest event, and to get started with GitHub and the open-source world.
In this repository, you can find the solutions (as source code) for the problems in [HackerRank](https://hackerrank.com), [Codechef](https://codechef.com) or any other online platform

### Why contribute to this repository
- Beginners Friendly
- You can generate your first PR on GitHub
- You can start with any problem of your choice on [Hackerrank](https://hackerrank.com), [Codechef](https://codechef.com)
- Good Chance to Win a T-Shirt by participating in [Hacktoberfest](hacktoberfest.digitalocean.com)
- Beginner-friendly
- Create your first Pull Request on GitHub
- Start with any problem of your choice on [HackerRank](https://hackerrank.com), [Codechef](https://codechef.com) etc
- Chance of receiving a T-Shirt for participating in the [Hacktoberfest](hacktoberfest.digitalocean.com)

### How to Contribute (Updated)
- For contributions in this repostiory, please read CONTRIBUTIONS.md first. (Please pull the changes from this repo if you have already forked the repository and facing conflicts)
- For contributions in this repository, please read `CONTRIBUTING.md` first. (Please pull the changes from this repo if you have already forked the repository and are facing conflicts)
- If you like the repository, please star it.

### Learning Resources
Expand All @@ -27,19 +27,25 @@ In this repository, you can find the solution code of problems from [Hackerrank]

## Contributors

| Name | Country | Programming Language |
|-------------------------------------------------------------------|-----------------------|--------------------------------|
| [Owais Ali](https://github.com/owaisalics/) | Pakistan | JAVA |
| [Yuibun](https://github.com/yuibun/) | United States | C++ |
| [Roopam Sharma](https://github.com/RoopamSharma/) | United States | Python3 |
| [Cass Smith](https://github.com/cassvs/) | Canada | C |
| [Advait Joshi](https://github.com/joshiadvait8/) | India | C++ |
| [Archana Prabhu](https://github.com/ArchanaPrabhu/) | India | C++ |
| [Aman Sharma](https://github.com/amsharma44/) | India | C# |
| [Carlos Gomez](https://github.com/Kurolox/) | Spain | |
| [Jason Aiken](https://github.com/sinuoustalker/) | United States | |
| [Saiij](https://github.com/Saiij/) | Germany | JavaScript |
| [Apurva](https://github.com/alonemayank) | United States | Java |
| Name | Country | Programming Language |
|------------------------------------------------------------------------------------------------------------------------------------|-----------------------|--------------------------------|
| [Owais Ali](https://github.com/owaisalics/) <br> <img src="https://github.com/ows-ali.png" width="100" height="100"> | Pakistan | JAVA |
| [Yuibun](https://github.com/yuibun/) <br> <img src="https://github.com/yuibun.png" width="100" height="100"> | United States | C++ |
| [Roopam Sharma](https://github.com/RoopamSharma/) <br> <img src="https://github.com/RoopamSharma.png" width="100" height="100"> | United States | Python3 |
| [Cass Smith](https://github.com/cassvs/) <br> <img src="https://github.com/cassvs.png" width="100" height="100"> | Canada | C |
| [Advait Joshi](https://github.com/joshiadvait8/) <br> <img src="https://github.com/joshiadvait8.png" width="100" height="100"> | India | C++ |
| [Archana Prabhu](https://github.com/ArchanaPrabhu/) <br> <img src="https://github.com/ArchanaPrabhu.png" width="100" height="100"> | India | C++ |
| [Aman Sharma](https://github.com/amsharma44/) <br> <img src="https://github.com/amsharma44.png" width="100" height="100"> | India | C# |
| [Carlos Gomez](https://github.com/Kurolox/) <br> <img src="https://github.com/Kurolox.png" width="100" height="100"> | Spain | |
| [Jason Aiken](https://github.com/sinuoustalker/) <br> <img src="https://github.com/sinuoustalker.png" width="100" height="100"> | United States | |
| [Saiij](https://github.com/Saiij/) <br> <img src="https://github.com/Saiij.png" width="100" height="100"> | Germany | JavaScript |
| [Apurva](https://github.com/alonemayank) <br> <img src="https://github.com/alonemayank.png" width="100" height="100"> | United States | Java |
| [Camila](https://github.com/milaaraujo) <br> <img src="https://github.com/milaaraujo.png" width="100" height="100"> | Canada | C++ |
| [Mohammad Sameer](https://github.com/m-sameer) <br> <img src="https://github.com/m-sameer.png" width="100" height="100"> | India | Java, C++ |
| [Anubhav Gupta](https://github.com/theanubhava) <br> <img src="https://github.com/theanubhava.png" width="100" height="100"> | India | Java, |
| [Inzemam Ul-Haq](https://github.com/Virusthegreat) <br> <img src="https://github.com/Virusthegreat.png" width="100" height="100"> | India | C++ |
| [Bertram Truong](https://github.com/bt) <br> <img src="https://github.com/bt.png" width="100" height="100"> | Australia | |


### License

Expand Down
Loading

0 comments on commit da90c52

Please sign in to comment.