File tree 6 files changed +134
-0
lines changed
6 files changed +134
-0
lines changed Original file line number Diff line number Diff line change
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 ()))
Original file line number Diff line number Diff line change
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 ()))
Original file line number Diff line number Diff line change
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 ()))
Original file line number Diff line number Diff line change
1
+ def FirstReverse (strParam ):
2
+ return strParam [::- 1 ]
3
+
4
+ # keep this function call here
5
+ print (FirstReverse (input ()))
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
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 ()))
You can’t perform that action at this time.
0 commit comments