Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iit_kandigai #351

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion c/p11.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ int isSameTree(struct TreeNode* p, struct TreeNode* q){
if(p == NULL && q == NULL){
return 1;
}
if(p == NULL && q != NULL) return 0;
if(p!=NULL && q==NULL) return 0;
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;
}
4 changes: 2 additions & 2 deletions c/p13.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
int i = 0;

int main(){
int i = i;
//int i = i;
int a[] = {1, 2, 3, 4, 5, 6};
int b[] = {7, 8, 9, 10, 11, 12, 13};

int n = sizeof(a)/sizeof(a[0]);
int m = sizeof(b)/sizeof(b[0]);

for(int i=0;i<n;i++);{
for(int i=0;i<n;i++){
printf("%d ", a[i]);
}
printf("\n");
Expand Down
1 change: 1 addition & 0 deletions c/p14.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ int romanToInt(char * s){
for(int i=0;i<strlen(s)-1;i++){
if(a[i] < a[i+1]){
a[i+1] -= a[i];
continue;
}
num += a[i];
}
Expand Down
10 changes: 5 additions & 5 deletions c/p15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ void Upper(char *word) {
int Check(char *S) {
for(int k = 0, v = 0; S[k]; k++)
switch(S[k]) {
case A:
case E:
case I:
case O:
case U: v++;
case A: v++; break;
case E:v++; break;
case I:v++; break;
case O:v++; break;
case U: v++; break;
}
return v;
}
Expand Down
11 changes: 6 additions & 5 deletions c/p2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class A{
A(int variable){
this->variable = variable;
}
int anotherFunc(A a){
a.variable += 3;
return a.variable;
}

int func();
~A(){
cout << "Object destroyed" << endl;
Expand All @@ -22,13 +27,9 @@ int A::func(){
return variable;
}

int anotherFunc(A a){
a.variable += 3;
return a.variable;
}

int main(){
A a;
cout << a.func() + anotherFunc(a) << endl;
cout << a.func() + a.anotherFunc(a) << endl;
return 0;
}
2 changes: 1 addition & 1 deletion c/p3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vector<int> productExceptSelf(vector<int>& nums) {
int r = 1;
for(int i=nums.size()-1;i>=0;i--){
ans[i] *= r;
r = nums[i];
r = r*nums[i];
}
return ans;
}
Expand Down
2 changes: 1 addition & 1 deletion c/p5.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ void main(){
int a=10;
int *ptr = &a;

*ptr++;
(*ptr)++;
printf("%d", *ptr);
}
2 changes: 1 addition & 1 deletion c/p6.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//allocating memory to a pointer through a function

#include<stdio.h>
int x = 5;
int *fun()
{
int x = 5;
return &x;
}
int main()
Expand Down
2 changes: 1 addition & 1 deletion c/p7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using namespace std;

int func(string s){
int counter=-1;
unsigned int counter=0;
while(counter<s.length())
counter++;
return counter;
Expand Down
2 changes: 1 addition & 1 deletion c/p8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
2 changes: 1 addition & 1 deletion c/p9.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int* filterMultiples(int* arr, int N, int* NOut, int num) {
}
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++;
Expand Down
4 changes: 4 additions & 0 deletions py/p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
def asterisk_tree(height,level):
if level > height:
return
for i in range(height-level):
print(" ", end="")
for j in range(2*level-1):
print("*", end="")
for i in range(height-level):
print(" ", end="")
print()
asterisk_tree(height, level + 1)

Expand Down
1 change: 1 addition & 0 deletions py/p10.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#Finding Average RGB values using the listmaker fuction to generate list of rgb values for a pixel

def listmaker(r,g,b,list1=[]):
Expand Down
6 changes: 4 additions & 2 deletions py/p11.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Function to convert decimal to binary number

def binaryconversion(n):
print(n % 2,end = '')
if n == 1:
print(n % 2,end = '')
if n > 1:
binaryconversion(n/2)
binaryconversion(n//2)
print(n % 2,end = '')

number=int(input("Enter Number: "))
binaryconversion(number)
Expand Down
1 change: 1 addition & 0 deletions py/p12.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Program to multiply two matrices using nested loops


A = [[1,2,3],[4,5,6],[7,8,9]]
B = [[10,11,12],[13,14,15],[16,17,18]]

Expand Down
3 changes: 2 additions & 1 deletion py/p2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#program to print an input as the only member of an array everytime the function is called
# input- 1 -> output- [1], input- 2 -> output- [2]

def add_item(item, items=[]):
def add_item(item):
items=[]
items.append(item)
return items

Expand Down
3 changes: 2 additions & 1 deletion py/p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#eg: [2, 4, 6, 17, 10] -> [17, 10]

def delete_starting_evens(list):
for item in list:
l=len(list)
for item in range(l):
if list[0] % 2 == 0:
list.pop(0)
else:
Expand Down
2 changes: 1 addition & 1 deletion py/p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
def countSort(arr):
k = max(arr)
count = [0 for i in range(k+1)]
ans = [0 for i in range(len(arr))]
ans = [0 for i in range(k+1)]
for i in arr:
count[i] += 1
for i in range(k+1):
Expand Down
1 change: 1 addition & 0 deletions py/p5.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#recursive program to accept a number between 1 and 10 and print it
#No changes

def get_number():
val1 = input('Enter a number: ')
Expand Down
3 changes: 2 additions & 1 deletion py/p6.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def addBinary(a: str, b: str) -> str:
j -= 1
s.append(str(carry % 2))
carry //= 2

if(carry!=0):
s.append(str(carry))
return ''.join(reversed(s))

print(addBinary("11", "0"))
2 changes: 1 addition & 1 deletion py/p9.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def ispangram(str1, alphabet=string.ascii_lowercase):
str = list(str1.lower())

# Check if all lowercase characters in the input string covers all characters in 'alphaset'
return alphaset <= str
return len(set(str)) == len(set(alphaset))

# 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'))