In the Centre?

Published by Mubashir Hassan in

Given a string containing mostly spaces and one non-space character, return whether the character is positioned in the very centre of the string. This means the number of spaces on both sides should be the same.

Examples

is_central("  #  ") ➞ true

is_central(" 2    ") ➞ false

is_central("@") ➞ true

Notes

Only one character other than spaces will be given at a time.

Watch a quick demo on how Edabit works.