+ 1

Can you make code for it. Moatly ask in interviews for developer.

444444444 433333334 432222234 432111234 432111234 432222234 433333334 444444444

15th Jan 2018, 7:28 AM
Rishabh Jhalani
Rishabh Jhalani - avatar
3 Antworten
+ 5
# Python3 as requested, size independent: n = 4 for i in range(-n,n+1): if i: for j in range(-n,n+1): x = abs(j) if j else 1 x = i if x < abs(i) else x print(abs(x),end='') print() """ Anyway, are you sure that's the right expected result you've wrote in description? Because I'm surprised that the "square" is not square: yours is 8 lines by 9 characters sized ^^ (I've done my code to be correct regarding your model :P) """
15th Jan 2018, 8:12 AM
visph
visph - avatar
0
My try in Java, probably not the most efficient way :) https://code.sololearn.com/c8slqwV0ur9X/?ref=app
15th Jan 2018, 8:06 AM
Jente
0
No wonder my code was a mess, I didn't think of using ranges from negatives.
15th Jan 2018, 8:18 AM
BlazingMagpie
BlazingMagpie - avatar