Count rook moves 1DTell me the movesWhat is the Probability that a Knight Stays on Chessboard?Can the king...

What is the maximal acceptable delay between pilot's input and flight control surface actuation?

Are there any writings by blinded and/or exiled Byzantine emperors?

Can an intercepting fighter jet force a small propeller aircraft down without completely destroying it?

Count rook moves 1D

How do I stop making people jump at home and at work?

Why not use futuristic pavise ballistic shields for protection?

What happens if you just start drawing from the Deck of Many Things without declaring any number of cards?

Received email from ISP saying one of my devices has malware

What is the converted mana cost of land cards?

Map a function that takes arguments in different levels of a list

To which country did MiGs in Top Gun belong?

Tiny image scraper for xkcd.com

How to add some symbol (or just add newline) if the numbers in the text are not continuous

Visiting girlfriend in the USA

Initializing a std::array with a constant value

How could reincarnation magic be limited to prevent overuse?

Why are Latin and Sanskrit called dead languages?

My boss says "This will help us better view the utilization of your services." Does this mean my job is ending in this organisation?

Is there anything in the universe that cannot be compressed?

How did Gollum know Sauron was gathering the Haradrim to make war?

Importance of electrolytic capacitor size

What is the significance of 104%?

Lumix G7: Raw photos only in 1920x1440, no higher res available

How to check status of Wi-Fi adapter through command line?



Count rook moves 1D


Tell me the movesWhat is the Probability that a Knight Stays on Chessboard?Can the king catch the pawn?Shifty Eyes Shifting I'sHelp Sam understand chessChess conversionEscape a chessboardWorking on my Knight movesHow many moves?






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







10












$begingroup$


Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over another rook. When a rook moves, the other rooks remain in place.



For example, from this position, 6 moves are possible:



.R..RRR.



  • The first (leftmost) rook can move 1 space left, or 1 or 2 spaces right (3 moves)

  • The next rook can only move 1 or 2 spaces left (2 moves)

  • The third rook cannot move at all because it's squeezed between two other rooks (0 moves)

  • The last rook can only move 1 space right (1 move)


Note that a position might have no rooks at all, or no empty spaces at all.



Input: A non-empty list (string, array, etc..) of rooks and empty spaces. You can represent them as True/False, 1/0, 'R'/'.', or any two consistent distinct single-byte characters or one-digit numbers of your choice. It's up to you which one means rook and which means empty space.



Output: A non-negative integer. Whole-number floats are also fine.



Test cases



The output is the number on the left.



6 .R..RRR.
0 .
0 R
4 R..RR
3 ...R
8 ..R..R..
0 ......


For more test cases, here are all inputs up to length 5.



0 .
0 R
0 ..
1 .R
1 R.
0 RR
0 ...
2 ..R
2 .R.
1 .RR
2 R..
2 R.R
1 RR.
0 RRR
0 ....
3 ...R
3 ..R.
2 ..RR
3 .R..
3 .R.R
2 .RR.
1 .RRR
3 R...
4 R..R
3 R.R.
2 R.RR
2 RR..
2 RR.R
1 RRR.
0 RRRR
0 .....
4 ....R
4 ...R.
3 ...RR
4 ..R..
4 ..R.R
3 ..RR.
2 ..RRR
4 .R...
5 .R..R
4 .R.R.
3 .R.RR
3 .RR..
3 .RR.R
2 .RRR.
1 .RRRR
4 R....
6 R...R
5 R..R.
4 R..RR
4 R.R..
4 R.R.R
3 R.RR.
2 R.RRR
3 RR...
4 RR..R
3 RR.R.
2 RR.RR
2 RRR..
2 RRR.R
1 RRRR.
0 RRRRR









share|improve this question









