+ 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.
16 Answers
+ 6
Your answer [Updated]
https://code.sololearn.com/c4kU3SrkPjQ2/?ref=app
+ 19
here is my try ☺
https://code.sololearn.com/cVK7NFDpChn0/?ref=app
+ 15
My answer :
https://code.sololearn.com/ciNCUgoMAthI/?ref=app
+ 13
https://code.sololearn.com/ctR2zK5uMuuq/?ref=app
+ 13
My try in assembly:
https://code.sololearn.com/c8do4ld7xbsn/?ref=app
+ 12
+ 11
My Python, is here!!!!
https://code.sololearn.com/cQSR6lt3i814/?ref=app
+ 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).
+ 5
https://code.sololearn.com/cAifJ12KlayB/?ref=app
+ 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
+ 4
There fixed.
https://code.sololearn.com/cdzLUZOkmKgL/?ref=app
+ 4
@LukArToDo it is fixed