[Question]
  [
In cryptography, [PKCS#7 padding](https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7) is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N.
For example, `Hello, World!`, which has 13 bytes, is the following in hex:
```
48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
```
If we choose to PKCS#7 pad to length 16, then the result is:
```
48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 03 03 03
```
And if we choose to pad to length 20, then the result is:
```
48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 07 07 07 07 07 07 07
```
Note that in the first example we add three `03` bytes, and in the second we add seven `07` bytes.
Your task will be to *validate* whether a string (or integer array) has correct PKCS#7 padding. That is, if the last byte of the input string is N, then your program should check that the last N bytes of the string are equal to N.
## Input
A single nonempty ASCII string containing characters between code points 1 and 127 inclusive. If you wish, you may take input as an array of integers instead.
## Output
A [truthy](https://codegolf.meta.stackexchange.com/questions/2190/interpretation-of-truthy-falsey) value if the input string has valid PKCS#7 padding, otherwise a falsy value.
Both functions and full programs are acceptable. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the aim is to minimise the number of bytes in your code.
## Test cases
The integer array version of inputs is presented here — the string version would have unprintable characters for many of the following test cases:
**Truthy:**
```
[1]
[1, 1]
[2, 1]
[2, 2]
[5, 6, 5, 3, 3, 3]
[1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]
[95, 115, 80, 32, 71, 7, 122, 49, 13, 7, 7, 7, 7, 7, 7, 7, 7]
[27, 33, 54, 65, 97, 33, 52, 55, 60, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
[15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
```
**Falsy:**
```
[2]
[1, 2]
[5, 5, 5, 5]
[5, 6, 5, 4, 4, 4]
[3, 3, 3, 94, 3, 3]
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 127]
[50, 39, 94, 105, 49, 29, 74, 102, 2, 106, 44, 7, 7, 7, 7, 7, 7]
[26, 27, 59, 25, 122, 110, 20, 30, 114, 6, 9, 62, 121, 42, 22, 60, 33, 12]
```
  
[Answer]
# Python, ~~47~~ ~~34~~ 33 bytes
```
lambda s:s[-1:]*s[-1]==s[-s[-1]:]
```
`s[-1]` is the last member of the list `s`. Checks that the last `s[-1]` members of the input array `s` are the same as an array of `s[-1]` repeated that many times.
Takes input as an array of integers. This is a lambda expression; to use it, assign it by prefixing `lambda` with `f=`.
[Try it on Ideone!](http://ideone.com/ZzcGBF)
To test:
```
>>> f=lambda s:s[-1:]*s[-1]==s[-s[-1]:]
>>> f([27, 33, 54, 65, 97, 33, 52, 55, 60, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
True
>>> f([50, 39, 94, 105, 49, 29, 74, 102, 2, 106, 44, 7, 7, 7, 7, 7, 7])
False
```
*Saved 13 bytes thanks to Leaky Nun!*
*Saved a byte thanks to Dennis!*
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 14 bytes
```
~c[A:B]t#=h~lB
```
[Try it online!](http://brachylog.tryitonline.net/#code=fmNbQTpCXXQjPWh-bEI&input=WzI3OjMzOjU0OjY1Ojk3OjMzOjUyOjU1OjYwOjE6MTA6MTA6MTA6MTA6MTA6MTA6MTA6MTA6MTA6MTBd)
```
~c[A:B]t#=h~lB
~c[A:B]                input is concatenation of A and B
       t               B
        #=             has all equal elements
          h~lB         the first item of B is the length of B
```
[Answer]
# Pyth, 5 bytes
```
gFer8
```
RLE on input, take the last pair and check if the number of repeats is greater or equal than the value. 
Try it online: [Demonstration](http://pyth.herokuapp.com/?code=gFer8&input=%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D&test_suite_input=%5B1%5D%0A%5B1%2C%201%5D%0A%5B2%2C%201%5D%0A%5B2%2C%202%5D%0A%5B5%2C%206%2C%205%2C%203%2C%203%2C%203%5D%0A%5B1%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%5D%0A%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B27%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%5D%0A%5B15%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%5D%0A%5B2%5D%0A%5B1%2C%202%5D%0A%5B5%2C%205%2C%205%2C%205%5D%0A%5B5%2C%206%2C%205%2C%204%2C%204%2C%204%5D%0A%5B3%2C%203%2C%203%2C%2094%2C%203%2C%203%5D%0A%5B1%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%5D%0A%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%5D%0A%5B50%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B26%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%5D&debug=0) or [Test Suite](http://pyth.herokuapp.com/?code=gFer8&input=%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D&test_suite=1&test_suite_input=%5B1%5D%0A%5B1%2C%201%5D%0A%5B2%2C%201%5D%0A%5B2%2C%202%5D%0A%5B5%2C%206%2C%205%2C%203%2C%203%2C%203%5D%0A%5B1%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%5D%0A%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B27%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%5D%0A%5B15%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%5D%0A%5B2%5D%0A%5B1%2C%202%5D%0A%5B5%2C%205%2C%205%2C%205%5D%0A%5B5%2C%206%2C%205%2C%204%2C%204%2C%204%5D%0A%5B3%2C%203%2C%203%2C%2094%2C%203%2C%203%5D%0A%5B1%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%5D%0A%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%5D%0A%5B50%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B26%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%5D&debug=0)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ŒgṪṫṪ
```
Input is an array of code points, output is a non-empty array (truthy) or an empty array (falsy).
[Try it online!](http://jelly.tryitonline.net/#code=xZJn4bmq4bmr4bmq&input=&args=WzE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNV0) or [verify all test cases](http://jelly.tryitonline.net/#code=xZJn4bmq4bmr4bmqCjEgMMOHP8K14oKs4oKsRw&input=&args=W1sKIFsxXSwKIFsxLCAxXSwKIFsyLCAxXSwKIFsyLCAyXSwKIFs1LCA2LCA1LCAzLCAzLCAzXSwKIFsxLCAxLCAyLCAyLCAxLCAxLCAyLCAyLCAxLCAxLCAyLCAyXSwKIFs5NSwgMTE1LCA4MCwgMzIsIDcxLCA3LCAxMjIsIDQ5LCAxMywgNywgNywgNywgNywgNywgNywgNywgN10sCiBbMjcsIDMzLCA1NCwgNjUsIDk3LCAzMywgNTIsIDU1LCA2MCwgMSwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTBdLAogWzE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNV0KXSxbCiBbMl0sCiBbMSwgMl0sCiBbNSwgNSwgNSwgNV0sCiBbNSwgNiwgNSwgNCwgNCwgNF0sCiBbMywgMywgMywgOTQsIDMsIDNdLAogWzEsIDIsIDEsIDIsIDEsIDIsIDEsIDIsIDEsIDIsIDEsIDJdLAogWzEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEyN10sCiBbNTAsIDM5LCA5NCwgMTA1LCA0OSwgMjksIDc0LCAxMDIsIDIsIDEwNiwgNDQsIDcsIDcsIDcsIDcsIDcsIDddLAogWzI2LCAyNywgNTksIDI1LCAxMjIsIDExMCwgMjAsIDMwLCAxMTQsIDYsIDksIDYyLCAxMjEsIDQyLCAyMiwgNjAsIDMzLCAxMl0KXV0).
### How it works
```
ŒgṪṫṪ  Main link. Argument: A (array)
Œg     Group all runs of consecutive, equal integers.
  Ṫ    Tail; yield the last run. It should consist of n or more occurrences of n.
    Ṫ  Tail; yield n, the last element of A.
   ṫ   Dyadic tail; discard everything after the n-th element of the last run.
       If the last run was long enough, this will yield a non-empty array (truthy);
       if not, the result will be an empty array (falsy).
```
[Answer]
## CJam, ~~9~~ 8 bytes
*Thanks to Sp3000 for saving 1 byte.*
```
{e`W=:/}
```
Takes an integer list as input and returns `0` (falsy) or a positive integer (truthy).
[Test suite.](http://cjam.tryitonline.net/#code=cX5dewoKe2VgVz06L30KCn5dbn0v&input=WzFdClsxIDFdClsyIDFdClsyIDJdCls1IDYgNSAzIDMgM10KWzEgMSAyIDIgMSAxIDIgMiAxIDEgMiAyXQpbOTUgMTE1IDgwIDMyIDcxIDcgMTIyIDQ5IDEzIDcgNyA3IDcgNyA3IDcgN10KWzI3IDMzIDU0IDY1IDk3IDMzIDUyIDU1IDYwIDEgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTBdClsxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNSAxNV0KWzJdClsxIDJdCls1IDUgNSA1XQpbNSA2IDUgNCA0IDRdClsxIDIgMSAyIDEgMiAxIDIgMSAyIDEgMl0KWzEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMTI3XQpbNTAgMzkgOTQgMTA1IDQ5IDI5IDc0IDEwMiAyIDEwNiA0NCA3IDcgNyA3IDcgN10KWzI2IDI3IDU5IDI1IDEyMiAxMTAgMjAgMzAgMTE0IDYgOSA2MiAxMjEgNDIgMjIgNjAgMzMgMTJd)
### Explanation
```
e`   e# Run-length encoding, yielding pairs of run-length R and value V.
W=   e# Get the last pair.
:/   e# Compute R/V, which is positive iff R ≥ V. Works, because V is guaranteed
     e# to be non-zero.
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 9 bytes
No run-length encodings for osabie :(
```
¤sR¬£¬QOQ
```
Explanation:
```
¤           # Get the last element of the array
 s          # Swap the two top elements
  R         # Reverse the array
   ¬        # Get the first element
    £       # Substring [0:first element]
     ¬      # Get the first element
      Q     # Check if they are equal
       OQ   # Sum up and check if equal
```
With an example:
```
¤           # [5, 6, 5, 3, 3, 3]  3
 s          # 3  [5, 6, 5, 3, 3, 3]
  R         # 3  [3, 3, 3, 5, 6, 5]
   ¬        # 3  [3, 3, 3, 5, 6, 5]  3
    £       # 3  [3, 3, 3]
     ¬      # 3  [3, 3, 3]  3
      Q     # 3  [1, 1, 1]
       OQ   # 3==3 which results into 1
```
Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=wqRzUsKswqPCrFFPUQ&input=Wzk1LCAxMTUsIDgwLCAzMiwgNzEsIDcsIDEyMiwgNDksIDEzLCA3LCA3LCA3LCA3LCA3LCA3LCA3LCA3XQ)
[Answer]
# [MATL](http://github.com/lmendo/MATL), 10 bytes
*Thanks to @Adnan for noticing a problem with an earlier version of the code*
```
P0hG0):)&=
```
When the input has correct padding, the output is an array containing only ones, which is [truthy](http://matl.tryitonline.net/#code=PyAgICAgICAgICUgaWYKJ3RydXRoeScKfSAgICAgICAgICUgZWxzZQonZmFsc3kn&input=WzEgMSAxOyAxIDEgMTsgMSAxIDFd). When it has incorrect padding, the output is an array containing at least a zero, and so is [falsy](http://matl.tryitonline.net/#code=PyAgICAgICAgICUgaWYKJ3RydXRoeScKfSAgICAgICAgICUgZWxzZQonZmFsc3kn&input=WzEgMSAxOyAxIDEgMTsgMSAxIDBd).
[Try it online!](http://matl.tryitonline.net/#code=UDBoRzApOikmPQ&input=Wzk1LCAxMTUsIDgwLCAzMiwgNzEsIDcsIDEyMiwgNDksIDEzLCA3LCA3LCA3LCA3LCA3LCA3LCA3LCA3XQ) Or [verify all test cases](http://matl.tryitonline.net/#code=YFhLClAwaEswKTopJj0KRFQ&input=WzFdClsxLCAxXQpbMiwgMV0KWzIsIDJdCls1LCA2LCA1LCAzLCAzLCAzXQpbMSwgMSwgMiwgMiwgMSwgMSwgMiwgMiwgMSwgMSwgMiwgMl0KWzk1LCAxMTUsIDgwLCAzMiwgNzEsIDcsIDEyMiwgNDksIDEzLCA3LCA3LCA3LCA3LCA3LCA3LCA3LCA3XQpbMjcsIDMzLCA1NCwgNjUsIDk3LCAzMywgNTIsIDU1LCA2MCwgMSwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTBdClsxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTVdClsyXQpbMSwgMl0KWzUsIDUsIDUsIDVdCls1LCA2LCA1LCA0LCA0LCA0XQpbMywgMywgMywgOTQsIDMsIDNdClsxLCAyLCAxLCAyLCAxLCAyLCAxLCAyLCAxLCAyLCAxLCAyXQpbMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMSwgMTI3XQpbNTAsIDM5LCA5NCwgMTA1LCA0OSwgMjksIDc0LCAxMDIsIDIsIDEwNiwgNDQsIDcsIDcsIDcsIDcsIDcsIDddClsyNiwgMjcsIDU5LCAyNSwgMTIyLCAxMTAsIDIwLCAzMCwgMTE0LCA2LCA5LCA2MiwgMTIxLCA0MiwgMjIsIDYwLCAzMywgMTJd).
### Explanation
```
P     % Implicitly take numeric array as input. Reverse the array
0h    % Append a 0. This ensures falsy output if input array is too short
G0)   % Push input again. Get its last element
:     % Range from 1 to that
)     % Apply as index into the array
&=    % 2D array of all pairwise equality comparisons. Implicitly display
```
[Answer]
## Mathematica, 29 bytes
```
#&@@#<=Length@#&@*Last@*Split
```
Split the input into runs of equal elements, extract the last, and check that its first element is less than or equal to the length of that run.
[Answer]
## Haskell, 50 bytes
```
import Data.List
((>=)<$>head<*>length).last.group
```
Takes an array of integers as input.
[Answer]
# J, 13 bytes
```
#~@{:-:{:{.|.
```
Takes the list as a single argument and outputs `1` if it is truthy and `0` if falsey.
## Usage
```
   f =: #~@{:-:{:{.|.
   f 5 6 5 3 3 3
1
   f 5 6 5 4 4 4
0
```
## Explanation
```
#~@{:-:{:{.|.  Input: array A
           |.  Reverse A
       {:      Get the last value in A
         {.    Take that many values from the reverse of A
   {:          Get the last value in A
#~@            Make a list with that many copies of the last value
     -:        Test if the list of copies matches the sublist of A and return
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak/tree/752fab329eec303ea9878c9faaf74a380708f93b), 54 bytes
```
(({})[()]){({}[()]<({}[({})]){<>}{}>)}{}{<>(<(())>)}{}
```
Input is a list of integers, output is 1 for truthy and empty for falsey.
## Explanation
```
(({})[()]){ Loop a number of times equal to the last integer in the input - 1
    ({}[()] Handle loop counter
        < Silently...
            ({}[({})]) Replace the last code point in the string with its difference with the code point before it
            {<>} If the difference is not zero then switch stacks
            {} Discard the difference
        > End silently
    ) Handle loop counter
} End loop
{} Discard the loop counter
{<>(<(())>)} If the top of the current stack is not 0 (which means we have not switched stacks push 0 then 1
{} Discard the top of the stack (either nothing if falsey or 0 if truthy)
```
The loop does not immediately end when a value that would result in a falsey return is encountered. It is instead switched to the other stack which is empty and spends the rest of its iterations comparing 0 and 0.
[Answer]
## Batch, 101 bytes
```
@for %%a in (%*)do @set/an=%%a,c=0
@for %%a in (%*)do @set/ac+=1,c*=!(n-%%a)
@if %c% geq %n% echo 1
```
Takes input as command-line parameters, loops over them all so that it can get the last one into `n`, loops over them all again to count the run of trailing `n`s, finally printing `1` if the count is at least equal to `n`. Alternatively if printing `0` or a non-zero value is acceptable, then for 93 bytes, change the last line to `@cmd/cset/ac/n`.
[Answer]
# Haskell, 49 bytes
```
f s|x<-(==last s)=x.length.fst.span x.reverse$s
```
[Try it on Ideone.](https://ideone.com/Gw3I8f)
Shorter version which returns `True` for truthy and `False` or an exception for falsy:
```
((==).head>>=all).(head>>=take).reverse
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 10 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
(⊃∧.=⊃↑⊢)⌽
```
`⊃` Is the first  
`∧.=` all-equal to  
`⊃` the first  
`↑` *n* taken from  
`⊢` the  
`⌽` reversed argument?  
[TryAPL online!](http://tryapl.org/?a=f%u2190%28%u2283%u2227.%3D%u2283%u2191%u22A2%29%u233D%20%u22C4%20f%A8%28%2C1%29%281%2C%201%29%282%2C%201%29%282%2C%202%29%285%2C%206%2C%205%2C%203%2C%203%2C%203%29%281%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%29%2895%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%29%2827%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%29%2815%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%29%20%u22C4%20f%A8%28%2C2%29%281%2C%202%29%285%2C%205%2C%205%2C%205%29%285%2C%206%2C%205%2C%204%2C%204%2C%204%29%283%2C%203%2C%203%2C%2094%2C%203%2C%203%29%281%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%29%281%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%29%2850%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%29%2826%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%29&run)
[Answer]
## Javascript (ES6), ~~51~~ ~~47~~ 41 bytes
```
a=>(r=k=>a.pop()^n?k<2:r(k-1))(n=a.pop())
```
Examples:
```
let f =
a=>(r=k=>a.pop()^n?k<2:r(k-1))(n=a.pop())
console.log(f([5, 6, 5, 3, 3, 3]))
console.log(f([5, 6, 5, 4, 4, 4]))
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak) 84 bytes
*100000000 beat me [here](https://codegolf.stackexchange.com/a/91478/56656)*
[Try It Online!](http://brain-flak.tryitonline.net/#code=KCgoe30pKSl7KHt9WygpXTwoKHt9KTwoW3t9XXt9PD4pPD4-KT4pfTw-KFtdKSh7PHt9Pnt9PChbXSk-fXt9PCgoKSk-KXsoKDx7fXt9PikpfXt9&input=)
```
((({}))){({}[()]<(({})<([{}]{}<>)<>>)>)}<>([])({<{}>{}<([])>}{}<(())>){((<{}{}>))}{}
```
Takes input as array of integers.
Explanation to come.
Here is a 64 byte version that outputs the not of the answer:
```
((({}))){({}[()]<(({})<([{}]{}<>)<>>)>)}<>([])({<{}>{}<([])>}{})
```
[Answer]
# C 91 Bytes
```
int f(int*l){int n;for(n=0;l[++n];);l+=n-1;for(int i=*l;i;)if(l[-i--+1]^*l||n<*l)return 0;}
```
Input: a pointer to a null-terminated array.  
Output: returns `0` for invalid padding and non-zero for valid (the last element in the array)
Examples:
```
int a[] = {5, 6, 5, 3, 3, 3, 0};
printf("%d\n", f(&a[5], 6));
int b[] = {1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0};
printf("%d\n", f(&b[11],12 ));
int m[] = {5, 6, 5, 4, 4, 4, 0};
printf("%d\n", f(&m[5], 6));
int n[] = {3, 3, 3, 94, 3, 3, 0};
printf("%d\n", f(&n[5], 6));
```
Gives:
```
3
2
0
0
```
This does rely on undefined behavior. If the padding is valid there is no return statement, but using `gcc -std=c99` this returns the last element of the array that was passed in (at least on my machine).
[Answer]
# [Perl 5](https://www.perl.org/), 30 bytes
Includes `+1` for `-p`
```
#!/usr/bin/perl -p
$_=/(.)\1*\z/s+length$&>ord$1
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZfQ08zxlArpkq/WDsnNS@9JENFzS6/KEXF8P9/U4WSzNzUYoUYUysFVhD4l19QkpmfV/xftwAA "Perl 5 – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 6 bytes
```
a₁=.l∈
```
[Try it online!](https://tio.run/##nU/LSgQxEPyVIQdP5ZLuPMYc9EeGOYyy6mFAWJVB1j24gow3/8KrFy/@zeZHxu7sIriIiFQeVUknXXW66M4u7/qrC56Wg6kOTyozHCzz01teP@bx1dwsbufmXtl511/PzWows8psPp5Xm/eXqcvrh@NZn8dxmpqGWjQsk0BlVc6FBxQUzUVH0V7xpZxCVNmR/E7KZ5BH2Nu3DfDDlJsUQBRwZOEYNaEGMcMnkBP@DbsOfwBrLddwDsEjBqQtZwQJYLXE/jI0p/hJmoxsUDecUKsosWyE9/vOJMc/h3qNELtB@oSSn8QHiwVxQxIACVEOmeDFAGsEiUPctp8 "Brachylog – Try It Online")
Outputs through predicate success or failure, as Leaky Nun's Brachylog v1 answer does. Takes a similar approach, as well, but comes out a lot shorter.
```
a₁        There exists a suffix of the input
  =       the elements of which are all equal
   .      which is the output variable
    l     the length of which
     ∈    is an element of
          the output variable.
```
# [Brachylog](https://github.com/JCumin/Brachylog), 6 bytes
```
ḅt.l≥∈
```
[Try it online!](https://tio.run/##nU/LSgMxFP2VIQtXx5J7J8mYjT8yzKJK1cWAUCuDtN1UlOnOnxC3bgTxbyY/Mt6bFsEiInLyOCe5yT3nbD49v7prry95XHamOD4tTHe0TI@vaXOf@hezmN/OzErZxbS9mZl1ZyaFGT626@HtaRzeHxaTNm2fU9@PY11Tg5plEiivyjlzj4ysOesg2im@VKkQlXdEt5fyGeQRDvZdA/ww5SZ6EHmcWJSMilCBmOEiqBT@DfsOfwBrLVcoS3iH4BF3nOElgNUS@8vQnOInajKyXt1wRKUix7IBzh06kxz/HOo1QOx66eNzfhIfLBbEDUkARAQ5ZIITA6wRJA5x03wC "Brachylog – Try It Online")
An alternate version that comes out to the same length which takes some inspiration from Dennis' Jelly answer.
```
 t        The last
ḅ         block of consecutive equal elements of the input
  .       is the output variable
   l      the length of which
    ≥     is greater than or equal to
     ∈    an element of
          the output variable.
```
[Answer]
# [Retina](http://github.com/mbuettner/retina), 34 bytes
Byte count assumes ISO 8859-1 encoding.
```
.+
$*
\b(1(1)*)(?<-2>¶\1)*$(?(2)!)
```
Input is a linefeed-separated list of integers. Prints `0` or `1`.
[Try it online!](http://retina.tryitonline.net/#code=JShTYFxzCi4rCiQqClxiKDEoMSkqKSg_PC0yPsK2XDEpKiQoPygyKSEp&input=MQoxIDEKMiAxCjIgMgo1IDYgNSAzIDMgMwoxIDEgMiAyIDEgMSAyIDIgMSAxIDIgMgo5NSAxMTUgODAgMzIgNzEgNyAxMjIgNDkgMTMgNyA3IDcgNyA3IDcgNyA3CjI3IDMzIDU0IDY1IDk3IDMzIDUyIDU1IDYwIDEgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAKMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUKMgoxIDIKNSA1IDUgNQo1IDYgNSA0IDQgNAozIDMgMyA5NCAzIDMKMSAyIDEgMiAxIDIgMSAyIDEgMiAxIDIKMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxMjcKNTAgMzkgOTQgMTA1IDQ5IDI5IDc0IDEwMiAyIDEwNiA0NCA3IDcgNyA3IDcgNwoyNiAyNyA1OSAyNSAxMjIgMTEwIDIwIDMwIDExNCA2IDkgNjIgMTIxIDQyIDIyIDYwIDMzIDEy) (The first line enables a test suite, where there is one space-separated test case per line.)
An alternative idea that ends up at 35 bytes and prints `0` or a positive integer:
```
.+
$*
\b(?=(1+)(¶\1)*$)(?<-2>1)*1\b
```
[Answer]
## Pyke, 7 bytes
```
eQ>}lt!
```
[Try it here!](http://pyke.catbus.co.uk/?code=eQ%3E%7Dlt%21&input=%5B95%2C+115%2C+80%2C+32%2C+71%2C+7%2C+122%2C+49%2C+13%2C+7%2C+7%2C+7%2C+7%2C+7%2C+7%2C+7%2C+7%5D&warnings=0)
[Answer]
# Javascript (ES5), 89 bytes
```
function(b){for(var d=b[b.length-1],c=0;c<d;c++)if(b[b.length-c-1]!=d)return!1;return!0};
```
Ungolfed:
```
function a(arr){
var b=arr[arr.length-1];
for(var i=0;i<b;i++){
    if(arr[arr.length-i-1]!=b)return false;
}
return true;
}
```
]