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.
defdoorMat(n,m):result=""ifn%2==0:return"Error: N is not natural odd number"ifm/3!=n:return"Error: M is not 3 times of N"mid_row=n// 2mid_col=m// 2defpattern_creator(row):sep="|.."mid_symbol="|"half_pat_minus_mid="."+(row*sep)dashes=(mid_col-len(half_pat_minus_mid))*"-"temp_result=(dashes+half_pat_minus_mid+mid_symbol+half_pat_minus_mid[::-1]+dashes)returntemp_resultforrowinrange(mid_row):result+="\n"+pattern_creator(row)dashes=(m-7)// 2 * "-"temp_result=dashes+"WELCOME"+dashesresult+="\n"+temp_resultforrowinrange(mid_row-1,-1,-1):result+="\n"+pattern_creator(row)print(result[1:])if__name__=="__main__":inp=list(input().split(" "))n=int(inp[0])m=int(inp[1])doorMat(n,m)
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 →