[Question]
  [
# Mölkky
[Mölkky](https://en.wikipedia.org/wiki/M%C3%B6lkky) is a Finnish throwing game. The players use a wooden pin (also called "mölkky") to try to knock over wooden pins of almost similar dimensions with the throwing pin, marked with numbers from 1 to 12. The initial position of the pins is as follows:
```
   (07)(09)(08)
 (05)(11)(12)(06)
   (03)(10)(04)
     (01)(02)
```
*This description and the rules below are based on [Wikipedia](https://en.wikipedia.org/wiki/M%C3%B6lkky).*
# Simplified Mölkky rules
1. Knocking over **one pin** scores the number of points marked on the pin.
2. Knocking **2 or more pins** scores the number of pins knocked over (e.g., knocking over 3 pins scores 3 points).
3. The aim of the game is to reach exactly **50** points. Scoring more than 50 is penalized by setting the score back to **25** points.
4. For the purpose of this challenge, we will make the assumption that the pins are *always* in the exact order described above. (In a real game, the pins are stood up again after each throw in the location where they landed.)
All other Mölkky rules are ignored and only a single player is considered.
# Input
A non-empty list of lists of 12 booleans. Each list of booleans describes the outcome of a throw: **1** if the pin was knocked over and **0** otherwise. The booleans are given in the exact order of the pins, from top left to bottom right: **7**, **9**, **8**, **5**, **11**, **12**, **6**, **3**, **10**, **4**, **1**, **2**.
# Output
The score after all throws described in the input, calculated by applying rules **1**, **2** and **3**.
# Detailed example
Let's consider the following input:
```
// 07 09 08 05 11 12 06 03 10 04 01 02
[ [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ],  // scores 5 (rule #1)
  [ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ],  // scores 2 (rule #2), total: 7
  [ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 ],  // scores 7, total: 14
  [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],  // scores 12, total: 26
  [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],  // scores 12, total: 38
  [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ],  // scores 11, total: 49
  [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],  // scores 7, total: 56 -> 25 (rule #3)
  [ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ] // scores 2, total: 27
```
The expected output is **27**.
# Challenge rules
* You may take input in any reasonable format. Instead of lists of booleans, you can use integers where the most significant bit is the pin #7 and the least significant bit is the pin #2. In this format, the above example would be passed as `[ 256, 2304, 127, 64, 64, 128, 2048, 3072 ]`.
* The input list may contain throws where no pin at all is knocked over, in which case the score is let unchanged.
* You don't have anything special to do when the score reaches *exactly* 50 points. But you can assume that no other throw will follow when it happens.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.
# Test cases
Using lists of integers as input:
```
[ 0 ] --> 0
[ 528 ] --> 2
[ 4095 ] --> 12
[ 64, 0, 3208 ] --> 16
[ 16, 1907, 2048 ] --> 18
[ 2023, 2010, 1, 8 ] --> 29
[ 1726, 128, 35, 3136, 1024 ] --> 34
[ 32, 32, 2924, 2, 256, 16 ] --> 28
[ 64, 64, 2434, 1904, 3251, 32, 256 ] --> 25
[ 3659, 2777, 2211, 3957, 64, 2208, 492, 2815 ] --> 25
[ 2047, 1402, 2, 2599, 4, 1024, 2048, 3266 ] --> 50
[ 256, 2304, 127, 64, 64, 128, 2048, 3072 ] --> 27
[ 16, 8, 128, 1, 2048, 1, 2048, 513, 8, 3206 ] --> 30
```
You can [follow this link](https://pastebin.com/LjjhDESQ) to get these test cases in Boolean format.
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~126 111 108~~ 104 bytes
*-3 bytes thanks to Jonathan Allan*
*-4 bytes thanks to Kaya!*
```
f=lambda A,t=0:t>50and f(A,25)or A and f(A[1:],t-~(sum(A[0])-1or 762447093078/12**A[0].index(1)%12))or t
```
[Try it online!](https://tio.run/##TVLBboMwDD3DV1idppIqbLGTEEBqpX4H40DVoVEVWrWZ1F326yyhoevBke33/J4TOP/Yr9NA49iuj02/2zew5XYtSrvRohn20CZbTpqdLrCFUFdY1tymv8n1u3eVqFmKDjcZKWVEIYXJ35FWKw@9dcP@85Yge0ViXsWOrTs76AaoKhBQ8ziqQFMeMiUKHdJMcRAcJIkZxIwDFsJwIKHmJgmSvoGOixweXEOeTblT0C5Q@lKQCrgkPgUV5Hx8oj0hezL3QUqqyVR5usYwpGeezHThamP8UoQeL7QJs25zDqrwAznqx77K4agEBdvCCaj7bveLeY9sNpjWIun9kYJwpsLNAlsYenqhPIA4449Eo5xg96ROPo7qMo4OsIZjd7VJ35yT8Avcyv9WN1gO7pv1jU1ufPkiUO2WrKKyZoxDx1gcnS@OBB2HxYdN082Ct8mBQRyPfw "Python 2 – Try It Online")
Defines a recursive function that takes a 2D array of 1s and 0s and returns an integer value. Nothing too special in the construction, and I'm sure there's a simpler solution.
### Explanation:
```
f=lambda A,t=0:    #Define the function, initialising t to 0 on the first iteration
               t>50and f(A,25)      #If t>50 then iterate again with t=25
                              or    #Else
               A and                #If A exists
                     f(A[1:],       #Iterate again without the first list of A
                        t-~         #And add to t, either
                           (sum(A[0])-1   #The sum of all elements if that's not 1
                                         or
                           762447093078/12**A[0].index(1)%12   #Else the appropriate pin value (black magic!)
               or t       #Finally, if A is finished, just return t
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 25 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“ñ€bḷ’œ?TLḢṖ?µ€+25¹>?50ɗ/
```
A monadic link accepting a list of lists of ones and zeros (each of length 12) which returns an integer.
**[Try it online!](https://tio.run/##y0rNyan8//9Rw5zDGx81rUl6uGP7o4aZRyfbh/g83LHo4c5p9oe2AsW1jUwP7bSzNzU4OV3/////0dEGOiBoqGOACmN1uBSiDfHIIfiGyBBDDp8@XHKGON1igMOdWGVjYwE "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##LU@xTsNADP2V7nWF7bPvckuDmBlZUJQFiaXqD7BFLEiMILUglYWZhQGRSEytMvAZyY8E3wXpZPue3733bnO73d5N09gcTp/j/cfN0H6PzWv/XF5dDu370O3K45fhS9Zjty4Vf/dn01Iw@ouhfbSFndODlf7nvH8auhcbNwluDovVar0Ym7fraaoqrKFSLqzaW7XmBRAcY4LIA0UMwCjpysjOZkIgyOvARuACnIIjZzOyGO7YBIAjC1hTw/0sbIfFSRIVoyhlnqat8xqBQzAzJsOjhky3ICDRWAVpjiABSJCzcowg2TQnNDGfpJIjO3MgzhpecsiZgoHnjxUZpBn@b0oOkgz6uv4D "Jelly – Try It Online") (using the integer values given in the OP)
### How?
This solution makes use of, `œ?`, which given a number, n, and a list finds the nth lexicographical permutation of the list where the list defines the sort order. First we need to work out this `n`:
```
 index:  1  2  3  4  5  6  7  8  9 10 11 12
 value:  7  9  8  5 11 12  6  3 10  4  1  2   (as defined by the question)
     P: 11 12  8 10  4  7  1  3  2  9  5  6   (our permutation lookup array)
```
...that is, `P` at index `i` is set to the original index of the value `i`.  
This `P` has a lexicographical index of **438,337,469** (that is, if you took all **12!** permutations of the numbers **1** to **12** and sorted them lexicographically, the **438,337,469th** would be `P`).  
This may be found [using Jelly's `Œ¿` atom](https://tio.run/##y0rNyan8///opEP7////H21oqKNgaKSjYAGkDHQUTHQUzIEsHQVjHQWgqKWOgqmOglksAA "Jelly – Try It Online").  
Both steps may be performed in one go [using the Jelly program `ĠŒ¿`](https://tio.run/##y0rNyan8///IgqOTDu3///9/tLmOgqWOgoWOgqmOgqEhEBvpKJjpKBgDWQY6CiZASkfBKBYA "Jelly – Try It Online")
```
“ñ€bḷ’œ?TLḢṖ?µ€+25¹>?50ɗ/ - Link: list of lists of zeros and ones
             µ€           - perform the monadic chain to the left for €ach list:
“ñ€bḷ’                    -   base 250 number = 438337469
      œ?                  -   nth permutation (reorder the 1s and 0s to their pin values)
        T                 -   truthy indices (get the pin values of the 1s)
            ?             -   if...
           Ṗ              -   ...condition: pop (length greater than 1 ?)
         L                -   ...then: length (the number of pins)
          Ḣ               -   ...else: head (the first (& only) pin value)
                        / - reduce the resulting list of integers with:
                       ɗ  -   last three links as a dyad:
               +          -     addition (add the two values together)
                     50   -     literal fifty
                    ?     -     if...
                   >      -     ...condition: greater than (sum greater than 50 ?)
                25        -     ...then: literal twenty-five
                  ¹       -     ...else: identity (do nothing - just yield the sum)
```
[Answer]
# [Python 2](https://docs.python.org/2/), 90 bytes
Heavily inspired by [Jo King's Python 2 answer](https://codegolf.stackexchange.com/a/164279/53748) and utilising [Kaya's base-12 representation comment](https://codegolf.stackexchange.com/questions/164270/lets-play-m%c3%b6lkky/164309#comment397640_164279)
```
t=0
for v in input():t+=sum(v)-1or 762447093078/12**v.index(1)%12;t=[t+1,25][t>49]
print t
```
**[Try it online!](https://tio.run/##dY7LDsIgFET3/Qo2JtCichHFavBHCDs1sigl9bbRr8e68hHImc3kZJKJT7z1QaaERlTXfiAT8WFOHJGyAzbmPnZ0YkuYld5JpbRoN0Lv1yDrelr5cL48KLAFyCMaiw1wuXUWT6p1VRx8QIIpWSv4G@DiF8ctFM2nwTd/przJGyg8ENlvWefcCw "Python 2 – Try It Online")** Or see the [test-suite](https://tio.run/##TVLbboMwDH3nK/IyAa3ZYichpBP9ir0hHnrJNqQWqjatuq/vnDBNRRFOjo/OceycfsL3NNJjN@19m@f5I7Qy@5zO4iaGkdfpGopyFZbt5XosbmWFnLI1aW2lU9I2b0iLxe11GPf@XmD5gvQe2i4sEcj0XVhr12en8zAGER4snyXF9rA5bveb1XaaDn4zfvhLyJIp8/yXP0cg2ned7KEz1PBfS2c41BokKJIRwhrQSQskdTySJMV7lICQ0paYQA0oAwoV7yVpxhWxAJAjDRwM4/UszIu00lFUM8Vg4pmYVbVxQNayGSHjzthE50JAO2Y1aFIJ2gJqSUnZOdDJNFXIYnWUio6k2AEpadQ6FTlTpKX5Yk0CcYb/gkEFUUbWfb/KBH9PDRSt6I6bU8EtBFHkMl8gLbfDyEPraNWXXYUxiKfZ/ve6T2LzmJ5gELmoqrXIIeX93e@K@E7Kxy8 "Python 2 – Try It Online")
[Answer]
# Pyth, ~~51~~ ~~48~~ 38 bytes
```
VQI>[[email protected]](/cdn-cgi/l/email-protection)"îO&"S12xN1J50=Z25;Z
```
Saved 10 bytes thanks to Jonathan Allan
Takes input as a list of lists of booleans.  
[Try it here](https://pyth.herokuapp.com/?code=VQI%3E%3D%2BZ%3FqJsN1%40.PC%22%0F%C3%AEO%26%22S12xN1J50%3DZ25%3BZ&input=%5B+%5B+0%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+1%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+0%2C+0%2C+0%2C+0%2C+0%2C+1%2C+1%2C+1%2C+1%2C+1%2C+1%2C+1+%5D%2C+%5B+0%2C+0%2C+0%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+0%2C+0%2C+0%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+0%2C+0%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D%2C+%5B+1%2C+1%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0%2C+0+%5D+%5D&debug=0)
### Explanation
```
VQI>[[email protected]](/cdn-cgi/l/email-protection)"îO&"S12xN1J50=Z25;Z
VQ                                  ;     For each input...
    =+Z                                   ... add to the total...
       ?q sN1                             ... if one pin is down...
             @.PC"îO&"S12xN1              ... the score of that pin.
         J                    J           ... otherwise, the count.
  I>                           50         If we pass 50...
                                 =Z25     ... reset to 25.
                                     Z    Output the total.
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~29~~ 28 bytes
```
v•CÞŸαLć•13вyOΘmyÏOO25‚¬50›è
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/7FHDIufD847uOLfR50g7kGNofGFTpf@5GbmVh/v9/Y1MHzXMOrTG1OBRw67DK/7/j4420FHARIbI3FgdBeyqUBSiqzLEqgOfWQitIFWGhFTRyCxDAmYRFxKGSAKGGApBIrGxAA "05AB1E – Try It Online")
**Explanation**
```
v                              # for each boolean list in input
 •CÞŸαLć•                      # push 13875514324986
         13в                   # convert to a list of base-13 numbers
            yO                 # push the sum of y
              Θm               # truthify and raise the pin-list to this number (0 or 1)
                yÏ             # keep those which are true in the current list
                  OO           # sum the list and the stack
                    25‚        # pair with 25
                       ¬50›    # check if the first number is larger than 50
                           è   # index into the pair with this result
```
[Answer]
# [Perl 5](https://www.perl.org/), ~~74~~ 70 bytes
```
$\+=y/1//-1||/1/g&&(0,6,8,7,4,10,11,5,2,9,3,0,1)[pos];$\=25if++$\>50}{
```
[Try it online!](https://tio.run/##TYtdDoIwEITfOUUDlWhYZIvWnxi8gScQQzQp2MRAQ8sDUa9uLfiAk0km386sEu2D20Bfe1pkWrWyNqU/Q5befKDFIei0IOYuNTENMUIbIkvSaVlXxC1FJdqxkbXqjKV5lPUJS5KYvV4uqzCcI2xgB1tYA0NgDDiksIcVOFicVaMvB5pnKZdlFNH8yPH9tBbZKBzS@wEORg8nsX@YGveFn0YZ2dTaxie@dBcbqy8 "Perl 5 – Try It Online")
Takes input as a series of newline separated bitstrings.
[Answer]
# [Haskell](https://www.haskell.org/), 96 bytes
```
foldl(\s a->([s..50]++e)!!sum(last$zipWith(*)[7,9,8,5,11,12,6,3,10,4,1,2]a:[a|sum a>1]))0
e=25:e
```
[Try it online!](https://tio.run/##hY/NDoIwEITvfYol4QCykBbFHxJ4DQ/QQ4NFiOUntl6Mz27Fi8FoNDuHzeabyWwj9EkqZeustPWgDsorNYgw9wodRQnlQSB9x9GXzlNCG/fajvvWNN7CLza4wy0myBiyGNe4REZxhQxjLtJC3CYPiJxx36dEZnGSSmukNpBBMQ1FYB@iOLsDRwJfSfq@0Bn5W@wf@eowZQInpBNtPxU@DATGc9sbcKGG5xfE3qtaiaO2YTWODw "Haskell – Try It Online")
The wrapping is clever: I essentially index at position `s+sum(…)` into the list `([0..50]++cycle[25])`. However, a shorter way to write that is indexing at position `sum(…)` and beginning the list at `s`.
[Answer]
# Java 10, ~~131~~ ~~130~~ 129 bytes
```
m->{int r=0,i,s,t;for(var a:m){for(i=s=t=0;i<12;s+=a[i++])t=a[i]>0?"    \n".charAt(i):t;r+=s<2?t:s;r=r>50?25:r;}return r;}
```
Contains 10 unprintables.  
Input as integer-matrix of zeros and ones.
-1 byte thanks to *@JonathanFrech*, changing `\t` into an actual tab (works in TIO, doesn't work in my local IDE).
[Try it online.](https://tio.run/##7VdNb9swDMW@t3Y/QujJRtxADNBLXCfYD1gvPWY5aK7bqouVQlIyDIZ/eyo7xmzXWUxm2bDDonzYBqXwkXxP1INYi/OHm2@beCGMYZ@FVNkJY1LZRN@KOGFXxW35gMWe@57NZ3OW@qF7mruPexsrrIzZFVMsYpv0fJIVxjrigQxMYMPbpfbWQjMxTv2suJGRiWzEQ3kJo9AMIjGTg8Hct8XFfMKnZ@8@vH9z@vHtqy/q9YuXZ8P4XuhP1pP@2IZ6EJnL0dSOTagjPbng09HFWIe5TuxKK@auNuHWrcfV14Vzq/JuvZQ3LHXovGurpbpzIIS/hWYTYz2VfGcVuizjQTEg4O2RB6V955UB0b62geZA2VPXp9gDCS8nxGfnjDwvy@jXGaDOgC7uPTMg2DlQXlHzQIsTtP8FHSdAeLRFWf/yvZUHB@ShGc2fNd7rUe1ViYMYU0DbAxIBb0QJUB4Bmf3NTAOCPdiq@x22wYEI@vSinV8g86Y/A4foL1Yr/rQC10zBIu7yGKssGN4fVhFAqLmmPjQ866mhZxWEUC4gsKwdUUDqCpD2TCBGFJCc6SpW/262e//bryvwzKvjsRg6Ox@ga7Qxi6yLx@5yoN2H9KrK/z7zX@kzgdzRwZERU7sbaoT@xvpwhO4M2yFXbKsy3D6Qlke@MuX1sXV74rv@YWySDpcrO3x0h0G7UJ4axl7qV6vkmyc)
**Explanation:**
```
m->{                // Method with integer-matrix parameter and integer return-type
  int r=0,          //  Result-integer, starting at 0
      i,s,t;        //  Temp integers
  for(var a:m){     //  Loop over the integer-arrays of the input
    for(i=s=t=0;    //   Reset `i`, `s` and `t` to 0
        i<12;       //   Loop `i` in the range [0,12)
        s+=a[i++])  //    Increase `s` by the current value (0 or 1)
      t=a[i]>0?     //    If the current value is 1:
         "  \n".charAt(i)
                    //     Set `t` to the score at this position
        :t;         //    Else: Leave `t` the same
    r+=s<2?         //   If only a single pin was hit:
        t           //    Add its score `t` to the result
       :            //   Else:
        s;          //    Add the amount of pins `s` to the result
    r=r>50?         //   If the result is now above 50
       25           //    Penalize it back to 25
      :r;}          //   If not, it stays the same
  return r;}        //  Return the result
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 43 bytes
```
≔⁰ηＦθ«≧⁺⎇⊖ΣιΣι⌕α§”$｜#z⁸Ｕg⊗”⌕ι¹η¿›η⁵⁰≔²⁵η»Ｉη
```
[Try it online!](https://tio.run/##jY9PawJBDMXPzqcInhJIYafgyZN/qrVVkLa3ZQ/D7ugMrGM7O0pL8bOPygrFiuzCO4S8X5KX3Cifb1UZ46Cq7NphwmCoL1ZbD/hF8Cs6C/VZe292bQIuy13F8KG9U/4Hxzr3eqNd0AW@7zZoiRjqgmFiXYGKYRBmrtDf2H1@mU3mi@n49Wk46l58yyDpPHU@27ErwKnXKmiPhqGXEMEl2WOvZg5i6a0LOFJVQEPUjzFNRQqn5LUk/9VXgoxPnGzJ/evKW93j2u5r5mSbP5LGf2UTJ7IsPuzLIw "Charcoal – Try It Online") Link is to verbose version of code. Takes input as a boolean array. Explanation:
```
≔⁰η
```
Set the score to 0.
```
Ｆθ«
```
Loop over the throws.
```
⎇⊖Σι
```
Is the number of pins 1?
```
Σι
```
If not, then take the number of pins.
```
⌕α§”$｜#z⁸Ｕg⊗”⌕ι¹
```
Otherwise, translate the position of the pin to a value.
```
≧⁺...η
```
Add it to the score.
```
¿›η⁵⁰≔²⁵η
```
If the score exceeds 50 then set it back to 25.
```
»Ｉη
```
Print the final result after all the throws.
[Answer]
# [Haskell](https://www.haskell.org/), 110 bytes
```
m s|sum s==1=sum$zipWith(*)[7,9,8,5,11,12,6,3,10,4,1,2]s|1>0=sum s
f l=foldl(\b->c.(b+).m)0l
c a|a>50=25|1>0=a
```
Same length: `f l=foldl(\b a->last$b+m a:[25|b+m a>50])0l` instead of `f` and `c`
[Try it online!](https://tio.run/##jY/PboMwDMbvPIUPHKA1VczG2lUKr7ED42C6UKIlrGrSHSbenYVqUvdHE0ifrE/Wz/bnjt2rMmY8gpHtm3kxyXMDnJWGnY@btQXeV3kxXF1ZiDoVBrLMsVVgVH/0HbDx6tyz1@9qtOAGdwlVSpLBxB/69KR9l6zSaouPuMMCiZByfMA7JIH3SJjXbqBSyOtg1H4LkpWHTdKs040NZ6MD8DBlkCHPxPNoWfcg4XTWvYcYWvDK@SiaqqygAoFfIrz5H4IaA0cLuV9d@qv/uKX75jla8oeY/ZfmOKjHTw "Haskell – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~47~~ 35 bytes
-12 bytes thanks to [H.PWiz](https://codegolf.stackexchange.com/users/71256/h-pwiz?tab=profile) (better way of generating the list encoding points)!
```
F₅0
S?25>50+?←Lε`f`+Nm+3d4652893071
```
[Try it online!](https://tio.run/##yygtzv7/3@1RU6sBV7C9kamdqYG2/aO2CT7ntiakJWj75Wobp5iYmRpZWBobmBv@//8/OtpABwQNdQxQYaxOtCFOGQTPEBmiyeDWg13GEIcLDLC6DatcbCwA "Husk – Try It Online")
### Explanation
```
F₅0  -- input is a list of boolean lists
F    -- left fold by
 ₅   -- | the function flipped (overflowing label) on line 1
  0  -- | with initial value 0
S?25>50+?←Lε`f`+Nm+3d4652893071  -- example inputs: [0,0,0,1,0,0,0,0,0,0,0,0] 0
                     4652893071  -- integer literal: 4652893071
                    d            -- digits: [4,6,5,2,8,9,3,0,7,1]
                 m+3             -- map (+3): [7,9,8,5,11,12,6,3,10,4]
              `+N                -- append natural numbers: [7,9,8,5,11,12,6,3,10,4,1,2,3,...
            `f                   -- filter this list by argument: [5]
        ?  ε                     -- if it's of length 1
         ←                       -- | take first
          L                      -- | else the length
                                 -- : 5
       +                         -- add to argument: 5
 ?  >50                          -- if the value is > 50
  25                             -- | then 25
S                                -- | else the value
                                 -- : 5
```
[Answer]
# [Red](http://www.red-lang.org), 189 172 bytes
```
func[b][s: 0 foreach c b[d: 0 foreach e c[if e = 1[d: d + 1]]i: find c 1
n: either i[pick[7 9 8 5 11 12 6 3 10 4 1 2]index? i][0]if 50 < s: s + either 1 < d[d][n][s: 25]]s]
```
[Try it online!](https://tio.run/##fVJBboMwELzzirn3sktL0tJW@UOvqz002FasSiSCVMrvqQkBDDLVSrbsmR3PDjTWdF/WiGau7NxvXclRpS1BcOfGflcnVDiKiS8sKvEubJ/gHjF4Aqv6Es7XJvA5q0tYfz3ZBl4uvvqRPd7wigLM4Bw7PIMJL2DkGnrs7QCvQhpkC8IHgoE2qD40ONwYMSr13VpeqLbaXRpfX@EgQuiLQctS4S1gPnBcS2CzIwmsXxlfp5StJKSKd@T7bD1YihiYlCRu2t7wwMu@uwfeRdJDNDOFh9CG8R6HaaURmJlTzCpjzhTt9G/qKalorqXg1MHr79r/nn22RfcH "Red – Try It Online")
## Explanation of the ungolfed code:
```
f: func[b][                                            ; a block of blocks of booleans
    s: 0                                               ; sets sum to 0
    foreach c b[                                       ; for each row of booleans 
        d: 0 foreach e c[if e = 1[d: d + 1]            ; count the number of 1s         
        i: find c 1                                    ; the index of the first 1
        n: either i[pick [7 9 8 5 11 12 6 3 10 4 1 2]  ; if there is 1, pick the number
                    index? i][0]                       ; at the index of 1
                                                       ; otherwise 0  
        if 50 < s: s + either 1 < d[d][n][s: 25]       ; if there is only one 1, add 
                                                       ; the number to the sum, otherwise
                                                       ; the number of 1s 
                                                       ; if the sum > 50, reset it to 25 
    ]
    s                                                  ; return the sum 
]
```
[Answer]
# JavaScript (ES6), 98 bytes
```
a=>a.map(b=>b.map((m,i)=>(c+=m,d+=m*('0x'+'7985bc63a412'[i])),c=d=0)|(t+=c>1?c:d)>50?t=25:0,t=0)|t
```
**Test cases:**
```
f=
a=>a.map(b=>b.map((m,i)=>(c+=m,d+=m*('0x'+'7985bc63a412'[i])),c=d=0)|(t+=c>1?c:d)>50?t=25:0,t=0)|t
console.log(f([ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ])) // 0
 
console.log(f([ [ 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] ])) // 2
 
console.log(f([ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ])) // 12
console.log(f(
[ [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ]
)); // 16
console.log(f(
[ [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
  [ 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 ],
  [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] 
])); // 18
console.log(f(
[ [ 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1 ],
  [ 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] ] 
)); // 29
console.log(f(
[ [ 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0 ],
  [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ],
  [ 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],
  [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0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ],
  [ 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ] ] 
)) // 30
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 37 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
├T<↓"♥←~;▌6»≥øF←î5░U╚_π○Q▒<│∟└ù║pε♀▀æ
```
[Run and debug it](http://stax.tomtheisen.com/#p=c3543c1922031b7e3bdd36aff200461b8c35b055c85fe30951b13cb31cc097ba70ee0cdf91&i=[[+0,+0,+0,+1,+0,+0,+0,+0,+0,+0,+0,+0+],[+1,+0,+0,+1,+0,+0,+0,+0,+0,+0,+0,+0+],[+0,+0,+0,+0,+0,+1,+1,+1,+1,+1,+1,+1+],[+0,+0,+0,+0,+0,+1,+0,+0,+0,+0,+0,+0+],[+0,+0,+0,+0,+0,+1,+0,+0,+0,+0,+0,+0+],[+0,+0,+0,+0,+1,+0,+0,+0,+0,+0,+0,+0+],[+1,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0+],[+1,+1,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0+]]%0A)
[Try It online!](https://tio.run/##Ky5JrPj//9GUOSE2j9omKz2aufRR24Q660fTeswO7X7UufTwDjegwOF1po@mTQx9NHVW/PmGR9O7Ax9Nm2TzaErTo475j6ZMObzz0dSJBee2PprZ8Ghaw@Fl//9HRysY6ECRoQ6CjYIUYnWiEbL4laEJGmIiHMqINI2gMkMivGBAyKeGhJTFcgEA)
**Explanation**
```
F:1"=EA5MQ9-I1%)"!s@c%1={h+}{%+}?c50>{d25}{}?    # Full program, unpacked
F                                                # Loop through every element
 :1                                              # Get indices of truthy elements
   "=EA5MQ9-I1%)"!                               # Push encoded [7,9,8,5,11,12,6,3,10,4,1,2]
                 s@                              # Swap the top 2 elements of stack and get elements at indexes
                   c%1=                          # Copy the top element, get length of array, compare to length of 1
                       {h+}{%+}?                 # If it has length of 1, add the element, otherwise add the length of the array to total
                                 c50>            # Compare total to 50, 
                                     {d25}{}?    # If it is greater, pop it off and push 25 to reset counter, otherwise do nothing
```
Not my best work, but it works. I'm sure there is somehting I'm missing to make it a bit shorter.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~109~~ ~~105~~ 103 bytes
```
c=0
for l in input():a=sum(l);c+=int('7985bc63a412'[l.index(1)],16)if a==1else a;c=(25,c)[c<51]
print c
```
[Try it online!](https://tio.run/##jY/LCsIwEEX3/YrZNcEgnWrro@ZLQhZxbDEQ09IH6NfHLoSioi2cxTD3cOE2j/5a@zQEkklU1S04sH6kGXrGj0Z2w405XtBKWt@zeHfYZ2fKN2aLaazc2vpLeWfItcCc2wqMlFi6rgRTkGRpJogrOmWoo6YdC4BCUKAgES9QTPcboIWa0v/axxO/@aEtbJvVcMGEZG4pzmmgnw "Python 2 – Try It Online")
Alternative without a recursive function.
-2 with thanks to @Jo King
]