In this simple but fun challenge, you were asked to determine if Jimmy would fall of their platform. Jimmy has three body parts /
, o
, and \
arranged like this
/o\
Platforms are represented with -
. Jimmy will fall off their platform iff they have two or more body parts that are not directly above a platform.
Some examples:
/o\
- -------
Jimmy will balance since all their body parts are above a -
.
/o\
------ ---
Jimmy will balanced since two body parts are above -
s.
/o\
-- ---- --
Jimmy will balance even though they are split between two platforms
/o\
-
Jimmy will not be balanced since two body parts are not above a platform.
Your task is to write a program that takes a platform as a lengthed container containing only -
s and
s (e.g. a string) and outputs the number of Jimmys that can be placed on the platform such that none of them will fall and none of them will overlap. A Jimmy may have one of their body parts to the left of the beginning of the string or the right of the end of the string.
This is code-golf so answers are scored in bytes with fewer bytes being the aim.
Test cases
Inputs
- - -
- -
--
-- --
----
- -- --
------- -
Respective outputs
0
0
1
1
2
2
2
3