0

Hackerrank Logo

https://code.sololearn.com/cqJApCdMm11z/?ref=app CAN ANYONE SUGGEST AN EASIER WAY TO MAKE THIS CODE ? PLZ

12th Jul 2020, 12:54 PM
Pranjal Tripathi
Pranjal Tripathi - avatar
1 Answer
+ 4
There are 5 components in your logo 1. ∆ 2. I I 3. -------- 4. I I 5. √ (inverse triangle) You have used 5 for loops for them You can make 4 user - defined function & call all 2. & 4. will be called twice ----------------------------------------------------- Let's make Functions For 1st Function for i in range(1,n+1): print(" "*(n-i)+"H"*(2*i-1)) For 2nd Function for i in range(1,n+1): print(" "*(your requirement)+"H"*n+" "*(your requirement)) For 3rd Function print(("H"*(your number)+"\n")*(your number)) For 4th Function for i in range(1,n+1): print(" "*(your number)+" "*(i-1)+"H"*(n-i)*2-1) Call all I hope you understood 🙂
12th Jul 2020, 1:18 PM
Prince Kumar
Prince Kumar - avatar