'Basic Programming Python3 practice question with runtime error from Hackerearth
I am trying to solve a question where I am supposed to print the max number of a particular symbol that repeats continuously but I have to give inputs manually for each individual row. If I copy and paste the test cases it returns an error. Below is the full code and testcase with outputs given after.
NOTE: if not fully understood the problem please visit https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/maximum-border-9767e14c/
def maxborder(a):
maxi=0
for i in range(len(a)):
count=0
for j in range(len(a[0])):
if(a[i][j]=='#'):
count+=1
if count> maxi:
maxi=count
return maxi
no=int(input())
while(no!=0):
m=int(input())
n=int(input())
a=[]
for i in range(m):
r=[]
e=str(input())
if len(e)!=0:
for x in range(len(e)):
r.append(e[x])
a.append(r)
res=maxborder(a)
no-=1
print(res)
Test case and output,(full test case down below)
TESTCASE:
2 #loop_count(no)
2 15 #row and column(m and n)
.....####......
.....#.........
7 9
...###...
...###...
..#......
.####....
..#......
...#####.
.........
EXPECTED OUTPUT:
4
5
What I get:
Execution failed.
ValueError: invalid literal for int() with base 10 : '2 15'
Stack Trace:
Traceback (most recent call last):
File "something.py3", line 26, in <module>
m=int(input())
ValueError: invalid literal for int() with base 10: '2 15'
Full test case:
10
2 15
.....####......
.....#.........
7 9
...###...
...###...
..#......
.####....
..#......
...#####.
.........
18 11
.#########.
########...
.........#.
####.......
.....#####.
.....##....
....#####..
.....####..
..###......
......#....
....#####..
...####....
##.........
#####......
....#####..
....##.....
.#######...
.#.........
1 15
.....######....
5 11
..#####....
.#######...
......#....
....#####..
...#####...
8 13
.....######..
......##.....
########.....
...#.........
.............
#######......
..######.....
####.........
7 5
.....
..##.
###..
..##.
.....
..#..
.#...
14 2
..
#.
..
#.
..
#.
..
..
#.
..
..
..
#.
..
7 15
.###########...
##############.
...####........
...##########..
.......#.......
.....#########.
.#######.......
12 6
#####.
###...
#.....
##....
###...
......
.##...
..##..
...#..
..#...
#####.
####..
Expected output for the above test case:
4
5
9
6
7
8
3
1
14
5
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
