29
1
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 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
141 bytes – Shaggy – 2019-07-04T19:59:04.720
7@Shaggy Thanks! I knew something was wrong there, but I had to help my wife on some Super Mario Galaxy level in the meantime... and it was also a problem about broken platforms. :p – Arnauld – 2019-07-04T20:12:11.013
2the
---
wasn't sitting well with me either, until I was working on my port and realised they weren't needed. Think I'll call it a day here, grab a bag of cans and throw on SMG myself - haven't played it in an age. – Shaggy – 2019-07-04T20:24:32.367And now all the other answers are using the same regex. – Cœur – 2019-07-07T02:15:12.323