From 113979075f18382b58bfa102afd57f764885e35b Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:49:26 +0530 Subject: [PATCH 01/16] Update p1.py --- py/p1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py/p1.py b/py/p1.py index b648ec0..fdcefc0 100644 --- a/py/p1.py +++ b/py/p1.py @@ -7,6 +7,7 @@ def asterisk_tree(height,level): if level > height: return + print(' '*(height-level),end='') for j in range(2*level-1): print("*", end="") print() From 5fc7cae10c57864b8dcdef828937193b1d3b07ee Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:53:52 +0530 Subject: [PATCH 02/16] Update p2.py --- py/p2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/p2.py b/py/p2.py index 237c9b9..0998d66 100644 --- a/py/p2.py +++ b/py/p2.py @@ -2,7 +2,7 @@ # input- 1 -> output- [1], input- 2 -> output- [2] def add_item(item, items=[]): - items.append(item) + items=[item] return items print(add_item(1)) From d4e33848f74ab174d87d547b283f29af3d7da55a Mon Sep 17 00:00:00 2001 From: CS23I1065 <163622273+CS23I1065@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:04:15 +0530 Subject: [PATCH 03/16] Update p5.c --- c/p5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p5.c b/c/p5.c index 09475d3..977cf80 100644 --- a/c/p5.c +++ b/c/p5.c @@ -6,6 +6,6 @@ void main(){ int a=10; int *ptr = &a; - *ptr++; + (*ptr)++; printf("%d", *ptr); } From eb314a415d7f46c26e69740e4871f4b73c236b00 Mon Sep 17 00:00:00 2001 From: SathvikaMadhamshetty <163622346+SathvikaMadhamshetty@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:07:20 +0530 Subject: [PATCH 04/16] Update p13.c --- c/p13.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/c/p13.c b/c/p13.c index 753cad1..89751b5 100644 --- a/c/p13.c +++ b/c/p13.c @@ -12,8 +12,7 @@ int main(){ int n = sizeof(a)/sizeof(a[0]); int m = sizeof(b)/sizeof(b[0]); - - for(int i=0;i Date: Sat, 16 Mar 2024 10:08:52 +0530 Subject: [PATCH 05/16] Update p3.py --- py/p3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/p3.py b/py/p3.py index c83d5ad..e211252 100644 --- a/py/p3.py +++ b/py/p3.py @@ -2,7 +2,7 @@ #eg: [2, 4, 6, 17, 10] -> [17, 10] def delete_starting_evens(list): - for item in list: + while True: if list[0] % 2 == 0: list.pop(0) else: From d5fdab3afeae84c39e9abf1d0c6c2bb4099eea24 Mon Sep 17 00:00:00 2001 From: CS23I1065 <163622273+CS23I1065@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:15:56 +0530 Subject: [PATCH 06/16] Update p6.c --- c/p6.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c/p6.c b/c/p6.c index 2e46837..1677361 100644 --- a/c/p6.c +++ b/c/p6.c @@ -4,7 +4,8 @@ int *fun() { int x = 5; - return &x; + int *t=&x + return t; } int main() { From 1f9f9f64acb78a13573a7d09c7c4aebbf5edf48e Mon Sep 17 00:00:00 2001 From: CS23I1065 <163622273+CS23I1065@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:22:16 +0530 Subject: [PATCH 07/16] Update p8.c --- c/p8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p8.c b/c/p8.c index 5379851..654c7d8 100644 --- a/c/p8.c +++ b/c/p8.c @@ -5,7 +5,7 @@ float computeAverage(float* x, size_t* N) { float numerator = 0.0; float denominator = 0.0; - for (size_t i = 0; i < (size_t)N; i++) { + for (size_t i = 0; i < *N; i++) { numerator += x[i]; denominator++; } From fb59771dda1147ce0cbd7f075b87df67535c593e Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:25:18 +0530 Subject: [PATCH 08/16] Update p6.py --- py/p6.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py/p6.py b/py/p6.py index fc571ba..1f367ff 100644 --- a/py/p6.py +++ b/py/p6.py @@ -15,7 +15,6 @@ def addBinary(a: str, b: str) -> str: j -= 1 s.append(str(carry % 2)) carry //= 2 - - return ''.join(reversed(s)) + return str(carry)+''.join(reversed(s)) print(addBinary("11", "0")) From 155e69708f69be77737494c0811d379f6f60cc07 Mon Sep 17 00:00:00 2001 From: SathvikaMadhamshetty <163622346+SathvikaMadhamshetty@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:56:33 +0530 Subject: [PATCH 09/16] Update p9.c --- c/p9.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c/p9.c b/c/p9.c index 62ae10a..bf9b815 100644 --- a/c/p9.c +++ b/c/p9.c @@ -9,18 +9,18 @@ */ #include - +#include int* filterMultiples(int* arr, int N, int* NOut, int num) { int numPrimes = 0; *NOut = 0; for (int i = 0; i < N; i++) { if (arr[i] >= num && arr[i]%num == 0) { - *NOut++; + (*NOut)++; } } - int* multiples = malloc((*NOut)*sizeof(int)); + int* multiples =malloc((*NOut)*sizeof(int)); int idx = 0; - for (int i = 0; i < *NOut; i++) { + for (int i = 0; i < N; i++) { if (arr[i] >= num && arr[i]%num == 0) { multiples[idx] = arr[i]; idx++; From 5c525e21c506a2966bba86a10520267ddecf33aa Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:58:01 +0530 Subject: [PATCH 10/16] Update p9.py --- py/p9.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/py/p9.py b/py/p9.py index 4ea1c58..76f93e6 100644 --- a/py/p9.py +++ b/py/p9.py @@ -9,9 +9,12 @@ def ispangram(str1, alphabet=string.ascii_lowercase): alphaset = list(alphabet) str = list(str1.lower()) - + for i in ''.join(alphaset): + if i not in ''.join(str): + return False + # Check if all lowercase characters in the input string covers all characters in 'alphaset' - return alphaset <= str + return True # Print the result of checking if the string is a pangram by calling the 'ispangram' function print(ispangram('The quick brown fox jumps over the lazy dog')) From 0c606292b13ba29cdd15d438a56dac29272fd684 Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:02:23 +0530 Subject: [PATCH 11/16] Update p10.py --- py/p10.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/p10.py b/py/p10.py index cfc822f..7433176 100644 --- a/py/p10.py +++ b/py/p10.py @@ -1,6 +1,7 @@ #Finding Average RGB values using the listmaker fuction to generate list of rgb values for a pixel -def listmaker(r,g,b,list1=[]): +def listmaker(r,g,b): + list1=[] list1.append(r) list1.append(g) list1.append(b) From b57b0f89bb1f375f09149d394db125c34931d6ed Mon Sep 17 00:00:00 2001 From: CS23I1065 <163622273+CS23I1065@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:04:32 +0530 Subject: [PATCH 12/16] Update p14.c --- c/p14.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/c/p14.c b/c/p14.c index fdd4b97..4ae0c51 100644 --- a/c/p14.c +++ b/c/p14.c @@ -18,13 +18,18 @@ int romanToInt(char * s){ } } int num=0; - for(int i=0;i Date: Sat, 16 Mar 2024 11:15:10 +0530 Subject: [PATCH 13/16] Update p11.py --- py/p11.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/p11.py b/py/p11.py index 3d35661..df66c20 100644 --- a/py/p11.py +++ b/py/p11.py @@ -1,9 +1,9 @@ # Function to convert decimal to binary number def binaryconversion(n): - print(n % 2,end = '') - if n > 1: - binaryconversion(n/2) + if n > 1: + binaryconversion(n//2) + print(n%2,end='') number=int(input("Enter Number: ")) binaryconversion(number) From d6814e96078b52f9ea64274c93357cf890ca2c04 Mon Sep 17 00:00:00 2001 From: CS23I1065 <163622273+CS23I1065@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:22:07 +0530 Subject: [PATCH 14/16] Update p11.c --- c/p11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/p11.c b/c/p11.c index d6ef183..b67fd08 100644 --- a/c/p11.c +++ b/c/p11.c @@ -13,7 +13,7 @@ int isSameTree(struct TreeNode* p, struct TreeNode* q){ return 1; } if(p->val == q->val){ - return isSameTree(p->left, q->left) || isSameTree(p->right, q->right); + return isSameTree(p->left, q->left) && isSameTree(p->right, q->right); } return 0; } From 42f0b9d2694c984b59483b9d14ea53eb670d21d4 Mon Sep 17 00:00:00 2001 From: Sujith0513 <155612522+Sujith0513@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:30:34 +0530 Subject: [PATCH 15/16] Update p4.py --- py/p4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/p4.py b/py/p4.py index 2ae30d4..6c379cb 100644 --- a/py/p4.py +++ b/py/p4.py @@ -6,10 +6,10 @@ def countSort(arr): ans = [0 for i in range(len(arr))] for i in arr: count[i] += 1 - for i in range(k+1): + for i in range(1,k+1): count[i] += count[i-1] for i in range(len(arr)-1, -1, -1): - ans[count[arr[i]]] = arr[i] + ans[count[arr[i]]-1] = arr[i] count[arr[i]] -= 1 return ans From da94487ffcedc68fe985ee167dfbfbe277215112 Mon Sep 17 00:00:00 2001 From: SathvikaMadhamshetty <163622346+SathvikaMadhamshetty@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:37:14 +0530 Subject: [PATCH 16/16] Update p4.cpp --- c/p4.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/p4.cpp b/c/p4.cpp index 1e83511..4129be4 100644 --- a/c/p4.cpp +++ b/c/p4.cpp @@ -10,10 +10,10 @@ string caesar(string s, int k, string direction){ string ans = ""; for(int i=0;i