Skip to content

Commit c88aee5

Browse files
committed
Adding all previously written code
0 parents  commit c88aee5

6 files changed

+134
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def CodelandUsernameValidation(strParam):
2+
3+
if len(strParam) < 4:
4+
return "false"
5+
if len(strParam) > 25:
6+
return "false"
7+
if not strParam[0].isalpha():
8+
return "false"
9+
if strParam[-1] == "_":
10+
return "false"
11+
for char in strParam:
12+
if not(char.isalpha() or char.isnumeric() or char == "_"):
13+
return "false"
14+
return "true"
15+
16+
# keep this function call here
17+
print(CodelandUsernameValidation(input()))

2021/Easy/Find_Intersection.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def FindIntersection(strArr):
2+
3+
# code goes here
4+
first = [int(x.strip()) for x in strArr[0].split(',')]
5+
second = [int(x.strip()) for x in strArr[1].split(',')]
6+
7+
i = 0
8+
j = 0
9+
result = ""
10+
interection = False
11+
while i < len(first) and j < len(second):
12+
if first[i] == second[j]:
13+
result = result + str(first[i])
14+
result = result + ","
15+
interection = True
16+
i = i + 1
17+
j = j + 1
18+
elif first[i] < second[j]:
19+
i = i + 1
20+
else:
21+
j = j + 1
22+
23+
if interection:
24+
if result[-1] == ",":
25+
return result[:-1]
26+
return result
27+
return "false"
28+
29+
# keep this function call here
30+
print(FindIntersection(input()))

2021/Easy/First_Factorial.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def FirstFactorial(num):
2+
3+
# code goes here
4+
if num == 1:
5+
return 1
6+
return num * FirstFactorial(num - 1)
7+
8+
# keep this function call here
9+
print(FirstFactorial(input()))

2021/Easy/First_Reverse.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def FirstReverse(strParam):
2+
return strParam[::-1]
3+
4+
# keep this function call here
5+
print(FirstReverse(input()))

2021/Easy/Longest_Word.java

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
public static String LongestWord(String sen) {
6+
7+
// code goes here
8+
/* Note: In Java the return type of a function and the
9+
parameter types being passed are defined, so this return
10+
call must match the return type of the function.
11+
You are free to modify the return type. */
12+
13+
String result = "";
14+
String[] senArray = sen.replaceAll("[^a-zA-Z ]", "").toLowerCase().split("\\s+");
15+
16+
result = senArray[0];
17+
for (int i = 1; i < senArray.length; i++)
18+
{
19+
if (result.length() < senArray[i].length())
20+
{
21+
result = senArray[i];
22+
}
23+
}
24+
25+
return result;
26+
27+
}
28+
29+
public static void main (String[] args) {
30+
// keep this function call here
31+
Scanner s = new Scanner(System.in);
32+
System.out.print(LongestWord(s.nextLine()));
33+
}
34+
35+
}Longest Word
36+

2021/Easy/Questions_Marks.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def QuestionsMarks(strParam):
2+
3+
# code goes here
4+
liststr=[]
5+
liststr[:0]=strParam
6+
listdigquest = []
7+
for el in liststr:
8+
if el.isdigit():
9+
listdigquest.append(int(el))
10+
elif el == "?":
11+
listdigquest.append(el)
12+
13+
i = 0
14+
j = i + 1
15+
result = False
16+
while i < len(listdigquest) - 4:
17+
if listdigquest[i] != "?":
18+
for j in range(i + 1, len(listdigquest)):
19+
if listdigquest[j] != "?" and listdigquest[i] + listdigquest[j] == 10:
20+
if countquest(listdigquest, i + 1, j) == 3:
21+
result = True
22+
else:
23+
return "false"
24+
i = i + 1
25+
if result:
26+
return "true"
27+
return "false"
28+
29+
def countquest(arr, st, en):
30+
cnt = 0
31+
for i in range(st, en):
32+
if arr[i] == "?":
33+
cnt = cnt + 1
34+
return cnt
35+
36+
# keep this function call here
37+
print(QuestionsMarks(input()))

0 commit comments

Comments
 (0)