How many Jimmys can fit?Will Jimmy fall off his platform?A scene of Jimmy diversityCan Jimmy hang on his rope?Jimmy needs your help!Jimmy needs a new pair of shoes!Battle of the JimmysMove platforms!Can this list be balanced?Rosencrantz and Guildenstern are CodeCan this container hold this much liquid?Will Jimmy fall off his platform?Jimmy needs your help!Can Jimmy hang on his rope?Jimmy needs a new pair of shoes!A scene of Jimmy diversityBattle of the Jimmys

Replacing 2-prong outlets in basement - existing wiring has two hot wires, one neutral?

Why the real and imaginary parts of a complex analytic function are not independent?

What happens if a country signs mutual defense treaties with several countries who later go to war with each other?

Lvl20 Samurai+true strike=9 attacks all with advantage?

Drying clothes: windy but cold outside vs warm(ish) inside?

Why is Carbon Dioxide a Greenhouse Gas whereas Ammonia is not?

Is it usual for a US president to make specific comments about a UK Prime Minister's suitability during a general election?

What is Trump's position on the whistle blower allegations? What does he mean by "witch hunt"?

Can I say: “The train departs at 16 past every hour“?

Why is the air inside airliners so dry (low humidity)?

Installing a sliding patio door...why does the entire frame have to be square, level and plumb?

Help with formulating an implication

Security risks of user generated HTML?

Is there any reason we shouldn't allow activities on custom object

Complete the Pointer Set

A new combinatorial property for the character table of a finite group?

Oh you, I need in every second

What is the hidden passcode?

Why aren't large, low-speed propellers widely used?

30 fake coins out of 99 coins v2

Converting a Scheme function to Emacs Lisp

Would rocket engine exhaust create pockets of gas in space which could hinder further space exploration?

What is the equivalent of "if you say so" in German?

Why would gloves be necessary for handling flobberworms?



How many Jimmys can fit?


Will Jimmy fall off his platform?A scene of Jimmy diversityCan Jimmy hang on his rope?Jimmy needs your help!Jimmy needs a new pair of shoes!Battle of the JimmysMove platforms!Can this list be balanced?Rosencrantz and Guildenstern are CodeCan this container hold this much liquid?Will Jimmy fall off his platform?Jimmy needs your help!Can Jimmy hang on his rope?Jimmy needs a new pair of shoes!A scene of Jimmy diversityBattle of the Jimmys






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









29














$begingroup$


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









share|improve this question












