Skip to content

Commit c78b7a1

Browse files
author
Bhrigu Kansra
authored
Merge branch 'master' into master
2 parents 3c6eafd + 3b7d718 commit c78b7a1

File tree

9 files changed

+218
-1
lines changed

9 files changed

+218
-1
lines changed

24 hr.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
def convert24(str1):
3+
4+
if str1[-2:] == "AM" and str1[:2] == "12":
5+
return "00" + str1[2:-2]
6+
7+
8+
elif str1[-2:] == "AM":
9+
return str1[:-2]
10+
elif str1[-2:] == "PM" and str1[:2] == "12":
11+
return str1[:-2]
12+
13+
else:
14+
15+
return str(int(str1[:2]) + 12) + str1[2:8]
16+
17+
18+
str1=input("enter time")
19+
print(convert24("str1"))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long
4+
#define o 100005
5+
#define MOD 1000000007
6+
#define pb push_back
7+
#define mp make_pair
8+
#define mem(a,b) memset(a,(b),sizeof(a))
9+
#define lpo(a) for(int i=0;i<a;i++)
10+
#define loop(a,x) for(int i=a;i<x;i++)
11+
#define srt(x) sort(x.begin(),x.end())
12+
#define all(x) x.begin(),x.end()
13+
const ll MAX=1000000000000000001;
14+
typedef pair<int,int> pii;
15+
int knapSack(int W, int wt[], int val[], int n)
16+
{
17+
int i, w;
18+
int K[n+1][W+1];
19+
for (i = 0; i <= n; i++)
20+
{
21+
for (w = 0; w <= W; w++)
22+
{
23+
if (i==0 || w==0)
24+
K[i][w] = 0;
25+
else if (wt[i-1] <= w)
26+
K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]);
27+
else
28+
K[i][w] = K[i-1][w];
29+
}
30+
}
31+
32+
return K[n][W];
33+
}
34+
35+
int main()
36+
{
37+
int val[] = {20, 30, 40};
38+
int wt[] = {10, 20, 30};
39+
int W = 50;
40+
int n = sizeof(val)/sizeof(val[0]);
41+
cout<<knapSack(W, wt, val, n);
42+
return 0;
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
3+
#define N 4
4+
#include<stdio.h>
5+
#include<stdbool.h>
6+
7+
void printSolution(int board[N][N])
8+
{
9+
for (int i = 0; i < N; i++)
10+
{
11+
for (int j = 0; j < N; j++)
12+
printf(" %d ", board[i][j]);
13+
printf("\n");
14+
}
15+
}
16+
17+
18+
bool isSafe(int board[N][N], int row, int col)
19+
{
20+
int i, j;
21+
22+
/* Check this row on left side */
23+
for (i = 0; i < col; i++)
24+
if (board[row][i])
25+
return false;
26+
27+
/* Check upper diagonal on left side */
28+
for (i=row, j=col; i>=0 && j>=0; i--, j--)
29+
if (board[i][j])
30+
return false;
31+
32+
/* Check lower diagonal on left side */
33+
for (i=row, j=col; j>=0 && i<N; i++, j--)
34+
if (board[i][j])
35+
return false;
36+
37+
return true;
38+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
void printFun(int test)
7+
{
8+
if (test < 1)
9+
return;
10+
else
11+
{
12+
cout << test << " ";
13+
printFun(test-1); // statement 2
14+
cout << test << " ";
15+
return;
16+
}
17+
}
18+
19+
int main()
20+
{
21+
int test = 3;
22+
printFun(test);
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
4+
def printFun(test):
5+
6+
if (test < 1):
7+
return
8+
else:
9+
10+
print( test,end = " ")
11+
printFun(test-1) # statement 2
12+
print( test,end = " ")
13+
return
14+
15+
16+
test = 3
17+
printFun(test)

contributors.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@
4242
40. [Riya Singh](https://github.com/riya24899)
4343
41. [Sarthak gupta](https://github.com/sarthak-g)
4444
42. [Nitish Kumar](https://github.com/nitish14kumr)
45-
43. [Your Name](https://github.com/yourusername)
45+
43. [Seemant Aggarwal] (https://github.com/seemantaggarwal)
46+
44. [Vibhav Tiwari] (https://github.com/VibhavTiwari)
47+
45. [Your Name](https://github.com/yourusername)

math/C++/determinant.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#define N 4
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
6+
void getCofactor(int mat[N][N], int temp[N][N], int p, int q, int n)
7+
{
8+
int i = 0, j = 0;
9+
10+
11+
for (int row = 0; row < n; row++)
12+
{
13+
for (int col = 0; col < n; col++)
14+
{
15+
16+
if (row != p && col != q)
17+
{
18+
temp[i][j++] = mat[row][col];
19+
20+
21+
if (j == n - 1)
22+
{
23+
j = 0;
24+
i++;
25+
}
26+
}
27+
}
28+
}
29+
}

math/C++/prime number.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n, i;
7+
bool isPrime = true;
8+
9+
cout << "Enter a positive integer: ";
10+
cin >> n;
11+
12+
for(i = 2; i <= n / 2; ++i)
13+
{
14+
if(n % i == 0)
15+
{
16+
isPrime = false;
17+
break;
18+
}
19+
}
20+
if (isPrime)
21+
cout << "This is a prime number";
22+
else
23+
cout << "This is not a prime number";
24+
25+
return 0;
26+
}

math/Python/prime number.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
num = 407
2+
3+
# take input from the user
4+
# num = int(input("Enter a number: "))
5+
6+
# prime numbers are greater than 1
7+
if num > 1:
8+
# check for factors
9+
for i in range(2,num):
10+
if (num % i) == 0:
11+
print(num,"is not a prime number")
12+
print(i,"times",num//i,"is",num)
13+
break
14+
else:
15+
print(num,"is a prime number")
16+
17+
# if input number is less than
18+
# or equal to 1, it is not prime
19+
else:
20+
print(num,"is not a prime number")

0 commit comments

Comments
 (0)