We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defis_valid_input(height:int,width:int)->bool:return(isinstance(height,int)andisinstance(width,int)andheight%2==1andwidth==height*3and5<height<101)defdesign_doormat(height:int,width:int)->list[str]:ifnotis_valid_input(height,width):raiseValueError("Invalid input: N must be odd, M must be 3*N")lines=[]# Topforiinrange(1,height,2):pattern=".|."*ilines.append(pattern.center(width,"-"))# Centerlines.append("WELCOME".center(width,"-"))# Bottomforiinrange(height-2,0,-2):pattern=".|."*ilines.append(pattern.center(width,"-"))returnlinesif__name__=="__main__":n,m=map(int,input().split())forlineindesign_doormat(n,m):print(line)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Designer Door Mat
You are viewing a single comment's thread. Return to all comments →