$endgroup$





















    29














    $begingroup$


    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









    share|improve this question












    $endgroup$

















      29












      29








      29


      1



      $begingroup$


      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









      share|improve this question












      $endgroup$




      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






      code-golf string






      share|improve this question
















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 4 at 19:11







      Wheat Wizard

















      asked Jul 4 at 18:47









      Wheat WizardWheat Wizard

      38.4k10 gold badges172 silver badges386 bronze badges




      38.4k10 gold badges172 silver badges386 bronze badges























          13 Answers
          13






          active

          oldest

          votes


















          15
















          $begingroup$

          JavaScript (ES6),  45 41  40 bytes



          Saved 4 bytes thanks to @Shaggy





          s=>(0+s+0).split(/.--|-.-|--./).length-1


          Try it online!






          share|improve this answer












          $endgroup$










          • 1




            $begingroup$
            41 bytes
            $endgroup$
            – Shaggy
            Jul 4 at 19:59







          • 7




            $begingroup$
            @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
            $endgroup$
            – Arnauld
            Jul 4 at 20:12






          • 2




            $begingroup$
            the --- 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.
            $endgroup$
            – Shaggy
            Jul 4 at 20:24










          • $begingroup$
            And now all the other answers are using the same regex.
            $endgroup$
            – Cœur
            Jul 7 at 2:15


















          8
















          $begingroup$


          Python 2, 53 bytes





          lambda s:len(re.findall('.--|-.-|--.',`s`))
          import re


          Try it online!



          Based on Arnauld's regex. 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, 57 bytes





          f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])


          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 -.






          share|improve this answer












          $endgroup$






















            3
















            $begingroup$


            Perl 5 -p, 28 bytes



            Uses the same method as @Arnauld's JavaScript.





            $_=@a=" $_ "=~/.--|-.-|--./g


            Try it online!






            share|improve this answer










            $endgroup$






















              3
















              $begingroup$


              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



              û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





              share|improve this answer












              $endgroup$






















                3
















                $begingroup$

                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))





                share|improve this answer










                $endgroup$






















                  3
















                  $begingroup$


                  05AB1E, 16 bytes



                  ðì‚ε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 or verify all test cases.



                  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)





                  share|improve this answer










                  $endgroup$






















                    3
















                    $begingroup$


                    Ruby, 39 bytes





                    ->s--(.


                    Try it online!






                    share|improve this answer










                    $endgroup$














                    • $begingroup$
                      38 bytes
                      $endgroup$
                      – Value Ink
                      Jul 5 at 21:52


















                    2
















                    $begingroup$


                    Stax, 13 bytes



                    ƒó±KêyG←à╛Ωô∟


                    Run and debug it






                    share|improve this answer










                    $endgroup$






















                      2
















                      $begingroup$

                      Java 8, 41 bytes





                      s->(0+s+10).split(".--|--.|-.-").length-1


                      Try it online.



                      Port of @Arnauld's JavaScript answer, except that +0 is +10 to fix test cases like ----. This is necessary because the String#split builtin in Java will remove trailing empty Strings by default. This can be changed by adding an additional parameter to the split builtin (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). In this case changing the +0 to +10 saves two bytes over the ,-1, though. :)






                      share|improve this answer












                      $endgroup$






















                        0
















                        $begingroup$


                        Jelly, 12 bytes



                        n⁶,Ż$s€3§Ẓ§Ṁ


                        Try it online!



                        Based on @KevinCrujissen’s 05AB1E answer so be sure to upvote him too.






                        share|improve this answer










                        $endgroup$






















                          0
















                          $begingroup$


                          Charcoal, 25 bytes



                          Pθ↖Fθ¿›№KM-¹«⊞υωM³→»→⎚ILυ


                          Try it online! Link is to verbose version of code. Explanation:



                          Pθ↖


                          Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.



                          Fθ


                          Look for as many Jimmies as there are platform positions.



                          ¿›№KM-¹


                          Check to see whether there is more than one piece of platform at this position.



                          «⊞υω


                          If so then note a valid Jimmy position...



                          M³→»


                          ... 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.



                          ⎚ILυ


                          Clear the platform and output the count of discovered positions.






                          share|improve this answer










                          $endgroup$






















                            0
















                            $begingroup$


                            PowerShell, 38 bytes



                            Port of Arnauld's JavaScript answer.





                            (" $args "-split'.--|-.-|--.').count-1


                            Try it online!






                            share|improve this answer










                            $endgroup$






















                              0
















                              $begingroup$

                              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's JavaScript answer. Verify all test cases here.



                              Alternative solution without regex, significantly longer at 171 bytes:



                              f p=(String.foldl(zx,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)inx=y,y=z,s=t,c=d)x=' ',y=' ',s=0,c=0(p++" ")).c


                              Verify all test cases here.






                              share|improve this answer










                              $endgroup$
















                                Your Answer






                                StackExchange.ifUsing("editor", function ()
                                StackExchange.using("externalEditor", function ()
                                StackExchange.using("snippets", function ()
                                StackExchange.snippets.init();
                                );
                                );
                                , "code-snippets");

                                StackExchange.ready(function()
                                var channelOptions =
                                tags: "".split(" "),
                                id: "200"
                                ;
                                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                StackExchange.using("externalEditor", function()
                                // Have to fire editor after snippets, if snippets enabled
                                if (StackExchange.settings.snippets.snippetsEnabled)
                                StackExchange.using("snippets", function()
                                createEditor();
                                );

                                else
                                createEditor();

                                );

                                function createEditor()
                                StackExchange.prepareEditor(
                                heartbeatType: 'answer',
                                autoActivateHeartbeat: false,
                                convertImagesToLinks: false,
                                noModals: true,
                                showLowRepImageUploadWarning: true,
                                reputationToPostImages: null,
                                bindNavPrevention: true,
                                postfix: "",
                                imageUploader:
                                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                allowUrls: true
                                ,
                                onDemand: true,
                                discardSelector: ".discard-answer"
                                ,immediatelyShowMarkdownHelp:true
                                );



                                );














                                draft saved

                                draft discarded
















                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f187682%2fhow-many-jimmys-can-fit%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown


























                                13 Answers
                                13






                                active

                                oldest

                                votes








                                13 Answers
                                13






                                active

                                oldest

                                votes









                                active

                                oldest

                                votes






                                active

                                oldest

                                votes









                                15
















                                $begingroup$

                                JavaScript (ES6),  45 41  40 bytes



                                Saved 4 bytes thanks to @Shaggy





                                s=>(0+s+0).split(/.--|-.-|--./).length-1


                                Try it online!






                                share|improve this answer












                                $endgroup$










                                • 1




                                  $begingroup$
                                  41 bytes
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 19:59







                                • 7




                                  $begingroup$
                                  @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
                                  $endgroup$
                                  – Arnauld
                                  Jul 4 at 20:12






                                • 2




                                  $begingroup$
                                  the --- 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.
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 20:24










                                • $begingroup$
                                  And now all the other answers are using the same regex.
                                  $endgroup$
                                  – Cœur
                                  Jul 7 at 2:15















                                15
















                                $begingroup$

                                JavaScript (ES6),  45 41  40 bytes



                                Saved 4 bytes thanks to @Shaggy





                                s=>(0+s+0).split(/.--|-.-|--./).length-1


                                Try it online!






                                share|improve this answer












                                $endgroup$










                                • 1




                                  $begingroup$
                                  41 bytes
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 19:59







                                • 7




                                  $begingroup$
                                  @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
                                  $endgroup$
                                  – Arnauld
                                  Jul 4 at 20:12






                                • 2




                                  $begingroup$
                                  the --- 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.
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 20:24










                                • $begingroup$
                                  And now all the other answers are using the same regex.
                                  $endgroup$
                                  – Cœur
                                  Jul 7 at 2:15













                                15














                                15










                                15







                                $begingroup$

                                JavaScript (ES6),  45 41  40 bytes



                                Saved 4 bytes thanks to @Shaggy





                                s=>(0+s+0).split(/.--|-.-|--./).length-1


                                Try it online!






                                share|improve this answer












                                $endgroup$



                                JavaScript (ES6),  45 41  40 bytes



                                Saved 4 bytes thanks to @Shaggy





                                s=>(0+s+0).split(/.--|-.-|--./).length-1


                                Try it online!







                                share|improve this answer















                                share|improve this answer




                                share|improve this answer








                                edited Jul 4 at 21:03

























                                answered Jul 4 at 19:14









                                ArnauldArnauld

                                96.7k7 gold badges114 silver badges392 bronze badges




                                96.7k7 gold badges114 silver badges392 bronze badges










                                • 1




                                  $begingroup$
                                  41 bytes
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 19:59







                                • 7




                                  $begingroup$
                                  @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
                                  $endgroup$
                                  – Arnauld
                                  Jul 4 at 20:12






                                • 2




                                  $begingroup$
                                  the --- 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.
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 20:24










                                • $begingroup$
                                  And now all the other answers are using the same regex.
                                  $endgroup$
                                  – Cœur
                                  Jul 7 at 2:15












                                • 1




                                  $begingroup$
                                  41 bytes
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 19:59







                                • 7




                                  $begingroup$
                                  @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
                                  $endgroup$
                                  – Arnauld
                                  Jul 4 at 20:12






                                • 2




                                  $begingroup$
                                  the --- 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.
                                  $endgroup$
                                  – Shaggy
                                  Jul 4 at 20:24










                                • $begingroup$
                                  And now all the other answers are using the same regex.
                                  $endgroup$
                                  – Cœur
                                  Jul 7 at 2:15







                                1




                                1




                                $begingroup$
                                41 bytes
                                $endgroup$
                                – Shaggy
                                Jul 4 at 19:59





                                $begingroup$
                                41 bytes
                                $endgroup$
                                – Shaggy
                                Jul 4 at 19:59





                                7




                                7




                                $begingroup$
                                @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
                                $endgroup$
                                – Arnauld
                                Jul 4 at 20:12




                                $begingroup$
                                @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
                                $endgroup$
                                – Arnauld
                                Jul 4 at 20:12




                                2




                                2




                                $begingroup$
                                the --- 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.
                                $endgroup$
                                – Shaggy
                                Jul 4 at 20:24




                                $begingroup$
                                the --- 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.
                                $endgroup$
                                – Shaggy
                                Jul 4 at 20:24












                                $begingroup$
                                And now all the other answers are using the same regex.
                                $endgroup$
                                – Cœur
                                Jul 7 at 2:15




                                $begingroup$
                                And now all the other answers are using the same regex.
                                $endgroup$
                                – Cœur
                                Jul 7 at 2:15













                                8
















                                $begingroup$


                                Python 2, 53 bytes





                                lambda s:len(re.findall('.--|-.-|--.',`s`))
                                import re


                                Try it online!



                                Based on Arnauld's regex. 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, 57 bytes





                                f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])


                                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 -.






                                share|improve this answer












                                $endgroup$



















                                  8
















                                  $begingroup$


                                  Python 2, 53 bytes





                                  lambda s:len(re.findall('.--|-.-|--.',`s`))
                                  import re


                                  Try it online!



                                  Based on Arnauld's regex. 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, 57 bytes





                                  f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])


                                  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 -.






                                  share|improve this answer












                                  $endgroup$

















                                    8














                                    8










                                    8







                                    $begingroup$


                                    Python 2, 53 bytes





                                    lambda s:len(re.findall('.--|-.-|--.',`s`))
                                    import re


                                    Try it online!



                                    Based on Arnauld's regex. 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, 57 bytes





                                    f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])


                                    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 -.






                                    share|improve this answer












                                    $endgroup$




                                    Python 2, 53 bytes





                                    lambda s:len(re.findall('.--|-.-|--.',`s`))
                                    import re


                                    Try it online!



                                    Based on Arnauld's regex. 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, 57 bytes





                                    f=lambda s:'--'in s[:3]*2and-~f(s[3:])or s>''and f(s[1:])


                                    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 -.







                                    share|improve this answer















                                    share|improve this answer




                                    share|improve this answer








                                    edited Jul 4 at 20:05

























                                    answered Jul 4 at 19:43









                                    xnorxnor

                                    102k20 gold badges210 silver badges476 bronze badges




                                    102k20 gold badges210 silver badges476 bronze badges
























                                        3
















                                        $begingroup$


                                        Perl 5 -p, 28 bytes



                                        Uses the same method as @Arnauld's JavaScript.





                                        $_=@a=" $_ "=~/.--|-.-|--./g


                                        Try it online!






                                        share|improve this answer










                                        $endgroup$



















                                          3
















                                          $begingroup$


                                          Perl 5 -p, 28 bytes



                                          Uses the same method as @Arnauld's JavaScript.





                                          $_=@a=" $_ "=~/.--|-.-|--./g


                                          Try it online!






                                          share|improve this answer










                                          $endgroup$

















                                            3














                                            3










                                            3







                                            $begingroup$


                                            Perl 5 -p, 28 bytes



                                            Uses the same method as @Arnauld's JavaScript.





                                            $_=@a=" $_ "=~/.--|-.-|--./g


                                            Try it online!






                                            share|improve this answer










                                            $endgroup$




                                            Perl 5 -p, 28 bytes



                                            Uses the same method as @Arnauld's JavaScript.





                                            $_=@a=" $_ "=~/.--|-.-|--./g


                                            Try it online!







                                            share|improve this answer













                                            share|improve this answer




                                            share|improve this answer










                                            answered Jul 4 at 20:23









                                            XcaliXcali

                                            7,1641 gold badge7 silver badges25 bronze badges




                                            7,1641 gold badge7 silver badges25 bronze badges
























                                                3
















                                                $begingroup$


                                                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



                                                û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





                                                share|improve this answer












                                                $endgroup$



















                                                  3
















                                                  $begingroup$


                                                  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



                                                  û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





                                                  share|improve this answer












                                                  $endgroup$

















                                                    3














                                                    3










                                                    3







                                                    $begingroup$


                                                    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



                                                    û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





                                                    share|improve this answer












                                                    $endgroup$




                                                    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



                                                    û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






                                                    share|improve this answer















                                                    share|improve this answer




                                                    share|improve this answer








                                                    edited Jul 4 at 20:29

























                                                    answered Jul 4 at 19:57









                                                    ShaggyShaggy

                                                    22.6k3 gold badges21 silver badges73 bronze badges




                                                    22.6k3 gold badges21 silver badges73 bronze badges
























                                                        3
















                                                        $begingroup$

                                                        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))





                                                        share|improve this answer










                                                        $endgroup$



















                                                          3
















                                                          $begingroup$

                                                          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))





                                                          share|improve this answer










                                                          $endgroup$

















                                                            3














                                                            3










                                                            3







                                                            $begingroup$

                                                            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))





                                                            share|improve this answer










                                                            $endgroup$



                                                            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))






                                                            share|improve this answer













                                                            share|improve this answer




                                                            share|improve this answer










                                                            answered Jul 5 at 1:46









                                                            remoelremoel

                                                            5113 silver badges6 bronze badges




                                                            5113 silver badges6 bronze badges
























                                                                3
















                                                                $begingroup$


                                                                05AB1E, 16 bytes



                                                                ðì‚ε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 or verify all test cases.



                                                                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)





                                                                share|improve this answer










                                                                $endgroup$



















                                                                  3
















                                                                  $begingroup$


                                                                  05AB1E, 16 bytes



                                                                  ðì‚ε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 or verify all test cases.



                                                                  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)





                                                                  share|improve this answer










                                                                  $endgroup$

















                                                                    3














                                                                    3










                                                                    3







                                                                    $begingroup$


                                                                    05AB1E, 16 bytes



                                                                    ðì‚ε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 or verify all test cases.



                                                                    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)





                                                                    share|improve this answer










                                                                    $endgroup$




                                                                    05AB1E, 16 bytes



                                                                    ðì‚ε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 or verify all test cases.



                                                                    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)






                                                                    share|improve this answer













                                                                    share|improve this answer




                                                                    share|improve this answer










                                                                    answered Jul 5 at 6:50









                                                                    Kevin CruijssenKevin Cruijssen

                                                                    53k7 gold badges87 silver badges253 bronze badges




                                                                    53k7 gold badges87 silver badges253 bronze badges
























                                                                        3
















                                                                        $begingroup$


                                                                        Ruby, 39 bytes





                                                                        ->s--(.


                                                                        Try it online!






                                                                        share|improve this answer










                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          38 bytes
                                                                          $endgroup$
                                                                          – Value Ink
                                                                          Jul 5 at 21:52















                                                                        3
















                                                                        $begingroup$


                                                                        Ruby, 39 bytes





                                                                        ->s--(.


                                                                        Try it online!






                                                                        share|improve this answer










                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          38 bytes
                                                                          $endgroup$
                                                                          – Value Ink
                                                                          Jul 5 at 21:52













                                                                        3














                                                                        3










                                                                        3







                                                                        $begingroup$


                                                                        Ruby, 39 bytes





                                                                        ->s--(.


                                                                        Try it online!






                                                                        share|improve this answer










                                                                        $endgroup$




                                                                        Ruby, 39 bytes





                                                                        ->s--(.


                                                                        Try it online!







                                                                        share|improve this answer













                                                                        share|improve this answer




                                                                        share|improve this answer










                                                                        answered Jul 5 at 7:15









                                                                        G BG B

                                                                        9,06414 silver badges31 bronze badges




                                                                        9,06414 silver badges31 bronze badges














                                                                        • $begingroup$
                                                                          38 bytes
                                                                          $endgroup$
                                                                          – Value Ink
                                                                          Jul 5 at 21:52
















                                                                        • $begingroup$
                                                                          38 bytes
                                                                          $endgroup$
                                                                          – Value Ink
                                                                          Jul 5 at 21:52















                                                                        $begingroup$
                                                                        38 bytes
                                                                        $endgroup$
                                                                        – Value Ink
                                                                        Jul 5 at 21:52




                                                                        $begingroup$
                                                                        38 bytes
                                                                        $endgroup$
                                                                        – Value Ink
                                                                        Jul 5 at 21:52











                                                                        2
















                                                                        $begingroup$


                                                                        Stax, 13 bytes



                                                                        ƒó±KêyG←à╛Ωô∟


                                                                        Run and debug it






                                                                        share|improve this answer










                                                                        $endgroup$



















                                                                          2
















                                                                          $begingroup$


                                                                          Stax, 13 bytes



                                                                          ƒó±KêyG←à╛Ωô∟


                                                                          Run and debug it






                                                                          share|improve this answer










                                                                          $endgroup$

















                                                                            2














                                                                            2










                                                                            2







                                                                            $begingroup$


                                                                            Stax, 13 bytes



                                                                            ƒó±KêyG←à╛Ωô∟


                                                                            Run and debug it






                                                                            share|improve this answer










                                                                            $endgroup$




                                                                            Stax, 13 bytes



                                                                            ƒó±KêyG←à╛Ωô∟


                                                                            Run and debug it







                                                                            share|improve this answer













                                                                            share|improve this answer




                                                                            share|improve this answer










                                                                            answered Jul 4 at 21:42









                                                                            recursiverecursive

                                                                            8,43115 silver badges32 bronze badges




                                                                            8,43115 silver badges32 bronze badges
























                                                                                2
















                                                                                $begingroup$

                                                                                Java 8, 41 bytes





                                                                                s->(0+s+10).split(".--|--.|-.-").length-1


                                                                                Try it online.



                                                                                Port of @Arnauld's JavaScript answer, except that +0 is +10 to fix test cases like ----. This is necessary because the String#split builtin in Java will remove trailing empty Strings by default. This can be changed by adding an additional parameter to the split builtin (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). In this case changing the +0 to +10 saves two bytes over the ,-1, though. :)






                                                                                share|improve this answer












                                                                                $endgroup$



















                                                                                  2
















                                                                                  $begingroup$

                                                                                  Java 8, 41 bytes





                                                                                  s->(0+s+10).split(".--|--.|-.-").length-1


                                                                                  Try it online.



                                                                                  Port of @Arnauld's JavaScript answer, except that +0 is +10 to fix test cases like ----. This is necessary because the String#split builtin in Java will remove trailing empty Strings by default. This can be changed by adding an additional parameter to the split builtin (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). In this case changing the +0 to +10 saves two bytes over the ,-1, though. :)






                                                                                  share|improve this answer












                                                                                  $endgroup$

















                                                                                    2














                                                                                    2










                                                                                    2







                                                                                    $begingroup$

                                                                                    Java 8, 41 bytes





                                                                                    s->(0+s+10).split(".--|--.|-.-").length-1


                                                                                    Try it online.



                                                                                    Port of @Arnauld's JavaScript answer, except that +0 is +10 to fix test cases like ----. This is necessary because the String#split builtin in Java will remove trailing empty Strings by default. This can be changed by adding an additional parameter to the split builtin (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). In this case changing the +0 to +10 saves two bytes over the ,-1, though. :)






                                                                                    share|improve this answer












                                                                                    $endgroup$



                                                                                    Java 8, 41 bytes





                                                                                    s->(0+s+10).split(".--|--.|-.-").length-1


                                                                                    Try it online.



                                                                                    Port of @Arnauld's JavaScript answer, except that +0 is +10 to fix test cases like ----. This is necessary because the String#split builtin in Java will remove trailing empty Strings by default. This can be changed by adding an additional parameter to the split builtin (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). In this case changing the +0 to +10 saves two bytes over the ,-1, though. :)







                                                                                    share|improve this answer















                                                                                    share|improve this answer




                                                                                    share|improve this answer








                                                                                    edited Jul 5 at 8:46

























                                                                                    answered Jul 5 at 7:53









                                                                                    Kevin CruijssenKevin Cruijssen

                                                                                    53k7 gold badges87 silver badges253 bronze badges




                                                                                    53k7 gold badges87 silver badges253 bronze badges
























                                                                                        0
















                                                                                        $begingroup$


                                                                                        Jelly, 12 bytes



                                                                                        n⁶,Ż$s€3§Ẓ§Ṁ


                                                                                        Try it online!



                                                                                        Based on @KevinCrujissen’s 05AB1E answer so be sure to upvote him too.






                                                                                        share|improve this answer










                                                                                        $endgroup$



















                                                                                          0
















                                                                                          $begingroup$


                                                                                          Jelly, 12 bytes



                                                                                          n⁶,Ż$s€3§Ẓ§Ṁ


                                                                                          Try it online!



                                                                                          Based on @KevinCrujissen’s 05AB1E answer so be sure to upvote him too.






                                                                                          share|improve this answer










                                                                                          $endgroup$

















                                                                                            0














                                                                                            0










                                                                                            0







                                                                                            $begingroup$


                                                                                            Jelly, 12 bytes



                                                                                            n⁶,Ż$s€3§Ẓ§Ṁ


                                                                                            Try it online!



                                                                                            Based on @KevinCrujissen’s 05AB1E answer so be sure to upvote him too.






                                                                                            share|improve this answer










                                                                                            $endgroup$




                                                                                            Jelly, 12 bytes



                                                                                            n⁶,Ż$s€3§Ẓ§Ṁ


                                                                                            Try it online!



                                                                                            Based on @KevinCrujissen’s 05AB1E answer so be sure to upvote him too.







                                                                                            share|improve this answer













                                                                                            share|improve this answer




                                                                                            share|improve this answer










                                                                                            answered Jul 5 at 20:39









                                                                                            Nick KennedyNick Kennedy

                                                                                            7,4901 gold badge9 silver badges19 bronze badges




                                                                                            7,4901 gold badge9 silver badges19 bronze badges
























                                                                                                0
















                                                                                                $begingroup$


                                                                                                Charcoal, 25 bytes



                                                                                                Pθ↖Fθ¿›№KM-¹«⊞υωM³→»→⎚ILυ


                                                                                                Try it online! Link is to verbose version of code. Explanation:



                                                                                                Pθ↖


                                                                                                Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.



                                                                                                Fθ


                                                                                                Look for as many Jimmies as there are platform positions.



                                                                                                ¿›№KM-¹


                                                                                                Check to see whether there is more than one piece of platform at this position.



                                                                                                «⊞υω


                                                                                                If so then note a valid Jimmy position...



                                                                                                M³→»


                                                                                                ... 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.



                                                                                                ⎚ILυ


                                                                                                Clear the platform and output the count of discovered positions.






                                                                                                share|improve this answer










                                                                                                $endgroup$



















                                                                                                  0
















                                                                                                  $begingroup$


                                                                                                  Charcoal, 25 bytes



                                                                                                  Pθ↖Fθ¿›№KM-¹«⊞υωM³→»→⎚ILυ


                                                                                                  Try it online! Link is to verbose version of code. Explanation:



                                                                                                  Pθ↖


                                                                                                  Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.



                                                                                                  Fθ


                                                                                                  Look for as many Jimmies as there are platform positions.



                                                                                                  ¿›№KM-¹


                                                                                                  Check to see whether there is more than one piece of platform at this position.



                                                                                                  «⊞υω


                                                                                                  If so then note a valid Jimmy position...



                                                                                                  M³→»


                                                                                                  ... 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.



                                                                                                  ⎚ILυ


                                                                                                  Clear the platform and output the count of discovered positions.






                                                                                                  share|improve this answer










                                                                                                  $endgroup$

















                                                                                                    0














                                                                                                    0










                                                                                                    0







                                                                                                    $begingroup$


                                                                                                    Charcoal, 25 bytes



                                                                                                    Pθ↖Fθ¿›№KM-¹«⊞υωM³→»→⎚ILυ


                                                                                                    Try it online! Link is to verbose version of code. Explanation:



                                                                                                    Pθ↖


                                                                                                    Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.



                                                                                                    Fθ


                                                                                                    Look for as many Jimmies as there are platform positions.



                                                                                                    ¿›№KM-¹


                                                                                                    Check to see whether there is more than one piece of platform at this position.



                                                                                                    «⊞υω


                                                                                                    If so then note a valid Jimmy position...



                                                                                                    M³→»


                                                                                                    ... 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.



                                                                                                    ⎚ILυ


                                                                                                    Clear the platform and output the count of discovered positions.






                                                                                                    share|improve this answer










                                                                                                    $endgroup$




                                                                                                    Charcoal, 25 bytes



                                                                                                    Pθ↖Fθ¿›№KM-¹«⊞υωM³→»→⎚ILυ


                                                                                                    Try it online! Link is to verbose version of code. Explanation:



                                                                                                    Pθ↖


                                                                                                    Print the platform without moving the cursor, then move the cursor up and left as that is the first potential Jimmy position.



                                                                                                    Fθ


                                                                                                    Look for as many Jimmies as there are platform positions.



                                                                                                    ¿›№KM-¹


                                                                                                    Check to see whether there is more than one piece of platform at this position.



                                                                                                    «⊞υω


                                                                                                    If so then note a valid Jimmy position...



                                                                                                    M³→»


                                                                                                    ... 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.



                                                                                                    ⎚ILυ


                                                                                                    Clear the platform and output the count of discovered positions.







                                                                                                    share|improve this answer













                                                                                                    share|improve this answer




                                                                                                    share|improve this answer










                                                                                                    answered Jul 7 at 10:04









                                                                                                    NeilNeil

                                                                                                    90.7k8 gold badges46 silver badges190 bronze badges




                                                                                                    90.7k8 gold badges46 silver badges190 bronze badges
























                                                                                                        0
















                                                                                                        $begingroup$


                                                                                                        PowerShell, 38 bytes



                                                                                                        Port of Arnauld's JavaScript answer.





                                                                                                        (" $args "-split'.--|-.-|--.').count-1


                                                                                                        Try it online!






                                                                                                        share|improve this answer










                                                                                                        $endgroup$



















                                                                                                          0
















                                                                                                          $begingroup$


                                                                                                          PowerShell, 38 bytes



                                                                                                          Port of Arnauld's JavaScript answer.





                                                                                                          (" $args "-split'.--|-.-|--.').count-1


                                                                                                          Try it online!






                                                                                                          share|improve this answer










                                                                                                          $endgroup$

















                                                                                                            0














                                                                                                            0










                                                                                                            0







                                                                                                            $begingroup$


                                                                                                            PowerShell, 38 bytes



                                                                                                            Port of Arnauld's JavaScript answer.





                                                                                                            (" $args "-split'.--|-.-|--.').count-1


                                                                                                            Try it online!






                                                                                                            share|improve this answer










                                                                                                            $endgroup$




                                                                                                            PowerShell, 38 bytes



                                                                                                            Port of Arnauld's JavaScript answer.





                                                                                                            (" $args "-split'.--|-.-|--.').count-1


                                                                                                            Try it online!







                                                                                                            share|improve this answer













                                                                                                            share|improve this answer




                                                                                                            share|improve this answer










                                                                                                            answered Jul 8 at 9:01









                                                                                                            mazzymazzy

                                                                                                            4,1221 gold badge5 silver badges21 bronze badges




                                                                                                            4,1221 gold badge5 silver badges21 bronze badges
























                                                                                                                0
















                                                                                                                $begingroup$

                                                                                                                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's JavaScript answer. Verify all test cases here.



                                                                                                                Alternative solution without regex, significantly longer at 171 bytes:



                                                                                                                f p=(String.foldl(zx,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)inx=y,y=z,s=t,c=d)x=' ',y=' ',s=0,c=0(p++" ")).c


                                                                                                                Verify all test cases here.






                                                                                                                share|improve this answer










                                                                                                                $endgroup$



















                                                                                                                  0
















                                                                                                                  $begingroup$

                                                                                                                  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's JavaScript answer. Verify all test cases here.



                                                                                                                  Alternative solution without regex, significantly longer at 171 bytes:



                                                                                                                  f p=(String.foldl(zx,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)inx=y,y=z,s=t,c=d)x=' ',y=' ',s=0,c=0(p++" ")).c


                                                                                                                  Verify all test cases here.






                                                                                                                  share|improve this answer










                                                                                                                  $endgroup$

















                                                                                                                    0














                                                                                                                    0










                                                                                                                    0







                                                                                                                    $begingroup$

                                                                                                                    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's JavaScript answer. Verify all test cases here.



                                                                                                                    Alternative solution without regex, significantly longer at 171 bytes:



                                                                                                                    f p=(String.foldl(zx,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)inx=y,y=z,s=t,c=d)x=' ',y=' ',s=0,c=0(p++" ")).c


                                                                                                                    Verify all test cases here.






                                                                                                                    share|improve this answer










                                                                                                                    $endgroup$



                                                                                                                    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's JavaScript answer. Verify all test cases here.



                                                                                                                    Alternative solution without regex, significantly longer at 171 bytes:



                                                                                                                    f p=(String.foldl(zx,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)inx=y,y=z,s=t,c=d)x=' ',y=' ',s=0,c=0(p++" ")).c


                                                                                                                    Verify all test cases here.







                                                                                                                    share|improve this answer













                                                                                                                    share|improve this answer




                                                                                                                    share|improve this answer










                                                                                                                    answered Jul 9 at 12:04









                                                                                                                    O.O.BalanceO.O.Balance

                                                                                                                    1,4681 gold badge4 silver badges18 bronze badges




                                                                                                                    1,4681 gold badge4 silver badges18 bronze badges































                                                                                                                        draft saved

                                                                                                                        draft discarded















































                                                                                                                        If this is an answer to a challenge…



                                                                                                                        • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                        • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                          Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                        • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                        More generally…



                                                                                                                        • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                        • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                        draft saved


                                                                                                                        draft discarded














                                                                                                                        StackExchange.ready(
                                                                                                                        function ()
                                                                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f187682%2fhow-many-jimmys-can-fit%23new-answer', 'question_page');

                                                                                                                        );

                                                                                                                        Post as a guest















                                                                                                                        Required, but never shown





















































                                                                                                                        Required, but never shown














                                                                                                                        Required, but never shown












                                                                                                                        Required, but never shown







                                                                                                                        Required, but never shown

































                                                                                                                        Required, but never shown














                                                                                                                        Required, but never shown












                                                                                                                        Required, but never shown







                                                                                                                        Required, but never shown









                                                                                                                        Popular posts from this blog

                                                                                                                        Tamil (spriik) Luke uk diar | Nawigatjuun

                                                                                                                        Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                                                                                                        Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?