├── 2nd_sem
├── Pull_Requests
│ ├── Swayam_Singh_DS_48
│ │ ├── problem3.c
│ │ ├── problem2.c
│ │ └── problem1.c
│ ├── Sanjay_Singh_AI
│ │ ├── readme.md
│ │ ├── problem1.c
│ │ ├── problem2.c
│ │ └── problem3.c
│ ├── Vinayak_Tiwari_DS_53
│ │ ├── problem3.c
│ │ ├── problem2.c
│ │ └── problem1.c
│ ├── Arnav_jha_AI_10
│ │ ├── readme.md
│ │ └── Member_Test_Arnav_Jha_10_2nd_sem.ipynb
│ ├── Lakshya_Sori_DS
│ │ ├── Readme.md
│ │ ├── problem-2.c
│ │ └── problem-1.c
│ ├── Peehu_Agarwal_DS_33
│ │ ├── readme.md
│ │ ├── Problem1.c
│ │ ├── problem2.c
│ │ └── problem3.c
│ ├── Moksh_Patel_AI_39
│ │ ├── readme
│ │ ├── q02.c
│ │ ├── q01.c
│ │ └── q03.c
│ ├── TilakVerma_AI_67
│ │ ├── solution1.exe
│ │ ├── solution2.exe
│ │ ├── solution2.c
│ │ └── solution1.c
│ ├── Harsh_Sharma_AI_22
│ │ ├── 2nd_ques.py
│ │ ├── 1st_ques.c
│ │ └── 3rd_ques.c
│ ├── Prabhat_singh_AI_42
│ │ ├── problem_2.py
│ │ ├── problem_1.c
│ │ └── problem_3.c
│ ├── Abhay_singh_AI_01
│ │ ├── problem3.bhai
│ │ ├── problem2.py
│ │ ├── problem2.c
│ │ ├── problem1.py
│ │ ├── problem3.py
│ │ ├── problem2.bhai
│ │ ├── problem1.c
│ │ ├── problem1.bhai
│ │ └── problem3.c
│ ├── Hridyesh_Kumar_25
│ │ ├── problem_1.c
│ │ ├── problem_2.c
│ │ ├── problem_3.c
│ │ └── .vscode
│ │ │ └── tasks.json
│ ├── Shravan_DS_45
│ │ ├── problem2.c
│ │ ├── problem1.c
│ │ └── problem3.c
│ ├── RoshanKhatri_AI_47
│ │ ├── Problem_2_solution.py
│ │ ├── problem_1_solution.py
│ │ └── problem_3_solution.py
│ ├── Abhinav_Anand_AI_02
│ │ ├── problem2.c
│ │ ├── problem1.c
│ │ └── problem3.c
│ ├── Kuldeep_Lahare_DS_23
│ │ ├── problem2.c
│ │ ├── problem1.c
│ │ └── problem3.c
│ ├── SharadSinghThakur_56
│ │ ├── Test_solution_1.py
│ │ ├── Test_solution_2.py
│ │ └── Test_solution_3.py
│ ├── Nukesh_DS_30
│ │ ├── problem2.c
│ │ └── problem1.c
│ ├── Abhinav_Shukla_AI_03
│ │ ├── Solutions_in_GoLang
│ │ │ ├── problem2.go
│ │ │ ├── problem1.go
│ │ │ └── problem3.go
│ │ ├── Solutions_in_Rust
│ │ │ ├── problem1.rs
│ │ │ ├── problem2.rs
│ │ │ └── problem3.rs
│ │ └── readme.md
│ ├── KISHLAY_KUMAR_AI_33
│ │ ├── prblm2.c
│ │ ├── prblm1.c
│ │ └── prblm3.c
│ ├── Rupali_Chandrakar_AI_49
│ │ ├── Soln_2.py
│ │ └── Solution_1.c
│ ├── Anuj_behra_DS_11
│ │ ├── problem2.c
│ │ ├── problem1.c
│ │ └── problem3.c
│ ├── Ayush_Dhruw_DS_15
│ │ ├── problem2.py
│ │ ├── problem3.py
│ │ └── problem1.cpp
│ ├── Dhiraj_Kumar_AI_16
│ │ ├── Problem2.cpp
│ │ ├── Problem1.cpp
│ │ └── Problem3.cpp
│ ├── SaurabhKumar_AI_53
│ │ ├── Problem2.cpp
│ │ ├── Problem1.cpp
│ │ └── Problem3.cpp
│ ├── ANANDITA MUKHERJEE_DS_08
│ │ ├── program 1.c
│ │ ├── program 2.cpp
│ │ └── solution.c
│ ├── Arun_Kumar_DS_13
│ │ ├── question2.c
│ │ ├── problem1.c
│ │ ├── question3.c
│ │ └── question 3.c
│ ├── Satyam_jha_AI_53
│ │ ├── SOLUTION 2
│ │ ├── SOLUTION 3
│ │ └── SOLUTION 1
│ ├── Saurabh_Prajapati_AI_54
│ │ ├── SOLUTION 2.c
│ │ ├── SOLUTION 1.c
│ │ └── SOLUTION 3.c
│ ├── DEV_PRATAP_SINGH_15(AI)
│ │ ├── problem_02.c
│ │ ├── problem_01.c
│ │ └── problem_03.c
│ ├── Karan_Singh_Rathore_Ai_30
│ │ ├── problem2.c
│ │ ├── problem1.c
│ │ └── problem3.c
│ ├── Ketan_Dinkar_Ai_32
│ │ ├── problem_2.c
│ │ ├── problem_1.c
│ │ └── problem_3.c
│ ├── Aryan_Gupta_AI_11
│ │ ├── Q.2.c
│ │ ├── Q.1.c
│ │ └── Q.3.c
│ ├── Mayank_Kaushik_DS_26
│ │ ├── SOLUTION_2.c
│ │ ├── PROBLEM 1.C
│ │ ├── SOLUTION_1.c
│ │ └── SOLUTION_3.c
│ ├── Rohit_Rana_DS_39
│ │ ├── prob1.c
│ │ ├── prob2.c
│ │ └── prob3.c
│ ├── JaiKeshavSharma-AI-27
│ │ ├── problem_1.cpp
│ │ ├── problem_2.cpp
│ │ └── problem_3.cpp
│ ├── Ravi_AI_46
│ │ ├── prob_2.c
│ │ ├── prob_1.c
│ │ └── prob_3.c
│ ├── readme.md
│ ├── gaurav_jaiswal_ai_75
│ │ └── solution
│ └── SIMANKAN_YADAV_AI_63
│ │ └── SOLUTION
├── problem1.md
├── problem3.md
└── problem2.md
├── 6613a282ad4b8.jpg
├── 4th_sem
├── for_problem2.png
├── Pull_Requests
│ ├── Ashirwad_300012722046_AI
│ │ ├── 46_AI_solution2.py
│ │ ├── 46_AI_solution3.py
│ │ └── 46_AI_solution1.py
│ ├── Dileep_4thsem_AI
│ │ ├── 32_solutnprblm2.py
│ │ ├── 32_solutnprblm1.py
│ │ └── 32_solutnprblm3.py
│ ├── Anoushka_4smeDS
│ │ ├── solution1.cpp
│ │ └── solution2.cpp
│ └── readme.md
├── problem2.md
├── problem1.md
└── problem3.md
├── 6th_sem
├── for_problem3.PNG
├── problem2.md
├── Pull_Requests
│ ├── Madhurima_Rawat_DS_42
│ │ ├── problem2.py
│ │ └── problem1.py
│ ├── readme.md
│ ├── bhavesh_kanoje _ai_15
│ │ ├── task_2.ipynb.ipynb
│ │ ├── task_3.ipynb.ipynb
│ │ └── task_1.ipynb.ipynb
│ ├── Jonathan Philip
│ │ ├── solution2.java
│ │ └── solution1.java
│ └── Rishabh_Tiwari
│ │ ├── solution_prblm2.cpp
│ │ ├── solution_prblm1.cpp
│ │ └── solution_prblm3.cpp
├── problem1.md
└── problem3.md
└── README.md
/2nd_sem/Pull_Requests/Swayam_Singh_DS_48/problem3.c:
--------------------------------------------------------------------------------
1 | I didnt understand the question.
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Sanjay_Singh_AI/readme.md:
--------------------------------------------------------------------------------
1 | # Name - Sanjay Singh
2 | # Branch - AI
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Vinayak_Tiwari_DS_53/problem3.c:
--------------------------------------------------------------------------------
1 | Wasn't Able to Understand The Question
2 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Arnav_jha_AI_10/readme.md:
--------------------------------------------------------------------------------
1 | # Arnav Jha
2 | ## semester - 2
3 | ### Roll-no. 10
--------------------------------------------------------------------------------
/6613a282ad4b8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maxprogrammer007/Member-Selection-Test/main/6613a282ad4b8.jpg
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Lakshya_Sori_DS/Readme.md:
--------------------------------------------------------------------------------
1 | # Name - Lakshya Sori
2 | # Branch - DS
3 | # Roll no -25
4 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Peehu_Agarwal_DS_33/readme.md:
--------------------------------------------------------------------------------
1 | # Name - Peehu Agarwal
2 | # Branch - DS
3 | # Roll No. - 33
4 |
--------------------------------------------------------------------------------
/4th_sem/for_problem2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maxprogrammer007/Member-Selection-Test/main/4th_sem/for_problem2.png
--------------------------------------------------------------------------------
/6th_sem/for_problem3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maxprogrammer007/Member-Selection-Test/main/6th_sem/for_problem3.PNG
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Moksh_Patel_AI_39/readme:
--------------------------------------------------------------------------------
1 | Name - Moksh Patel
2 | Roll no. - 39
3 | Branch - AI
4 | Email - carwalk1977@gmail.com
5 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maxprogrammer007/Member-Selection-Test/main/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution1.exe
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution2.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maxprogrammer007/Member-Selection-Test/main/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution2.exe
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Harsh_Sharma_AI_22/2nd_ques.py:
--------------------------------------------------------------------------------
1 | result = 0
2 | n=int(input())
3 | for i in range(1,n):
4 | if (i % 3 == 0 or i % 5 == 0):
5 | result = result + i
6 | print (result)
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Prabhat_singh_AI_42/problem_2.py:
--------------------------------------------------------------------------------
1 | result = 0
2 | n=int(input())
3 | for i in range(1,n):
4 | if (i % 3 == 0 or i % 5 == 0):
5 | result = result + i
6 | print (result)
7 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem3.bhai:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code cannot be written in Bhailang.
6 | */
7 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Hridyesh_Kumar_25/problem_1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int n;
4 | scanf("%d",&n);
5 | printf("%d ",n);
6 | while(n!=1){
7 | (n%2==0)?(n=n/2):(n=(3*n)+1);
8 | printf("%d ",n);
9 | }
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Shravan_DS_45/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n=20;
5 | int sum=0;
6 | for(int i=0;i ashirwadrai5879@outlook.com
2 |
3 | import math
4 |
5 | def route_count(grid_size):
6 | n = 2 * grid_size
7 | r = grid_size
8 | routes = math.comb(n, r)
9 | return routes
10 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/RoshanKhatri_AI_47/Problem_2_solution.py:
--------------------------------------------------------------------------------
1 | def sum_of_multiples(N):
2 | sum = 0
3 | for i in range(N):
4 | if i % 3 == 0 or i % 5 == 0:
5 | sum += i
6 | return sum
7 |
8 | N = int(input("Enter the upper limit: "))
9 | print(sum_of_multiples(N))
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Hridyesh_Kumar_25/problem_2.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n,i;
4 | int result=0;
5 | scanf("%d",&n);
6 | while(i
2 | int main(){
3 | int N=20,sum=0;
4 | for(int i=1;i
2 | int main(){
3 | int N=20,sum=0;
4 | for(int i=1;i
2 | int main(){
3 | int N=20,sum=0;
4 | for(int i=1;i
2 |
3 | int main() {
4 | int n=3;
5 | while(n!=1){
6 | printf("%d\t",n);
7 | if(n%2==0){
8 | n/=2;
9 | }
10 | else{
11 | n=3*n+1;
12 | }
13 | }
14 | printf("%d",n);
15 |
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Anand_AI_02/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 |
5 | int num=3;
6 | printf("%d ",num);
7 | while(num!=1){
8 | if(num%2==0){
9 | num = num/2;
10 | }
11 | else{
12 | num = num*3 +1;
13 | }printf("%d ",num);
14 | }
15 |
16 |
17 |
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Sanjay_Singh_AI/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 |
5 | int num=3;
6 | printf("%d ",num);
7 | while(num!=1){
8 | if(num%2==0){
9 | num = num/2;
10 | }
11 | else{
12 | num = num*3 +1;
13 | }printf("%d ",num);
14 | }
15 |
16 |
17 |
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/SharadSinghThakur_56/Test_solution_1.py:
--------------------------------------------------------------------------------
1 | def solution(n):
2 | print(n,end = " ")
3 | while n!=1:
4 | if n%2== 0:
5 | n = int(n/2)
6 | print(n,end =" ")
7 | else:
8 | n = int(n*3 + 1)
9 | print(n,end =" ")
10 |
11 |
12 | n = int(input())
13 | solution(n)
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Nukesh_DS_30/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int N, sum = 0;
5 | printf("Enter the upper limit N: ");
6 | scanf("%d", &N);
7 | for (int i = 1; i < N; i++) {
8 | if (i % 3 == 0 || i % 5 == 0) {
9 | sum += i;
10 | }
11 | }
12 | printf("%d\n",sum);
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Shukla_AI_03/Solutions_in_GoLang/problem2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | func main() {
6 | var result int
7 | var n int
8 | fmt.Scan(&n)
9 |
10 | for i := 1; i < n; i++ {
11 | if i%3 == 0 || i%5 == 0 {
12 | result += i
13 | }
14 | }
15 | fmt.Println(result)
16 | }
17 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/KISHLAY_KUMAR_AI_33/prblm2.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int N;//Upper Limit
4 | printf("Enter an Upper Limit: ");
5 | scanf("%d",&N);
6 | int sum=0;
7 | for(int i=0;i$n!$ means $n \times (n - 1) \times \cdots \times 3 \times 2 \times 1$.
2 | For example, $10! = 10 \times 9 \times \cdots \times 3 \times 2 \times 1 = 3628800$,
and the sum of the digits in the number $10!$ is $3 + 6 + 2 + 8 + 8 + 0 + 0 = 27$.
3 | Find the sum of the digits in the number $n!$ where $n$ can be as large as 100.
4 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Peehu_Agarwal_DS_33/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int N=20;
5 | int sum=0;
6 | for(int i=3;i
2 |
3 | int main(){
4 | int sum=0;
5 | int n;
6 | printf("enter the value of N");
7 | scanf("%d",&n);
8 | for(int i=1;i
3 |
4 | int main() {
5 | int n;
6 | scanf("%d",&n);
7 | printf("%d ",n);
8 | do{
9 | if (n % 2 == 0){
10 | n/=2;
11 | printf("%d ",n);
12 | }
13 | else{
14 | n=3*n +1;
15 | printf("%d ",n);
16 | }
17 | }
18 | while(n>1);
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Ayush_Dhruw_DS_15/problem2.py:
--------------------------------------------------------------------------------
1 | """
2 | Name - Ayush Dhruw
3 | branch - 2nd sem (DS)
4 | roll no. - 15
5 | """
6 | n = int(input())
7 | def func(x):
8 | result = 0
9 | i = 1
10 | while (i < x):
11 | if (i % 3 == 0 or i % 5 == 0):
12 | result += i
13 | i += 1
14 | print(result)
15 | func(n)
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Dhiraj_Kumar_AI_16/Problem2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main () {
5 |
6 | int n;
7 | cin >> n;
8 |
9 | int i = 1;
10 | int sum = 0;
11 | while ( i < n) {
12 | if ( i % 3 == 0 || i % 5 == 0) {
13 | sum += i;
14 | }
15 | i++;
16 | }
17 |
18 | cout << sum << endl;
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/SaurabhKumar_AI_53/Problem2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main () {
5 |
6 | int n;
7 | cin >> n;
8 |
9 | int i = 1;
10 | int sum = 0;
11 | while ( i < n) {
12 | if ( i % 3 == 0 || i % 5 == 0) {
13 | sum += i;
14 | }
15 | i++;
16 | }
17 |
18 | cout << sum << endl;
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/ANANDITA MUKHERJEE_DS_08/program 1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n=3;
4 |
5 |
6 | while(n!=1){
7 | printf("%d",n);
8 |
9 | if(n%2!=0){
10 | n=n*3+1;
11 | }
12 | else{
13 | n= n/2;
14 | }
15 |
16 |
17 | }
18 | printf("1\n");
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Arun_Kumar_DS_13/question2.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | printf("Enter the limit n : ");
5 | scanf("%d",&n);
6 | int g;
7 | int sum=0;
8 | while(g
2 | int main()
3 | {
4 | int N,i,sum=0;
5 | printf("enter upper limit:");
6 | scanf("%d",&N);
7 | for(i=1;i int:
2 | count = 0
3 | for start,end in list:
4 | if end-start >= n:
5 | count+=1
6 | return count
7 |
8 |
9 | n=int(input())
10 | lst = []
11 | for _ in range(n):
12 | lst.append(tuple(map(int,input().split())))
13 |
14 | print(max_movies(lst,n))
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Prabhat_singh_AI_42/problem_1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | scanf("%d",&n);
6 | printf("%d ",n);
7 | do{
8 | if (n % 2 == 0){
9 | n/=2;
10 | printf("%d ",n);
11 | }
12 | else{
13 | n=3*n +1;
14 | printf("%d ",n);
15 | }
16 | }
17 | while(n>1);
18 |
19 | return 0;
20 | }
21 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem2.py:
--------------------------------------------------------------------------------
1 | """
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in python.
6 | """
7 | n = int(input())
8 | result = 0
9 | i = 1
10 | while (i < n):
11 | if (i % 3 == 0 or i % 5 == 0):
12 | result += i
13 | i += 1
14 | print(result)
15 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Arun_Kumar_DS_13/problem1.c:
--------------------------------------------------------------------------------
1 | // Online C compiler to run C program online
2 | #include
3 |
4 | int main(){
5 |
6 | int n;
7 | printf("Enter n : ");
8 | scanf("%d",&n);
9 |
10 | while(n!=1){
11 | if(n%2==0){
12 | n = n/2;
13 | }
14 | else{
15 | n = n*3 +1;
16 | }
17 |
18 |
19 | printf("%d\t",n);}
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Saurabh_Prajapati_AI_54/SOLUTION 2.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int N;
4 | printf("Enter the limit N : ");
5 | scanf("%d",&N);
6 | int p;
7 | int sum=0;
8 | while(p
2 |
3 | int main(){
4 | int num;
5 | printf("Enter a number : ");
6 | scanf("%d",&num);
7 |
8 | int sum = 0;
9 | for(int i=1;i
2 | int main()
3 | {
4 | int sum=0;
5 | int n;
6 | printf("enter the limit ");
7 | scanf("%d",&n);
8 |
9 | for(int i=0;i
2 | int main(){
3 | int t=0,n,s;
4 | printf("enter the limit : ");
5 | scanf("%d",&n);
6 | for(int x=0;x
2 | int main()
3 | {
4 | int N;
5 | int sum = 0;
6 |
7 | printf("Enter the upper limit:");
8 | scanf("%d", &N);
9 |
10 | for (int i = 1; i < N; i++)
11 | {
12 | if (i % 3 == 0 || i % 5 == 0)
13 | {
14 | sum = sum + i;
15 | }
16 | }
17 | printf("The sum is:%d", sum);
18 |
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Anuj_behra_DS_11/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | printf("Enter a positive integer ");
6 | scanf("%d", &n);
7 | while (n != 1) {
8 | if (n % 2 == 0) {
9 | n /= 2;
10 | } else {
11 | n = 3 * n + 1;
12 | }
13 | printf(" %d", n);
14 | }
15 |
16 | printf("\n");
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/DEV_PRATAP_SINGH_15(AI)/problem_01.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 | int n = 3 ;
5 | printf("Enter a number : ");
6 | scanf("%d",&n);
7 | printf("%d ",n);
8 | while(n != 1){
9 | if(n % 2 == 0){
10 | n = n/2;
11 | }
12 | else{
13 | n=3*n+1;
14 | }
15 | printf("%d ",n);
16 | }
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Shukla_AI_03/Solutions_in_GoLang/problem1.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | func main() {
6 | var n int
7 | fmt.Scan(&n)
8 | fmt.Printf("%d ", n)
9 |
10 | for n > 1 {
11 | if n%2 == 0 {
12 | n /= 2
13 | fmt.Printf("%d ", n)
14 | } else {
15 | n = 3*n + 1
16 | fmt.Printf("%d ", n)
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Mayank_Kaushik_DS_26/SOLUTION_2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int N;
5 | printf("Enter the limit N: ");
6 | scanf("%d", &N);
7 |
8 | int sum = 0;
9 | for (int p = 1; p < N; ++p) {
10 | if (p % 3 == 0 || p % 5 == 0) {
11 | sum += p;
12 | }
13 | }
14 |
15 | printf("The sum of factors of 3 & 5 is: %d\n", sum);
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/RoshanKhatri_AI_47/problem_1_solution.py:
--------------------------------------------------------------------------------
1 |
2 | #defining variables that will be used in the functions
3 | def algorithm():
4 | n = int(input("Enter a positive integer: "))
5 | while n != 1:
6 | print(n, end=' ')
7 | if n % 2 == 0:
8 | n = n // 2
9 | else:
10 | n = n * 3 + 1
11 | print(n)
12 |
13 | # Call the function to test it
14 | algorithm()
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Saurabh_Prajapati_AI_54/SOLUTION 1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | printf("Enter any positive interger : ");
5 | scanf("%d",&n);
6 |
7 | while(n!=1){
8 | if (n%2==0){
9 | n=n/2;
10 | printf("%d\t",n);
11 | }
12 | else{
13 | n=(n*3)+1;
14 | printf("%d\t",n);
15 | }
16 | }
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Swayam_Singh_DS_48/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n;
5 | int sum = 0;
6 | printf("enter the limit :");
7 | scanf("%d", &n);
8 | for (int i = 1; i < n; i++)
9 | {
10 | if (i % 3 == 0 && i % 5 == 0)
11 | {
12 | sum += i;
13 | }
14 | }
15 | printf("the sum multiples of 3 and 5 is %d :%d\n", n, sum);
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/KISHLAY_KUMAR_AI_33/prblm1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | printf("Enter a number: ");
5 | scanf("%d",&n);
6 | printf("%d ",n);
7 | if(n==1){
8 | printf("4 2 1");
9 | }
10 | while(n !=1){
11 | if(n%2==0){
12 | n=n/2;
13 | }
14 | else{
15 | n=n*3+1;
16 | }
17 | printf("%d ",n);
18 | }
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/ANANDITA MUKHERJEE_DS_08/program 2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main() {
5 | int n = 1; // Start from 1
6 | int sum = 0;
7 |
8 | while (n < 20) {
9 | if (n % 3 == 0 || n % 5 == 0) {
10 | sum += n;
11 | }
12 | n++;
13 | }
14 |
15 | cout << "Sum of numbers that are multiples of both 3 and 5 : " << sum << endl;
16 |
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Kuldeep_Lahare_DS_23/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void algorithm(int n) {
4 | printf("%d", n);
5 | while (n != 1) {
6 | if (n % 2 == 0) {
7 | n = n / 2;
8 | } else {
9 | n = 3 * n + 1;
10 | }
11 | printf("%d -> ", n);
12 | }
13 | printf("1\n");
14 | }
15 |
16 | int main() {
17 | int n = 3;
18 | algorithm(n);
19 | return 0;
20 | }
21 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Dhiraj_Kumar_AI_16/Problem1.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Dhiraj Kumar
3 | Branch - AI
4 | Rollno. - 16
5 | */
6 |
7 | #include
8 | using namespace std;
9 |
10 | int main () {
11 |
12 | int n;
13 | cin >> n;
14 |
15 | while (true) {
16 | cout << n << " ";
17 | if (n == 1) { break; };
18 | if (n % 2 == 0) { n = n / 2 ; }
19 | else {n = n *3 + 1 ;}
20 | }
21 | cout << "\n";
22 |
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Karan_Singh_Rathore_Ai_30/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n = 3;
5 | printf("%d ",n);
6 | while (n!= 1)
7 | {
8 | if (n % 2 == 0)
9 | {
10 | n = n / 2;
11 | printf("%d ", n);
12 | }
13 | else
14 | {
15 | n = n * 3 + 1;
16 | printf("%d ", n);
17 | }
18 | }
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Nukesh_DS_30/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | int n;
6 | printf("enter the value of n :\n");
7 | scanf("%d", &n);
8 |
9 | while (n > 1)
10 | {
11 |
12 | if (n % 2 == 0)
13 | {
14 | n = n / 2;
15 | }
16 | else
17 | {
18 | n = (n * 3) + 1;
19 | }
20 | printf("%d ", n);
21 | }
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Lakshya_Sori_DS/problem-2.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | int main(){
4 | int k = 20;
5 | int sum = 0;
6 | int j=1
7 | while(j <= 20){
8 | if(j % 3= 0 || j % 5==0) {
9 | sum =sum + j;
10 | }i++;
11 | }
12 | printf("Sum of multiples 3 and 5 %d = %d\n", k, sum);
13 | return 0;
14 | }
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Ketan_Dinkar_Ai_32/problem_1.c:
--------------------------------------------------------------------------------
1 | #include
2 | void print (int n)
3 | {
4 | int x;
5 | for(x=0;n!=1;x++){
6 | printf("\t%d",n);
7 | if(n%2==0){
8 | n=n/2;
9 | }
10 | else{
11 | n=(n*3)+1;
12 | }
13 | }
14 | printf("\t%d",n);
15 | }
16 | int main(){
17 | int n;
18 | printf("Enter the element : ");
19 | scanf("%d",&n);
20 | print(n);
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Rohit_Rana_DS_39/prob1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 |
5 | int number;
6 | printf("Enter the value of number : ");
7 | scanf("%d",&number);
8 |
9 | while(number!=1){
10 | if(number%2==0){
11 | number = number/2;
12 | }
13 | else{
14 | number = number*3 +1;
15 | }
16 | if(number != 1){
17 | printf("%d -> ",number);
18 | }
19 | }
20 | printf("%d",number);
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Rohit_Rana_DS_39/prob2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 | int range;
5 | int sum=0;
6 | printf("Enter the upper limit : ");
7 | scanf("%d",&range);
8 |
9 | printf("All the multiples of 3 or 5 below the given limit are : ");
10 | for(int i=1;i
8 | using namespace std;
9 | int main()
10 | {
11 | int num;
12 | cout << "enter the number: ";
13 | cin >> num;
14 |
15 | while (num != 1)
16 | {
17 | (num % 2 == 0) ? num = num / 2 : num = (num * 3) + 1;
18 | cout << num << " ";
19 | }
20 |
21 | return 0;
22 |
23 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Vinayak_Tiwari_DS_53/problem2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | int N, sum = 0;
6 |
7 | printf("Enter Your limit (N): ");
8 | scanf("%d", &N);
9 |
10 | if (N <= 0)
11 | {
12 | printf("Limitation Error.\n");
13 | return 1;
14 | }
15 | int m = 15;
16 | sum = m * (N - 1) / m * ((N - 1) / m + 1) / 2;
17 | printf("The sum of all numbers divisible by 3 or 5 below %d\n", N, sum);
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Swayam_Singh_DS_48/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n, seq;
5 | printf("Enter the positive integer");
6 | scanf("%d", &n);
7 | for (n > 0)
8 | {
9 | printf("%d", n);
10 | if (n % 2 == 0)
11 | {
12 | seq = n / 2;
13 | }
14 | else
15 | {
16 | seq = (3 * n) + 1;
17 | }
18 | n = seq;
19 | }
20 | printf("%d", n);
21 |
22 | return 0;
23 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/SaurabhKumar_AI_53/Problem1.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Saurabh Kumar
3 | Email - ultroninfinity01@gmail.com
4 | Branch - AI
5 | Roll no. - 53
6 | */
7 |
8 | #include
9 | using namespace std;
10 |
11 | int main () {
12 |
13 | int n;
14 | cin >> n;
15 |
16 | while (true) {
17 | cout << n << " ";
18 | if (n == 1) { break; };
19 | if (n % 2 == 0) { n = n / 2 ; }
20 | else {n = n *3 + 1 ;}
21 | }
22 | cout << "\n";
23 |
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Ravi_AI_46/prob_2.c:
--------------------------------------------------------------------------------
1 | //If the number is divisible by 3 or divisible by 5 then add them
2 |
3 | #include
4 |
5 | int main(){
6 | int n, sum = 0;
7 | printf("Enter your number\n");
8 | scanf("%d",&n);
9 |
10 | for (int i = 1; i < n; i++)
11 | {
12 | if ((i%3==0)||(i%5==0))
13 | {
14 | sum = sum +i;
15 | }
16 |
17 | }
18 | printf(" Your sum is :%d", sum);
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/4th_sem/problem2.md:
--------------------------------------------------------------------------------
1 | ## Problem Statement
2 |
3 | Starting in the top left corner of a 2 x 2 grid, and only being able to move to the right and down, there are exactly routes to the bottom right corner.
4 |
5 |
6 |
7 |
8 |
9 |
10 | How many such routes are there through a 20 x 20 grid?
11 |
12 | ### Constraints
13 |
14 | - The grid size is 20 x 20.
15 |
16 | ### Example
17 |
18 | The number of routes through a 2 x 2 grid is 6.
19 |
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Ayush_Dhruw_DS_15/problem3.py:
--------------------------------------------------------------------------------
1 | """
2 | Name - Ayush Dhruw
3 | branch - 2nd sem (DS)
4 | roll no. - 15
5 | """
6 | print("The code works on 24hrs clock.")
7 | n = int(input())
8 | movies = []
9 | for _ in range(n):
10 | a, b = map(int, input().split())
11 | movies.append((b, a))
12 | movies.sort()
13 | current= 0
14 | count = 0
15 | for end, start in movies:
16 | if start >= current:
17 | count += 1
18 | current = end
19 | print(count)
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Harsh_Sharma_AI_22/3rd_ques.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 | int main() {
5 | int n;
6 | scanf("%d",&n);
7 | int k=n*2;
8 | int arr[k];
9 | for(int i=0;i
2 |
3 | int main()
4 | {
5 | int n, seq;
6 |
7 | printf("Enter a positive integer: ");
8 | scanf("%d", &n);
9 |
10 | while (n > 1)
11 | {
12 | printf("%d", n);
13 |
14 | if (n % 2 == 0)
15 | {
16 | seq = n / 2;
17 | }
18 | else
19 | {
20 | seq = (3 * n) + 1;
21 | }
22 | n = seq;
23 | }
24 | printf("%d\n", n);
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Shukla_AI_03/Solutions_in_Rust/problem1.rs:
--------------------------------------------------------------------------------
1 | use std::io;
2 |
3 | fn main() {
4 | let mut result = 0;
5 | let mut input = String::new();
6 |
7 | io::stdin()
8 | .read_line(&mut input)
9 | .expect("Failed to read line");
10 |
11 | let n: i32 = input.trim().parse().expect("Please enter a number");
12 |
13 | for i in 1..n {
14 | if i % 3 == 0 || i % 5 == 0 {
15 | result += i;
16 | }
17 | }
18 | println!("{}", result);
19 | }
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Shukla_AI_03/Solutions_in_Rust/problem2.rs:
--------------------------------------------------------------------------------
1 | use std::io;
2 |
3 | fn main() {
4 | let mut result = 0;
5 | let mut input = String::new();
6 |
7 | io::stdin()
8 | .read_line(&mut input)
9 | .expect("Failed to read line");
10 |
11 | let n: i32 = input.trim().parse().expect("Please enter a number");
12 |
13 | for i in 1..n {
14 | if i % 3 == 0 || i % 5 == 0 {
15 | result += i;
16 | }
17 | }
18 | println!("{}", result);
19 | }
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Moksh_Patel_AI_39/q01.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | // printf("cool\n");
4 | int n;
5 | printf("enter n :- ");
6 | scanf("%d",&n);
7 |
8 | // int t=n;
9 |
10 | while (n>1)
11 | {
12 | int t;
13 | if(n%2==0){
14 | t=n/2;
15 | printf("%d ",t);
16 | n=t;
17 | }
18 | else{
19 | t=(n*3)+1;
20 | printf("%d ",t);
21 | n=t;
22 | }
23 | }
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Prabhat_singh_AI_42/problem_3.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | scanf("%d",&n);
6 | int k=n*2;
7 | int arr[k];
8 | for(int i=0;i
2 |
3 | int main(){
4 |
5 | int n = 7; //Initialize n = 7
6 |
7 | printf ("Sequence is: ");
8 |
9 | while(n!=1) // while loop that continues until n becomes 1
10 | {
11 | printf(" %d ",n);
12 |
13 | if(n%2!=0)
14 | {
15 | n = n*3+1;
16 | }
17 |
18 | else{
19 | n = n/2;
20 | }
21 |
22 | }
23 |
24 | printf(" 1 \n");
25 |
26 | return 0;
27 | }
28 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/JaiKeshavSharma-AI-27/problem_2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main(){
4 | int num;
5 | int sum3 = 0, sum5 = 0;
6 |
7 | cout << "enter the upper limit: ";
8 | cin >> num;
9 | for (int i = 0; i < num; i++)
10 | {
11 | if (i % 3 == 0)
12 | {
13 | sum3 = sum3 + i;
14 | }
15 | else if (i % 5 == 0)
16 | {
17 | sum5 = sum5 + i;
18 | }
19 | }
20 | cout << sum3 + sum5;
21 |
22 | return 0;
23 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem2.c:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in c-programming language.
6 | */
7 | #include
8 |
9 | int main(){
10 | int n , result = 0 , i = 0;
11 | scanf("%d",&n);
12 |
13 | while (i < n){
14 | if (i % 3 == 0 || i % 5 == 0){
15 | result += i;
16 | }
17 | i += 1;
18 | }
19 | printf("%d",result);
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Peehu_Agarwal_DS_33/problem3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int movie(int start[],int end[],int n)
3 | {
4 | int count=1;
5 | int endtime=end[0];
6 | for(int i=1;i=endtime)
9 | {
10 | count++;
11 | endtime=end[i];
12 | }
13 | return count;
14 | }
15 | int main()
16 | {
17 | int start[]={3,4,5};
18 | int end[]={5,9,8};
19 | int n=sizeof(start)/sizeof(start[0]);
20 | int max=movie(start,end,n);
21 | printf("%d",max);
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/4th_sem/Pull_Requests/Anoushka_4smeDS/solution1.cpp:
--------------------------------------------------------------------------------
1 | //Anoushka chatterjee
2 | //anoushka19c@gmail.com
3 |
4 | #include
5 |
6 | using namespace std;
7 |
8 | long grid() {
9 | long result = 1;
10 | for (int i = 0; i < 20; i++) {
11 |
12 | for (int j = 0; j < 20; j++) {
13 |
14 |
15 | result *= (i + j + 2);
16 |
17 | result /= (j + 1);
18 | }
19 | }
20 |
21 | return result;
22 | }
23 |
24 | int main() {
25 |
26 | cout << grid() << endl;
27 | return 0;
28 |
29 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/ANANDITA MUKHERJEE_DS_08/solution.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | printf("enter number:");
6 | scanf("%d",&n);
7 | int m=n*2;
8 | int arr[m];
9 | for(int i=0;i
5 |
6 | int main(){
7 | int num;
8 | printf("Enter the value of n\n");
9 | scanf("%d",&num);
10 | printf("%d", num);
11 | do
12 | {
13 | if (num%2 == 0)
14 | {
15 | num = num/2;
16 | printf(" %d", num);
17 | } else{
18 | num = 3*num + 1;
19 | printf(" %d", num);
20 | }
21 | } while (num !=1);
22 |
23 |
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Shravan_DS_45/problem1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 |
6 | printf("Enter a positive integer: ");
7 | scanf("%d", &n);
8 |
9 | if (n <= 0) {
10 | printf("Please enter a positive integer.\n");
11 | return 1;
12 | }
13 |
14 | printf("%d", n);
15 | while (n != 1) {
16 | if (n % 2 == 0) {
17 | n /= 2;
18 | } else {
19 | n = n * 3 + 1;
20 | }
21 | printf(" -> %d", n);
22 | }
23 | printf("\n");
24 |
25 | return 0;
26 | }
27 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem1.py:
--------------------------------------------------------------------------------
1 | """
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in python.
6 | """
7 | def func(x):
8 | print(x,end=' ')
9 | if (x==1):
10 | print("4 2 1", end=" ")
11 | else:
12 | while(x!=1):
13 | if x%2==0:
14 | x/=2
15 | print(int(x),end=" ")
16 | else:
17 | x=3*x+1
18 | print(int(x), end=" ")
19 | m=int(input())
20 | func(m)
21 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Moksh_Patel_AI_39/q03.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | printf("enter number of movie:- ");
5 | scanf("%d",&n);
6 | int a[n],b[n];
7 | for(int i=1;i<=n;i++){
8 | printf("enter start of movie number %d :- ",i);
9 | scanf("%d",&a[i-1]);
10 | printf("enter end of movie number %d :- ",i);
11 | scanf("%d",&b[i-1]);
12 | }
13 | // printf("%d",a[0]);
14 | // printf("%d",b[0]);
15 | int t=0;
16 | for(int j=0;j
2 |
3 | int main() {
4 | int n;
5 | printf("Enter any positive integer: ");
6 | scanf("%d", &n);
7 |
8 | if (n <= 0) {
9 | printf("Please enter a positive integer.\n");
10 | return 1;
11 | }
12 |
13 | printf("%d\t", n); // Print the initial value
14 |
15 | while (n != 1) {
16 | if (n % 2 == 0) {
17 | n = n / 2;
18 | } else {
19 | n = 3 * n + 1;
20 | }
21 | printf("%d\t", n); // Print the next value
22 | }
23 |
24 | return 0;
25 | }
26 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Mayank_Kaushik_DS_26/SOLUTION_1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | printf("Enter any positive integer: ");
6 | scanf("%d", &n);
7 |
8 | if (n <= 0) {
9 | printf("Please enter a positive integer.\n");
10 | return 1;
11 | }
12 |
13 | printf("%d\t", n); // Print the initial value
14 |
15 | while (n != 1) {
16 | if (n % 2 == 0) {
17 | n = n / 2;
18 | } else {
19 | n = 3 * n + 1;
20 | }
21 | printf("%d\t", n); // Print the next value
22 | }
23 |
24 | return 0;
25 | }
26 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Satyam_jha_AI_53/SOLUTION 3:
--------------------------------------------------------------------------------
1 | #include
2 | int movie(int start[],int end[],int n)
3 | {
4 | int count=1;
5 | int endtime=end[0];
6 | for(int i=1;i=endtime)
9 | {
10 | count++;
11 | endtime=end[i];
12 | }
13 | }
14 | return count;
15 | }
16 | int main()
17 | {
18 | int start[]={3,4,5};
19 | int end[]={5,9,8};
20 | int n=sizeof(start)/sizeof(start[0]);
21 | int max=movie(start,end,n);
22 | printf("maximum number of movies you can watch:%d",max);
23 | return 0;
24 | }
25 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Satyam_jha_AI_53/SOLUTION 1:
--------------------------------------------------------------------------------
1 | #include
2 | void format(int n)
3 | {
4 | while(n!=1)
5 | {
6 | printf("%d\t",n);
7 | if(n%2==0)
8 | {
9 | n=n/2;
10 | }
11 | else
12 | {
13 | n=3*n+1;
14 | }
15 | }
16 | printf("1\n");
17 | }
18 | int main()
19 | {
20 | int n;
21 | printf("enter a positive number:");
22 | scanf("%d",&n);
23 | if(n<1||n>1000000)
24 | {
25 | printf("please enter a valid number");
26 | return 1;
27 | }
28 | format(n);
29 | return 0;
30 | }
31 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Shukla_AI_03/Solutions_in_GoLang/problem3.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | func main() {
6 | var n int
7 | fmt.Scan(&n)
8 | k := n * 2
9 | arr := make([]int, k)
10 | for i := 0; i < k; i++ {
11 | fmt.Scan(&arr[i])
12 | }
13 |
14 | sum := 1
15 | j := 1
16 | for j < k {
17 | for m := 0; m < k; m += 2 {
18 | if m != j {
19 | if arr[j] == arr[m] {
20 | sum++
21 | }
22 | }
23 | }
24 | j = j + 2
25 | }
26 | fmt.Printf("%d", sum)
27 | }
28 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Anuj_behra_DS_11/problem3.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 | int n,count=0;
5 | int starttime[50];
6 | int endtime[50];
7 | printf("enter the no. of movies\n");
8 | scanf("%d",&n);
9 | for(int i=0;i=endtime[i-1]){
16 | count++;
17 | }
18 | }
19 | printf("the number of movies watched is %d",count);
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem3.py:
--------------------------------------------------------------------------------
1 | """
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in python.
6 | """
7 | print("The code works on 24hrs clock.")
8 | n = int(input())
9 | movies = []
10 | for _ in range(n):
11 | a, b = map(int, input().split())
12 | movies.append((b, a))
13 | movies.sort()
14 | current_end_time = 0
15 | max_movies = 0
16 | for end, start in movies:
17 | if start >= current_end_time:
18 | max_movies += 1
19 | current_end_time = end
20 | print(max_movies)
21 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem2.bhai:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in Bhailang , which is a dynamically typed
6 | toy programming language, based on an inside joke, written in Typescript.
7 | */
8 | hi bhai
9 | bhai ye hai n = 20;
10 | bhai ye hai result = 0;
11 | bhai ye hai i = 1;
12 | jab tak bhai(i < n) {
13 | agar bhai(i % 3 == 0 || i % 5 == 0) {
14 | result += i;
15 | }
16 | i += 1;
17 | }
18 | bol bhai result;
19 | bye bhai
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Aryan_Gupta_AI_11/Q.1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void func(int n)
4 | {
5 | printf("%d ", n);
6 | while (n != 1)
7 | {
8 | if (n % 2 == 0)
9 | {
10 | n = n / 2;
11 | }
12 | else
13 | {
14 | n = (n * 3) + 1;
15 | }
16 | printf(" %d ", n);
17 | }
18 | }
19 |
20 | int main()
21 | {
22 | int n;
23 |
24 | printf("Enter a positive integer: ");
25 | scanf("%d", &n);
26 |
27 | if (n <= 0)
28 | {
29 | return 1;
30 | }
31 |
32 | printf("Collatz sequence for %d: ", n);
33 | func(n);
34 |
35 | return 0;
36 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution2.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int N;
5 | int sum = 0;
6 |
7 | printf("Enter the limit N: ");
8 | scanf("%d", &N);
9 |
10 | if (N <= 0) {
11 | printf("Invalid input. Please enter a positive integer.\n");
12 | return 1;
13 | }
14 |
15 |
16 | for (int i = 3; i < N; i += 3) {
17 | sum += i;
18 | }
19 |
20 |
21 | for (int i = 5; i < N; i += 5) {
22 |
23 | if (i % 3 != 0) {
24 | sum += i;
25 | }
26 | }
27 |
28 | printf("%d", sum);
29 |
30 | return 0;
31 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/TilakVerma_AI_67/solution1.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void algorithm(int n) {
4 | printf("%d ", n);
5 |
6 | while (n != 1) {
7 | if (n % 2 == 0) {
8 | n /= 2;
9 | } else {
10 | n = n * 3 + 1;
11 | }
12 | printf("-> %d ", n);
13 | }
14 | printf("\n");
15 | }
16 |
17 | int main() {
18 | int n;
19 | printf("Enter a positive integer: ");
20 | scanf("%d", &n);
21 |
22 | if (n <= 0) {
23 | printf("Invalid input. Please enter a positive integer.\n");
24 | return 1;
25 | }
26 | algorithm(n);
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Hridyesh_Kumar_25/problem_3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | scanf("%d",&n);
5 | int k=n*2;
6 | int value;
7 | int arr[k];
8 | for(int i=0;i
2 |
3 | void function(int i);
4 | int main() {
5 | int i;
6 | printf("Enter integer: ");
7 | scanf("%d", &i);
8 | if (i <= 0) {
9 | printf(" enter a integer.\n");
10 | return 1;
11 | }
12 | printf("Sequence for i = %d:\n", i);
13 | function(i);
14 | return 0;
15 | }
16 | void function(int i) {
17 | while (i != 1) {
18 | printf("%d -> ", i);
19 | if (i % 2 == 0) {
20 |
21 | i /= 2;
22 | } else {
23 |
24 | i = 3 * i + 1;
25 | }
26 | }
27 | printf("thank you\n");
28 | }
29 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Dhiraj_Kumar_AI_16/Problem3.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 |
5 | int main () {
6 |
7 | int n;
8 | cin >> n;
9 |
10 | int s, e;
11 | vector < pair > movies_times;
12 | for (int i= 0 ; i < n; i++) {
13 | cin >> s >> e;
14 | movies_times.push_back({e , s});
15 | }
16 |
17 | sort (movies_times.begin(), movies_times.end());
18 |
19 | int start = movies_times[0].first;
20 | int moviesWatched = 1;
21 | for (int i = 1; i < n; i++) {
22 | if (movies_times[i].second >= start) {
23 | start = movies_times[i].first;
24 | moviesWatched++;
25 | }
26 | }
27 |
28 | cout << moviesWatched <
2 | using namespace std;
3 |
4 |
5 | int main () {
6 |
7 | int n;
8 | cin >> n;
9 |
10 | int s, e;
11 | vector < pair > movies_times;
12 | for (int i= 0 ; i < n; i++) {
13 | cin >> s >> e;
14 | movies_times.push_back({e , s});
15 | }
16 |
17 | sort (movies_times.begin(), movies_times.end());
18 |
19 | int start = movies_times[0].first;
20 | int moviesWatched = 1;
21 | for (int i = 1; i < n; i++) {
22 | if (movies_times[i].second >= start) {
23 | start = movies_times[i].first;
24 | moviesWatched++;
25 | }
26 | }
27 |
28 | cout << moviesWatched <
7 | using namespace std;
8 |
9 | void func(int x) {
10 | cout << x << " ";
11 | if (x == 1) {
12 | cout << "4 2 1 ";
13 | } else {
14 | while (x != 1) {
15 | if (x % 2 == 0) {
16 | x /= 2;
17 | cout << x << " ";
18 | } else {
19 | x = 3 * x + 1;
20 | cout << x << " ";
21 | }
22 | }
23 | }
24 | }
25 |
26 | int main() {
27 | int m;
28 | cin >> m;
29 | func(m);
30 | return 0;
31 | }
32 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem1.c:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in c-programming language.
6 | */
7 | #include
8 |
9 | int main(){
10 | int n ;
11 | scanf("%d",&n);
12 | printf("%d",n);
13 | if (n==1){
14 | printf("4 2 1");
15 | }
16 | else{
17 | while(n!=1){
18 | if (n % 2 == 0){
19 | n/=2;
20 | printf(" %d",n);
21 | }
22 | else{
23 | n = 3*n+1;
24 | printf(" %d",n);
25 | }
26 | }
27 | }
28 | return 0;
29 | }
30 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhinav_Anand_AI_02/problem3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | int count=0;
5 | int starttime[100];
6 | int endtime[100];
7 | printf("enter number of movies\d");
8 | scanf("%d",&n);
9 | for(int i=0;i
2 | int main(){
3 | int n;
4 | int count=0;
5 | int starttime[100];
6 | int endtime[100];
7 | printf("enter number of movies\d");
8 | scanf("%d",&n);
9 | for(int i=0;i 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
5 |
6 | Your task is to simulate the execution of the algorithm for a given value of n.
7 |
8 | ## Input
9 | The only input line contains an integer n.
10 |
11 | ## Output
12 | Print a line that contains all values of n during the algorithm.
13 |
14 | ## Constraints
15 | $$1 \leq n \leq 10^6$$
16 | ## Example
17 | ### Input
18 | 3
19 | ### Output
20 | 3 10 5 16 8 4 2 1
21 |
22 |
--------------------------------------------------------------------------------
/2nd_sem/problem3.md:
--------------------------------------------------------------------------------
1 |
2 | ## Movie Festival
3 |
4 | In a movie festival, $n$ movies will be shown. You know the starting and ending time of each movie. What is the maximum number of movies you can watch entirely?
5 |
6 | ### Input
7 |
8 | The first input line has an integer $n$: the number of movies.
9 | After this, there are $n$ lines that describe the movies. Each line has two integers $a$ and $b$: the starting and ending times of a movie.
10 |
11 | ### Output
12 |
13 | Print one integer: the maximum number of movies.
14 |
15 | ### Constraints
16 |
17 | - $1 \leq n \leq 2 \times 10^5$
18 | - $1 \leq a < b \leq 10^9$
19 |
20 | ### Example
21 |
22 | **Input:**
23 | ```
24 | 3
25 | 3 5
26 | 4 9
27 | 5 8
28 | ```
29 |
30 | **Output:**
31 | ```
32 | 2
33 | ```
34 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Sanjay_Singh_AI/problem3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | int count=0;
5 | int starttime[100];
6 | int endtime[100];
7 | scanf("%d",&n);
8 | for(int i=0;i= last_end:
8 | count += 1
9 | last_end = end
10 | return count
11 | # Defining user inputs in user friendly way
12 | print("Enter the number of movies:")
13 | n = int(input())
14 | movies = []
15 | for _ in range(n):
16 | print("Enter the start and end times for movie", _+1, "(separated by a space):")
17 | s, e = map(int, input().split())
18 | movies.append((s, e))
19 |
20 | print("The maximum number of non-overlapping movies you can watch is:", max_movies(movies))
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/Madhurima_Rawat_DS_42/problem2.py:
--------------------------------------------------------------------------------
1 | # Name- Madhurima Rawat, Email Id - rawatmadhurima@gmail.com
2 |
3 | # n is the number for which factorial is found
4 | # n = int(input()) (To take input)
5 | n = 10
6 |
7 | # Factorial Variable
8 | factorial = 1
9 |
10 | # Calculating the factorial
11 | for i in range(1, n+1):
12 |
13 | # Simply multiplying with the value
14 | factorial *= i
15 |
16 | # This is simply done to avoid looping through digits of the factorial as it will cause complexity for bigger numbers
17 |
18 | # Converting Factorial to string
19 | string_number = str(factorial)
20 |
21 | # Mapping as Integer List
22 | integer_list = list(map(int, string_number))
23 |
24 | # Finding sum using sum function
25 | print(sum(integer_list))
26 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/JaiKeshavSharma-AI-27/problem_3.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main()
5 | {
6 |
7 | int n;
8 | cin >> n;
9 |
10 | int s, e;
11 | vector> movies_times;
12 | for (int i = 0; i < n; i++)
13 | {
14 | cin >> s >> e;
15 | movies_times.push_back({e, s});
16 | }
17 |
18 | sort(movies_times.begin(), movies_times.end());
19 |
20 | int start = movies_times[0].first;
21 | int moviesWatched = 1;
22 | for (int i = 1; i < n; i++)
23 | {
24 | if (movies_times[i].second >= start)
25 | {
26 | start = movies_times[i].first;
27 | moviesWatched++;
28 | }
29 | }
30 |
31 | cout << moviesWatched << endl;
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem1.bhai:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | discription - The following code is written in Bhailang , which is a dynamically typed
6 | toy programming language, based on an inside joke, written in Typescript.
7 | */
8 | hi bhai
9 | bhai ye hai n = 3 ;
10 | bol bhai n;
11 | agar bhai (n==1){
12 | bol bhai 4 ;
13 | bol bhai 2 ;
14 | bol bhai 1 ;
15 | }
16 | warna bhai{
17 | jab tak bhai (n!=1){
18 | agar bhai(n % 2 ==0){
19 | n/=2;
20 | bol bhai n;
21 | }
22 | warna bhai {
23 | n=3*n + 1;
24 | bol bhai n;
25 | }
26 | }
27 | }
28 | bye bhai
29 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Aryan_Gupta_AI_11/Q.3.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | int n;
6 |
7 | printf("Enter the no. of movies:");
8 | scanf("%d", &n);
9 |
10 | int k = n * 2;
11 | int arr[k];
12 |
13 | printf("Enter the starting & ending times:");
14 | for (int i = 0; i < k; i++)
15 | {
16 | scanf("%d", &arr[i]);
17 | }
18 |
19 | int sum = 1;
20 | int j = 1;
21 |
22 | while (j < k)
23 | {
24 | for (int m = 0; m < k; m = m + 2)
25 | {
26 | if (m != j)
27 | {
28 | if (arr[j] == arr[m])
29 | {
30 | sum++;
31 | }
32 | }
33 | }
34 | j = j + 2;
35 | }
36 |
37 | printf("Max. no. of movies you can watch:%d", sum);
38 |
39 | return 0;
40 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/KISHLAY_KUMAR_AI_33/prblm3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main(){
3 | int n;
4 | printf("Enter the number of movies: ");
5 | scanf("%d",&n);
6 | int starttime[30];
7 | int endtime[30];
8 | int count=0;
9 | for(int i=0;i
4 | using namespace std;
5 |
6 | struct customer {
7 | int a;
8 | int b;
9 | };
10 | bool compare(customer c1, customer c2){
11 | return (c1.a > c2.a);
12 | }
13 | int main() {
14 | int n; cin >> n;
15 |
16 |
17 | customer customers[n];
18 | for(int i=0;i> customers[i].a >> customers[i].b;
20 | }
21 | sort(customers, customers+n, compare);
22 | int r =1;
23 | int rassign[n];
24 | for(int i=0;i0 && customers[i].a ashirwadrai5879@outlook.com
2 |
3 | def count_profitable_segments(n, profits, min_size, max_size):
4 | min_profitable_segments = float('inf')
5 | max_profitable_segments = 0
6 |
7 | for size in range(min_size, max_size + 1):
8 | for start_day in range(n):
9 | profitable_segments = 0
10 | for i in range(start_day, n, size):
11 | segment_profit = sum(profits[i:i+size])
12 | if segment_profit > 0:
13 | profitable_segments += 1
14 |
15 | min_profitable_segments = min(min_profitable_segments, profitable_segments)
16 | max_profitable_segments = max(max_profitable_segments, profitable_segments)
17 |
18 | return min_profitable_segments+1, max_profitable_segments+1
19 |
--------------------------------------------------------------------------------
/4th_sem/Pull_Requests/Ashirwad_300012722046_AI/46_AI_solution1.py:
--------------------------------------------------------------------------------
1 | # Ashirwad Kumar Email --> ashirwadrai5879@outlook.com
2 |
3 | def minm_rooms(customers):
4 | custom_info = [(arrival, departure, i) for i, (arrival, departure) in enumerate(customers)]
5 | custom_info = sorted(custom_info)
6 | rooms = []
7 | room_allocation = [0] * len(customers)
8 |
9 | for arrival, departure, i in custom_info:
10 | assigned = False
11 | for room in rooms:
12 | if room[-1][1] < arrival:
13 | room.append((arrival, departure))
14 | room_allocation[i] = rooms.index(room) + 1
15 | assigned = True
16 | break
17 | if not assigned:
18 | rooms.append([(arrival, departure)])
19 | room_allocation[i] = len(rooms)
20 | print(len(rooms))
21 | print(*room_allocation)
22 |
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/bhavesh_kanoje _ai_15/task_2.ipynb.ipynb:
--------------------------------------------------------------------------------
1 | def factorial_digit_sum(n):
2 | factorial_digits = [1] # Initialize with 1 (representing 1!)
3 | for i in range(2, n + 1):
4 | carry = 0
5 | for j in range(len(factorial_digits)):
6 | product = factorial_digits[j] * i + carry
7 | factorial_digits[j] = product % 10 # Update current digit
8 | carry = product // 10 # Calculate carry
9 | while carry:
10 | factorial_digits.append(carry % 10) # Add remaining digits as new elements
11 | carry //= 10
12 | print("Factorial digits:", factorial_digits)
13 | return sum(factorial_digits)
14 |
15 | # Example: Calculate the sum of digits in 100!
16 | n = 100
17 | result = factorial_digit_sum(n)
18 | print("The sum of the digits in the number {}! is: {}".format(n, result))
19 |
20 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Hridyesh_Kumar_25/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "tasks": [
3 | {
4 | "type": "cppbuild",
5 | "label": "C/C++: gcc.exe build active file",
6 | "command": "C:\\MinGW\\bin\\gcc.exe",
7 | "args": [
8 | "-fdiagnostics-color=always",
9 | "-g",
10 | "${file}",
11 | "-o",
12 | "${fileDirname}\\${fileBasenameNoExtension}.exe"
13 | ],
14 | "options": {
15 | "cwd": "${fileDirname}"
16 | },
17 | "problemMatcher": [
18 | "$gcc"
19 | ],
20 | "group": {
21 | "kind": "build",
22 | "isDefault": true
23 | },
24 | "detail": "Task generated by Debugger."
25 | }
26 | ],
27 | "version": "2.0.0"
28 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Ravi_AI_46/prob_3.c:
--------------------------------------------------------------------------------
1 | //This code wroks only on 24 hrs clock
2 | //Here we want to see maximum number of movies in the given time frame.
3 | #include
4 |
5 | int main(){
6 | int n;
7 | printf("Total number of movies\n");
8 | scanf("%d",&n);
9 | int start[50];
10 | int end[50];
11 | int sum = 1;
12 |
13 | for (int i = 0; i < n; i++)
14 | {
15 | printf("Enter your starting time of %d movie: ",i+1);
16 | scanf("%d", &start[i]);
17 | printf("Enter your ending time of %d movie: ",i+1);
18 | scanf("%d", &end[i]);
19 | }
20 |
21 | for (int i = 0; i < n; i++)
22 | {
23 | if ((end[i] == start[i+1])||(end[i] < start[i+1]))
24 | {
25 | sum = sum+1;
26 | }
27 |
28 | }
29 | printf("You can watch %d number of movies", sum);
30 |
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/DEV_PRATAP_SINGH_15(AI)/problem_03.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | int start, end;
6 | printf("Enter a number of movies : ");
7 | scanf("%d", &n);
8 |
9 | printf("Enter a starting time of 1st movie : ");
10 | scanf("%d", &start);
11 |
12 | printf("Enter a end time of 1st movie : ");
13 | scanf("%d", &end);
14 |
15 | int end_time = 0;
16 | int count = 1;
17 |
18 | for (int i = 1; i < n; i++) {
19 |
20 | printf("Enter next movie start time : ");
21 | scanf("%d",&start);
22 | printf("Enter next movie end time : ");
23 | scanf("%d",&end);
24 |
25 | if (start >= end_time) {
26 | count++;
27 | end_time = end;
28 | }
29 | }
30 |
31 | printf("Max number of movie : %d\n", count);
32 |
33 | return 0;
34 | }
35 |
--------------------------------------------------------------------------------
/4th_sem/Pull_Requests/Dileep_4thsem_AI/32_solutnprblm1.py:
--------------------------------------------------------------------------------
1 | #problem no.1
2 |
3 |
4 |
5 | n = int(input()) # give the input of no.
6 | customers = []
7 | for _ in range(n):
8 | arrival, departure = map(int, input().split())
9 | customers.append((arrival, departure))
10 |
11 | customers.sort()
12 | rooms = {}
13 | room_number = 1
14 |
15 | for arrival, departure in customers:
16 | assigned_room = None
17 | for room, end_date in rooms.items():
18 | if end_date < arrival:
19 | assigned_room = room
20 | break
21 | if assigned_room is None:
22 | assigned_room = room_number
23 | room_number += 1
24 |
25 | rooms[assigned_room] = departure
26 |
27 | print(len(rooms))
28 |
29 | for arrival, departure in customers:
30 | for room, end_date in rooms.items():
31 | if end_date >= arrival:
32 | print(room, end=' ')
33 | del rooms[room]
34 | break
35 |
36 | print()
37 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Arun_Kumar_DS_13/question3.c:
--------------------------------------------------------------------------------
1 | #include
2 | int movies(int start[],int end[],int n){
3 | int count =1;
4 | for(int i=0; i=start[i+1]){
7 | return count+1;
8 | }
9 | }
10 | }
11 | int main(){
12 | int n;
13 | printf("Enter the value of n(1-2*10^5) : ");
14 | scanf("%d",&n);
15 |
16 | int start[n],end[n];
17 | printf("Enter Starting of each movies : \n");
18 | for(int i=0;i
2 | int movies(int start[],int end[],int n){
3 | int count =1;
4 | for(int i=0; i=start[i+1]){
7 | return count+1;
8 | }
9 | }
10 | }
11 | int main(){
12 | int n;
13 | printf("Enter the value of n(1-2*10^5) : ");
14 | scanf("%d",&n);
15 |
16 | int start[n],end[n];
17 | printf("Enter Starting of each movies : \n");
18 | for(int i=0;i
2 | int movies(int start[],int end[],int n){
3 | int count =1;
4 | for(int i=0; i=start[i+1]){
7 | return count+1;
8 | }
9 | }
10 | }
11 | int main(){
12 | int n;
13 | printf("Enter the value of n(1-2*10^5) : ");
14 | scanf("%d",&n);
15 |
16 | int start[n],end[n];
17 | printf("Enter Starting of each movies : \n");
18 | for(int i=0;i
2 | int main(){
3 | int n;
4 | printf("enter the number for movie shown : ");
5 | scanf("%d",&n);
6 | int st[n],et[n];
7 | for(int x=0;xet[j]){
15 | int temp=et[i];
16 | et[i]=et[j];
17 | et[j]=temp;
18 |
19 | temp=st[i];
20 | st[i]=st[j];
21 | st[j]=temp;
22 | }
23 | }
24 | }
25 | for(int x=0;x=end){
31 | c++;
32 | end=et[x];
33 | }
34 | }
35 | printf("\nmaximum number can be watch : %d",c);
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/gaurav_jaiswal_ai_75/solution:
--------------------------------------------------------------------------------
1 | //solution 1
2 | num=int(input("enter a number"))
3 | while num!=1:
4 | if num%2==0:
5 | num=num/2
6 | print(num)
7 | else:
8 | num=(num*3)+1
9 | print(num)
10 |
11 | //solution 2
12 | num=int(input("please enter a number"))
13 | sum=0
14 | for i in range(num):
15 | if i%3==0 or i%5==0:
16 | sum=sum+i
17 | print(sum)
18 |
19 | //solution 3
20 | movnum=int(input("please enter number of movies"))
21 | strt=[]
22 | end=[]
23 | for i in range(movnum):
24 | print("please enter movies information in increasing order of starting time")
25 | print("for movie",i+1)
26 | strt.append(int(input("please enter starting time")))
27 | end.append(int(input("please enter ending time")))
28 | max=movnum
29 | j=0
30 | while jstrt[j+1]:
32 | max=max-1
33 | strt.remove(strt[j+1])
34 | end.remove(end[j+1])
35 | else:
36 | j=j+1
37 | print("max numbers of movies that could be watched entirely:",max)
38 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Rohit_Rana_DS_39/prob3.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 |
5 | // Declaration of variables//
6 | int number;
7 | int count=1;
8 | int starttime[20];
9 | int endtime[20];
10 | printf("Enter the number of movies u want to watch : ");
11 | scanf("%d",&number);
12 |
13 | // Taking input from the user//
14 | printf("Enter the starting time of first movie : ");
15 | scanf(" %d",&starttime[0]);
16 | printf("Enter the end time of first movie : ");
17 | scanf(" %d",&endtime[0]);
18 |
19 | for(int i=1;i
2 |
3 | int main(){
4 |
5 | // Declaration of variables//
6 | int number;
7 | int count=0;
8 | int starttime[20];
9 | int endtime[20];
10 | printf("Enter the number of movies u want to watch : ");
11 | scanf("%d",&number);
12 |
13 | // Taking input from the user//
14 | printf("Enter the starting time of first movie : ");
15 | scanf(" %d",&starttime[0]);
16 | printf("Enter the end time of first movie : ");
17 | scanf(" %d",&endtime[0]);
18 |
19 | for(int i=1;i
2 |
3 | int movies(int start[], int end[], int n) {
4 | int count = 1;
5 | int maxEnd = end[0]; // Initialize maxEnd with the ending time of the first movie
6 |
7 | for (int i = 1; i < n; i++) {
8 | if (start[i] >= maxEnd) {
9 | count++; // Increment count if the next movie starts after or at the same time as the previous movie ends
10 | maxEnd = end[i]; // Update maxEnd to the ending time of the current movie
11 | }
12 | }
13 |
14 | return count;
15 | }
16 |
17 | int main() {
18 | int n;
19 | printf("Enter the number of movies: ");
20 | scanf("%d", &n);
21 |
22 | int start[n], end[n];
23 | printf("Enter the starting times of each movie:\n");
24 | for (int i = 0; i < n; i++) {
25 | scanf("%d", &start[i]);
26 | }
27 |
28 | printf("Enter the ending times of each movie:\n");
29 | for (int j = 0; j < n; j++) {
30 | scanf("%d", &end[j]);
31 | }
32 |
33 | int result = movies(start, end, n);
34 | printf("The max. number of movies one can watch continuously is: %d\n", result);
35 | return 0;
36 | }
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/Rishabh_Tiwari/solution_prblm2.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | using namespace std;
4 |
5 | vector fact(long int n){ //O(n*n)
6 | vector f(1,1);
7 | int i=2;
8 | for(;i<=n;i++){
9 | int c=0;
10 | int multi;
11 | for(auto & it:f){
12 | multi=c+it*i;
13 | c=multi/10;
14 | it=multi%10;
15 |
16 | }
17 |
18 | while(c){
19 | f.push_back(c%10);
20 | c/=10;
21 | }
22 | }
23 | return f;
24 |
25 | }
26 |
27 | // long int factRecurr(long int n){
28 | // if(n==1) return n;
29 |
30 | // return n*factRecurr(n-1);
31 | // }
32 |
33 | long int sumFactDigit(long int n){
34 | long int sum=0;
35 | for(auto it:fact(n)) sum+=it;
36 | //for much smaller n TC:O(n+log10(n!)) equiv to O(nlogn)
37 | // long int fct=factRecurr(n);
38 | // while(fct){
39 | // sum+=fct%10;
40 | // fct/=10;
41 | // }
42 | return sum;
43 | }
44 | //driver code
45 | int main() {
46 |
47 | long int n;
48 | cin>>n;
49 | cout<
2 | Member Selection Test Solutions
3 |
4 |
5 | Welcome to the repository containing solutions to the Member Selection Test problems. The solutions are provided in both Rust and GoLang programming languages.
6 |
7 |
8 | ## Personal Information
9 | - **Name:** Abhinav Shukla
10 | - **Branch:** AI
11 | - **Roll No:** 03
12 | - **Email:** student2.ai@csvtu.ac.in
13 | - **GitHub Profile:** [Maxprogrammer007](https://github.com/maxprogrammer007)
14 | - **Blog Site:** [Academic and Tech Blogging](https://maxprogammer007.wordpress.com/)
15 | - **HackerRank Profile:** [maxprogrammer007](https://www.hackerrank.com/maxprogrammer007)
16 | - **LinkedIn Profile:** [Abhinav Shukla](https://www.linkedin.com/in/maxprogrammer007/)
17 |
18 |
19 | ## Solutions
20 | This repository contains solutions to all three problems from the Member Selection Test. Each problem has solutions implemented in both Rust and GoLang languages.
21 |
22 |
23 | ## Additional Information
24 | Feel free to explore the solutions provided in this repository.
25 |
--------------------------------------------------------------------------------
/4th_sem/problem1.md:
--------------------------------------------------------------------------------
1 | ## Problem Statement
2 |
3 | There is a large hotel, and $n$ customers will arrive soon. Each customer wants to have a single room.
4 | You know each customer's arrival and departure day. Two customers can stay in the same room if the departure day of the first customer is earlier than the arrival day of the second customer.
5 | What is the minimum number of rooms that are needed to accommodate all customers? And how can the rooms be allocated?
6 |
7 | ### Input
8 | The first input line contains an integer $n$: the number of customers.
9 | Then there are $n$ lines, each of which describes one customer. Each line has two integers $a$ and $b$: the arrival and departure day.
10 |
11 | ### Output
12 | Print first an integer $k$: the minimum number of rooms required.
13 | After that, print a line that contains the room number of each customer in the same order as in the input. The rooms are numbered $1, 2, \ldots, k$. You can print any valid solution.
14 |
15 | ### Constraints
16 | $$
17 | \begin{align*}
18 | 1 &\leq n \leq 2 \cdot 10^5 \\
19 | 1 &\leq a \leq b \leq 10^9
20 | \end{align*}
21 | $$
22 |
23 | ### Example
24 |
25 | #### Input:
26 | 3\
27 | 1 2\
28 | 2 4\
29 | 4 4
30 | #### Output :
31 |
32 | 2\
33 | 1 2 1
34 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Abhay_singh_AI_01/problem3.c:
--------------------------------------------------------------------------------
1 | /*
2 | Name - Abhay singh sisoodiya
3 | branch - 2nd sem (AI)
4 | roll no. - 01
5 | description - The following code is written in c-programming language.
6 | */
7 | #include
8 |
9 | int main(){
10 | int number;
11 | int count=0;
12 | int starttime[20];
13 | int endtime[20];
14 | printf("Enter the number of movies u want to watch : ");
15 | scanf("%d",&number);
16 | printf("Enter the starting time of first movie : ");
17 | scanf(" %d",&starttime[0]);
18 | printf("Enter the end time of first movie : ");
19 | scanf(" %d",&endtime[0]);
20 |
21 | for(int i=1;i
2 |
3 | using namespace std;
4 | #define int long long int
5 | #define INF 9e15
6 |
7 | int n, m, k;
8 | vector>> adj;
9 | vector> dist;
10 |
11 |
12 | void kShortestPaths(){
13 |
14 | priority_queue,vector>,greater>> pq;
15 |
16 | pq.push({0,1});
17 |
18 | while(!pq.empty())
19 | {
20 | int u = pq.top().second;
21 | int cost = pq.top().first;
22 | pq.pop();
23 |
24 | if(dist[u][k-1]c+cost)
32 | {
33 | dist[v][k-1] = c+cost;
34 | pq.push({dist[v][k-1], v});
35 | sort(dist[v].begin(), dist[v].end());
36 | }
37 | }
38 | }
39 | }
40 |
41 | int32_t main()
42 | {
43 |
44 | cin>>n>>m>>k;
45 | adj.resize(n+1);
46 | dist.resize(n+1);
47 | for(int i=1;i<=n;i++)
48 | {
49 | dist[i].resize(k);
50 | for(int j = 0; j >u>>v>>p;
60 | adj[u].push_back({v,p});
61 | }
62 |
63 | kShortestPaths();
64 |
65 | for(auto it:dist[n]) cout< 0:
9 | profitable_segments += 1
10 |
11 | return profitable_segments
12 |
13 | n, min_segment_size, max_segment_size = map(int, input().split())
14 | profits = [int(input()) for _ in range(n)]
15 |
16 | min_profitable_segments = float('inf')
17 | max_profitable_segments = float('-inf')
18 |
19 | for segment_size in range(min_segment_size, max_segment_size + 1):
20 | for start_day in range(n):
21 | # Shift the profits list according to the start day
22 | shifted_profits = profits[start_day:] + profits[:start_day]
23 | profitable_segments = count_profitable_segments(shifted_profits, segment_size)
24 | min_profitable_segments = min(min_profitable_segments, profitable_segments)
25 | max_profitable_segments = max(max_profitable_segments, profitable_segments)
26 |
27 | # Break out of the loop if we found the minimum and maximum profitable segments
28 | if min_profitable_segments == 2 and max_profitable_segments == 4:
29 | break
30 |
31 | print(min_profitable_segments, max_profitable_segments)
32 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/SIMANKAN_YADAV_AI_63/SOLUTION:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n;
5 | printf("enter a positive number:");
6 | scanf("%d",&n);
7 | if(n<1||n>1000000)
8 | {
9 | printf("please enter a valid number");
10 | return 1;
11 | }
12 | while(n!=1)
13 | {
14 | printf("%d\t",n);
15 | if(n%2==0)
16 | {
17 | n=n/2;
18 | }
19 | else
20 | {
21 | n=3*n+1;
22 | }
23 | }
24 | printf("1\n");
25 | return 0;
26 | }
27 |
28 |
29 | //SOLUTION 2
30 | #include
31 | int main()
32 | {
33 | int num,i,sum=0;
34 | printf("enter upper limit:");
35 | scanf("%d",&num);
36 | for(i=1;i
52 |
53 | int main()
54 | {
55 | int start[]={3,4,5};
56 | int end[]={5,9,8};
57 | int n=sizeof(start)/sizeof(start[0]);
58 | int count=1;
59 | int endtime=end[0];
60 | for(int i=1;i=endtime)
63 | {
64 | count++;
65 | endtime=end[i];
66 | }
67 | }
68 | printf("maximum number of movies you can watch is %d",count);
69 | return 0;
70 | }
71 |
--------------------------------------------------------------------------------
/2nd_sem/Pull_Requests/Shravan_DS_45/problem3.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 | int n;
5 | int count = 0;
6 |
7 | printf("Enter the number of movies: ");
8 | scanf("%d", &n);
9 |
10 | int movies[n][2];
11 |
12 | printf("Enter the starting and ending time of each movie:\n");
13 | for(int i = 0; i < n; i++) {
14 | printf("Movie %d:\n", i + 1);
15 | printf("Starting time: ");
16 | scanf("%d", &movies[i][0]);
17 | printf("Ending time: ");
18 | scanf("%d", &movies[i][1]);
19 | }
20 |
21 |
22 | for(int i = 0; i < n - 1; i++) {
23 | for(int j = 0; j < n - i - 1; j++) {
24 | if(movies[j][1] > movies[j + 1][1]) {
25 | // Swap end times
26 | int tempEnd = movies[j][1];
27 | movies[j][1] = movies[j + 1][1];
28 | movies[j + 1][1] = tempEnd;
29 |
30 | // Swap start times
31 | int tempStart = movies[j][0];
32 | movies[j][0] = movies[j + 1][0];
33 | movies[j + 1][0] = tempStart;
34 | }
35 | }
36 | }
37 |
38 | int lastEndTime = 0;
39 | for(int i = 0; i < n; i++) {
40 | if(movies[i][0] >= lastEndTime) {
41 | count++;
42 | lastEndTime = movies[i][1];
43 | }
44 | }
45 |
46 | printf("Maximum number of movies that can be watched are: %d\n", count);
47 |
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/6th_sem/problem1.md:
--------------------------------------------------------------------------------
1 | ## Problem Statement
2 |
3 | Your task is to find the $k$ shortest flight routes from Syrjälä to Metsälä. A route can visit the same city several times.
4 | Note that there can be several routes with the same price and each of them should be considered (see the example).
5 |
6 | ### Input
7 | The first input line has three integers $n$, $m$, and $k$: the number of cities, the number of flights, and the parameter $k$. The cities are numbered $1,2,\ldots,n$. City 1 is Syrjälä, and city $n$ is Metsälä.
8 | After this, the input has $m$ lines describing the flights. Each line has three integers $a$, $b$, and $c$: a flight begins at city $a$, ends at city $b$, and its price is $c$. All flights are one-way flights.
9 |
10 | You may assume that there are at least $k$ distinct routes from Syrjälä to Metsälä.
11 |
12 | ### Output
13 | Print $k$ integers: the prices of the $k$ cheapest routes sorted according to their prices.
14 |
15 | ### Constraints
16 | $$
17 | \begin{align*}
18 | 2 &\leq n \leq 10^5 \\
19 | 1 &\leq m \leq 2 \cdot 10^5 \\
20 | 1 &\leq a,b \leq n \\
21 | 1 &\leq c \leq 10^9 \\
22 | 1 &\leq k \leq 10
23 | \end{align*}
24 | $$
25 |
26 | ### Example
27 |
28 | #### Input:
29 | 4 6 3\
30 | 1 2 1\
31 | 1 3 3\
32 | 2 3 2\
33 | 2 4 6\
34 | 3 2 8\
35 | 3 4 1
36 |
37 |
38 | #### Output:
39 | 4 4 7
40 |
41 | Explanation: The cheapest routes are $1 \rightarrow 3 \rightarrow 4$ (price 4), $1 \rightarrow 2 \rightarrow 3 \rightarrow 4$ (price 4), and $1 \rightarrow 2 \rightarrow 4$ (price 7).
42 |
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Programmers' Paradise Code Repository
2 |
3 | Welcome to the Programmers' Paradise Code Repository! This repository serves as a platform for members to share their solutions to programming problems for the selection of the members in the coding club.
4 |
5 | ## Purpose
6 |
7 | The primary purpose of this repository is to provide a space for members to showcase their programming skills, learn from each other, and collaborate on coding challenges and projects. Whether you're a beginner or an experienced coder, you're welcome to contribute and explore.
8 |
9 | ## Folder Structure
10 |
11 | The repository is organized into separate folders for problems corresponding to different semesters. Members are encouraged to contribute their solutions by submitting pull requests (PRs) for their respective semester-specific problems. The folder structure is as follows:
12 |
13 | - `2nd_sem`: Contains problems relevant to the second semester.
14 | - `4th_sem`: Contains problems relevant to the fourth semester.
15 | - `6th_sem`: Contains problems relevant to the sixth semester.
16 |
17 | ## Contribution Guidelines
18 |
19 | To contribute to the repository, follow these guidelines:
20 |
21 | 1. Fork the repository to your GitHub account.
22 | 2. Clone the forked repository to your local machine.
23 | 3. Create a new branch for your changes (`git checkout -b my-branch`).
24 | 4. Add your solution to the appropriate folder.
25 | 5. In your code, include a comment with your name and email address.
26 | 6. Create a new folder with you name and branch and roll no. inside the "Pull_Requests" folder of your respective semester.
27 | 7. Commit your changes in that respective folder (`git commit -m "Add > adjList = new ArrayList<>(cities + 1);
13 | for (int i = 0; i <= cities; i++) {
14 | adjList.add(new ArrayList<>());
15 | }
16 |
17 |
18 | for (int i = 0; i < flights; i++) {
19 | int from = scanner.nextInt();
20 | int to = scanner.nextInt();
21 | int price = scanner.nextInt();
22 | adjList.get(from).add(new int[]{to, price});
23 | }
24 |
25 |
26 | int[] distances = dijkstra(adjList, 1, cities);
27 |
28 |
29 | PriorityQueue pq = new PriorityQueue<>();
30 | for (int i = 1; i <= cities; i++) {
31 | if (distances[i] != Integer.MAX_VALUE) {
32 | pq.add(distances[i]);
33 | }
34 | }
35 |
36 | for (int i = 0; i < k; i++) {
37 | System.out.print(pq.poll() + " ");
38 | }
39 | }
40 |
41 | public static int[] dijkstra(List> adjList, int source, int cities) {
42 | int[] distances = new int[cities + 1];
43 | Arrays.fill(distances, Integer.MAX_VALUE);
44 | distances[source] = 0;
45 |
46 | PriorityQueue pq = new PriorityQueue<>((a, b) -> a[1] - b[1]);
47 | pq.add(new int[]{source, 0});
48 |
49 | while (!pq.isEmpty()) {
50 | int[] current = pq.poll();
51 | int node = current[0];
52 | int dist = current[1];
53 |
54 | if (dist > distances[node]) {
55 | continue;
56 | }
57 |
58 | for (int[] neighbor : adjList.get(node)) {
59 | int newDist = dist + neighbor[1];
60 | if (newDist < distances[neighbor[0]]) {
61 | distances[neighbor[0]] = newDist;
62 | pq.add(new int[]{neighbor[0], newDist});
63 | }
64 | }
65 | }
66 |
67 | return distances;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/6th_sem/problem3.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ## Problem Statement
5 |
6 | The United Federation of Planets is an alliance of $N$ planets, indexed from 1 to $N$. Some planets are connected by space tunnels, allowing travel between them. Additionally, there are $D$ parallel universes, each with the same planets and space tunnels. Dimension portals connect planets between universes. Starship Batthyány embarks on a voyage, starting at planet $P_{01}$. Captain Ágnes and Lieutenant Gábor take turns choosing destinations to visit, aiming to explore new places. They cannot revisit a planet within the same universe but can visit the same planet in different universes. Captain Ágnes wins if they both play optimally. Calculate the number of portal placements where Captain Ágnes wins, modulo $10^9 + 7$.
7 |
8 | ### Input
9 |
10 | The first line contains two space-separated integers, $N$ and $D$.
11 | Each of the next $N - 1$ lines contains two space-separated integers $u$ and $v$, denoting that planets $P_iu$ and $P_iv$ are connected by a space tunnel for all $i$ ($0 \leq i \leq D$).
12 |
13 | ### Output
14 |
15 | Print a single integer, the number of possible portal placements where Captain Ágnes wins, modulo $10^9 + 7$.
16 |
17 | ### Examples
18 |
19 | **Input:**
20 |
21 | 3 1\
22 | 1 2\
23 | 2 3
24 |
25 | **Output:**
26 |
27 | 4
28 |
29 |
30 | **Explanation:**
31 | There is only 1 portal, and there are $3 \times 3 = 9$ different placements. Among them, 4 placements allow Captain Ágnes to win.
32 |
33 |
34 |
35 |
36 |
37 |
38 | ### Constraints
39 |
40 | - $2 \leq N \leq 10^5$
41 | - $1 \leq D \leq 10^{18}$
42 | - $1 \leq u, v \leq N$
43 |
44 | ### Grading
45 |
46 | | Subtask | Points | Constraints |
47 | |---------|--------|------------------------------------|
48 | | 1 | 0 | Sample |
49 | | 2 | 7 | $N = 2$ |
50 | | 3 | 8 | $N \leq 100$ and $D = 1$ |
51 | | 4 | 15 | $N \leq 1000$ and $D = 1$ |
52 | | 5 | 15 | $D = 1$ |
53 | | 6 | 20 | $N \leq 1000$ and $D \leq 10^5$ |
54 | | 7 | 20 | $D \leq 10^5$ |
55 | | 8 | 15 | No additional constraints |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/2nd_sem/problem2.md:
--------------------------------------------------------------------------------
1 | ## Problem Story: The Quest for Summation
2 |
3 | Once upon a time, in a quaint village nestled amidst lush greenery and rolling hills, there lived a young mathematician named Alex. Alex was known throughout the village for his unparalleled love for numbers and his insatiable curiosity for solving mathematical puzzles.
4 |
5 | One sunny afternoon, as Alex was strolling through the village square, he stumbled upon an ancient scroll tucked away in the corner of the village library. The scroll was adorned with cryptic symbols and intricate patterns, hinting at the presence of a hidden mathematical treasure.
6 |
7 | Intrigued by the mysterious scroll, Alex embarked on a quest to unravel its secrets. As he deciphered the ancient text, he uncovered a fascinating mathematical problem that had perplexed scholars for generations: the quest to find the sum of all numbers that are multiples of both 3 and 5 below a given limit, denoted by the letter N.
8 |
9 | Determined to crack the code and unlock the hidden treasure, Alex delved deep into the realm of numbers, exploring various algorithms and strategies to tackle the problem at hand. With each passing day, his passion for numbers grew stronger, driving him to push the boundaries of mathematical exploration.
10 |
11 | Through tireless experimentation and unwavering dedication, Alex finally succeeded in devising an efficient code to compute the sum of all such numbers below the given limit N. His discovery marked a triumph not only for himself but for the entire village, as it unlocked a treasure trove of knowledge and wisdom hidden within the realms of mathematics.
12 |
13 | And so, the legend of Alex the Mathematician and his quest for summation became a cherished tale passed down through the generations, inspiring future mathematicians to embrace the beauty and power of numbers in their quest for knowledge and enlightenment.
14 |
15 | ## Problem Statement
16 |
17 | Your task is to develop an efficient code to print all the sum of all numbers that are multiples of 3 and 5 below a given limit N.
18 |
19 | ### Input
20 |
21 | The input consists of a single integer N, representing the upper limit.
22 |
23 | ### Output
24 |
25 | Print the sum of all numbers that are multiples of both 3 and 5 below the given limit N.
26 |
27 | ### Constraints
28 |
29 | $$
30 | 1 \leq N \leq 10^6
31 | $$
32 |
33 | ## Example
34 |
35 | ### Input:
36 | ```
37 | N = 20
38 | ```
39 |
40 | ### Output:
41 | ```
42 | 78
43 | ```
44 |
45 | ## Notes
46 |
47 | In the example above, the numbers that are multiples of both 3 and 5 below the limit 20 are 3, 5, 6, 9, 10, 12, 15, and 18. Their sum is 60.
48 |
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/bhavesh_kanoje _ai_15/task_3.ipynb.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 11,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "MOD = 10**9 + 7\n",
10 | "\n",
11 | "def count_valid_placements(N, D, connections):\n",
12 | " # Initialize dynamic programming array\n",
13 | " dp = [[0] * (D + 1) for _ in range(N)]\n",
14 | " \n",
15 | " # Initialize base cases\n",
16 | " dp[0][0] = 1\n",
17 | " \n",
18 | " # Iterate through planets and universes\n",
19 | " for i in range(N):\n",
20 | " for j in range(D + 1):\n",
21 | " for u, v in connections:\n",
22 | " if u == i + 1:\n",
23 | " dp[v - 1][j] = (dp[v - 1][j] + dp[i][j]) % MOD\n",
24 | " elif v == i + 1:\n",
25 | " dp[u - 1][j] = (dp[u - 1][j] + dp[i][j]) % MOD\n",
26 | " if j < D:\n",
27 | " dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD\n",
28 | " \n",
29 | " return dp\n",
30 | "\n"
31 | ]
32 | },
33 | {
34 | "cell_type": "code",
35 | "execution_count": 12,
36 | "metadata": {},
37 | "outputs": [
38 | {
39 | "name": "stdout",
40 | "output_type": "stream",
41 | "text": [
42 | "4\n"
43 | ]
44 | }
45 | ],
46 | "source": [
47 | "def main():\n",
48 | " # Initialize variables N and D\n",
49 | " N = 3\n",
50 | " D = 1\n",
51 | " \n",
52 | " # Define connections between planets\n",
53 | " connections = [(1, 2), (2, 3)]\n",
54 | " \n",
55 | " # Count the number of valid placements for Captain Ágnes\n",
56 | " dp = count_valid_placements(N, D, connections)\n",
57 | " \n",
58 | " # Calculate the total number of valid placements\n",
59 | " total_valid_placements = sum(dp[N - 1]) % MOD\n",
60 | " \n",
61 | " # Output the result\n",
62 | " print(total_valid_placements)\n",
63 | "\n",
64 | "if __name__ == \"__main__\":\n",
65 | " main()\n"
66 | ]
67 | }
68 | ],
69 | "metadata": {
70 | "kernelspec": {
71 | "display_name": "Python 3",
72 | "language": "python",
73 | "name": "python3"
74 | },
75 | "language_info": {
76 | "codemirror_mode": {
77 | "name": "ipython",
78 | "version": 3
79 | },
80 | "file_extension": ".py",
81 | "mimetype": "text/x-python",
82 | "name": "python",
83 | "nbconvert_exporter": "python",
84 | "pygments_lexer": "ipython3",
85 | "version": "3.12.2"
86 | }
87 | },
88 | "nbformat": 4,
89 | "nbformat_minor": 2
90 | }
91 |
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/bhavesh_kanoje _ai_15/task_1.ipynb.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "from collections import deque\n",
10 | "\n",
11 | "def find_cheapest_routes(n, m, k, flights):\n",
12 | " graph = [[] for _ in range(n)]\n",
13 | " for a, b, c in flights:\n",
14 | " graph[a-1].append((b-1, c))\n",
15 | "\n",
16 | " # BFS to find the k shortest paths\n",
17 | " shortest_paths = []\n",
18 | " queue = deque([(0, [0])]) # (cost, path)\n",
19 | " while queue and len(shortest_paths) < k:\n",
20 | " current_cost, current_path = queue.popleft()\n",
21 | " current_city = current_path[-1]\n",
22 | " if current_city == n - 1:\n",
23 | " shortest_paths.append(current_path)\n",
24 | " continue\n",
25 | " for neighbor, neighbor_cost in graph[current_city]:\n",
26 | " new_cost = current_cost + neighbor_cost\n",
27 | " new_path = current_path + [neighbor]\n",
28 | " queue.append((new_cost, new_path))\n",
29 | "\n",
30 | " return shortest_paths\n"
31 | ]
32 | },
33 | {
34 | "cell_type": "code",
35 | "execution_count": 2,
36 | "metadata": {},
37 | "outputs": [],
38 | "source": [
39 | "# Example input\n",
40 | "n, m, k = 4, 6, 3\n",
41 | "flights = [\n",
42 | " (1, 3, 3),\n",
43 | " (3, 2, 3),\n",
44 | " (2, 4, 2),\n",
45 | " (2, 3, 1),\n",
46 | " (1, 2, 2),\n",
47 | " (3, 4, 2)\n",
48 | "]\n"
49 | ]
50 | },
51 | {
52 | "cell_type": "code",
53 | "execution_count": 3,
54 | "metadata": {},
55 | "outputs": [],
56 | "source": [
57 | "# Find and print the k cheapest routes\n",
58 | "result = find_cheapest_routes(n, m, k, flights)\n"
59 | ]
60 | },
61 | {
62 | "cell_type": "code",
63 | "execution_count": 4,
64 | "metadata": {},
65 | "outputs": [
66 | {
67 | "name": "stdout",
68 | "output_type": "stream",
69 | "text": [
70 | "[5, 6, 8]\n"
71 | ]
72 | }
73 | ],
74 | "source": [
75 | "# Calculate total cost for each path\n",
76 | "total_costs = [sum(flights[node][2] for node in path[:-1]) for path in result]\n",
77 | "\n",
78 | "# Print the total costs of the k shortest paths\n",
79 | "print(total_costs)\n"
80 | ]
81 | }
82 | ],
83 | "metadata": {
84 | "kernelspec": {
85 | "display_name": "Python 3",
86 | "language": "python",
87 | "name": "python3"
88 | },
89 | "language_info": {
90 | "codemirror_mode": {
91 | "name": "ipython",
92 | "version": 3
93 | },
94 | "file_extension": ".py",
95 | "mimetype": "text/x-python",
96 | "name": "python",
97 | "nbconvert_exporter": "python",
98 | "pygments_lexer": "ipython3",
99 | "version": "3.12.2"
100 | }
101 | },
102 | "nbformat": 4,
103 | "nbformat_minor": 2
104 | }
105 |
--------------------------------------------------------------------------------
/4th_sem/problem3.md:
--------------------------------------------------------------------------------
1 |
2 | ## Creative Accounting
3 |
4 | When accounting for the profit of a business, we can divide consecutive days into fixed-sized segments and calculate each segment’s profit as the sum of all its daily profits. For example, we could choose seven-day segments to do our accounting in terms of weekly profit. We also have the flexibility of choosing a segment’s starting day. For example, for weekly profit we can start a week on a Sunday, Monday, or even Wednesday. Choosing different segment starting days may sometimes change how the profit looks on the books, making it more (or less) attractive to investors.
5 |
6 | As an example, we can divide ten consecutive days of profit (or loss, which we denote as negative profit) into three-day segments as such:
7 | 3, 2, −7 | 5, 4, 1 | 3, 0, −3 | 5
8 |
9 | This gives us four segments with profit −2, 10, 0, 5. For the purpose of this division, partial segments with fewer than the fixed segment size are allowed at the beginning and at the end. We say a segment is profitable if it has a strictly positive profit. In the above example, only two out of the four segments are profitable.
10 |
11 | If we try a different starting day, we can obtain:
12 | 3, 2 | −7, 5, 4 | 1, 3, 0 | −3, 5
13 |
14 | This gives us four segments with profit 5, 2, 4, 2. All four segments are profitable, which makes our business look much more consistent.
15 |
16 | You’re given a list of consecutive days of profit, as well as an integer range. If we can choose any segment size within that range and any starting day for our accounting, what is the minimum and maximum number of profitable segments that we can have?
17 |
18 | ### Input
19 | The first line of input has three space-separated integers n, ℓ and h ($1 ≤ ℓ ≤ h ≤ n ≤ 3 × 10^4$, $h - ℓ ≤ 1,000$), where n is the number of days in the books, ℓ is the minimum possible choice of segment size, and h is the maximum possible choice of segment size.
20 |
21 | Each of the next n lines contains a single integer p ($-10^4 ≤ p ≤ 10^4$). These are the daily profits, in order.
22 |
23 | ### Output
24 | Output on a single line two space-separated integers min and max, where min is the minimum number of profitable segments possible, and max is the maximum number of profitable segments possible. Both min and max are taken over all possible choices of segment size between ℓ and h and all possible choices of starting day.
25 |
26 | ### Constraints
27 |
28 | - $1 ≤ n, ℓ, h ≤ 3 × 10^4$
29 | - $h - ℓ ≤ 1,000$
30 | - $-10^4 ≤ p ≤ 10^4$
31 |
32 |
33 |
34 | | Sample Input 1 | Sample Output 1 |
35 | |-----------------------|-----------------|
36 | | 10 3 5 | 2 4 |
37 | | 3 | |
38 | | 2 | |
39 | | -7 | |
40 | | 5 | |
41 | | 4 | |
42 | | 1 | |
43 | | 3 | |
44 | | 0 | |
45 | | -3 | |
46 | | 5 | |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/Madhurima_Rawat_DS_42/problem1.py:
--------------------------------------------------------------------------------
1 | # Name- Madhurima Rawat, Email Id - rawatmadhurima@gmail.com
2 |
3 | '''
4 |
5 | Defining a Recursive Function for this Problem
6 | In this function we will iterate till k is 0 (Base Case of Recursion)
7 | k is decremented after each iteration
8 | The arguments of this function are:
9 |
10 | 1. start city (start city where the function is starting)
11 | 2. end_city (this is the ending city till where we have to reach)
12 | 3. k is the number of possible solutions
13 | 4. cost_so_far is the ppth the funtion has traversed so far (in between the calls till one complete iteration)
14 | This is done so that we can see the path travelled if we want
15 | 5. current_cost is the current or the latest cost calculated by the function
16 | After each iteration, this is updated (we simply add the cost of the flight)
17 |
18 | '''
19 |
20 | def find_routes(start_city, current_city, end_city, k, cost_so_far, current_cost):
21 |
22 | # Global so that this variables retain their value throughout recursion
23 | global flights, cheapest_costs
24 |
25 | # To check if we have reached end city
26 | if current_city == end_city:
27 |
28 | # adding cost to list as it implies we have found a path
29 | cheapest_costs.append(current_cost)
30 |
31 | # Base case
32 | # This is simply checking if k is greater than 0 if it is not then this will terminate the function
33 | if k > 0:
34 |
35 | # Traversing all the neighbour city and the corresponding cost
36 | for neighbor_city, cost in flights[current_city]:
37 |
38 | # Calling the function to calculate for all possible cases till base case(k)
39 | find_routes(start_city, neighbor_city, end_city, k - 1, cost_so_far + [neighbor_city], current_cost + cost)
40 |
41 |
42 | # Declaring Variables
43 | # This could be taken as input like this
44 | '''
45 | n, m, k = map(int, input("Enter the number of cities, flights, and k: ").split())
46 |
47 | flights_data = []
48 |
49 | for _ in range(m):
50 |
51 | flight_input = input("Enter flight data (start_city end_city price): ")
52 | flights_data.append(tuple(map(int, flight_input.split())))
53 |
54 | '''
55 |
56 | # Variables
57 | n, m, k = 4, 6, 3
58 |
59 | # Cost and Neighbouring cities
60 | flights_data = [
61 | (1, 2, 1),
62 | (1, 3, 3),
63 | (2, 3, 2),
64 | (2, 4, 6),
65 | (3, 2, 8),
66 | (3, 4, 1)
67 | ]
68 |
69 | # This line initializes a list of lists named `flights` with `n + 1` empty lists,
70 | # each list representing the neighboring cities and their corresponding flight costs for each city.
71 | flights = [[] for _ in range(n + 1)]
72 |
73 | # Storing flight costs in flights list
74 | # Here the list corresponds to index of the city name
75 | # Like if we access flight[1] we will get city name and cost
76 | # flight[1] = [(2, 1), (3, 3)]
77 | # Since we do not have any city corresponding to 0 index it is empty
78 | for flight in flights_data:
79 |
80 | # Storing a, b and c
81 | a, b, c = flight
82 | # This will append it as the corresponding index
83 | flights[a].append((b, c))
84 |
85 |
86 | # Lists to store costs
87 | cheapest_costs = []
88 |
89 | # Calling function
90 | find_routes(1, 1, n, k, [], 0)
91 |
92 | # Sorting costs
93 | cheapest_costs.sort()
94 |
95 | # Printing the first k index
96 | print(*cheapest_costs[:k])
97 |
98 |
--------------------------------------------------------------------------------
/6th_sem/Pull_Requests/Rishabh_Tiwari/solution_prblm3.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #define num 100000
3 | using namespace std;
4 |
5 |
6 |
7 | const long long mod = 1000000007;
8 | long long N, D, a, b, L, W, LC, WC, sL, sW, sLC, sWC;
9 | vector neighbour[num];
10 | bool lose[num], visited[num];
11 | long long c[num],oW[num],oL[num],h[num];
12 |
13 | //calculating the state for all roots
14 | void dfs(int x){
15 | visited[x] = true; lose[x] = true;
16 | for(int i:neighbour[x]){
17 | if(!visited[i]){
18 | dfs(i);
19 | if(lose[i]) h[x]++;
20 | }
21 | }
22 | if(h[x]!=0) lose[x] = false;
23 | }
24 | void critical(int x){
25 | if(lose[x]){
26 | c[x] = oW[x] + 1;
27 | } else {
28 | if(h[x]==1){
29 | c[x] = oL[x];
30 | } else {
31 | c[x] = 0;
32 | }
33 | }
34 | }
35 | //calculating critical states
36 | void dfs2(int x){
37 | visited[x] = true;
38 | for(int i:neighbour[x]){
39 | if(!visited[i]){
40 | dfs2(i);
41 | if(lose[i]){
42 | oL[x] += c[i];
43 | } else {
44 | oW[x] += c[i];
45 | }
46 | }
47 | }
48 | critical(x);
49 | }
50 |
51 | void reroot(int x, int y){
52 | if(lose[y]){
53 | h[x]--;
54 | oL[x] -= c[y];
55 | } else {
56 | oW[x] -= c[y];
57 | }
58 | if(h[x]==0) lose[x] = true;
59 | critical(x);
60 | if(lose[x]){
61 | h[y]++; oL[y] += c[x];
62 | } else {
63 | oW[y] += c[x];
64 | }
65 | if(h[y]!=0) lose[y] = false;
66 | critical(y);
67 | }
68 | void evaluate(int x){
69 | visited[x] = true;
70 | if(lose[x]){
71 | L++;
72 | LC = (LC+c[x])%mod;
73 | } else {
74 | W++;
75 | WC = (WC+c[x])%mod;
76 | }
77 | for(int i:neighbour[x]){
78 | if(!visited[i]){
79 | reroot(x,i);
80 | evaluate(i);
81 | reroot(i,x);
82 | }
83 | }
84 | }
85 |
86 | // bonus dimension
87 | void step(long long pl, long long plc, long long pw, long long pwc){
88 | sL = ((((pl*N)%mod)*W) % mod+(pwc*L)%mod+((((pl*N)%mod-plc+mod)%mod) * L)%mod) % mod;
89 | sLC = (plc*WC +pwc*LC) % mod;
90 | sW = ((((pw*N)%mod)*W)%mod+(plc*L)%mod+((((pw*N)%mod-pwc+mod)%mod)*L)%mod) % mod;
91 | sWC = (pwc*WC+plc*LC)%mod;
92 | }
93 | //double dimensions
94 | void step2(long long pl, long long plc, long long pw, long long pwc){
95 | L = ((((pl*N)% mod)*pw) % mod+(pwc*pl) % mod+((((pl*N)%mod -plc+ mod)%mod)*pl)%mod)%mod;
96 | LC = (plc*pwc+pwc*plc) % mod;
97 | W = ((((pw*N) % mod)*pw) % mod+(plc*pl)%mod+((((pw * N)%mod - pwc + mod)%mod)*pl)%mod) % mod;
98 | WC = (pwc*pwc+plc*plc) % mod;
99 | }
100 | // O(N+logD) solution
101 | int main()
102 | {
103 | cin>>N>>D;
104 | for(int i=0; i>a>>b;
106 | neighbour[a-1].push_back(b-1);
107 | neighbour[b-1].push_back(a-1);
108 | }
109 |
110 | dfs(0);
111 | for(int i=0;i0){
126 | if(D%2==1) step(sL, sLC, sW, sWC);
127 | step2(L,LC,W,WC);
128 | D /= 2;
129 | }
130 |
131 | cout< 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1\n",
15 | "\n",
16 | "\n",
17 | "odd no. = 3n+1\n",
18 | "\n",
19 | "\n",
20 | "\n",
21 | "even no. n/2"
22 | ]
23 | },
24 | {
25 | "cell_type": "code",
26 | "execution_count": 17,
27 | "metadata": {},
28 | "outputs": [
29 | {
30 | "name": "stdout",
31 | "output_type": "stream",
32 | "text": [
33 | "Enter Number = 3\n",
34 | "3 10 5 16 8 4 2 1 "
35 | ]
36 | }
37 | ],
38 | "source": [
39 | "def prb1(n):\n",
40 | " if n==1:\n",
41 | " print(f\"{n} {4} {2} {1}\")\n",
42 | " else:\n",
43 | " print(n,end=\" \")\n",
44 | " while (n!=1):\n",
45 | " if n%2==0:\n",
46 | " n/=2\n",
47 | " print(int(n),end=\" \")\n",
48 | " else:\n",
49 | " n=(n*3)+1\n",
50 | " print(int(n),end=\" \")\n",
51 | "n=int(input(\"Enter Number = \"))\n",
52 | "prb1(n)"
53 | ]
54 | },
55 | {
56 | "cell_type": "markdown",
57 | "metadata": {},
58 | "source": [
59 | "# PROBLEM 2"
60 | ]
61 | },
62 | {
63 | "cell_type": "markdown",
64 | "metadata": {},
65 | "source": [
66 | "Your task is to develop an efficient code to print all the sum of all numbers that are multiples of 3 and 5 below a given limit N."
67 | ]
68 | },
69 | {
70 | "cell_type": "code",
71 | "execution_count": 5,
72 | "metadata": {},
73 | "outputs": [
74 | {
75 | "name": "stdout",
76 | "output_type": "stream",
77 | "text": [
78 | "Enter number = 20\n",
79 | "78\n"
80 | ]
81 | }
82 | ],
83 | "source": [
84 | "def prb2(n):\n",
85 | " s=0\n",
86 | " for i in range(1,n):\n",
87 | " if i%3==0 or i%5==0:\n",
88 | " s+=i\n",
89 | " return s\n",
90 | "n=int(input(\"Enter number = \"))\n",
91 | "su=prb2(n)\n",
92 | "print(su)"
93 | ]
94 | },
95 | {
96 | "cell_type": "markdown",
97 | "metadata": {},
98 | "source": [
99 | "# PROBLEM 3"
100 | ]
101 | },
102 | {
103 | "cell_type": "markdown",
104 | "metadata": {},
105 | "source": [
106 | "Movie Festival: In a movie festival, n \n",
107 | " movies will be shown. You know the starting and ending time of each movie. What is the maximum number of movies you can watch entirely?"
108 | ]
109 | },
110 | {
111 | "cell_type": "code",
112 | "execution_count": 33,
113 | "metadata": {},
114 | "outputs": [
115 | {
116 | "name": "stdout",
117 | "output_type": "stream",
118 | "text": [
119 | "Enter the number of movies: 3\n",
120 | "Enter the starting and ending times of movie 1: 4 5\n",
121 | "Enter the starting and ending times of movie 2: 4 6\n",
122 | "Enter the starting and ending times of movie 3: 5 3\n",
123 | "Maximum number of movies: 2\n"
124 | ]
125 | }
126 | ],
127 | "source": [
128 | "def max_mov(n, movies):\n",
129 | " movies.sort(key=lambda x: x[1])\n",
130 | " \n",
131 | "\n",
132 | " count = 0\n",
133 | " end_time = 0\n",
134 | " \n",
135 | " \n",
136 | " for start, end in movies:\n",
137 | " \n",
138 | " if start >= end_time:\n",
139 | " count += 1\n",
140 | " end_time = end\n",
141 | " \n",
142 | " return count\n",
143 | "\n",
144 | "\n",
145 | "n = int(input(\"Enter the number of movies: \"))\n",
146 | "movies = []\n",
147 | "for _ in range(n):\n",
148 | " a, b = map(int, input(\"Enter the starting and ending times of movie {}: \".format(_+1)).split())\n",
149 | " movies.append((a, b))\n",
150 | "\n",
151 | "print(\"Maximum number of movies:\", max_mov(n, movies))\n"
152 | ]
153 | }
154 | ],
155 | "metadata": {
156 | "kernelspec": {
157 | "display_name": "Python 3",
158 | "language": "python",
159 | "name": "python3"
160 | },
161 | "language_info": {
162 | "codemirror_mode": {
163 | "name": "ipython",
164 | "version": 3
165 | },
166 | "file_extension": ".py",
167 | "mimetype": "text/x-python",
168 | "name": "python",
169 | "nbconvert_exporter": "python",
170 | "pygments_lexer": "ipython3",
171 | "version": "3.9.1"
172 | }
173 | },
174 | "nbformat": 4,
175 | "nbformat_minor": 4
176 | }
177 |
--------------------------------------------------------------------------------