+ 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!:-)
26 odpowiedzi
+ 29
+ 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! 👍😉
+ 15
pretty much the same as others solutions
https://code.sololearn.com/cPJnv6Cqmls3/?ref=app
+ 13
+ 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
+ 9
My implementation
https://code.sololearn.com/cxJ28Jr14DI1/?ref=app
+ 7
+ 7
+ 4
https://code.sololearn.com/c4oO0hP1SvZp/#py
+ 4
Straight C code solution.
https://code.sololearn.com/caC79GsJ5msu/#
+ 4
This is mine.
https://code.sololearn.com/cbv1CLPJSaYP/?ref=app