+ 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.

17th Oct 2017, 4:09 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
13 Answers
+ 10
Here's my C# implementation! ✌ Enjoy~ ❤ https://code.sololearn.com/cogRMeh7yutc/?ref=app
17th Oct 2017, 5:26 PM
Zephyr Koo
Zephyr Koo - avatar
17th Oct 2017, 4:37 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 5
@VcC your code doesn't print the required figure.
18th Oct 2017, 3:03 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 4
heres mineee.... one liner.. enter side<=10 https://code.sololearn.com/cE22Gsmvo3Ht/?ref=app
17th Oct 2017, 4:31 PM
sayan chandra
sayan chandra - avatar
+ 4
@Kartikey Sahu your code only prints hexagon with certain inputs.
18th Oct 2017, 4:01 AM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 4
https://code.sololearn.com/cUi64iDGfs4N/?ref=app this a variable hexagon written in c++ depends on user input :) enjoy
29th Jan 2018, 5:50 PM
Silver Key
Silver Key - avatar
+ 3
https://code.sololearn.com/cNX7Znbxl5B5/?ref=app This might be it. Updated the code, now looks cooler.
17th Oct 2017, 4:34 PM
AlphaCoder
AlphaCoder - avatar
17th Oct 2017, 4:47 PM
Prajwal Gowda
Prajwal Gowda - avatar
17th Oct 2017, 6:24 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 2
Here you go. Checks for valid input https://code.sololearn.com/cR96Ng0lXdpq/?ref=app
19th Oct 2017, 6:15 PM
Vari93
Vari93 - avatar
+ 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)
17th Oct 2017, 5:27 PM
Kartikey Sahu
Kartikey Sahu - avatar
0
https://code.sololearn.com/c31zStJdSnBx/?ref=app
18th Oct 2017, 2:41 PM
VcC
VcC - avatar