$endgroup$





















    10












    $begingroup$


    Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over another rook. When a rook moves, the other rooks remain in place.



    For example, from this position, 6 moves are possible:



    .R..RRR.



    • The first (leftmost) rook can move 1 space left, or 1 or 2 spaces right (3 moves)

    • The next rook can only move 1 or 2 spaces left (2 moves)

    • The third rook cannot move at all because it's squeezed between two other rooks (0 moves)

    • The last rook can only move 1 space right (1 move)


    Note that a position might have no rooks at all, or no empty spaces at all.



    Input: A non-empty list (string, array, etc..) of rooks and empty spaces. You can represent them as True/False, 1/0, 'R'/'.', or any two consistent distinct single-byte characters or one-digit numbers of your choice. It's up to you which one means rook and which means empty space.



    Output: A non-negative integer. Whole-number floats are also fine.



    Test cases



    The output is the number on the left.



    6 .R..RRR.
    0 .
    0 R
    4 R..RR
    3 ...R
    8 ..R..R..
    0 ......


    For more test cases, here are all inputs up to length 5.



    0 .
    0 R
    0 ..
    1 .R
    1 R.
    0 RR
    0 ...
    2 ..R
    2 .R.
    1 .RR
    2 R..
    2 R.R
    1 RR.
    0 RRR
    0 ....
    3 ...R
    3 ..R.
    2 ..RR
    3 .R..
    3 .R.R
    2 .RR.
    1 .RRR
    3 R...
    4 R..R
    3 R.R.
    2 R.RR
    2 RR..
    2 RR.R
    1 RRR.
    0 RRRR
    0 .....
    4 ....R
    4 ...R.
    3 ...RR
    4 ..R..
    4 ..R.R
    3 ..RR.
    2 ..RRR
    4 .R...
    5 .R..R
    4 .R.R.
    3 .R.RR
    3 .RR..
    3 .RR.R
    2 .RRR.
    1 .RRRR
    4 R....
    6 R...R
    5 R..R.
    4 R..RR
    4 R.R..
    4 R.R.R
    3 R.RR.
    2 R.RRR
    3 RR...
    4 RR..R
    3 RR.R.
    2 RR.RR
    2 RRR..
    2 RRR.R
    1 RRRR.
    0 RRRRR









    share|improve this question









    $endgroup$

















      10












      10








      10





      $begingroup$


      Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over another rook. When a rook moves, the other rooks remain in place.



      For example, from this position, 6 moves are possible:



      .R..RRR.



      • The first (leftmost) rook can move 1 space left, or 1 or 2 spaces right (3 moves)

      • The next rook can only move 1 or 2 spaces left (2 moves)

      • The third rook cannot move at all because it's squeezed between two other rooks (0 moves)

      • The last rook can only move 1 space right (1 move)


      Note that a position might have no rooks at all, or no empty spaces at all.



      Input: A non-empty list (string, array, etc..) of rooks and empty spaces. You can represent them as True/False, 1/0, 'R'/'.', or any two consistent distinct single-byte characters or one-digit numbers of your choice. It's up to you which one means rook and which means empty space.



      Output: A non-negative integer. Whole-number floats are also fine.



      Test cases



      The output is the number on the left.



      6 .R..RRR.
      0 .
      0 R
      4 R..RR
      3 ...R
      8 ..R..R..
      0 ......


      For more test cases, here are all inputs up to length 5.



      0 .
      0 R
      0 ..
      1 .R
      1 R.
      0 RR
      0 ...
      2 ..R
      2 .R.
      1 .RR
      2 R..
      2 R.R
      1 RR.
      0 RRR
      0 ....
      3 ...R
      3 ..R.
      2 ..RR
      3 .R..
      3 .R.R
      2 .RR.
      1 .RRR
      3 R...
      4 R..R
      3 R.R.
      2 R.RR
      2 RR..
      2 RR.R
      1 RRR.
      0 RRRR
      0 .....
      4 ....R
      4 ...R.
      3 ...RR
      4 ..R..
      4 ..R.R
      3 ..RR.
      2 ..RRR
      4 .R...
      5 .R..R
      4 .R.R.
      3 .R.RR
      3 .RR..
      3 .RR.R
      2 .RRR.
      1 .RRRR
      4 R....
      6 R...R
      5 R..R.
      4 R..RR
      4 R.R..
      4 R.R.R
      3 R.RR.
      2 R.RRR
      3 RR...
      4 RR..R
      3 RR.R.
      2 RR.RR
      2 RRR..
      2 RRR.R
      1 RRRR.
      0 RRRRR









      share|improve this question









      $endgroup$




      Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over another rook. When a rook moves, the other rooks remain in place.



      For example, from this position, 6 moves are possible:



      .R..RRR.



      • The first (leftmost) rook can move 1 space left, or 1 or 2 spaces right (3 moves)

      • The next rook can only move 1 or 2 spaces left (2 moves)

      • The third rook cannot move at all because it's squeezed between two other rooks (0 moves)

      • The last rook can only move 1 space right (1 move)


      Note that a position might have no rooks at all, or no empty spaces at all.



      Input: A non-empty list (string, array, etc..) of rooks and empty spaces. You can represent them as True/False, 1/0, 'R'/'.', or any two consistent distinct single-byte characters or one-digit numbers of your choice. It's up to you which one means rook and which means empty space.



      Output: A non-negative integer. Whole-number floats are also fine.



      Test cases



      The output is the number on the left.



      6 .R..RRR.
      0 .
      0 R
      4 R..RR
      3 ...R
      8 ..R..R..
      0 ......


      For more test cases, here are all inputs up to length 5.



      0 .
      0 R
      0 ..
      1 .R
      1 R.
      0 RR
      0 ...
      2 ..R
      2 .R.
      1 .RR
      2 R..
      2 R.R
      1 RR.
      0 RRR
      0 ....
      3 ...R
      3 ..R.
      2 ..RR
      3 .R..
      3 .R.R
      2 .RR.
      1 .RRR
      3 R...
      4 R..R
      3 R.R.
      2 R.RR
      2 RR..
      2 RR.R
      1 RRR.
      0 RRRR
      0 .....
      4 ....R
      4 ...R.
      3 ...RR
      4 ..R..
      4 ..R.R
      3 ..RR.
      2 ..RRR
      4 .R...
      5 .R..R
      4 .R.R.
      3 .R.RR
      3 .RR..
      3 .RR.R
      2 .RRR.
      1 .RRRR
      4 R....
      6 R...R
      5 R..R.
      4 R..RR
      4 R.R..
      4 R.R.R
      3 R.RR.
      2 R.RRR
      3 RR...
      4 RR..R
      3 RR.R.
      2 RR.RR
      2 RRR..
      2 RRR.R
      1 RRRR.
      0 RRRRR






      code-golf counting chess






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      xnorxnor

      98.7k19 gold badges202 silver badges463 bronze badges




      98.7k19 gold badges202 silver badges463 bronze badges

























          17 Answers
          17






          active

          oldest

          votes


















          2













          $begingroup$

          JavaScript (ES6),  38  33 bytes



          Saved 5 bytes thanks to @JoKing



          Takes input as a string. Expects a space for an empty square and any other character for a rook.





          s=>(s+s).trim().split` `.length-1


          Try it online!



          Commented



          s =>          // s = input, e.g. " R  RRR "
          (s + s) // double -> " R RRR R RRR "
          .trim() // remove leading and trailing spaces -> "R RRR R RRR"
          .split` ` // split on spaces -> [ 'R', '', 'RRR', '', 'R', '', 'RRR' ]
          .length - 1 // return the length - 1 -> 6





          Python 2, 40 bytes





          lambda s:len((s+s).strip().split(' '))-1


          Try it online!






          share|improve this answer











          $endgroup$















          • $begingroup$
            The Python version should use count instead of split (TIO)
            $endgroup$
            – Grimy
            4 hours ago



















          2













          $begingroup$


          Retina, 14 9 bytes



          w`_+R|R_+


          Try it online! Link includes test cases. Uses _ for empty space as it's the most pleasant non-regex character. Works by counting the number of substrings that correspond to a valid Rook move. A substring is a valid Rook move if it contains at least one _ plus a single R at either the beginning or the end.






          share|improve this answer











          $endgroup$















          • $begingroup$
            Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
            $endgroup$
            – mbomb007
            4 hours ago



















          2













          $begingroup$


          Python 3, 30 29 bytes





          lambda s:sum((s+s).strip())/9


          Try it online!



          -1 byte thanks to @JoKing



          The function takes a Python byte string as input. Each empty space is encoded as a tab and each rook is encoded as a byte b'x00' having value 0.



          The computation is equivalent to lambda s:(s+s).strip().count(b't') while having a lower byte count.






          share|improve this answer











          $endgroup$























            1













            $begingroup$


            Jelly, 6 bytes



            t1;ḟẠS


            Try it online!



            A monadic link taking a list of 0 for rook and 1 for space and returning an integer with the number of moves. The TIO link takes the pasted list of possible boards given in the question, converts to the right format and then outputs the calculated and correct answers.



            Explanation



            t1     | Trim 1s from end
            ; | Concatenate to input
            ḟẠ | Filter out 1s if all input were 1s, otherwise filter out 0s
            S | Sum





            share|improve this answer









            $endgroup$























              1













              $begingroup$


              Python 2, 59 bytes





              def f(r):S=map(len,r.split('R'));return sum(S)*2-S[0]-S[-1]


              Try it online!






              share|improve this answer









              $endgroup$























                1













                $begingroup$


                Perl 6, 16 bytes





                {+m:ex/s+R|Rs+/}


                Try it online!



                A regex that matches all exhaustive instances of rooks followed by spaces, or spaces followed by a rook and returns the number of matches.






                share|improve this answer











                $endgroup$























                  1













                  $begingroup$


                  Retina, 23 15 bytes



                  Double the number of spaces between rooks, grep lines with at least one rook, then count the number of spaces.



                  R +R
                  $0$0
                  G`R



                  Try it online!



                  Though the program uses spaces instead of periods, I added prefix code so that the test cases provided may be easily pasted in and used.



                  I was hoping I could use overlapping matches with (?<=R.*) | (?=.*R), but overlaps aren't quite that aggressive. It would need to count all possible ways a match could be obtained in order to return the correct result with that method.






                  share|improve this answer











                  $endgroup$























                    0













                    $begingroup$


                    Jelly, 6 bytes



                    ṣ0§+ƝS


                    Try it online!



                    0 represent a rook, 1 represents an empty space.






                    share|improve this answer











                    $endgroup$











                    • 1




                      $begingroup$
                      If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                      $endgroup$
                      – Jonathan Allan
                      5 hours ago





















                    0













                    $begingroup$


                    Japt, 6 bytes



                    ²x ¸ÊÉ


                    Try it online






                    share|improve this answer









                    $endgroup$























                      0













                      $begingroup$


                      Japt, 6 bytes



                      Spaces for spaces, any other character for rooks.



                      ²x ¸ÊÉ


                      Try it






                      share|improve this answer









                      $endgroup$















                      • $begingroup$
                        Beat ya by 10 minutes :P
                        $endgroup$
                        – Oliver
                        5 hours ago



















                      0













                      $begingroup$


                      Stax, 7 bytes



                      âE¶ƒÅ╒±


                      Run and debug it






                      share|improve this answer









                      $endgroup$























                        0













                        $begingroup$


                        Wolfram Language (Mathematica), 43 38 bytes



                        Count[Subsequences@#,{0,1..}|{1..,0}]&


                        Try it online!



                        Port of Neil's Retina solution. Uses 1 for spaces and 0 for rooks.






                        share|improve this answer











                        $endgroup$























                          0













                          $begingroup$


                          05AB1E, 5 bytes



                          «ðÚð¢


                          Try it online!



                          «       # concatenate the input with itself
                          ðÚ # remove leading and trailing spaces
                          ð¢ # count spaces





                          share|improve this answer









                          $endgroup$























                            0













                            $begingroup$


                            C# (Visual C# Interactive Compiler), 28 bytes





                            x=>(x+x).Trim().Sum(d=>d)/32


                            Try it online!






                            share|improve this answer











                            $endgroup$























                              0













                              $begingroup$


                              Japt, 5 bytes



                              ²x èS


                              Try it



                              ²x èS        Implicit input string of U
                              ² U + U
                              x Remove trailing and leading whitespace
                              èS Number of spaces





                              share|improve this answer









                              $endgroup$























                                0













                                $begingroup$


                                Haskell, 68 58 54 bytes





                                (n#y)(a:x)|a<1=n+(0#1)x|m<-n+1=y+(m#y)x
                                (_#_)x=0
                                f=0#0


                                Try it online!






                                share|improve this answer











                                $endgroup$























                                  0













                                  $begingroup$


                                  C, 181 bytes



                                  #include<stdio.h>
                                  #include<string.h>
                                  main(a,c,d,e){c=a=d=0;char*b=calloc(99,1);gets(b);do{if(b[a]=='R'){c+=e*(1+d);e=0;d=1;}if(b[a]=='.')e++;a++;}while(b[a]);c+=e;printf("%i",c);}





                                  share|improve this answer








                                  New contributor



                                  user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.





                                  $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/3.0/"u003ecc by-sa 3.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%2f191180%2fcount-rook-moves-1d%23new-answer', 'question_page');
                                    }
                                    );

                                    Post as a guest















                                    Required, but never shown

























                                    17 Answers
                                    17






                                    active

                                    oldest

                                    votes








                                    17 Answers
                                    17






                                    active

                                    oldest

                                    votes









                                    active

                                    oldest

                                    votes






                                    active

                                    oldest

                                    votes









                                    2













                                    $begingroup$

                                    JavaScript (ES6),  38  33 bytes



                                    Saved 5 bytes thanks to @JoKing



                                    Takes input as a string. Expects a space for an empty square and any other character for a rook.





                                    s=>(s+s).trim().split` `.length-1


                                    Try it online!



                                    Commented



                                    s =>          // s = input, e.g. " R  RRR "
                                    (s + s) // double -> " R RRR R RRR "
                                    .trim() // remove leading and trailing spaces -> "R RRR R RRR"
                                    .split` ` // split on spaces -> [ 'R', '', 'RRR', '', 'R', '', 'RRR' ]
                                    .length - 1 // return the length - 1 -> 6





                                    Python 2, 40 bytes





                                    lambda s:len((s+s).strip().split(' '))-1


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$















                                    • $begingroup$
                                      The Python version should use count instead of split (TIO)
                                      $endgroup$
                                      – Grimy
                                      4 hours ago
















                                    2













                                    $begingroup$

                                    JavaScript (ES6),  38  33 bytes



                                    Saved 5 bytes thanks to @JoKing



                                    Takes input as a string. Expects a space for an empty square and any other character for a rook.





                                    s=>(s+s).trim().split` `.length-1


                                    Try it online!



                                    Commented



                                    s =>          // s = input, e.g. " R  RRR "
                                    (s + s) // double -> " R RRR R RRR "
                                    .trim() // remove leading and trailing spaces -> "R RRR R RRR"
                                    .split` ` // split on spaces -> [ 'R', '', 'RRR', '', 'R', '', 'RRR' ]
                                    .length - 1 // return the length - 1 -> 6





                                    Python 2, 40 bytes





                                    lambda s:len((s+s).strip().split(' '))-1


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$















                                    • $begingroup$
                                      The Python version should use count instead of split (TIO)
                                      $endgroup$
                                      – Grimy
                                      4 hours ago














                                    2














                                    2










                                    2







                                    $begingroup$

                                    JavaScript (ES6),  38  33 bytes



                                    Saved 5 bytes thanks to @JoKing



                                    Takes input as a string. Expects a space for an empty square and any other character for a rook.





                                    s=>(s+s).trim().split` `.length-1


                                    Try it online!



                                    Commented



                                    s =>          // s = input, e.g. " R  RRR "
                                    (s + s) // double -> " R RRR R RRR "
                                    .trim() // remove leading and trailing spaces -> "R RRR R RRR"
                                    .split` ` // split on spaces -> [ 'R', '', 'RRR', '', 'R', '', 'RRR' ]
                                    .length - 1 // return the length - 1 -> 6





                                    Python 2, 40 bytes





                                    lambda s:len((s+s).strip().split(' '))-1


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$



                                    JavaScript (ES6),  38  33 bytes



                                    Saved 5 bytes thanks to @JoKing



                                    Takes input as a string. Expects a space for an empty square and any other character for a rook.





                                    s=>(s+s).trim().split` `.length-1


                                    Try it online!



                                    Commented



                                    s =>          // s = input, e.g. " R  RRR "
                                    (s + s) // double -> " R RRR R RRR "
                                    .trim() // remove leading and trailing spaces -> "R RRR R RRR"
                                    .split` ` // split on spaces -> [ 'R', '', 'RRR', '', 'R', '', 'RRR' ]
                                    .length - 1 // return the length - 1 -> 6





                                    Python 2, 40 bytes





                                    lambda s:len((s+s).strip().split(' '))-1


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 5 hours ago

























                                    answered 7 hours ago









                                    ArnauldArnauld

                                    91.6k7 gold badges107 silver badges373 bronze badges




                                    91.6k7 gold badges107 silver badges373 bronze badges















                                    • $begingroup$
                                      The Python version should use count instead of split (TIO)
                                      $endgroup$
                                      – Grimy
                                      4 hours ago


















                                    • $begingroup$
                                      The Python version should use count instead of split (TIO)
                                      $endgroup$
                                      – Grimy
                                      4 hours ago
















                                    $begingroup$
                                    The Python version should use count instead of split (TIO)
                                    $endgroup$
                                    – Grimy
                                    4 hours ago




                                    $begingroup$
                                    The Python version should use count instead of split (TIO)
                                    $endgroup$
                                    – Grimy
                                    4 hours ago













                                    2













                                    $begingroup$


                                    Retina, 14 9 bytes



                                    w`_+R|R_+


                                    Try it online! Link includes test cases. Uses _ for empty space as it's the most pleasant non-regex character. Works by counting the number of substrings that correspond to a valid Rook move. A substring is a valid Rook move if it contains at least one _ plus a single R at either the beginning or the end.






                                    share|improve this answer











                                    $endgroup$















                                    • $begingroup$
                                      Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                      $endgroup$
                                      – mbomb007
                                      4 hours ago
















                                    2













                                    $begingroup$


                                    Retina, 14 9 bytes



                                    w`_+R|R_+


                                    Try it online! Link includes test cases. Uses _ for empty space as it's the most pleasant non-regex character. Works by counting the number of substrings that correspond to a valid Rook move. A substring is a valid Rook move if it contains at least one _ plus a single R at either the beginning or the end.






                                    share|improve this answer











                                    $endgroup$















                                    • $begingroup$
                                      Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                      $endgroup$
                                      – mbomb007
                                      4 hours ago














                                    2














                                    2










                                    2







                                    $begingroup$


                                    Retina, 14 9 bytes



                                    w`_+R|R_+


                                    Try it online! Link includes test cases. Uses _ for empty space as it's the most pleasant non-regex character. Works by counting the number of substrings that correspond to a valid Rook move. A substring is a valid Rook move if it contains at least one _ plus a single R at either the beginning or the end.






                                    share|improve this answer











                                    $endgroup$




                                    Retina, 14 9 bytes



                                    w`_+R|R_+


                                    Try it online! Link includes test cases. Uses _ for empty space as it's the most pleasant non-regex character. Works by counting the number of substrings that correspond to a valid Rook move. A substring is a valid Rook move if it contains at least one _ plus a single R at either the beginning or the end.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 5 hours ago

























                                    answered 5 hours ago









                                    NeilNeil

                                    88.2k8 gold badges46 silver badges186 bronze badges




                                    88.2k8 gold badges46 silver badges186 bronze badges















                                    • $begingroup$
                                      Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                      $endgroup$
                                      – mbomb007
                                      4 hours ago


















                                    • $begingroup$
                                      Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                      $endgroup$
                                      – mbomb007
                                      4 hours ago
















                                    $begingroup$
                                    Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                    $endgroup$
                                    – mbomb007
                                    4 hours ago




                                    $begingroup$
                                    Oh, you basically figured out how to do what I mentioned in my answer. Idk why I didn't think of that.
                                    $endgroup$
                                    – mbomb007
                                    4 hours ago











                                    2













                                    $begingroup$


                                    Python 3, 30 29 bytes





                                    lambda s:sum((s+s).strip())/9


                                    Try it online!



                                    -1 byte thanks to @JoKing



                                    The function takes a Python byte string as input. Each empty space is encoded as a tab and each rook is encoded as a byte b'x00' having value 0.



                                    The computation is equivalent to lambda s:(s+s).strip().count(b't') while having a lower byte count.






                                    share|improve this answer











                                    $endgroup$




















                                      2













                                      $begingroup$


                                      Python 3, 30 29 bytes





                                      lambda s:sum((s+s).strip())/9


                                      Try it online!



                                      -1 byte thanks to @JoKing



                                      The function takes a Python byte string as input. Each empty space is encoded as a tab and each rook is encoded as a byte b'x00' having value 0.



                                      The computation is equivalent to lambda s:(s+s).strip().count(b't') while having a lower byte count.






                                      share|improve this answer











                                      $endgroup$


















                                        2














                                        2










                                        2







                                        $begingroup$


                                        Python 3, 30 29 bytes





                                        lambda s:sum((s+s).strip())/9


                                        Try it online!



                                        -1 byte thanks to @JoKing



                                        The function takes a Python byte string as input. Each empty space is encoded as a tab and each rook is encoded as a byte b'x00' having value 0.



                                        The computation is equivalent to lambda s:(s+s).strip().count(b't') while having a lower byte count.






                                        share|improve this answer











                                        $endgroup$




                                        Python 3, 30 29 bytes





                                        lambda s:sum((s+s).strip())/9


                                        Try it online!



                                        -1 byte thanks to @JoKing



                                        The function takes a Python byte string as input. Each empty space is encoded as a tab and each rook is encoded as a byte b'x00' having value 0.



                                        The computation is equivalent to lambda s:(s+s).strip().count(b't') while having a lower byte count.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 3 hours ago

























                                        answered 4 hours ago









                                        JoelJoel

                                        8618 bronze badges




                                        8618 bronze badges


























                                            1













                                            $begingroup$


                                            Jelly, 6 bytes



                                            t1;ḟẠS


                                            Try it online!



                                            A monadic link taking a list of 0 for rook and 1 for space and returning an integer with the number of moves. The TIO link takes the pasted list of possible boards given in the question, converts to the right format and then outputs the calculated and correct answers.



                                            Explanation



                                            t1     | Trim 1s from end
                                            ; | Concatenate to input
                                            ḟẠ | Filter out 1s if all input were 1s, otherwise filter out 0s
                                            S | Sum





                                            share|improve this answer









                                            $endgroup$




















                                              1













                                              $begingroup$


                                              Jelly, 6 bytes



                                              t1;ḟẠS


                                              Try it online!



                                              A monadic link taking a list of 0 for rook and 1 for space and returning an integer with the number of moves. The TIO link takes the pasted list of possible boards given in the question, converts to the right format and then outputs the calculated and correct answers.



                                              Explanation



                                              t1     | Trim 1s from end
                                              ; | Concatenate to input
                                              ḟẠ | Filter out 1s if all input were 1s, otherwise filter out 0s
                                              S | Sum





                                              share|improve this answer









                                              $endgroup$


















                                                1














                                                1










                                                1







                                                $begingroup$


                                                Jelly, 6 bytes



                                                t1;ḟẠS


                                                Try it online!



                                                A monadic link taking a list of 0 for rook and 1 for space and returning an integer with the number of moves. The TIO link takes the pasted list of possible boards given in the question, converts to the right format and then outputs the calculated and correct answers.



                                                Explanation



                                                t1     | Trim 1s from end
                                                ; | Concatenate to input
                                                ḟẠ | Filter out 1s if all input were 1s, otherwise filter out 0s
                                                S | Sum





                                                share|improve this answer









                                                $endgroup$




                                                Jelly, 6 bytes



                                                t1;ḟẠS


                                                Try it online!



                                                A monadic link taking a list of 0 for rook and 1 for space and returning an integer with the number of moves. The TIO link takes the pasted list of possible boards given in the question, converts to the right format and then outputs the calculated and correct answers.



                                                Explanation



                                                t1     | Trim 1s from end
                                                ; | Concatenate to input
                                                ḟẠ | Filter out 1s if all input were 1s, otherwise filter out 0s
                                                S | Sum






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 6 hours ago









                                                Nick KennedyNick Kennedy

                                                6,3971 gold badge9 silver badges15 bronze badges




                                                6,3971 gold badge9 silver badges15 bronze badges


























                                                    1













                                                    $begingroup$


                                                    Python 2, 59 bytes





                                                    def f(r):S=map(len,r.split('R'));return sum(S)*2-S[0]-S[-1]


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$




















                                                      1













                                                      $begingroup$


                                                      Python 2, 59 bytes





                                                      def f(r):S=map(len,r.split('R'));return sum(S)*2-S[0]-S[-1]


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$


















                                                        1














                                                        1










                                                        1







                                                        $begingroup$


                                                        Python 2, 59 bytes





                                                        def f(r):S=map(len,r.split('R'));return sum(S)*2-S[0]-S[-1]


                                                        Try it online!






                                                        share|improve this answer









                                                        $endgroup$




                                                        Python 2, 59 bytes





                                                        def f(r):S=map(len,r.split('R'));return sum(S)*2-S[0]-S[-1]


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 6 hours ago









                                                        Chas BrownChas Brown

                                                        6,5491 gold badge6 silver badges27 bronze badges




                                                        6,5491 gold badge6 silver badges27 bronze badges


























                                                            1













                                                            $begingroup$


                                                            Perl 6, 16 bytes





                                                            {+m:ex/s+R|Rs+/}


                                                            Try it online!



                                                            A regex that matches all exhaustive instances of rooks followed by spaces, or spaces followed by a rook and returns the number of matches.






                                                            share|improve this answer











                                                            $endgroup$




















                                                              1













                                                              $begingroup$


                                                              Perl 6, 16 bytes





                                                              {+m:ex/s+R|Rs+/}


                                                              Try it online!



                                                              A regex that matches all exhaustive instances of rooks followed by spaces, or spaces followed by a rook and returns the number of matches.






                                                              share|improve this answer











                                                              $endgroup$


















                                                                1














                                                                1










                                                                1







                                                                $begingroup$


                                                                Perl 6, 16 bytes





                                                                {+m:ex/s+R|Rs+/}


                                                                Try it online!



                                                                A regex that matches all exhaustive instances of rooks followed by spaces, or spaces followed by a rook and returns the number of matches.






                                                                share|improve this answer











                                                                $endgroup$




                                                                Perl 6, 16 bytes





                                                                {+m:ex/s+R|Rs+/}


                                                                Try it online!



                                                                A regex that matches all exhaustive instances of rooks followed by spaces, or spaces followed by a rook and returns the number of matches.







                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited 5 hours ago

























                                                                answered 5 hours ago









                                                                Jo KingJo King

                                                                31k4 gold badges72 silver badges139 bronze badges




                                                                31k4 gold badges72 silver badges139 bronze badges


























                                                                    1













                                                                    $begingroup$


                                                                    Retina, 23 15 bytes



                                                                    Double the number of spaces between rooks, grep lines with at least one rook, then count the number of spaces.



                                                                    R +R
                                                                    $0$0
                                                                    G`R



                                                                    Try it online!



                                                                    Though the program uses spaces instead of periods, I added prefix code so that the test cases provided may be easily pasted in and used.



                                                                    I was hoping I could use overlapping matches with (?<=R.*) | (?=.*R), but overlaps aren't quite that aggressive. It would need to count all possible ways a match could be obtained in order to return the correct result with that method.






                                                                    share|improve this answer











                                                                    $endgroup$




















                                                                      1













                                                                      $begingroup$


                                                                      Retina, 23 15 bytes



                                                                      Double the number of spaces between rooks, grep lines with at least one rook, then count the number of spaces.



                                                                      R +R
                                                                      $0$0
                                                                      G`R



                                                                      Try it online!



                                                                      Though the program uses spaces instead of periods, I added prefix code so that the test cases provided may be easily pasted in and used.



                                                                      I was hoping I could use overlapping matches with (?<=R.*) | (?=.*R), but overlaps aren't quite that aggressive. It would need to count all possible ways a match could be obtained in order to return the correct result with that method.






                                                                      share|improve this answer











                                                                      $endgroup$


















                                                                        1














                                                                        1










                                                                        1







                                                                        $begingroup$


                                                                        Retina, 23 15 bytes



                                                                        Double the number of spaces between rooks, grep lines with at least one rook, then count the number of spaces.



                                                                        R +R
                                                                        $0$0
                                                                        G`R



                                                                        Try it online!



                                                                        Though the program uses spaces instead of periods, I added prefix code so that the test cases provided may be easily pasted in and used.



                                                                        I was hoping I could use overlapping matches with (?<=R.*) | (?=.*R), but overlaps aren't quite that aggressive. It would need to count all possible ways a match could be obtained in order to return the correct result with that method.






                                                                        share|improve this answer











                                                                        $endgroup$




                                                                        Retina, 23 15 bytes



                                                                        Double the number of spaces between rooks, grep lines with at least one rook, then count the number of spaces.



                                                                        R +R
                                                                        $0$0
                                                                        G`R



                                                                        Try it online!



                                                                        Though the program uses spaces instead of periods, I added prefix code so that the test cases provided may be easily pasted in and used.



                                                                        I was hoping I could use overlapping matches with (?<=R.*) | (?=.*R), but overlaps aren't quite that aggressive. It would need to count all possible ways a match could be obtained in order to return the correct result with that method.







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited 4 hours ago

























                                                                        answered 6 hours ago









                                                                        mbomb007mbomb007

                                                                        18.6k5 gold badges47 silver badges120 bronze badges




                                                                        18.6k5 gold badges47 silver badges120 bronze badges


























                                                                            0













                                                                            $begingroup$


                                                                            Jelly, 6 bytes



                                                                            ṣ0§+ƝS


                                                                            Try it online!



                                                                            0 represent a rook, 1 represents an empty space.






                                                                            share|improve this answer











                                                                            $endgroup$











                                                                            • 1




                                                                              $begingroup$
                                                                              If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                              $endgroup$
                                                                              – Jonathan Allan
                                                                              5 hours ago


















                                                                            0













                                                                            $begingroup$


                                                                            Jelly, 6 bytes



                                                                            ṣ0§+ƝS


                                                                            Try it online!



                                                                            0 represent a rook, 1 represents an empty space.






                                                                            share|improve this answer











                                                                            $endgroup$











                                                                            • 1




                                                                              $begingroup$
                                                                              If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                              $endgroup$
                                                                              – Jonathan Allan
                                                                              5 hours ago
















                                                                            0














                                                                            0










                                                                            0







                                                                            $begingroup$


                                                                            Jelly, 6 bytes



                                                                            ṣ0§+ƝS


                                                                            Try it online!



                                                                            0 represent a rook, 1 represents an empty space.






                                                                            share|improve this answer











                                                                            $endgroup$




                                                                            Jelly, 6 bytes



                                                                            ṣ0§+ƝS


                                                                            Try it online!



                                                                            0 represent a rook, 1 represents an empty space.







                                                                            share|improve this answer














                                                                            share|improve this answer



                                                                            share|improve this answer








                                                                            edited 7 hours ago

























                                                                            answered 7 hours ago









                                                                            Erik the OutgolferErik the Outgolfer

                                                                            36k4 gold badges30 silver badges113 bronze badges




                                                                            36k4 gold badges30 silver badges113 bronze badges











                                                                            • 1




                                                                              $begingroup$
                                                                              If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                              $endgroup$
                                                                              – Jonathan Allan
                                                                              5 hours ago
















                                                                            • 1




                                                                              $begingroup$
                                                                              If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                              $endgroup$
                                                                              – Jonathan Allan
                                                                              5 hours ago










                                                                            1




                                                                            1




                                                                            $begingroup$
                                                                            If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                            $endgroup$
                                                                            – Jonathan Allan
                                                                            5 hours ago






                                                                            $begingroup$
                                                                            If you use a space character for a Rook and another character for a space you can use to get the five: ḲẈ+ƝS
                                                                            $endgroup$
                                                                            – Jonathan Allan
                                                                            5 hours ago













                                                                            0













                                                                            $begingroup$


                                                                            Japt, 6 bytes



                                                                            ²x ¸ÊÉ


                                                                            Try it online






                                                                            share|improve this answer









                                                                            $endgroup$




















                                                                              0













                                                                              $begingroup$


                                                                              Japt, 6 bytes



                                                                              ²x ¸ÊÉ


                                                                              Try it online






                                                                              share|improve this answer









                                                                              $endgroup$


















                                                                                0














                                                                                0










                                                                                0







                                                                                $begingroup$


                                                                                Japt, 6 bytes



                                                                                ²x ¸ÊÉ


                                                                                Try it online






                                                                                share|improve this answer









                                                                                $endgroup$




                                                                                Japt, 6 bytes



                                                                                ²x ¸ÊÉ


                                                                                Try it online







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered 5 hours ago









                                                                                OliverOliver

                                                                                6,6002 gold badges9 silver badges36 bronze badges




                                                                                6,6002 gold badges9 silver badges36 bronze badges


























                                                                                    0













                                                                                    $begingroup$


                                                                                    Japt, 6 bytes



                                                                                    Spaces for spaces, any other character for rooks.



                                                                                    ²x ¸ÊÉ


                                                                                    Try it






                                                                                    share|improve this answer









                                                                                    $endgroup$















                                                                                    • $begingroup$
                                                                                      Beat ya by 10 minutes :P
                                                                                      $endgroup$
                                                                                      – Oliver
                                                                                      5 hours ago
















                                                                                    0













                                                                                    $begingroup$


                                                                                    Japt, 6 bytes



                                                                                    Spaces for spaces, any other character for rooks.



                                                                                    ²x ¸ÊÉ


                                                                                    Try it






                                                                                    share|improve this answer









                                                                                    $endgroup$















                                                                                    • $begingroup$
                                                                                      Beat ya by 10 minutes :P
                                                                                      $endgroup$
                                                                                      – Oliver
                                                                                      5 hours ago














                                                                                    0














                                                                                    0










                                                                                    0







                                                                                    $begingroup$


                                                                                    Japt, 6 bytes



                                                                                    Spaces for spaces, any other character for rooks.



                                                                                    ²x ¸ÊÉ


                                                                                    Try it






                                                                                    share|improve this answer









                                                                                    $endgroup$




                                                                                    Japt, 6 bytes



                                                                                    Spaces for spaces, any other character for rooks.



                                                                                    ²x ¸ÊÉ


                                                                                    Try it







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered 5 hours ago









                                                                                    ShaggyShaggy

                                                                                    21.3k3 gold badges21 silver badges72 bronze badges




                                                                                    21.3k3 gold badges21 silver badges72 bronze badges















                                                                                    • $begingroup$
                                                                                      Beat ya by 10 minutes :P
                                                                                      $endgroup$
                                                                                      – Oliver
                                                                                      5 hours ago


















                                                                                    • $begingroup$
                                                                                      Beat ya by 10 minutes :P
                                                                                      $endgroup$
                                                                                      – Oliver
                                                                                      5 hours ago
















                                                                                    $begingroup$
                                                                                    Beat ya by 10 minutes :P
                                                                                    $endgroup$
                                                                                    – Oliver
                                                                                    5 hours ago




                                                                                    $begingroup$
                                                                                    Beat ya by 10 minutes :P
                                                                                    $endgroup$
                                                                                    – Oliver
                                                                                    5 hours ago











                                                                                    0













                                                                                    $begingroup$


                                                                                    Stax, 7 bytes



                                                                                    âE¶ƒÅ╒±


                                                                                    Run and debug it






                                                                                    share|improve this answer









                                                                                    $endgroup$




















                                                                                      0













                                                                                      $begingroup$


                                                                                      Stax, 7 bytes



                                                                                      âE¶ƒÅ╒±


                                                                                      Run and debug it






                                                                                      share|improve this answer









                                                                                      $endgroup$


















                                                                                        0














                                                                                        0










                                                                                        0







                                                                                        $begingroup$


                                                                                        Stax, 7 bytes



                                                                                        âE¶ƒÅ╒±


                                                                                        Run and debug it






                                                                                        share|improve this answer









                                                                                        $endgroup$




                                                                                        Stax, 7 bytes



                                                                                        âE¶ƒÅ╒±


                                                                                        Run and debug it







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered 5 hours ago









                                                                                        OliverOliver

                                                                                        6,6002 gold badges9 silver badges36 bronze badges




                                                                                        6,6002 gold badges9 silver badges36 bronze badges


























                                                                                            0













                                                                                            $begingroup$


                                                                                            Wolfram Language (Mathematica), 43 38 bytes



                                                                                            Count[Subsequences@#,{0,1..}|{1..,0}]&


                                                                                            Try it online!



                                                                                            Port of Neil's Retina solution. Uses 1 for spaces and 0 for rooks.






                                                                                            share|improve this answer











                                                                                            $endgroup$




















                                                                                              0













                                                                                              $begingroup$


                                                                                              Wolfram Language (Mathematica), 43 38 bytes



                                                                                              Count[Subsequences@#,{0,1..}|{1..,0}]&


                                                                                              Try it online!



                                                                                              Port of Neil's Retina solution. Uses 1 for spaces and 0 for rooks.






                                                                                              share|improve this answer











                                                                                              $endgroup$


















                                                                                                0














                                                                                                0










                                                                                                0







                                                                                                $begingroup$


                                                                                                Wolfram Language (Mathematica), 43 38 bytes



                                                                                                Count[Subsequences@#,{0,1..}|{1..,0}]&


                                                                                                Try it online!



                                                                                                Port of Neil's Retina solution. Uses 1 for spaces and 0 for rooks.






                                                                                                share|improve this answer











                                                                                                $endgroup$




                                                                                                Wolfram Language (Mathematica), 43 38 bytes



                                                                                                Count[Subsequences@#,{0,1..}|{1..,0}]&


                                                                                                Try it online!



                                                                                                Port of Neil's Retina solution. Uses 1 for spaces and 0 for rooks.







                                                                                                share|improve this answer














                                                                                                share|improve this answer



                                                                                                share|improve this answer








                                                                                                edited 5 hours ago

























                                                                                                answered 7 hours ago









                                                                                                attinatattinat

                                                                                                2,2272 silver badges10 bronze badges




                                                                                                2,2272 silver badges10 bronze badges


























                                                                                                    0













                                                                                                    $begingroup$


                                                                                                    05AB1E, 5 bytes



                                                                                                    «ðÚð¢


                                                                                                    Try it online!



                                                                                                    «       # concatenate the input with itself
                                                                                                    ðÚ # remove leading and trailing spaces
                                                                                                    ð¢ # count spaces





                                                                                                    share|improve this answer









                                                                                                    $endgroup$




















                                                                                                      0













                                                                                                      $begingroup$


                                                                                                      05AB1E, 5 bytes



                                                                                                      «ðÚð¢


                                                                                                      Try it online!



                                                                                                      «       # concatenate the input with itself
                                                                                                      ðÚ # remove leading and trailing spaces
                                                                                                      ð¢ # count spaces





                                                                                                      share|improve this answer









                                                                                                      $endgroup$


















                                                                                                        0














                                                                                                        0










                                                                                                        0







                                                                                                        $begingroup$


                                                                                                        05AB1E, 5 bytes



                                                                                                        «ðÚð¢


                                                                                                        Try it online!



                                                                                                        «       # concatenate the input with itself
                                                                                                        ðÚ # remove leading and trailing spaces
                                                                                                        ð¢ # count spaces





                                                                                                        share|improve this answer









                                                                                                        $endgroup$




                                                                                                        05AB1E, 5 bytes



                                                                                                        «ðÚð¢


                                                                                                        Try it online!



                                                                                                        «       # concatenate the input with itself
                                                                                                        ðÚ # remove leading and trailing spaces
                                                                                                        ð¢ # count spaces






                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered 4 hours ago









                                                                                                        GrimyGrimy

                                                                                                        6,02915 silver badges31 bronze badges




                                                                                                        6,02915 silver badges31 bronze badges


























                                                                                                            0













                                                                                                            $begingroup$


                                                                                                            C# (Visual C# Interactive Compiler), 28 bytes





                                                                                                            x=>(x+x).Trim().Sum(d=>d)/32


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$




















                                                                                                              0













                                                                                                              $begingroup$


                                                                                                              C# (Visual C# Interactive Compiler), 28 bytes





                                                                                                              x=>(x+x).Trim().Sum(d=>d)/32


                                                                                                              Try it online!






                                                                                                              share|improve this answer











                                                                                                              $endgroup$


















                                                                                                                0














                                                                                                                0










                                                                                                                0







                                                                                                                $begingroup$


                                                                                                                C# (Visual C# Interactive Compiler), 28 bytes





                                                                                                                x=>(x+x).Trim().Sum(d=>d)/32


                                                                                                                Try it online!






                                                                                                                share|improve this answer











                                                                                                                $endgroup$




                                                                                                                C# (Visual C# Interactive Compiler), 28 bytes





                                                                                                                x=>(x+x).Trim().Sum(d=>d)/32


                                                                                                                Try it online!







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 4 hours ago

























                                                                                                                answered 4 hours ago









                                                                                                                Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                                5,1561 silver badge30 bronze badges




                                                                                                                5,1561 silver badge30 bronze badges


























                                                                                                                    0













                                                                                                                    $begingroup$


                                                                                                                    Japt, 5 bytes



                                                                                                                    ²x èS


                                                                                                                    Try it



                                                                                                                    ²x èS        Implicit input string of U
                                                                                                                    ² U + U
                                                                                                                    x Remove trailing and leading whitespace
                                                                                                                    èS Number of spaces





                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$




















                                                                                                                      0













                                                                                                                      $begingroup$


                                                                                                                      Japt, 5 bytes



                                                                                                                      ²x èS


                                                                                                                      Try it



                                                                                                                      ²x èS        Implicit input string of U
                                                                                                                      ² U + U
                                                                                                                      x Remove trailing and leading whitespace
                                                                                                                      èS Number of spaces





                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$


















                                                                                                                        0














                                                                                                                        0










                                                                                                                        0







                                                                                                                        $begingroup$


                                                                                                                        Japt, 5 bytes



                                                                                                                        ²x èS


                                                                                                                        Try it



                                                                                                                        ²x èS        Implicit input string of U
                                                                                                                        ² U + U
                                                                                                                        x Remove trailing and leading whitespace
                                                                                                                        èS Number of spaces





                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$




                                                                                                                        Japt, 5 bytes



                                                                                                                        ²x èS


                                                                                                                        Try it



                                                                                                                        ²x èS        Implicit input string of U
                                                                                                                        ² U + U
                                                                                                                        x Remove trailing and leading whitespace
                                                                                                                        èS Number of spaces






                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 4 hours ago









                                                                                                                        Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                                        5,1561 silver badge30 bronze badges




                                                                                                                        5,1561 silver badge30 bronze badges


























                                                                                                                            0













                                                                                                                            $begingroup$


                                                                                                                            Haskell, 68 58 54 bytes





                                                                                                                            (n#y)(a:x)|a<1=n+(0#1)x|m<-n+1=y+(m#y)x
                                                                                                                            (_#_)x=0
                                                                                                                            f=0#0


                                                                                                                            Try it online!






                                                                                                                            share|improve this answer











                                                                                                                            $endgroup$




















                                                                                                                              0













                                                                                                                              $begingroup$


                                                                                                                              Haskell, 68 58 54 bytes





                                                                                                                              (n#y)(a:x)|a<1=n+(0#1)x|m<-n+1=y+(m#y)x
                                                                                                                              (_#_)x=0
                                                                                                                              f=0#0


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$


















                                                                                                                                0














                                                                                                                                0










                                                                                                                                0







                                                                                                                                $begingroup$


                                                                                                                                Haskell, 68 58 54 bytes





                                                                                                                                (n#y)(a:x)|a<1=n+(0#1)x|m<-n+1=y+(m#y)x
                                                                                                                                (_#_)x=0
                                                                                                                                f=0#0


                                                                                                                                Try it online!






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$




                                                                                                                                Haskell, 68 58 54 bytes





                                                                                                                                (n#y)(a:x)|a<1=n+(0#1)x|m<-n+1=y+(m#y)x
                                                                                                                                (_#_)x=0
                                                                                                                                f=0#0


                                                                                                                                Try it online!







                                                                                                                                share|improve this answer














                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer








                                                                                                                                edited 3 hours ago

























                                                                                                                                answered 3 hours ago









                                                                                                                                Sriotchilism O'ZaicSriotchilism O'Zaic

                                                                                                                                37.5k10 gold badges168 silver badges382 bronze badges




                                                                                                                                37.5k10 gold badges168 silver badges382 bronze badges


























                                                                                                                                    0













                                                                                                                                    $begingroup$


                                                                                                                                    C, 181 bytes



                                                                                                                                    #include<stdio.h>
                                                                                                                                    #include<string.h>
                                                                                                                                    main(a,c,d,e){c=a=d=0;char*b=calloc(99,1);gets(b);do{if(b[a]=='R'){c+=e*(1+d);e=0;d=1;}if(b[a]=='.')e++;a++;}while(b[a]);c+=e;printf("%i",c);}





                                                                                                                                    share|improve this answer








                                                                                                                                    New contributor



                                                                                                                                    user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                    Check out our Code of Conduct.





                                                                                                                                    $endgroup$




















                                                                                                                                      0













                                                                                                                                      $begingroup$


                                                                                                                                      C, 181 bytes



                                                                                                                                      #include<stdio.h>
                                                                                                                                      #include<string.h>
                                                                                                                                      main(a,c,d,e){c=a=d=0;char*b=calloc(99,1);gets(b);do{if(b[a]=='R'){c+=e*(1+d);e=0;d=1;}if(b[a]=='.')e++;a++;}while(b[a]);c+=e;printf("%i",c);}





                                                                                                                                      share|improve this answer








                                                                                                                                      New contributor



                                                                                                                                      user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                      Check out our Code of Conduct.





                                                                                                                                      $endgroup$


















                                                                                                                                        0














                                                                                                                                        0










                                                                                                                                        0







                                                                                                                                        $begingroup$


                                                                                                                                        C, 181 bytes



                                                                                                                                        #include<stdio.h>
                                                                                                                                        #include<string.h>
                                                                                                                                        main(a,c,d,e){c=a=d=0;char*b=calloc(99,1);gets(b);do{if(b[a]=='R'){c+=e*(1+d);e=0;d=1;}if(b[a]=='.')e++;a++;}while(b[a]);c+=e;printf("%i",c);}





                                                                                                                                        share|improve this answer








                                                                                                                                        New contributor



                                                                                                                                        user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                        Check out our Code of Conduct.





                                                                                                                                        $endgroup$




                                                                                                                                        C, 181 bytes



                                                                                                                                        #include<stdio.h>
                                                                                                                                        #include<string.h>
                                                                                                                                        main(a,c,d,e){c=a=d=0;char*b=calloc(99,1);gets(b);do{if(b[a]=='R'){c+=e*(1+d);e=0;d=1;}if(b[a]=='.')e++;a++;}while(b[a]);c+=e;printf("%i",c);}






                                                                                                                                        share|improve this answer








                                                                                                                                        New contributor



                                                                                                                                        user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                        Check out our Code of Conduct.








                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer






                                                                                                                                        New contributor



                                                                                                                                        user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                        Check out our Code of Conduct.








                                                                                                                                        answered 14 mins ago









                                                                                                                                        user1475369user1475369

                                                                                                                                        1




                                                                                                                                        1




                                                                                                                                        New contributor



                                                                                                                                        user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                        Check out our Code of Conduct.




                                                                                                                                        New contributor




                                                                                                                                        user1475369 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                        Check out our Code of Conduct.



































                                                                                                                                            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%2f191180%2fcount-rook-moves-1d%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

                                                                                                                                            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                                                                                                                                            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                                                                                                                                            Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m