Skip to content

Commit 39cdfe1

Browse files
Add files via upload
1 parent 87a8532 commit 39cdfe1

File tree

7 files changed

+235
-0
lines changed

7 files changed

+235
-0
lines changed

26 - Nested Logic/Solution.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <math.h>
4+
#include <stdlib.h>
5+
6+
int main() {
7+
8+
int Aday, Amonth, Ayear, Eday,Emonth, Eyear;
9+
int fine = 0;
10+
scanf("%d %d %d %d %d %d", &Aday, &Amonth, &Ayear, &Eday, &Emonth, &Eyear);
11+
if (Ayear == Eyear){
12+
if (Amonth == Emonth){
13+
fine = 15 * (Aday - Eday);
14+
}
15+
else {
16+
fine = 500 * (Amonth - Emonth);
17+
}
18+
}
19+
else if (Ayear > Eyear){
20+
fine = 10000;
21+
}
22+
//Aditya Seth
23+
24+
if (fine < 0){
25+
fine = 0;
26+
}
27+
28+
printf("%d", fine);
29+
return 0;
30+
}
31+

26 - Nested Logic/Solution.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int da, ma, ya;
7+
cin >> da;
8+
cin >> ma;
9+
cin >> ya;
10+
11+
int de, me, ye;
12+
cin >> de;
13+
cin >> me;
14+
cin >> ye;
15+
16+
int fine = 0;
17+
18+
if (ya > ye) fine = 10000;
19+
else if (ya == ye) {
20+
if (ma > me) fine = (ma - me) * 500;
21+
else if (ma == me && da > de) fine = (da - de) * 15;
22+
}
23+
//Aditya Seth
24+
25+
cout << fine;
26+
}

26 - Nested Logic/Solution.kt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.example.retrofitdemo
2+
3+
import java.util.Scanner
4+
5+
object Solution {
6+
fun main(args: Array<String>) {
7+
val `in` = Scanner(System.`in`)
8+
9+
val da = `in`.nextInt()
10+
val ma = `in`.nextInt()
11+
val ya = `in`.nextInt()
12+
13+
val de = `in`.nextInt()
14+
val me = `in`.nextInt()
15+
val ye = `in`.nextInt()
16+
17+
var fine = 0
18+
19+
if (ya > ye)
20+
fine = 10000
21+
else if (ya == ye) {
22+
if (ma > me)
23+
fine = (ma - me) * 500
24+
else if (ma == me && da > de) fine = (da - de) * 15
25+
}
26+
27+
println(fine)
28+
}
29+
}

26 - Nested Logic/Solution.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
actually = list(map(int, input().split()))
2+
da, ma, ya = actually
3+
4+
expected = list(map(int, input().split()))
5+
de, me, ye = expected
6+
7+
fine = 0
8+
9+
if ya > ye:
10+
fine = 10000
11+
elif ya == ye:
12+
if ma > me:
13+
fine = (ma - me) * 500
14+
elif ma == me and da > de:
15+
fine = (da - de) * 15
16+
17+
#Aditya Seth
18+
print(fine)

27- Testing/Solution.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <stdexcept>
2+
#include <cassert>
3+
#include <set>
4+
#include <vector>
5+
#include <iostream>
6+
#include <algorithm>
7+
using namespace std;
8+
9+
int minimum_index(vector<int> seq) {
10+
if (seq.empty()) {
11+
throw invalid_argument("Cannot get the minimum value index from an empty sequence");
12+
}
13+
int min_idx = 0;
14+
for (int i = 1; i < seq.size(); ++i) {
15+
if (seq[i] < seq[min_idx]) {
16+
min_idx = i;
17+
}
18+
}
19+
return min_idx;
20+
}
21+
//Aditya Seth
22+
class TestDataEmptyArray {
23+
public:
24+
static vector<int> get_array() {
25+
vector<int> vect{};
26+
return vect;
27+
}
28+
29+
};
30+
31+
class TestDataUniqueValues {
32+
public:
33+
static vector<int> get_array() {
34+
vector<int> vect{ 23,5,8,12,7 };
35+
return vect;
36+
}
37+
38+
static int get_expected_result() {
39+
return 1;
40+
}
41+
42+
};
43+
44+
class TestDataExactlyTwoDifferentMinimums {
45+
public:
46+
static vector<int> get_array() {
47+
vector<int> vect{ 9,23,3,8,12,3,7 };
48+
return vect;
49+
}
50+
51+
static int get_expected_result() {
52+
return 2;
53+
}
54+
55+
};

27- Testing/Solution.kt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
fun main(srgs: Array<String>) {
3+
println(5)
4+
println("4 3")
5+
println("0 -3 4 2")
6+
println("5 2")
7+
println("0 -3 4 2 2")
8+
println("3 3")
9+
println("0 -3 4")
10+
println("7 2")
11+
println("0 -3 1 1 1 1 1")
12+
println("6 3")
13+
println("0 -3 4 2 1 1")
14+
}
15+
16+
}

27- Testing/Solution.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
def minimum_index(seq):
2+
if len(seq) == 0:
3+
raise ValueError("Cannot get the minimum value index from an empty sequence")
4+
min_idx = 0
5+
for i in range(1, len(seq)):
6+
if seq[i] < seq[min_idx]:
7+
min_idx = i
8+
return min_idx
9+
10+
class TestDataEmptyArray:
11+
def get_array():
12+
return []
13+
14+
class TestDataUniqueValues:
15+
def get_array():
16+
return [1,2,3]
17+
def get_expected_result():
18+
return 0
19+
class TestDataExactlyTwoDifferentMinimums:
20+
def get_array():
21+
return [1,1,3]
22+
def get_expected_result():
23+
return 0
24+
25+
def TestWithEmptyArray():
26+
try:
27+
seq = TestDataEmptyArray.get_array()
28+
result = minimum_index(seq)
29+
except ValueError as e:
30+
pass
31+
else:
32+
assert False
33+
34+
35+
def TestWithUniqueValues():
36+
seq = TestDataUniqueValues.get_array()
37+
assert len(seq) >= 2
38+
39+
assert len(list(set(seq))) == len(seq)
40+
41+
expected_result = TestDataUniqueValues.get_expected_result()
42+
result = minimum_index(seq)
43+
assert result == expected_result
44+
45+
46+
def TestiWithExactyTwoDifferentMinimums():
47+
seq = TestDataExactlyTwoDifferentMinimums.get_array()
48+
assert len(seq) >= 2
49+
tmp = sorted(seq)
50+
assert tmp[0] == tmp[1] and (len(tmp) == 2 or tmp[1] < tmp[2])
51+
52+
expected_result = TestDataExactlyTwoDifferentMinimums.get_expected_result()
53+
result = minimum_index(seq)
54+
assert result == expected_result
55+
56+
TestWithEmptyArray()
57+
TestWithUniqueValues()
58+
TestiWithExactyTwoDifferentMinimums()
59+
print("OK")
60+
#Aditya Seth

0 commit comments

Comments
 (0)