[Question]
  [
In [this simple but fun challenge](https://codegolf.stackexchange.com/questions/187586/will-jimmy-fall-off-his-platform), 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](/questions/tagged/code-golf "show questions tagged '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
```
  
[Answer]
# JavaScript (ES6), ~~45 41~~ 40 bytes
*Saved 4 bytes thanks to @Shaggy*
```
s=>(0+s+0).split(/.--|-.-|--./).length-1
```
[Try it online!](https://tio.run/##fY09CoAwFIN3T1GcWiSvegC9i2j9o7TiK07evSpuUoVk@ZKQpd1b7rZ5DXC@N3GoI9eNLAsuSkW82jlITcABugzSiqxxY5hQxc479taQ9aMcZA4hbuVKZa8kgZAsIg3FB09j8TcAnud4Ag "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 53 bytes
```
lambda s:len(re.findall('.--|-.-|--.',`s`))
import re
```
[Try it online!](https://tio.run/##TYjBCsIwEETv@Yq9bQJuQI8F/0SwkSZ0YZuGbaQI/ntsrQdhZt7MlFcd53xp6XprEqbHEGDpJGar0SfOQxCx6Ine5DeTx1O/9M4ZnsqsFTS2dWSJcO4MFOVcIVkN651zeVbrXEMC2IUGN9G30BHw4wH4P2gf@AE "Python 2 – Try It Online")
Based on [Arnauld's regex](https://codegolf.stackexchange.com/a/187684/20260). Greedily searches for all the non-overlapping length-3 substrings with two or more `-`. A trick is to do ``s`` to enclose the input string in quotes as padding to leave room for Jimmys to hang off on either end like
```
/o\/o\
'----'
```
**[Python 2](https://docs.python.org/2/), 57 bytes**
```
f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])
```
[Try it online!](https://tio.run/##TYnNCoMwEITvPsXc1hT2oN4C7YuIlBQVA3YNSYr00ldPE@2hMMzPN@4dl03alObrap6P0SBoYiYrCL3uhktrZOTPXIe@04PaPMKNKDMU1GSU9sWuExpdwXkrMR/e7Hcr7hVrpRIxUEQVZfFR@DT88gz8Ay6Dvg "Python 2 – Try It Online")
Requires a cheesy I/O format of the input already in quotes. Outputs `False` for 0.
A recursive function that places each Jimmy on the leftmost position allowed, by either placing Jimmy over the first three characters if they can hold Jimmy, or otherwise deleting the first character. A cute trick is to check if `s[:3]` contains two or more `-` by doing `'--'in s[:3]*2`, which concatenates two copies of `s[:3]` and checks for two adjacent `-`.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 28 bytes
Uses the same method as @Arnauld's JavaScript.
```
$_=@a=" $_ "=~/.--|-.-|--./g
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tYh0VZJQSVeQcm2Tl9PV7dGVw@IdfX00///11VQACEuLl0goQtCCmASRCggOLog5r/8gpLM/Lzi/7q@pnoGhgb/dQtyAA "Perl 5 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 16 bytes
Based on Arnauld's original JS solution. I tried a few different methods to get the necessary padding either side of the input but all came in at the same length - still searching for a shorter way...
```
ûUÊÄÄ è".--|-."ê
```
[Test it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=%2b1XKxMQg6CIuLS18LS4i6g&input=WwoiLSAgLSAgLSIKIiIKIi0gLSIKIi0tIgoiLS0gLS0iCiItLS0tIgoiLSAtLSAtLSIKIi0tLS0tLS0gLSIKXS1t)
```
ûUÊÄÄ è".--|-."ê     :Implicit input of string U
û                    :Centre pad with spaces to length
 UÊ                  :  Length of U
   ÄÄ                :  Add 1, twice
      è              :Count the occurrences of
       ".--|-."ê     :  ".--|-." palindromised, resulting in the RegEx /.--|-.-|--./g
```
[Answer]
# Excel, 96 bytes
`A1` = platform.
Entered as array Formula `Ctrl`+`Shift`+`Enter`
```
=SUM(IF(LEN(TRIM(MID(IF(MOD(LEN(A1),3)=1," ","")&A1,3*ROW(INDIRECT("A1:A"&LEN(A1)))-2,3)))>1,1))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 16 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ðì‚ε3ôʒ'-¢2@}g}à
```
Can definitely be golfed.. Sometimes it's annoying to see all these regex answers in a challenge when using 05AB1E, which is lacking regex of any kind. ;)
[Try it online](https://tio.run/##yy9OTMpM/f//8IbDax41zDq31fjwllOT1HUPLTJyqE2vPbzg/39dCFDQBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TVnl4gr2SwqO2SQpK9v8Pbzi85lHDrHNbjQ9vOTVJXffQIiOH2vTawwv@6/zXVVAAIS4FLl0gqQtCCmASRCggOLogJgA).
**Explanation:**
```
ðì            # Prepend a space before the (implicit) input
  ‚           # Pair it with the unmodified (implicit) input
   ε          # Map both to:
    3ô        #  Split them into parts of size 3
      ʒ       #  Filter these parts by:
       '-¢   '#   Where the amount of "-"
          2@  #   Is larger than or equal to 2
      }g      #  After the filter: take the length to get the amount of items left
   }à         # After the map: get the maximum of the two
              # (which is output implicitly as result)
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 39 bytes
```
->s{s.scan(/(^|.)--|-.-|--(.|$)/).size}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1664ulivODkxT0NfI65GT1NXt0ZXD4h1NfRqVDT1NfWKM6tSa/9Hq@sqKICQuo46EOmCGboQQgFKQygFZAFdEEc9Vi83saC6pqKmQCEtuiK29j8A "Ruby – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
ƒó±KêyG←à╛Ωô∟
```
[Run and debug it](https://staxlang.xyz/#p=9fa2f14b8879471b85beea931c&i=%22-++-++-%22%0A%22%22%0A%22-+-%22%0A%22--%22%0A%22--+--%22%0A%22----%22%0A%22-+--+--%22%0A%22-------+-%22%0A&a=1&m=2)
[Answer]
# Java 8, 41 bytes
```
s->(0+s+10).split(".--|--.|-.-").length-1
```
[Try it online.](https://tio.run/##TZC9bgIxEIR7nmLkypazFrRESZM6NJQhhWMMMTG@03kBRXDPfvH9SZFWu57Rej5pT/Zq6bT/6Vy0OePdhnRfACGxbw7WeWx6ORhwcstNSEdk9VzMdlFaZsvBYYOEF3SZXuVSZ71aKpPrGFgKQ/QgMg8yJJSJPh35m1ZdH1BfvmL5O0Vcq7DHufAnyscnrBrhh6qZ0ewzv9nssUbyN8yrd0FAX@JJlKLhQWPDNMeB/wb1QrRqoADb38z@bKoLm7rkckxS7ITQM1QXtYbQyTg5e2q6Rdv9AQ)
Port of [*@Arnauld*'s JavaScript answer](https://codegolf.stackexchange.com/a/187684/52210), except that `+0` is `+10` to fix test cases like `----`. This is necessary because the [`String#split`](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#split-java.lang.String-) builtin in Java will remove trailing empty Strings by default. This can be changed by adding an [additional parameter to the `split` builtin](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#split-java.lang.String-int-) (which is `0` by default in the `split`-builtin with a single String argument). To quote the usage of this additional parameter from the docs:
> 
> The limit parameter controls the number of times the pattern is applied and therefore affects the length of the resulting array.  
> 
> If the limit \$n\$ is **greater than zero** then the pattern will be applied at most \$n-1\$ times, the array's length will be no greater than \$n\$, and the array's last entry will contain all input beyond the last matched delimiter.  
> 
> If \$n\$ is **non-positive** then the pattern will be applied as many times as possible and the array can have any length.  
> 
> If \$n\$ is **zero** then the pattern will be applied as many times as possible, the array can have any length, **and trailing empty strings will be discarded**.
> 
> 
> 
Because of this, usually `.split("...",-1)` is used to retain *ALL* trailing empty Strings, and I could have used it for this answer as well ([Try it online](https://tio.run/##TZBPbwIhEMXvfooXThAcoleb9tJzvXhse6CIFkV2s4w2je5n37L/kiaTGd4L836Ek71ZOu3PnYs2Z7zZkO4LICT2zcE6j20vBwNO7rgJ6YisnorZLkrLbDk4bJHwjC7Ti1zprFfK5DoGlsIQPYjMgwyJJa2ViT4d@ZvWXR9RX79i2Z5CblXY41JeMHHeP2HViD9UzQxnn/nVZo8Nkv/BfPUuCOhLLEUpGg40NkxzHPhvUC9EqwYKsPvN7C@murKpSy7HJMWHEHqG6qI2EDoZJ2dPTb/Rdn8)). In this case changing the `+0` to `+10` saves two bytes over the `,-1`, though. :)
[Answer]
# Elm 0.19, 108 bytes
```
import Regex as R
f p=List.length<|R.find(Maybe.withDefault R.never<|R.fromString".--|-.-|--.")(" "++p++" ")
```
Based on the regex in [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)'s JavaScript [answer](https://codegolf.stackexchange.com/a/187684/79343). Verify all test cases [here](https://ellie-app.com/63bn8psYDyxa1).
Alternative solution without regex, significantly longer at **171 bytes**:
```
f p=(String.foldl(\z{x,y,s,c}->let(t,d)=if s<1&&List.length(List.filter((==)'-')[x,y,z])>1 then(2,c+1)else(max 0 s-1,c)in{x=y,y=z,s=t,c=d}){x=' ',y=' ',s=0,c=0}(p++" ")).c
```
Verify all test cases [here](https://ellie-app.com/63qnVmb8V3Ba1).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
n⁶,Ż$s€3§Ẓ§Ṁ
```
[Try it online!](https://tio.run/##y0rNyan8/z/vUeM2naO7VYofNa0xPrT84a5JQGJnw/9HjfuUlLKsHzXMUdC1U3jUMNf6cDvXw91bDrcDFUb@/6@kpKSroABCXApcukBSF4QUwCSIUEBwdEFMoHoA "Jelly – Try It Online")
Based on [@KevinCrujissen’s 05AB1E answer](https://codegolf.stackexchange.com/a/187711/42248) so be sure to upvote him too. 
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 25 bytes
```
Ｐθ↖Ｆθ¿›№ＫＭ-¹«⊞υωＭ³→»→⎚ＩＬυ
```
[Try it online!](https://tio.run/##NY7BCoMwDIbP9imCpxT0MHbTo4ddFGSwBygStaxYF1t3GHv2LnOMwE/y8@dLhtnw4I1LqYsu2JXtEvCha9X5nbC6rS2NQcbRM4gPdgS8MJlAjI2PEu6J7p33TKgLyMtc9KQ1vFTWx23GWMBT9rODdy6gutpp/hLfitxG8LvzNxtHhlGa/nikMVvAlpYpCEhrXadUwlEqlbv7AA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｐθ↖
```
Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.
```
Ｆθ
```
Look for as many Jimmies as there are platform positions.
```
¿›№ＫＭ-¹
```
Check to see whether there is more than one piece of platform at this position.
```
«⊞υω
```
If so then note a valid Jimmy position...
```
Ｍ³→»
```
... and move three characters to the right so that the Jimmies don't overlap.
```
→
```
Otherwise the next potential Jimmy position is one character to the right.
```
⎚ＩＬυ
```
Clear the platform and output the count of discovered positions.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 38 bytes
Port of [Arnauld's JavaScript answer](https://codegolf.stackexchange.com/a/187684/52210).
```
(" $args "-split'.--|-.-|--.').count-1
```
[Try it online!](https://tio.run/##XY9hC4IwEIa/71ccYzUH3sj6JgT9kxCbFaxcblKg/vY1NTQ9drD3fd47OFO@VWVvSmvPCjhC4yMKLKuuFihao@@OS8QWZWiUXMi8rJ8OE98RcooIhIqjXcwRoH9czNb0T3qMCzmrfa9gbaw0LCOHMYI4rhXQwgaaATL1MSp36hIDMzpzRVk9bLiLnUdcKVtrF4xtOHdODJCy6MdRvaZFIp2m0r8JSjr/BQ "PowerShell – Try It Online")
]