From e4550276a5d334ad1f4c9e851f4a0ee8f033a164 Mon Sep 17 00:00:00 2001 From: Arpit-Rungta Date: Sat, 14 Oct 2023 18:28:47 +0530 Subject: [PATCH] adding my file --- .idea/.gitignore | 3 + .idea/Hacktoberfest.iml | 12 ++ .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 +++++++++++++++++ .idea/vcs.xml | 6 + Hackerrank/Hackerrank/IF_ELSE.java | 22 +++ LeetCode/Solution.java | 28 ++++ .../Hacktoberfest/Binary Search.cpp | 44 ++++++ .../Hacktoberfest/CandlesCounting.cpp | 81 ++++++++++++ .../Hacktoberfest/DiscountFinder.cpp | 46 +++++++ out/production/Hacktoberfest/HelloWorld.py | 2 + out/production/Hacktoberfest/MinMax.py | 7 + .../Hacktoberfest/SOLVE_ME_FIRST.javascript | 32 +++++ .../Hacktoberfest/Smiley_pattern.cpp | 15 +++ out/production/Hacktoberfest/Staircase.py | 17 +++ out/production/Hacktoberfest/a-very-big-sum.c | 10 ++ .../Hacktoberfest/a-very-big-sum.py | 10 ++ .../Hacktoberfest/angry-children.py | 23 ++++ .../Hacktoberfest/apple-and-orange.cpp | 125 ++++++++++++++++++ .../Hacktoberfest/array-left-rotation.cpp | 20 +++ out/production/Hacktoberfest/arrays-ds.cpp | 39 ++++++ .../Hacktoberfest/climbing_the_leaderboard.py | 94 +++++++++++++ out/production/Hacktoberfest/coin-change.cpp | 43 ++++++ out/production/Hacktoberfest/coin-change.cs | 57 ++++++++ .../Hacktoberfest/compare-the-triplets.cpp | 109 +++++++++++++++ .../Hacktoberfest/compare-the-triplets.py | 38 ++++++ .../Hacktoberfest/cpp-hello-world-v1.cpp | 8 ++ .../Hacktoberfest/cpp-hello-world-v2.cpp | 7 + ...whether-a-linked-list-contains-a-cycle.cpp | 22 +++ ...lassics-the-longest-common-subsequence.cpp | 67 ++++++++++ out/production/Hacktoberfest/euler001.py | 18 +++ .../Hacktoberfest/fp-hello-world-n-times.ml | 8 ++ .../fraudulent-activity-notifications.cpp | 86 ++++++++++++ out/production/Hacktoberfest/functions-in-c.c | 13 ++ .../Hacktoberfest/getRemoteSocketIo.js | 13 ++ out/production/Hacktoberfest/kangaroo.js | 19 +++ .../Hacktoberfest/list-comprehension.py | 11 ++ .../longest-increasing-subsequent.cpp | 57 ++++++++ .../Hacktoberfest/matrix_layer_rotation.py | 45 +++++++ out/production/Hacktoberfest/pangrams.cpp | 24 ++++ .../Hacktoberfest/police-operation.cpp | 61 +++++++++ .../Hacktoberfest/sherlockAndCost.py | 33 +++++ .../Hacktoberfest/simple-array-sum.c | 106 +++++++++++++++ .../Hacktoberfest/solve-me-first.javascript | 32 +++++ .../Hacktoberfest/solve-me-first.py | 9 ++ out/production/Hacktoberfest/staircase.cpp | 35 +++++ out/production/Hacktoberfest/stockmax.cpp | 53 ++++++++ out/production/Hacktoberfest/swap-case.py | 12 ++ .../Hacktoberfest/the-birthday-bar.js | 18 +++ .../Hacktoberfest/the-time-in-words.js | 43 ++++++ .../Hacktoberfest/time-conversion.rb | 38 ++++++ .../Hacktoberfest/torque-and-development.cs | 82 ++++++++++++ out/production/Hacktoberfest/word-order.py | 22 +++ 54 files changed, 1963 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Hacktoberfest.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 Hackerrank/Hackerrank/IF_ELSE.java create mode 100644 LeetCode/Solution.java create mode 100644 out/production/Hacktoberfest/Binary Search.cpp create mode 100644 out/production/Hacktoberfest/CandlesCounting.cpp create mode 100644 out/production/Hacktoberfest/DiscountFinder.cpp create mode 100644 out/production/Hacktoberfest/HelloWorld.py create mode 100644 out/production/Hacktoberfest/MinMax.py create mode 100644 out/production/Hacktoberfest/SOLVE_ME_FIRST.javascript create mode 100644 out/production/Hacktoberfest/Smiley_pattern.cpp create mode 100644 out/production/Hacktoberfest/Staircase.py create mode 100644 out/production/Hacktoberfest/a-very-big-sum.c create mode 100644 out/production/Hacktoberfest/a-very-big-sum.py create mode 100644 out/production/Hacktoberfest/angry-children.py create mode 100644 out/production/Hacktoberfest/apple-and-orange.cpp create mode 100644 out/production/Hacktoberfest/array-left-rotation.cpp create mode 100644 out/production/Hacktoberfest/arrays-ds.cpp create mode 100644 out/production/Hacktoberfest/climbing_the_leaderboard.py create mode 100644 out/production/Hacktoberfest/coin-change.cpp create mode 100644 out/production/Hacktoberfest/coin-change.cs create mode 100644 out/production/Hacktoberfest/compare-the-triplets.cpp create mode 100644 out/production/Hacktoberfest/compare-the-triplets.py create mode 100644 out/production/Hacktoberfest/cpp-hello-world-v1.cpp create mode 100644 out/production/Hacktoberfest/cpp-hello-world-v2.cpp create mode 100644 out/production/Hacktoberfest/detect-whether-a-linked-list-contains-a-cycle.cpp create mode 100644 out/production/Hacktoberfest/dynamic-programming-classics-the-longest-common-subsequence.cpp create mode 100644 out/production/Hacktoberfest/euler001.py create mode 100644 out/production/Hacktoberfest/fp-hello-world-n-times.ml create mode 100644 out/production/Hacktoberfest/fraudulent-activity-notifications.cpp create mode 100644 out/production/Hacktoberfest/functions-in-c.c create mode 100644 out/production/Hacktoberfest/getRemoteSocketIo.js create mode 100644 out/production/Hacktoberfest/kangaroo.js create mode 100644 out/production/Hacktoberfest/list-comprehension.py create mode 100644 out/production/Hacktoberfest/longest-increasing-subsequent.cpp create mode 100644 out/production/Hacktoberfest/matrix_layer_rotation.py create mode 100644 out/production/Hacktoberfest/pangrams.cpp create mode 100644 out/production/Hacktoberfest/police-operation.cpp create mode 100644 out/production/Hacktoberfest/sherlockAndCost.py create mode 100644 out/production/Hacktoberfest/simple-array-sum.c create mode 100644 out/production/Hacktoberfest/solve-me-first.javascript create mode 100644 out/production/Hacktoberfest/solve-me-first.py create mode 100644 out/production/Hacktoberfest/staircase.cpp create mode 100644 out/production/Hacktoberfest/stockmax.cpp create mode 100644 out/production/Hacktoberfest/swap-case.py create mode 100644 out/production/Hacktoberfest/the-birthday-bar.js create mode 100644 out/production/Hacktoberfest/the-time-in-words.js create mode 100644 out/production/Hacktoberfest/time-conversion.rb create mode 100644 out/production/Hacktoberfest/torque-and-development.cs create mode 100644 out/production/Hacktoberfest/word-order.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/Hacktoberfest.iml b/.idea/Hacktoberfest.iml new file mode 100644 index 00000000..ba91ef50 --- /dev/null +++ b/.idea/Hacktoberfest.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..e3a9e45a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..076a2e03 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..2b63946d --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Hackerrank/Hackerrank/IF_ELSE.java b/Hackerrank/Hackerrank/IF_ELSE.java new file mode 100644 index 00000000..a178a1d6 --- /dev/null +++ b/Hackerrank/Hackerrank/IF_ELSE.java @@ -0,0 +1,22 @@ +package Hackerrank; + +import java.util.*; + +public class IF_ELSE { + + 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])?"); + + if(N%2!=0){ + System.out.print("Weird"); + + }else if( N%2==0 && N>=2 && N<=5 ){System.out.println("Not Weird");} + else if(N%2==0 && N>=6 && N<=20 ){System.out.println("Weird");} + else if(N%2==0 && N>20){System.out.println("Not Weird");} + scanner.close(); + } +} + diff --git a/LeetCode/Solution.java b/LeetCode/Solution.java new file mode 100644 index 00000000..0faba19b --- /dev/null +++ b/LeetCode/Solution.java @@ -0,0 +1,28 @@ +package LeetCode; + + + +public class Solution { + public int[] twoSum(int[] nums, int target) { + + int a=0; + + for (int i = 0; i < nums.length-1; i++) { + + if(nums[i]+nums[i+1]==target){ + a=i; + break; + } + if(a==i) { + System.out.println("["+a + "," + (a + 1)+"]"); + } + } + return new int[]{}; + + } + + public static void main(String[] args) { +Solution s=new Solution(); +//s.twoSum(); + m } +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/Binary Search.cpp b/out/production/Hacktoberfest/Binary Search.cpp new file mode 100644 index 00000000..2b6fc8cc --- /dev/null +++ b/out/production/Hacktoberfest/Binary Search.cpp @@ -0,0 +1,44 @@ +#include +using namespace std; +//funtion for implementing binary search +int binarySearch(int *input,int beg,int end,int number){ + if(beg>end){ + return -1; + } + int mid = (beg+end)/2; + if(number == input[mid]){ + return mid; + } + //Search left sub array + if(number>n; + // Create An array Of size n Dynamically + int *input = new int[n]; + //Take Input Array in Ascending Order + for(int i=0;i>input[i]; + } + //Take number to be searched + cin>>number; + //call the recursive function + int index = binarySearch(input,0,n-1,number); + if(index!=-1){ + cout< + +using namespace std; + +vector split_string(string); + +/* + * Complete the candlesCounting function below. + */ +int candlesCounting(int k, vector> candles) { + /* + * Write your code here. + */ + +} + +int main() +{ + ofstream fout(getenv("OUTPUT_PATH")); + + string nk_temp; + getline(cin, nk_temp); + + vector nk = split_string(nk_temp); + + int n = stoi(nk[0]); + + int k = stoi(nk[1]); + + vector> candles(n); + for (int candles_row_itr = 0; candles_row_itr < n; candles_row_itr++) { + candles[candles_row_itr].resize(2); + + for (int candles_column_itr = 0; candles_column_itr < 2; candles_column_itr++) { + cin >> candles[candles_row_itr][candles_column_itr]; + } + + cin.ignore(numeric_limits::max(), '\n'); + } + + int result = candlesCounting(k, candles); + + fout << result << "\n"; + + fout.close(); + + return 0; +} + +vector split_string(string input_string) { + string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { + return x == y and x == ' '; + }); + + input_string.erase(new_end, input_string.end()); + + while (input_string[input_string.length() - 1] == ' ') { + input_string.pop_back(); + } + + vector splits; + char delimiter = ' '; + + size_t i = 0; + size_t pos = input_string.find(delimiter); + + while (pos != string::npos) { + splits.push_back(input_string.substr(i, pos - i)); + + i = pos + 1; + pos = input_string.find(delimiter, i); + } + + splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); + + return splits; +} diff --git a/out/production/Hacktoberfest/DiscountFinder.cpp b/out/production/Hacktoberfest/DiscountFinder.cpp new file mode 100644 index 00000000..d0877d20 --- /dev/null +++ b/out/production/Hacktoberfest/DiscountFinder.cpp @@ -0,0 +1,46 @@ +#include +#include +#include + +double off(float billPrice, float disc); + +int main() +{ + system("color 0A"); + using namespace std; + + float billPrice; + + cout << "\nEnter the bill value\n"; + cin >> billPrice; + + if (billPrice >= 2000) + { + if (billPrice >= 5000) + { + if (billPrice >= 10000) + cout << "\nYou got a discount of 10%. \nYour net payment is " << off(billPrice, 10) << '\n'; + else + cout << "\nYou got a discount of 5%. \nYour net payment is " << off(billPrice, 5) << '\n'; + } + else + cout << "\nYou got a discount of 2%. \nYour net payment is " << off(billPrice, 2) << '\n'; + } + else + cout << "\nSorry! You couldn't receive any discount on this bill. \nYour net payment is " << off(billPrice, 0) << '\n'; + + system("pause"); + + return 0; + +} + +double off(float billPrice, float disc) +{ + float netPrice; + + netPrice = billPrice - ((billPrice / 100) * disc); + + return (netPrice); + +} diff --git a/out/production/Hacktoberfest/HelloWorld.py b/out/production/Hacktoberfest/HelloWorld.py new file mode 100644 index 00000000..64521851 --- /dev/null +++ b/out/production/Hacktoberfest/HelloWorld.py @@ -0,0 +1,2 @@ +if __name__ == '__main__': + print("Hello, World!") \ No newline at end of file diff --git a/out/production/Hacktoberfest/MinMax.py b/out/production/Hacktoberfest/MinMax.py new file mode 100644 index 00000000..e5163be6 --- /dev/null +++ b/out/production/Hacktoberfest/MinMax.py @@ -0,0 +1,7 @@ +m=input() +arr=m.split(" ") +arrInt=list(map(int,arr)) +sum=0 +for i in arrInt: + sum+=i +print(sum-max(arrInt),sum-min(arrInt)) diff --git a/out/production/Hacktoberfest/SOLVE_ME_FIRST.javascript b/out/production/Hacktoberfest/SOLVE_ME_FIRST.javascript new file mode 100644 index 00000000..32ffdf10 --- /dev/null +++ b/out/production/Hacktoberfest/SOLVE_ME_FIRST.javascript @@ -0,0 +1,32 @@ +process.stdin.resume(); +process.stdin.setEncoding('ascii'); + +var input_stdin = ""; +var input_stdin_array = ""; +var input_currentline = 0; + +process.stdin.on('data', function (data) { + input_stdin += data; +}); + +process.stdin.on('end', function () { + input_stdin_array = input_stdin.split("\n"); + main(); +}); + +function readLine() { + return input_stdin_array[input_currentline++]; +} + +function solveMeFirst(a, b) { + return a + b; +} + + +function main() { + var a = parseInt(readLine()); + var b = parseInt(readLine());; + + var res = solveMeFirst(a, b); + console.log(res); +} diff --git a/out/production/Hacktoberfest/Smiley_pattern.cpp b/out/production/Hacktoberfest/Smiley_pattern.cpp new file mode 100644 index 00000000..b33a281b --- /dev/null +++ b/out/production/Hacktoberfest/Smiley_pattern.cpp @@ -0,0 +1,15 @@ +#include +#include +void main() +{ clrscr(); + int n; + cout<<"Enter the number of rows ="; + cin>>n; + char ch=1; + for(int i=0,i + +using namespace std; + +vector split_string(string); + +// Complete the countApplesAndOranges function below. +void countApplesAndOranges(int s, int t, int a, int b, vector apples, vector oranges,int m,int n) { + int apple=0,orange=0; + for(int i=0;i=s && (apples[i]+a)<=t) + { + apple++; + } + + } + + for(int i=0;i0) + continue; + if((b+oranges[i])>=s && (b+oranges[i])<=t) + { + orange++; + } + + } + cout< st = split_string(st_temp); + + int s = stoi(st[0]); + + int t = stoi(st[1]); + + string ab_temp; + getline(cin, ab_temp); + + vector ab = split_string(ab_temp); + + int a = stoi(ab[0]); + + int b = stoi(ab[1]); + + string mn_temp; + getline(cin, mn_temp); + + vector mn = split_string(mn_temp); + + int m = stoi(mn[0]); + + int n = stoi(mn[1]); + + string apples_temp_temp; + getline(cin, apples_temp_temp); + + vector apples_temp = split_string(apples_temp_temp); + + vector apples(m); + + for (int i = 0; i < m; i++) { + int apples_item = stoi(apples_temp[i]); + + apples[i] = apples_item; + } + + string oranges_temp_temp; + getline(cin, oranges_temp_temp); + + vector oranges_temp = split_string(oranges_temp_temp); + + vector oranges(n); + + for (int i = 0; i < n; i++) { + int oranges_item = stoi(oranges_temp[i]); + + oranges[i] = oranges_item; + } + + countApplesAndOranges(s, t, a, b, apples, oranges,m,n); + + return 0; +} + +vector split_string(string input_string) { + string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { + return x == y and x == ' '; + }); + + input_string.erase(new_end, input_string.end()); + + while (input_string[input_string.length() - 1] == ' ') { + input_string.pop_back(); + } + + vector splits; + char delimiter = ' '; + + size_t i = 0; + size_t pos = input_string.find(delimiter); + + while (pos != string::npos) { + splits.push_back(input_string.substr(i, pos - i)); + + i = pos + 1; + pos = input_string.find(delimiter, i); + } + + splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); + + return splits; +} diff --git a/out/production/Hacktoberfest/array-left-rotation.cpp b/out/production/Hacktoberfest/array-left-rotation.cpp new file mode 100644 index 00000000..ebbbc647 --- /dev/null +++ b/out/production/Hacktoberfest/array-left-rotation.cpp @@ -0,0 +1,20 @@ +#include + +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; +} diff --git a/out/production/Hacktoberfest/arrays-ds.cpp b/out/production/Hacktoberfest/arrays-ds.cpp new file mode 100644 index 00000000..cfb167cb --- /dev/null +++ b/out/production/Hacktoberfest/arrays-ds.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + + +int main(){ + int n; + cin >> n; + vector arr(n); + for(int arr_i = 0;arr_i < n;arr_i++){ + cin >> arr[arr_i]; + } + for(int arr_i = n-1;arr_i >= 0;arr_i--){ + cout << arr[arr_i]<<" "; + } + return 0; +} + diff --git a/out/production/Hacktoberfest/climbing_the_leaderboard.py b/out/production/Hacktoberfest/climbing_the_leaderboard.py new file mode 100644 index 00000000..80e262e1 --- /dev/null +++ b/out/production/Hacktoberfest/climbing_the_leaderboard.py @@ -0,0 +1,94 @@ +# Problem Link: https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem + +# Complete the climbingLeaderboard function below. +def climbingLeaderboard(scores, alice): + + def binsrch(scores,num): + """ + A binary search function that searches for a particular score in the scores + array, and returns a tuple containing the possible location of the scores + in the list and a boolean to show if the score existed in the list. + + Parameters + ------------------------------- + scores: list[int] + list of scores + num: int + integer to be searched in the scores list + + Returns + -------------------------------- + (pos,isFound): (int,bool) + a tuple containing the (possilbe) position of num in the scores array + and a boolean to indicate if the score was found in the array. + + """ + start = 0 + end = len(scores)-1 + + while start<=end: + mid = start + int((end-start)/2) + + if scores[mid]>num: + start = mid+1 + elif scores[mid] +#define ll long long +#define vll vector +#define llin(a) ll a; cin>>a; +#define llin2(a,b) ll a,b; cin>>a>>b; +#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c; +#define fulll(v) v.begin(),v.end() +#define vecin(n, v) for(ll i=0; i>v[i]; +#define vecout(n, v) for(ll i=0; i=n;i--) +#define pb push_back +#define mp make_pair +#define endl "\n" +#define test cout<<"test line"< +#define vpll vector +#define mod 1000000007 +#define INF 0x3f3f3f3f +using namespace std; + + + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + llin2(m,n); + vll v(n); + vecin(n,v); + ll dp[m+1]={0}; + dp[0]=1; + rep(i,1,n+1){ + rep(j,1,m+1){ + if(v[i-1]<=j) + dp[j]+=dp[j-v[i-1]]; + } + } + cout<(Console.ReadLine().Trim().Split(' '), e => int.Parse(e)); + int[] coins = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), e => int.Parse(e)); + int sum = l0[0]; + int n = l0[1]; + for(int i = 0; i < 52; i++) + { + for(int j = 0; j < 252; j++) + { + dp[i, j] = -1; + } + } + + Console.WriteLine(calculate(coins, sum, n - 1, 0)); + } + + public static long calculate(int[] coins, int sum, int numCoin, int i) + { + if(sum == 0) + { + return 1; + } + + if(sum < 0) + { + return 0; + } + + if(i > numCoin) + { + return 0; + } + + if(dp[i, sum] == -1) + { + dp[i, sum] = calculate(coins, sum, numCoin, i + 1) + calculate(coins, sum - coins[i], numCoin, i); + } + + return dp[i, sum]; + } + } +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/compare-the-triplets.cpp b/out/production/Hacktoberfest/compare-the-triplets.cpp new file mode 100644 index 00000000..6ba8a47e --- /dev/null +++ b/out/production/Hacktoberfest/compare-the-triplets.cpp @@ -0,0 +1,109 @@ +#include + +using namespace std; + +string ltrim(const string &); +string rtrim(const string &); +vector split(const string &); + +// Complete the compareTriplets function below. +vector compareTriplets(vector a, vector b) { + vector c = {0,0}; + + for(int i = 0; i < a.size(); i++) { + if(a[i] > b[i]) { + c[0] += 1; + } + else if (b[i] > a[i]){ + c[1] += 1; + } + } + + return c; +} + +int main() +{ + ofstream fout(getenv("OUTPUT_PATH")); + + string a_temp_temp; + getline(cin, a_temp_temp); + + vector a_temp = split(rtrim(a_temp_temp)); + + vector a(3); + + for (int i = 0; i < 3; i++) { + int a_item = stoi(a_temp[i]); + + a[i] = a_item; + } + + string b_temp_temp; + getline(cin, b_temp_temp); + + vector b_temp = split(rtrim(b_temp_temp)); + + vector b(3); + + for (int i = 0; i < 3; i++) { + int b_item = stoi(b_temp[i]); + + b[i] = b_item; + } + + vector result = compareTriplets(a, b); + + for (int i = 0; i < result.size(); i++) { + fout << result[i]; + + if (i != result.size() - 1) { + fout << " "; + } + } + + fout << "\n"; + + fout.close(); + + return 0; +} + +string ltrim(const string &str) { + string s(str); + + s.erase( + s.begin(), + find_if(s.begin(), s.end(), not1(ptr_fun(isspace))) + ); + + return s; +} + +string rtrim(const string &str) { + string s(str); + + s.erase( + find_if(s.rbegin(), s.rend(), not1(ptr_fun(isspace))).base(), + s.end() + ); + + return s; +} + +vector split(const string &str) { + vector tokens; + + string::size_type start = 0; + string::size_type end = 0; + + while ((end = str.find(" ", start)) != string::npos) { + tokens.push_back(str.substr(start, end - start)); + + start = end + 1; + } + + tokens.push_back(str.substr(start)); + + return tokens; +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/compare-the-triplets.py b/out/production/Hacktoberfest/compare-the-triplets.py new file mode 100644 index 00000000..570481dc --- /dev/null +++ b/out/production/Hacktoberfest/compare-the-triplets.py @@ -0,0 +1,38 @@ +#!/bin/python + +import math +import os +import random +import re +import sys + +# Complete the compareTriplets function below. +def compareTriplets(a, b): + alice=0 + bob=0 + for i in range(0,3) : + if(a[i]>b[i]): + alice+=1 + if(a[i] +#include +using namespace std; + +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/out/production/Hacktoberfest/cpp-hello-world-v2.cpp b/out/production/Hacktoberfest/cpp-hello-world-v2.cpp new file mode 100644 index 00000000..c08de498 --- /dev/null +++ b/out/production/Hacktoberfest/cpp-hello-world-v2.cpp @@ -0,0 +1,7 @@ +#include +using namespace std; + +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/out/production/Hacktoberfest/detect-whether-a-linked-list-contains-a-cycle.cpp b/out/production/Hacktoberfest/detect-whether-a-linked-list-contains-a-cycle.cpp new file mode 100644 index 00000000..e80f9c96 --- /dev/null +++ b/out/production/Hacktoberfest/detect-whether-a-linked-list-contains-a-cycle.cpp @@ -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; + } + } +} diff --git a/out/production/Hacktoberfest/dynamic-programming-classics-the-longest-common-subsequence.cpp b/out/production/Hacktoberfest/dynamic-programming-classics-the-longest-common-subsequence.cpp new file mode 100644 index 00000000..870f202f --- /dev/null +++ b/out/production/Hacktoberfest/dynamic-programming-classics-the-longest-common-subsequence.cpp @@ -0,0 +1,67 @@ +#include +#define ll long long +#define vll vector +#define llin(a) ll a; cin>>a; +#define llin2(a,b) ll a,b; cin>>a>>b; +#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c; +#define fulll(v) v.begin(),v.end() +#define vecin(n, v) for(ll i=0; i>v[i]; +#define vecout(n, v) for(ll i=0; i=n;i--) +#define pb push_back +#define mp make_pair +#define endl "\n" +#define test cout<<"test line"< +#define vpll vector +#define mod 1000000007 +#define INF 0x3f3f3f3f +using namespace std; + + + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + + llin2(n,m); + vll v(n); + vecin(n,v); + vll w(m); + vecin(m,w); + ll dp[n+1][m+1]; + rep(i,0,m+1) + dp[0][i]=0; + rep(i,0,n+1) + dp[i][0]=0; + rep(i,1,n+1) + { + rep(j,1,m+1) + { + if(v[i-1]==w[j-1]) + dp[i][j]=1+dp[i-1][j-1]; + else + dp[i][j]=max(dp[i-1][j], dp[i][j-1]); + } + } + string s=""; + for(ll i=n, j=m; i>0&&j>0;){ + if(v[i-1]==w[j-1]){ + s=to_string(v[i-1])+" "+s; + i--; + j--; + } + else if(dp[i][j-1]>dp[i-1][j]) + j--; + else + i--; + } + cout< 0 -> ( + print_endline "Hello World"; + f (x - 1) + ) +| _ -> ();; + +f (read_int()) \ No newline at end of file diff --git a/out/production/Hacktoberfest/fraudulent-activity-notifications.cpp b/out/production/Hacktoberfest/fraudulent-activity-notifications.cpp new file mode 100644 index 00000000..249f4ccf --- /dev/null +++ b/out/production/Hacktoberfest/fraudulent-activity-notifications.cpp @@ -0,0 +1,86 @@ +import java.io.*; +import java.util.*; + +public class Solution { + + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + int n = input.nextInt(); + int d = input.nextInt(); + int notifications = 0; + Queue queue = new LinkedList<>(); + int[] pastActivity = new int[201]; + + for(int i = 0; i < d; i++) + { + int transaction = input.nextInt(); + queue.offer(transaction); + pastActivity[transaction] = pastActivity[transaction]+1; + } + + for(int i = 0; i < n-d; i++) + { + int newTransaction = input.nextInt(); + + if(newTransaction >= (2* median(pastActivity, d))) + notifications++; + + int oldestTransaction = queue.poll(); + pastActivity[oldestTransaction] = pastActivity[oldestTransaction]-1; + queue.offer(newTransaction); + pastActivity[newTransaction] = pastActivity[newTransaction]+1; + } + + System.out.println(notifications); + } + + static double median(int[] array, int elements) + { + int index = 0; + + if(elements % 2 == 0) + { + int counter = (elements / 2); + + while(counter > 0) + { + counter -= array[index]; + index++; + } + index--; + if(counter <= -1) + return index; + else + { + int firstIndex = index; + int secondIndex = index+1; + while(array[secondIndex] == 0) + { + secondIndex++; + } + return (double) (firstIndex + secondIndex) / 2.0; + } + } + else//Find median of odd # of elements + { + int counter = (elements / 2); + + while(counter >= 0) + { + counter -= array[index]; index++; + } + return (double) index-1; + } + } + + + static void printArray(int[] array) + { + System.out.println("Array"); + for(int i = 0; i < array.length; i++) + { + if(array[i] > 0) + System.out.println(i+" : "+array[i]); + } + } +} diff --git a/out/production/Hacktoberfest/functions-in-c.c b/out/production/Hacktoberfest/functions-in-c.c new file mode 100644 index 00000000..d7b50fdd --- /dev/null +++ b/out/production/Hacktoberfest/functions-in-c.c @@ -0,0 +1,13 @@ +#include +/* +Add `int max_of_four(int a, int b, int c, int d)` here. +*/ + +int main() { + int a, b, c, d; + scanf("%d %d %d %d", &a, &b, &c, &d); + int ans = max_of_four(a, b, c, d); + printf("%d", ans); + + return 0; +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/getRemoteSocketIo.js b/out/production/Hacktoberfest/getRemoteSocketIo.js new file mode 100644 index 00000000..a60ec60a --- /dev/null +++ b/out/production/Hacktoberfest/getRemoteSocketIo.js @@ -0,0 +1,13 @@ +module.exports = { + getRemoteAddress(client) { + const { address, port, family } = client.conn.request.connection._getpeername(); + // debug(`Client ${client.id} ([${family}]${address}:${port}) is connected.`); + return { + address, + port, + family, + full: `[${family}]${address}:${port}`, + remote: `${address}:${port}`, + }; + }, +}; diff --git a/out/production/Hacktoberfest/kangaroo.js b/out/production/Hacktoberfest/kangaroo.js new file mode 100644 index 00000000..ae94628a --- /dev/null +++ b/out/production/Hacktoberfest/kangaroo.js @@ -0,0 +1,19 @@ +// This algorithm determines whether two 'kangaroos' ever jump into the same +// position simultaneously, given each kangaroo's starting position and +// jumping distance. +// x1, v1: integers, starting position and jump distance for kangaroo 1 +// x2, v2: integers, starting position and jump distance for kangaroo 2 +function kangaroo(x1, v1, x2, v2){ + let i = 1 + while (i < 10000) { + x1 += v1; + x2 += v2; + if (x1 == x2) { + return 'YES' + } + i++ + } + return 'NO' +} +let x1 = 1, v1 = 3, x2 = 4, v2 = 2 +console.log(kangaroo(x1, v1 , x2, v2)); \ No newline at end of file diff --git a/out/production/Hacktoberfest/list-comprehension.py b/out/production/Hacktoberfest/list-comprehension.py new file mode 100644 index 00000000..1cec0965 --- /dev/null +++ b/out/production/Hacktoberfest/list-comprehension.py @@ -0,0 +1,11 @@ +# Let's learn about list comprehensions! You are given three integers X, Y and Z representing the dimensions of a cuboid along with an integer N. You have to print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i + j +k is not equal to N. + +if __name__ == '__main__': + x = int(input()) + y = int(input()) + z = int(input()) + n = int(input()) + + t = [[i,j,k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if ( i + j + k) != n] + + print(t) \ No newline at end of file diff --git a/out/production/Hacktoberfest/longest-increasing-subsequent.cpp b/out/production/Hacktoberfest/longest-increasing-subsequent.cpp new file mode 100644 index 00000000..e35d6816 --- /dev/null +++ b/out/production/Hacktoberfest/longest-increasing-subsequent.cpp @@ -0,0 +1,57 @@ +#include +#define ll long long +#define vll vector +#define llin(a) ll a; cin>>a; +#define llin2(a,b) ll a,b; cin>>a>>b; +#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c; +#define fulll(v) v.begin(),v.end() +#define vecin(n, v) for(ll i=0; i>v[i]; +#define vecout(n, v) for(ll i=0; i=n;i--) +#define pb push_back +#define mp make_pair +#define endl "\n" +#define test cout<<"test line"< +#define vpll vector +#define mod 1000000007 +#define INF 0x3f3f3f3f +using namespace std; + +int bs(vll &v, int l, int r, int key) { + while (r-l > 1) { + int m = l + (r-l)/2; + if (v[m] >= key) + r = m; + else + l = m; + } + + return r; +} + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + llin(n); + vll v(n),w(n,0); + vecin(n,v) + w[0]=v[0]; + ll c=1; + rep(i,1,n) + { + if(v[i]w[c-1]) + w[c++]=v[i]; + else + w[bs(w,-1,c-1,v[i])]=v[i]; + } + cout< +#include +#include + +using namespace std; + +int main() { + string sen; + getline(cin,sen); + transform(sen.begin(), sen.end(), sen.begin(), ::tolower); + set letters; + + for (size_t i = 0; i < sen.size(); i++){ + if (isalpha(sen[i])) { + letters.insert(sen[i]); + } + } + if (letters.size() == 26) { + cout << "pangram" << endl; + } else { + cout << "not pangram" << endl; + } + return 0; +} diff --git a/out/production/Hacktoberfest/police-operation.cpp b/out/production/Hacktoberfest/police-operation.cpp new file mode 100644 index 00000000..c57ad494 --- /dev/null +++ b/out/production/Hacktoberfest/police-operation.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +using namespace std; + +long long dp[2000001]; +int a[2000000]; + +struct line{ + long long a,b; + + line(){} + line(long long _a, long long _b): + a(_a),b(_b){} +}; + +line H[2000000]; +int nh = 0,cur = 0; + +void add(long long m, long long b){ + while(nh >= 2 && (b - H[nh - 2].b) * (H[nh - 2].a - H[nh - 1].a) <= (H[nh - 1].b - H[nh - 2].b) * (H[nh - 2].a - m)){ + --nh; + cur = max(cur - 1,0); + } + + H[nh++] = line(m,b); +} + +long long eval(int pos, long long x){ + return H[pos].a * x + H[pos].b; +} + +long long query(long long x){ + while(cur + 1 < nh && eval(cur + 1,x) < eval(cur,x)) ++cur; + + return eval(cur,x); +} + +int main(){ + int n,h; + + scanf("%d %d",&n,&h); + + for(int i = 0;i < n;++i) + scanf("%d",&a[i]); + + sort(a,a + n); + + dp[0] = 0; + + for(int i = 0;i < n;++i){ + add(-2 * a[i],(long long)a[i] * a[i] + dp[i] + h); + + dp[i + 1] = query(a[i]) + (long long)a[i] * a[i]; + } + + printf("%lld\n",dp[n]); + + return 0; +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/sherlockAndCost.py b/out/production/Hacktoberfest/sherlockAndCost.py new file mode 100644 index 00000000..37c8a3b8 --- /dev/null +++ b/out/production/Hacktoberfest/sherlockAndCost.py @@ -0,0 +1,33 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the cost function below. +def cost(b): + n=len(b) + l, h = 0, 0 + for i in range(1, n): + l, h = (max(l, h + b[i - 1] - 1), + max(l + b[i] - 1, h + abs(b[i] - b[i - 1]))) + return max(l, h) + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + t = int(input()) + + for t_itr in range(t): + n = int(input()) + + B = list(map(int, input().rstrip().split())) + + result = cost(B) + + fptr.write(str(result) + '\n') + + fptr.close() + diff --git a/out/production/Hacktoberfest/simple-array-sum.c b/out/production/Hacktoberfest/simple-array-sum.c new file mode 100644 index 00000000..f1fdf8f8 --- /dev/null +++ b/out/production/Hacktoberfest/simple-array-sum.c @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include +#include +#include + +char* readline(); +char** split_string(char*); + +/* + * Complete the simpleArraySum function below. + */ +int simpleArraySum(int ar_count, int* ar) { + int sum = 0; + for (int i = 0; i < ar_count; i++) { + sum += ar[i]; + } + return sum; +} + +int main() +{ + FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w"); + + char* ar_count_endptr; + char* ar_count_str = readline(); + int ar_count = strtol(ar_count_str, &ar_count_endptr, 10); + + if (ar_count_endptr == ar_count_str || *ar_count_endptr != '\0') { exit(EXIT_FAILURE); } + + char** ar_temp = split_string(readline()); + + int ar[ar_count]; + + for (int ar_itr = 0; ar_itr < ar_count; ar_itr++) { + char* ar_item_endptr; + char* ar_item_str = ar_temp[ar_itr]; + int ar_item = strtol(ar_item_str, &ar_item_endptr, 10); + + if (ar_item_endptr == ar_item_str || *ar_item_endptr != '\0') { exit(EXIT_FAILURE); } + + ar[ar_itr] = ar_item; + } + + int result = simpleArraySum(ar_count, ar); + + fprintf(fptr, "%d\n", result); + + fclose(fptr); + + return 0; +} + +char* readline() { + size_t alloc_length = 1024; + size_t data_length = 0; + char* data = malloc(alloc_length); + + while (true) { + char* cursor = data + data_length; + char* line = fgets(cursor, alloc_length - data_length, stdin); + + if (!line) { break; } + + data_length += strlen(cursor); + + if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; } + + size_t new_length = alloc_length << 1; + data = realloc(data, new_length); + + if (!data) { break; } + + alloc_length = new_length; + } + + if (data[data_length - 1] == '\n') { + data[data_length - 1] = '\0'; + } + + data = realloc(data, data_length); + + return data; +} + +char** split_string(char* str) { + char** splits = NULL; + char* token = strtok(str, " "); + + int spaces = 0; + + while (token) { + splits = realloc(splits, sizeof(char*) * ++spaces); + if (!splits) { + return splits; + } + + splits[spaces - 1] = token; + + token = strtok(NULL, " "); + } + + return splits; +} diff --git a/out/production/Hacktoberfest/solve-me-first.javascript b/out/production/Hacktoberfest/solve-me-first.javascript new file mode 100644 index 00000000..f8b6dfe6 --- /dev/null +++ b/out/production/Hacktoberfest/solve-me-first.javascript @@ -0,0 +1,32 @@ +process.stdin.resume(); +process.stdin.setEncoding('ascii'); + +var input_stdin = ""; +var input_stdin_array = ""; +var input_currentline = 0; + +process.stdin.on('data', function (data) { + input_stdin += data; +}); + +process.stdin.on('end', function () { + input_stdin_array = input_stdin.split("\n"); + main(); +}); + +function readLine() { + return input_stdin_array[input_currentline++]; +} + +function solveMeFirst(a, b) { + return a+b; +} + + +function main() { + var a = parseInt(readLine()); + var b = parseInt(readLine());; + + var res = solveMeFirst(a, b); + console.log(res); +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/solve-me-first.py b/out/production/Hacktoberfest/solve-me-first.py new file mode 100644 index 00000000..7ace63fc --- /dev/null +++ b/out/production/Hacktoberfest/solve-me-first.py @@ -0,0 +1,9 @@ + + +def solveMeFirst(a,b): + return a+b + +num1 = int(input()) +num2 = int(input()) +res = solveMeFirst(num1,num2) +print(res) diff --git a/out/production/Hacktoberfest/staircase.cpp b/out/production/Hacktoberfest/staircase.cpp new file mode 100644 index 00000000..5a6f2470 --- /dev/null +++ b/out/production/Hacktoberfest/staircase.cpp @@ -0,0 +1,35 @@ +#include +#include + +using namespace std; + +void staircase(int n) { + for (int i = 0; i < n; i++) + { + int j = n; + while (j > i + 1) + { + cout << ' '; + j--; + } + int k = 0; + while (k <= i) + { + cout << '#'; + k++; + } + cout << '\n'; + } + +} + +int main() +{ + int n; + cin >> n; + cin.ignore(numeric_limits::max(), '\n'); + + staircase(n); + + return 0; +} diff --git a/out/production/Hacktoberfest/stockmax.cpp b/out/production/Hacktoberfest/stockmax.cpp new file mode 100644 index 00000000..585e0f68 --- /dev/null +++ b/out/production/Hacktoberfest/stockmax.cpp @@ -0,0 +1,53 @@ +#include +#define ll long long +#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); +#define vll vector +#define llin(a) ll a; cin>>a; +#define llin2(a,b) ll a,b; cin>>a>>b; +#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c; +#define fulll(v) v.begin(),v.end() +#define vecin(n, v) for(ll i=0; i>v[i]; +#define vecout(n, v) for(ll i=0; i=n;i--) +#define pb push_back +#define mkp make_pair +#define endl "\n" +#define test cout<<"test line"< +#define vpll vector +#define mod 1000000007 +#define INF 0x3f3f3f3f +using namespace std; + + + +int main() +{ + fast + + llin(t); + while(t--) + { + llin(n); + vll v; + cin.ignore(); + string s; + getline(cin,s); + stringstream str(s); + ll x;n=0; + while(str>>x){ + v.pb(x); + n++; + } + ll mx=0;x=0; + rrep(i,n-1,0){ + mx=max(v[i],mx); + x+=mx-v[i]; + //cout< sum += val, 0) + } + let segs = 0 + for (let i = 0; i < s.length-m; i++) { + if (sumFrag(s.slice(i, i+m)) === d) segs++; + } + return segs +} \ No newline at end of file diff --git a/out/production/Hacktoberfest/the-time-in-words.js b/out/production/Hacktoberfest/the-time-in-words.js new file mode 100644 index 00000000..b14c5b25 --- /dev/null +++ b/out/production/Hacktoberfest/the-time-in-words.js @@ -0,0 +1,43 @@ +// example input -> 5, 47 +// example output -> thirteen minutes to six + +function timeInWords(h, m) { + const incNums = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", "seventeen", "eighteen", "nineteen"]; + const tens = ["", "", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"]; + let sayHour = incNums[h]; + let sayMinute, sayTens, sayIncNums, relation, minutes; + if (m === 0) { + return sayHour + " o' clock" + } else if (m === 30) { + return "half past " + sayHour; + } else if (m < 30) { + relation = "past" + } else if (m > 30){ + relation = "to"; + sayHour = incNums[h + 1] + } + + if (m === 45 || m === 15) { + minutes = "quarter"; + } else if (m < 20) { + sayMinute = incNums[m]; + } else if (m > 40){ + minutes = incNums[60 - m]; + } else { + if (m < 30) { + sayTens = tens[parseInt(m.toString().split('')[0])]; + } else { + sayTens = tens[parseInt(m.toString().split('')[0]) - 1]; + } + sayIncNums = incNums[parseInt(m.toString().split('')[1])]; + minutes = sayIncNums ? sayTens + " " + sayIncNums : sayTens; + } + minutes = minutes || sayMinute; + + if (minutes === "quarter") { + return `${minutes} ${relation} ${sayHour}` + } else if (minutes === "one") { + return `${minutes} minute ${relation} ${sayHour}` + } + return `${minutes} minutes ${relation} ${sayHour}` +} diff --git a/out/production/Hacktoberfest/time-conversion.rb b/out/production/Hacktoberfest/time-conversion.rb new file mode 100644 index 00000000..aee0e36f --- /dev/null +++ b/out/production/Hacktoberfest/time-conversion.rb @@ -0,0 +1,38 @@ +# Given a time in -hour AM/PM format, +# convert it to military (24-hour) time. + + +def timeConversion(s) # Example s = 07:05:45PM string + day = s[8..9] + s_arr = s[0..7].split(":") + hrs = s_arr[0].to_i + if (hrs >= 1 )&& (hrs < 12) && (day == "AM") # if the hours are from 1 am to 11:59 AM + return s[0..7] + elsif hrs == 12 + if day == "AM" # 12 AM -- 00 + s_arr[0] = "00" + elsif day == "PM" + return s[0..7] + end + elsif day == "PM" + s_arr[0] = "#{s_arr[0].to_i + 12}" + end + return s_arr.join(":") +end + +# test cases +# p timeConversion("12:05:45AM") + " = 12:05:45" +# p timeConversion("01:05:45AM") + " = 01:05:45" +# p timeConversion("02:05:45AM") + " = 02:05:45" +# p timeConversion("05:05:45AM") + " = 05:05:45" +# p timeConversion("08:05:45AM") + " = 08:05:45" +# p timeConversion("10:05:45AM") + " = 10:05:45" +# p timeConversion("11:05:45AM") + " = 11:05:45" +# p timeConversion("12:05:45PM") + " = 12:05:45" +# p timeConversion("01:05:45PM") + " = 13:05:45" +# p timeConversion("02:05:45PM") + " = 14:05:45" +# p timeConversion("05:05:45PM") + " = 17:05:45" +# p timeConversion("07:05:45PM") + " = 19:05:45" +# p timeConversion("10:05:45PM") + " = 22:05:45" +# p timeConversion("11:05:45PM") + " = 23:05:45" +# p timeConversion("12:00:00AM") + " = 00:00:00" diff --git a/out/production/Hacktoberfest/torque-and-development.cs b/out/production/Hacktoberfest/torque-and-development.cs new file mode 100644 index 00000000..e2096c17 --- /dev/null +++ b/out/production/Hacktoberfest/torque-and-development.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace ConsoleApplication +{ + public class Graph + { + public List> g; + public bool[] visited; + public int vertices; + public static long cr = 0; + public static long cl = 0; + public static long total = 0; + public static long temp = 0; + + public Graph(int n) + { + this.g = new List>(); + for(int i =0; i < n; i++) + { + g.Add(new List()); + } + visited = new bool[n]; + this.vertices = n; + Graph.total = 0; + } + + public void MinCost() + { + for(int i = 0; i < this.vertices; i++) + { + if(this.visited[i] == false) + { + util(i); + total += Math.Min(cl + (temp - 1) * cr, temp * cl); + temp = 0; + } + } + } + + private void util(int v) + { + visited[v] = true; + ++temp; + foreach(int i in g[v]) + { + if(visited[i] == false) + { + util(i); + } + } + } + } + class Program + { + static void Main(string[] args) + { + int q = int.Parse(Console.ReadLine()); + while(q != 0) + { + int[] ar = Array.ConvertAll(Console.ReadLine().Split(' '), e => int.Parse(e)); + int m = ar[1]; + Graph city = new Graph(ar[0]); + Graph.cl = ar[2]; + Graph.cr = ar[3]; + + for (int i = 0; i < m; i++) + { + int[] l = Array.ConvertAll(Console.ReadLine().Split(' '), e => int.Parse(e)); + city.g[l[0] - 1].Add(l[1] - 1); + city.g[l[1] - 1].Add(l[0] - 1); + } + city.MinCost(); + Console.WriteLine(Graph.total); + q--; + } + } + } +} diff --git a/out/production/Hacktoberfest/word-order.py b/out/production/Hacktoberfest/word-order.py new file mode 100644 index 00000000..e79101f4 --- /dev/null +++ b/out/production/Hacktoberfest/word-order.py @@ -0,0 +1,22 @@ +# Problem link: https://www.hackerrank.com/challenges/word-order/problem + +num = int(input()) +dic = {} +words = [] +for i in range(num): + word = input() + if word not in dic: + dic[word] = 1 + words.append(word) + + else: + dic[word] += 1 + +line = "" +for key in words: + line += str(dic[key])+ " " + +line = line.rstrip(' ') + +print(len(dic)) +print(line) \ No newline at end of file