File tree Expand file tree Collapse file tree 10 files changed +154
-97
lines changed Expand file tree Collapse file tree 10 files changed +154
-97
lines changed Original file line number Diff line number Diff line change
1
+ '''
2
+ Title : Reading Raw Input
3
+ Subdomain : Introduction
4
+ Domain : Python
5
+ Author : Ahmedur Rahman Shovon
6
+ Created : 15 July 2016
7
+ '''
8
+ # Enter your code here. Read input from STDIN. Print output to STDOUT
9
+ name = raw_input ()
10
+ print name
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Designer Door Mat
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
7
Problem : https://www.hackerrank.com/challenges/designer-door-mat/problem
8
- '''
9
- N , M = map (int ,input ().split ()) # More than 6 lines of code will result in 0 score. Blank lines are not counted.
10
- for i in range (1 ,N , 2 ):
11
- print (int ((M - 3 * i ) / 2 ) * '-' + ( i * '.|.' )+ int ((M - 3 * i ) / 2 ) * '-' )
12
- print (int ((M - 7 ) / 2 ) * '-' + 'WELCOME' + int ((M - 7 ) / 2 ) * '-' )
13
- for i in range (N - 2 , - 1 ,- 2 ):
14
- print (int ((M - 3 * i ) / 2 ) * '-' + ( i * '.|.' )+ int ((M - 3 * i ) / 2 ) * '-' )
8
+ """
9
+ N , M = map (int , input ().split ())
10
+ for i in range (1 , N , 2 ):
11
+ print (int ((M - 3 * i ) / 2 ) * '-' + ( i * '.|.' ) + int ((M - 3 * i ) / 2 ) * '-' )
12
+ print (int ((M - 7 ) / 2 ) * '-' + 'WELCOME' + int ((M - 7 ) / 2 ) * '-' )
13
+ for i in range (N - 2 , - 1 , - 2 ):
14
+ print (int ((M - 3 * i ) / 2 ) * '-' + ( i * '.|.' ) + int ((M - 3 * i ) / 2 ) * '-' )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Find a string
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
7
Problem : https://www.hackerrank.com/challenges/find-a-string/problem
8
- '''
9
- # Enter your code here. Read input from STDIN. Print output to STDOUT
10
- s = raw_input ()
11
- ss = raw_input ()
12
- cnt = 0
13
- len_s = len (s )
14
- len_ss = len (ss )
15
- for i in range (0 ,len_s ):
16
- tmp = s [i :i + len_ss ]
17
- if (tmp == ss ):
18
- cnt = cnt + 1
19
- print cnt
8
+ """
9
+
10
+
11
+ def count_substring (string , sub_string ):
12
+ count_sub_string = 0
13
+ for i in range (len (string ) - len (sub_string ) + 1 ):
14
+ if string [i :i + len (sub_string )] == sub_string :
15
+ count_sub_string += 1
16
+ return count_sub_string
17
+
18
+
19
+ if __name__ == '__main__' :
20
+ string = input ().strip ()
21
+ sub_string = input ().strip ()
22
+
23
+ count = count_substring (string , sub_string )
24
+ print (count )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Mutations
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
- Updated : 25 October 2019
7
+ Updated : 08 July 2020
8
8
Problem : https://www.hackerrank.com/challenges/python-mutations/problem
9
- '''
9
+ """
10
+
11
+
10
12
def mutate_string (string , position , character ):
11
- return string [:position ]+ character + string [position + 1 :]
13
+ chars = list (string )
14
+ chars [position ] = character
15
+ return "" .join (chars )
16
+
12
17
18
+ if __name__ == '__main__' :
19
+ s = input ()
20
+ i , c = input ().split ()
21
+ s_new = mutate_string (s , int (i ), c )
22
+ print (s_new )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : String Split and Join
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
- Created : 15 July 2016
6
+ Created : 08 July 2020
7
7
Problem : https://www.hackerrank.com/challenges/python-string-split-and-join/problem
8
- '''
9
- # Enter your code here. Read input from STDIN. Print output to STDOUT
10
- print "-" .join (raw_input ().strip ().split ())
8
+ """
9
+
10
+
11
+ def split_and_join (sentence ):
12
+ return "-" .join (sentence .split ())
13
+
14
+
15
+ if __name__ == '__main__' :
16
+ line = input ()
17
+ result = split_and_join (line )
18
+ print (result )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : String Validators
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
+ Updated : 08 July 2020
7
8
Problem : https://www.hackerrank.com/challenges/string-validators/problem
8
- '''
9
- # Enter your code here. Read input from STDIN. Print output to STDOUT
10
- inputStr = input ()
11
- resalnum = False
12
- resalpha = False
13
- resdigit = False
14
- reslower = False
15
- resupper = False
16
- for i in inputStr :
17
- if ( i .isalnum () ):
18
- resalnum = True
19
- if ( i .isalpha () ):
20
- resalpha = True
21
- if ( i .isdigit () ):
22
- resdigit = True
23
- if ( i .islower () ):
24
- reslower = True
25
- if ( i .isupper () ):
26
- resupper = True
27
-
28
- print (resalnum )
29
- print (resalpha )
30
- print (resdigit )
31
- print (reslower )
32
- print (resupper )
9
+ """
10
+ if __name__ == '__main__' :
11
+ s = input ()
12
+ flag_alnum = False
13
+ flag_alpha = False
14
+ flag_digit = False
15
+ flag_lower = False
16
+ flag_upper = False
17
+ for i in s :
18
+ if i .isalnum ():
19
+ flag_alnum = True
20
+ if i .isalpha ():
21
+ flag_alpha = True
22
+ if i .isdigit ():
23
+ flag_digit = True
24
+ if i .islower ():
25
+ flag_lower = True
26
+ if i .isupper ():
27
+ flag_upper = True
28
+
29
+ print (flag_alnum )
30
+ print (flag_alpha )
31
+ print (flag_digit )
32
+ print (flag_lower )
33
+ print (flag_upper )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Text Alignment
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
+ Updated : 08 July 2020
7
8
Problem : https://www.hackerrank.com/challenges/text-alignment/problem
8
- '''
9
- #Replace all ______ with rjust, ljust or center.
9
+ """
10
10
11
- thickness = int (input ()) #This must be an odd number
11
+ thickness = int (input ())
12
12
c = 'H'
13
13
14
- #Top Cone
14
+ # Top Cone
15
15
for i in range (thickness ):
16
- print ((c * i ).rjust (thickness - 1 ) + c + ( c * i ).ljust (thickness - 1 ))
16
+ print ((c * i ).rjust (thickness - 1 ) + c + ( c * i ).ljust (thickness - 1 ))
17
17
18
- #Top Pillars
19
- for i in range (thickness + 1 ):
20
- print ((c * thickness ).center (thickness * 2 ) + ( c * thickness ).center (thickness * 6 ))
18
+ # Top Pillars
19
+ for i in range (thickness + 1 ):
20
+ print ((c * thickness ).center (thickness * 2 ) + ( c * thickness ).center (thickness * 6 ))
21
21
22
- #Middle Belt
23
- for i in range ((thickness + 1 ) // 2 ):
24
- print ((c * thickness * 5 ).center (thickness * 6 ))
22
+ # Middle Belt
23
+ for i in range ((thickness + 1 ) // 2 ):
24
+ print ((c * thickness * 5 ).center (thickness * 6 ))
25
25
26
- #Bottom Pillars
27
- for i in range (thickness + 1 ):
28
- print ((c * thickness ).center (thickness * 2 ) + ( c * thickness ).center (thickness * 6 ))
26
+ # Bottom Pillars
27
+ for i in range (thickness + 1 ):
28
+ print ((c * thickness ).center (thickness * 2 ) + ( c * thickness ).center (thickness * 6 ))
29
29
30
- #Bottom Cone
30
+ # Bottom Cone
31
31
for i in range (thickness ):
32
- print (((c * (thickness - i - 1 )).rjust (thickness )+ c + (c * (thickness - i - 1 )).ljust (thickness )).rjust (thickness * 6 ))
32
+ print (((c * (thickness - i - 1 )).rjust (thickness ) + c + (c * (thickness - i - 1 )).ljust (thickness )).rjust (
33
+ thickness * 6 ))
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Text Wrap
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
+ Updated : 08 July 2020
7
8
Problem : https://www.hackerrank.com/challenges/text-wrap/problem
8
- '''
9
+ """
9
10
import textwrap
10
- s = input ()
11
- w = int (input ().strip ())
12
- print (textwrap .fill (s ,w ))
11
+
12
+
13
+ def wrap (string , max_width ):
14
+ return textwrap .fill (string , max_width )
15
+
16
+
17
+ if __name__ == '__main__' :
18
+ string , max_width = input (), int (input ())
19
+ result = wrap (string , max_width )
20
+ print (result )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : Whats Your Name?
3
3
Subdomain : Introduction
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
7
Problem : https://www.hackerrank.com/challenges/whats-your-name/problem
8
- '''
9
- # Enter your code here. Read input from STDIN. Print output to STDOUT
10
- fname = raw_input ()
11
- lname = raw_input ()
12
- print "Hello " + fname + " " + lname + "! You just delved into python."
8
+ """
9
+
10
+
11
+ def print_full_name (a , b ):
12
+ print ("Hello {} {}! You just delved into python." .format (a , b ))
13
+
14
+
15
+ if __name__ == '__main__' :
16
+ first_name = input ()
17
+ last_name = input ()
18
+ print_full_name (first_name , last_name )
Original file line number Diff line number Diff line change 1
- '''
1
+ """
2
2
Title : sWAP cASE
3
3
Subdomain : Strings
4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
- Created : 15 July 2016
6
+ Created : 16 July 2016
7
+ Updated : 08 July 2020
7
8
Problem : https://www.hackerrank.com/challenges/swap-case/problem
8
- '''
9
- __author__ = 'arsho'
10
- def swap_case (s ):
11
- newstring = ""
12
-
13
- for item in s :
14
- if item .isupper ():
15
- newstring += item .lower ()
9
+ """
10
+
11
+
12
+ def swap_case (sentence ):
13
+ updated_s = ""
14
+ for c in sentence :
15
+ if c .isupper ():
16
+ updated_s += c .lower ()
17
+ elif c .islower ():
18
+ updated_s += c .upper ()
16
19
else :
17
- newstring += item .upper ()
18
-
19
- return newstring
20
+ updated_s += c
21
+ return updated_s
22
+
23
+
24
+ if __name__ == '__main__' :
25
+ s = input ()
26
+ result = swap_case (s )
27
+ print (result )
You can’t perform that action at this time.
0 commit comments