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

BUGGER KING #358

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions c/p1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ void checkSum(int a[], int n, int t){
table[i][0] = true;
}

for(int i=1;i<=n;i++){
for(int j=1;j<=t;j++){
for(int i=0;i<=n;i++){
for(int j=0;j<=t;j++){
if(j < a[i-1]){
table[i][j] = table[i-1][j];
}
Expand Down
2 changes: 1 addition & 1 deletion c/p10.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//CPP program to implement circular linked list

//no error
#include<bits/stdc++.h>
using namespace std;
struct node{ //defining the structure of the node
Expand Down
2 changes: 1 addition & 1 deletion c/p11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion c/p12.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//program to find the longest common subsequence (LCS) in two strings
//e.g. ABCDE and AFCZE have a common subsequence of ACE

//no errors
#include <bits/stdc++.h>
using namespace std;

Expand Down
4 changes: 2 additions & 2 deletions c/p13.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>

int i = 0;
//int i = 0;

int main(){
int i = i;
Expand All @@ -17,7 +17,7 @@ int main(){
printf("%d ", a[i]);
}
printf("\n");
for(i;i<m;i++){
for(int i=0;i<m;i++){
printf("%d ", b[i]);
}
}
7 changes: 5 additions & 2 deletions c/p14.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include<string.h>

int romanToInt(char * s){
int *a = (int *)malloc(strlen(s) * sizeof(int));
int *a = (int *)malloc((strlen(s)+1) * sizeof(int));
for(int i=0;i<strlen(s);i++){
switch(s[i]){
case 'I': a[i] = 1; break;
Expand All @@ -22,7 +22,10 @@ int romanToInt(char * s){
if(a[i] < a[i+1]){
a[i+1] -= a[i];
}
num += a[i];
else{
num += a[i];

}
}
num += a[strlen(s) - 1];
return num;
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':
case 'E':
case 'I':
case 'O':
case 'U': v++;
}
return v;
}
Expand Down
4 changes: 2 additions & 2 deletions c/p2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include<iostream>
using namespace std;

//no error
class A{
int variable;
public:
Expand All @@ -22,7 +22,7 @@ int A::func(){
return variable;
}

int anotherFunc(A a){
int anotherFunc(A &a){
a.variable += 3;
return a.variable;
}
Expand Down
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
4 changes: 2 additions & 2 deletions c/p4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ string caesar(string s, int k, string direction){
string ans = "";
for(int i=0;i<s.length();i++){
if(direction == "encode"){
ans += s[i] + k;
ans += char(((s[i] - 'a' + k) % 26) + 'a');
}
else if(direction == "decode"){
ans += s[i] - k;
ans += char(((s[i] - 'a' - k + 26) % 26) + 'a');
}
}
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
Expand Up @@ -3,7 +3,7 @@
#include<stdio.h>
int *fun()
{
int x = 5;
static 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;
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 @@ -16,6 +16,6 @@ int main()
{
float x[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
size_t N = 10;
printf("%.3g\n", computeAverage(x, &N));
printf("%.3f\n", computeAverage(x, &N));
return 0;
}
2 changes: 1 addition & 1 deletion c/p9.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

#include <stdio.h>

#include<stdlib.h>
int* filterMultiples(int* arr, int N, int* NOut, int num) {
int numPrimes = 0;
*NOut = 0;
Expand Down
2 changes: 2 additions & 0 deletions py/p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
def asterisk_tree(height,level):
if level > height:
return
for i in range(1,height-level+1): #for loop for adding spaces to centre the pattern
print(" ",end="")
for j in range(2*level-1):
print("*", end="")
print()
Expand Down
2 changes: 2 additions & 0 deletions py/p10.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#Finding Average RGB values using the listmaker fuction to generate list of rgb values for a pixel

def listmaker(r,g,b,list1=[]):
if (list1!=[]):
list1=[]
list1.append(r)
list1.append(g)
list1.append(b)
Expand Down
6 changes: 3 additions & 3 deletions py/p11.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion py/p12.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Program to multiply two matrices using nested loops

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

p = len(A)
Expand Down
6 changes: 4 additions & 2 deletions py/p2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# input- 1 -> output- [1], input- 2 -> output- [2]

def add_item(item, items=[]):
items.append(item)
return items
if len(items)!=0:
items.pop(0)
items.append(item)
return items

print(add_item(1))
print(add_item(2))
11 changes: 5 additions & 6 deletions py/p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#eg: [2, 4, 6, 17, 10] -> [17, 10]

def delete_starting_evens(list):
for item in list:
if list[0] % 2 == 0:
list.pop(0)
else:
break
for item in range(len(list),-1,-1): # changing to range
if list[item]%2==0: # eheck element at index is even
list.pop(item)
return list

list = [2, 8, 10, 11]
list = [2, 8, 10, 11
#changes visible
print(delete_starting_evens(list))
4 changes: 2 additions & 2 deletions py/p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions py/p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def get_number():
val1 = input('Enter a number: ')
val1 = int(val1)

str_to_print = '{:.1f}'.format(val1)
str_to_print = '{1f}'.format(val1)
return str_to_print

except ValueError:
get_number()
return get_number()

print(get_number())
2 changes: 1 addition & 1 deletion py/p6.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def addBinary(a: str, b: str) -> str:
i = len(a) - 1
j = len(b) - 1

while i >= 0 or j >= 0:
while i >= 0 or j >= 0 or carry!=0:
if i >= 0:
carry += int(a[i])
i -= 1
Expand Down
2 changes: 1 addition & 1 deletion py/p7.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#e.g. 2->4->3 + 5->6->4 = 7->0->8 (342 + 465 = 807)

# Definition for singly-linked list.
class ListNode(object):
class ListNode(object):#no error
def __init__(self, val=0, next=None):
self.val = val
self.next = next
Expand Down
6 changes: 5 additions & 1 deletion py/p8.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def append_item(self, data):
self.count += 1

def print_foward(self):
print(self.iter())
current=self.head
while current:
item_val=current.data
current=current.next
print(item_val)

def iter(self):
# Iterate the list
Expand Down
9 changes: 6 additions & 3 deletions py/p9.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ def ispangram(str1, alphabet=string.ascii_lowercase):
alphaset = list(alphabet)

str = list(str1.lower())

# Check if all lowercase characters in the input string covers all characters in 'alphaset'
return alphaset <= str
for i in range (0,26):
if alphaset[i] not in str:
break
if i==25:
return True
return False

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