+ 7
[🏆 Challenge 🏆] Hexagon using loops!🎮💡🏆
Create a program to input the length of the side and output a hexagon created using loops. Eg- Input-> 4 output-> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * I will soon add my own version. Edit: I have added my own version.
13 Antworten
+ 10
Here's my C# implementation! ✌
Enjoy~ ❤
https://code.sololearn.com/cogRMeh7yutc/?ref=app
+ 7
Finally, I have created it.
https://code.sololearn.com/c5CFuA3JJxy8/?ref=app
+ 5
@VcC your code doesn't print the required figure.
+ 4
heres mineee....
one liner..
enter side<=10
https://code.sololearn.com/cE22Gsmvo3Ht/?ref=app
+ 4
@Kartikey Sahu your code only prints hexagon with certain inputs.
+ 4
https://code.sololearn.com/cUi64iDGfs4N/?ref=app
this a variable hexagon written in c++ depends on user input :)
enjoy
+ 3
https://code.sololearn.com/cNX7Znbxl5B5/?ref=app
This might be it.
Updated the code, now looks cooler.
+ 3
+ 2
Here is mine
https://code.sololearn.com/cXpMTau4k13f/?ref=app
+ 2
Here you go. Checks for valid input
https://code.sololearn.com/cR96Ng0lXdpq/?ref=app
+ 1
k = int(input())
s = k
t = k - 2
for i in range(1, k*2):
if i <= 4:
s = s - 1
t = t + 2
else:
s = s + 1
t = t - 2
print(' '*s+'* '*t)
0
https://code.sololearn.com/c31zStJdSnBx/?ref=app