+ 33
[ ASSIGNMENT: ] Get the Middle Character
TASK : You are going to be given a word. Your task is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters. For Example :: getMiddle("happy") --> return "p" getMiddle("codings") --> return "i" getMiddle("SoloLearn") --> return "L" getMiddle("playground") --> return "gr" NOTE : Spaces are ignored! #Output : The middle character(s) of the word represented as a String! HappyCodings!:-)
30 Réponses
+ 20
https://code.sololearn.com/cJkjJ12YCWKs/?ref=app
+ 17
The task is updated for the reason that you are taking the white space as part of a word!
If the word's length is odd,
return the middle character.
If the word's length is even,
return the middle 2 characters.
--> Spaces are ignored!
Thank you all! 👍😉
+ 16
Kotlin oneliner 😉
https://code.sololearn.com/cP2ADjwgKj7P/?ref=app
https://code.sololearn.com/cia9VCaBIEbV/?ref=app
https://code.sololearn.com/cc1G4NQn0QL7/?ref=app
https://code.sololearn.com/cN7P94XLLew6/?ref=app
+ 15
pretty much the same as others solutions
https://code.sololearn.com/cPJnv6Cqmls3/?ref=app
+ 11
https://code.sololearn.com/cOomNTx8kfLr/?ref=app
+ 11
Another pythoneliner
https://code.sololearn.com/c42cvAa6AWbn/#py
+ 10
Yeah, Luka will do it in one line 😁
Here is mine
https://code.sololearn.com/c9hk0oOhzuC8/?ref=app
+ 9
+ 4
https://code.sololearn.com/c4oO0hP1SvZp/#py
+ 4
Straight C code solution.
https://code.sololearn.com/caC79GsJ5msu/#