+ 18

CHALLENGE : NUMBER OF DOTS 💻⌨️🖱️

Find how many dots exist in a pentagonal shape around a center dot on the Nth iteration. For example, on the first iteration there is a single dot, on the second there are 6 dots, on the third there are 16 dots, etc. First : ▪️ Second : ▪️ ▪️▪️▪️ ▪️▪️ Third : ▪️ ▪️ ▪️ ▪️ ▪️ ▪️▪️▪️ ▪️ ▪️ ▪️▪️ ▪️ ▪️▪️▪️ Your code receive positive integer N as number of iteration, and return the number of dots that exist in the whole pentagon on Nth iteration.

14th Dec 2017, 11:46 AM
LukArToDo
LukArToDo - avatar
16 ответов
14th Dec 2017, 11:55 AM
#RahulVerma
#RahulVerma - avatar
14th Dec 2017, 6:34 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
14th Dec 2017, 12:57 PM
LukArToDo
LukArToDo - avatar
+ 13
https://code.sololearn.com/ctR2zK5uMuuq/?ref=app
14th Dec 2017, 1:26 PM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
14th Dec 2017, 2:27 PM
qwerty
qwerty - avatar
14th Dec 2017, 12:02 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
14th Dec 2017, 2:35 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 8
@Zandifer Your code gives the number of dots in one (last) iteration. Need to find the number of dots in the whole pentagram (in N iterations).
14th Dec 2017, 12:27 PM
LukArToDo
LukArToDo - avatar
14th Dec 2017, 12:28 PM
David Akhihiero
David Akhihiero - avatar
14th Dec 2017, 3:38 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 5
https://code.sololearn.com/cAifJ12KlayB/?ref=app
14th Dec 2017, 1:17 PM
...
+ 5
I decided to complete this challenge using ALL languages supported in SoloLearn. The code was simplified and so only works with possitive integer inputs (1, 2, 3, ...). As far as I understood, PHP in SoloLearn doesn't support I/O, so I omitted it. Original (works with many input types): https://code.sololearn.com/WP6w8F6pV277/?ref=app Simplified and unified (works with positive integer inputs only): https://code.sololearn.com/cCaNP4VrOlJx/?ref=app https://code.sololearn.com/cPvVSSSUZP0s/?ref=app https://code.sololearn.com/cl57a9pm62r5/?ref=app https://code.sololearn.com/cnEERHz4tO8h/?ref=app https://code.sololearn.com/cvmPWfwJS0ts/?ref=app https://code.sololearn.com/WcKpJ2z2HPvq/?ref=app
14th Dec 2017, 5:17 PM
Augustinas Lukauskas
Augustinas Lukauskas - avatar
14th Dec 2017, 12:23 PM
Zandifier
Zandifier - avatar
+ 4
@LukArToDo it is fixed
14th Dec 2017, 12:35 PM
Zandifier
Zandifier - avatar
14th Dec 2017, 3:37 PM
Augustinas Lukauskas
Augustinas Lukauskas - avatar