From becf8a7cd2382136cfec4f6d68d2c97b91ab79f2 Mon Sep 17 00:00:00 2001 From: Yash Agarwal <38498671+yashagarwal1999@users.noreply.github.com> Date: Sat, 19 Oct 2019 12:43:22 +0530 Subject: [PATCH 1/8] Solved #162 Solved Largest sum of consecutive numbers in an array in cpp #162 --- cplusplus/kandaane.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cplusplus/kandaane.cpp diff --git a/cplusplus/kandaane.cpp b/cplusplus/kandaane.cpp new file mode 100644 index 00000000..5c4b9674 --- /dev/null +++ b/cplusplus/kandaane.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; +typedef long long int ll; +pair maxsum(ll arr[],ll n) +{ +ll sum=0; +ll max=0; +pairp; +ll x=0,y=0; +for(ll i=0;imax){max=sum;y=i;} +if(sum<0){sum=0;x=i+1;} + +} +p.first=x; +p.second=y; +return p; +} + +int main() +{ +int n; +cin>>n; +ll arr[n]; +for(ll i=0;i>arr[i]; +pairp=maxsum(arr,n); +cout< Date: Sat, 19 Oct 2019 12:58:39 +0530 Subject: [PATCH 2/8] Solved #96 issue Solved Valley Counting #96 in c++. If there are any changes let me know. --- cplusplus/countingvalley.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cplusplus/countingvalley.cpp diff --git a/cplusplus/countingvalley.cpp b/cplusplus/countingvalley.cpp new file mode 100644 index 00000000..8bb4a6c0 --- /dev/null +++ b/cplusplus/countingvalley.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; +typedef long long int ll; +int countingValleys(int n, string s) { + + +int sum=0; +if(s[0]=='U')sum++; +else sum--; +int count=0; +if(sum<0)count++; +for(int i=1;i>n; +string s; +cin>>s; +cout< Date: Sat, 19 Oct 2019 13:10:16 +0530 Subject: [PATCH 3/8] Solved Unique Array #323 Solved Unique Array #323 in python --- python/unique.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 python/unique.py diff --git a/python/unique.py b/python/unique.py new file mode 100644 index 00000000..ae60f8d5 --- /dev/null +++ b/python/unique.py @@ -0,0 +1,10 @@ +def getunique(arr): + finallist=[] + for i in arr: + if(i not in finallist): + finallist.append(i); + return finallist + +list1 = [10, 20, 10, 30, 40, 40] +print(getunique(list1)) + From be77d5ae660441e092147e08935121a4bc5cbb5a Mon Sep 17 00:00:00 2001 From: Yash Agarwal <38498671+yashagarwal1999@users.noreply.github.com> Date: Sat, 19 Oct 2019 13:23:09 +0530 Subject: [PATCH 4/8] Solved #78 in python Solved Pi Computation in One Line #78 in python --- python/getApproximatePiValue.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 python/getApproximatePiValue.py diff --git a/python/getApproximatePiValue.py b/python/getApproximatePiValue.py new file mode 100644 index 00000000..3a688404 --- /dev/null +++ b/python/getApproximatePiValue.py @@ -0,0 +1,4 @@ +def get_approx_pi(val): + return 4 * sum(-float(k%4 - 2) / k for k in range(1, 2*val+1, 2)) + +print(get_approx_pi(2000)) From dd85cc1ce42b8ec6a9fc0bacfb01549be1a97e83 Mon Sep 17 00:00:00 2001 From: Yash Agarwal <38498671+yashagarwal1999@users.noreply.github.com> Date: Mon, 21 Oct 2019 10:07:17 +0530 Subject: [PATCH 5/8] Delete countingvalley.cpp --- cplusplus/countingvalley.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 cplusplus/countingvalley.cpp diff --git a/cplusplus/countingvalley.cpp b/cplusplus/countingvalley.cpp deleted file mode 100644 index 8bb4a6c0..00000000 --- a/cplusplus/countingvalley.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -using namespace std; -typedef long long int ll; -int countingValleys(int n, string s) { - - -int sum=0; -if(s[0]=='U')sum++; -else sum--; -int count=0; -if(sum<0)count++; -for(int i=1;i>n; -string s; -cin>>s; -cout< Date: Mon, 21 Oct 2019 10:07:27 +0530 Subject: [PATCH 6/8] Delete kandaane.cpp --- cplusplus/kandaane.cpp | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 cplusplus/kandaane.cpp diff --git a/cplusplus/kandaane.cpp b/cplusplus/kandaane.cpp deleted file mode 100644 index 5c4b9674..00000000 --- a/cplusplus/kandaane.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -using namespace std; -typedef long long int ll; -pair maxsum(ll arr[],ll n) -{ -ll sum=0; -ll max=0; -pairp; -ll x=0,y=0; -for(ll i=0;imax){max=sum;y=i;} -if(sum<0){sum=0;x=i+1;} - -} -p.first=x; -p.second=y; -return p; -} - -int main() -{ -int n; -cin>>n; -ll arr[n]; -for(ll i=0;i>arr[i]; -pairp=maxsum(arr,n); -cout< Date: Mon, 21 Oct 2019 10:07:40 +0530 Subject: [PATCH 7/8] Delete getApproximatePiValue.py --- python/getApproximatePiValue.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 python/getApproximatePiValue.py diff --git a/python/getApproximatePiValue.py b/python/getApproximatePiValue.py deleted file mode 100644 index 3a688404..00000000 --- a/python/getApproximatePiValue.py +++ /dev/null @@ -1,4 +0,0 @@ -def get_approx_pi(val): - return 4 * sum(-float(k%4 - 2) / k for k in range(1, 2*val+1, 2)) - -print(get_approx_pi(2000)) From e633c85e72132b2c02b0395da4997b11931a3309 Mon Sep 17 00:00:00 2001 From: Yash Agarwal Date: Mon, 21 Oct 2019 10:14:24 +0530 Subject: [PATCH 8/8] Solved #162 --- ...sum_of_consecutive_numbers_in_an_array.cpp | 31 +++++++++++++++++++ .../yashagarwal1999_countingValley.cpp | 30 ++++++++++++++++++ .../python/yashagarwal1999_unique_array.py | 11 +++++++ .../yashagarwal1999_getApproximatePiValue.py | 4 +++ 4 files changed, 76 insertions(+) create mode 100644 honorary-one-line-wonders/cplusplus/yashagarwal1999_Largest _sum_of_consecutive_numbers_in_an_array.cpp create mode 100644 honorary-one-line-wonders/cplusplus/yashagarwal1999_countingValley.cpp create mode 100644 honorary-one-line-wonders/python/yashagarwal1999_unique_array.py create mode 100644 python/yashagarwal1999_getApproximatePiValue.py diff --git a/honorary-one-line-wonders/cplusplus/yashagarwal1999_Largest _sum_of_consecutive_numbers_in_an_array.cpp b/honorary-one-line-wonders/cplusplus/yashagarwal1999_Largest _sum_of_consecutive_numbers_in_an_array.cpp new file mode 100644 index 00000000..5c4b9674 --- /dev/null +++ b/honorary-one-line-wonders/cplusplus/yashagarwal1999_Largest _sum_of_consecutive_numbers_in_an_array.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; +typedef long long int ll; +pair maxsum(ll arr[],ll n) +{ +ll sum=0; +ll max=0; +pairp; +ll x=0,y=0; +for(ll i=0;imax){max=sum;y=i;} +if(sum<0){sum=0;x=i+1;} + +} +p.first=x; +p.second=y; +return p; +} + +int main() +{ +int n; +cin>>n; +ll arr[n]; +for(ll i=0;i>arr[i]; +pairp=maxsum(arr,n); +cout< +using namespace std; +typedef long long int ll; +int countingValleys(int n, string s) { + + +int sum=0; +if(s[0]=='U')sum++; +else sum--; +int count=0; +if(sum<0)count++; +for(int i=1;i>n; +string s; +cin>>s; +cout<