[Question]
  [
Write a program that accepts a single lowercase word as input and outputs the number of pairs of letters that have the same number of letters between them in the word as in the alphabet.
For example, in the word 'nature', we have 4 pairs:
* nr: since there are three letters between them inside the word (a, t, u) and three letters between them in the alphabet (o, p, q)
* ae: since there are three letters between them inside the word (t, u, r) and three letters between them in the alphabet (b, c, d)
* tu: since there are no letters between them inside the word and no letters between them in the alphabet
* tr: since there is one letter between them inside the word (u) and one letter between them in the alphabet (s)
Since there are four pairs, the output in this case should be 4.
  
[Answer]
# Pyth, 19 bytes
```
lfqF-MSMCT.cCUBCMz2
```
Try it online: [Demonstration](http://pyth.herokuapp.com/?code=lfqF-MSMCT.cCUBCMz2&input=nature)
### Explanation:
```
lfqF-MSMCT.cCUBCMz2
                 z   read a string from input
               CM    convert into list of ascii-values
            CUB      create a list of pairs (ascii-value, index in string)
          .c      2  all combinations of length 2
 f                   filter for combinations T, which satisfy:
        CT              transpose T ((ascii1, ascii2), (index1, index2)
      SM                sort each list
    -M                  create the the difference for each
  qF                    check if they are equal
l                    print the number of remaining combinations
```
[Answer]
## R, 110 bytes
```
function(s){w=strsplit(s,"")[[1]]
O=outer
n=nchar(s)
sum(abs(O(r<-match(w,letters),r,"-"))==O(1:n,1:n,"-"))-n}
```
Degolfed:
```
F = function(s){
   chars = strsplit(s,"")[[1]]
   num_chars = nchar(s)
   letter_rank = match(chars, letters)
   rank_dist = abs(outer(letter_rank, letter_rank, "-"))
   position_dist = outer(1:num_chars, 1:num_chars, "-")
   return(sum(rank_dist == position_dist) - num_chars)
}
F("nature")
# [1] 4
F("supercalifragilisticexpialidocious")
# [1] 25
```
[Answer]
# Octave, 41 bytes
```
@(s)nnz(abs(s-s')==(t=1:(u=nnz(s)))-t')-u
```
[Answer]
# CJam, 36 bytes
```
r:A,{)Aew}%1>{{:B,B0=BW=-z)=}%}%e_:+
```
[Try it Online.](http://cjam.aditsu.net/#code=r%3AA%2C%7B)Aew%7D%251%3E%7B%7B%3AB%2CB0%3DBW%3D-z)%3D%7D%25%7D%25e_%3A%2B&input=nature)
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
#S≡Γ·…→Q
```
[Try it online!](https://tio.run/##AR8A4P9odXNr//8jU@KJoc6TwrfigKbihpJR////bmF0dXJl "Husk – Try It Online")
## Explanation
```
#S≡Γ·…→Q
       Q all continuous sublists
#        number of sublists which satisfy:
 S≡      has the same shape and distribution of truthy/falsy values as: 
   Γ·…→  the range between its first and last character?
```
[Answer]
# J, 27 bytes
```
#-:@-~#\+/@,@:=&(|@-/~)3&u:
```
Usage:
```
   (#-:@-~#\+/@,@:=&(|@-/~)3&u:) 'nature'
4
```
Explanation:
```
#-:@-~#\+/@,@:=&(|@-/~)3&u:
      #\                    lengths of input prefixes (1,2,...,length)
                       3&u: codepoints of input
               &(     )     with the last two do parallel:
                 |@-/~      create difference table with itself and take absolute values
              =             compare the elements of the two difference tables
        +/@,@:              sum the table              
#   -~                      subtract the length of the input (self-similar letters)
 -:@                        half the result (each pair was accounted twice)
```
[Try it online here.](http://tryj.tk/)
[Answer]
# CJam, 25 bytes
```
l:T,_2m*{_:-\Tf=:-z=},,\-
```
[Try it online](http://cjam.aditsu.net/#code=l%3AT%2C_2m*%7B_%3A-%5CTf%3D%3A-z%3D%7D%2C%2C%5C-&input=nature)
Explanation:
```
l     Get input.
:T    Store in variable T for later use.
,     Calculate length.
_     Copy for use at the very end.
2m*   Use Cartesian power to calculate all possible position pairs.
{     Start filter.
  _     Create copy of index pair.
  :-    Calculate difference between indices.
  \     Swap copy of index pair to top.
  T     Get input string stored in variable T.
  f=    Extract the letters for the index pair.
  :-    Calculate difference of the two letters.
  z     Take the absolute value.
  =     Compare index difference and letter difference.
},    End filter.
,\
-     Pairs of identical indices passed the filter. Eliminate them from the
      count by subtracting the length of the input.
```
[Answer]
# JavaScript (ES6), 98 bytes
```
f=w=>(p=0,q="charCodeAt",[...w].map((c,a)=>{for(b=a;w[++b];)p+=Math.abs(w[q](a)-w[q](b))==b-a}),p)
```
## Usage
```
f("nature")
=> 4
```
## Explanation
```
f=w=>(
  p=0,                                 // p = number of pairs
  q="charCodeAt",
  [...w].map((c,a)=>{                  // iterate through each character of input
                                       // a = character A index
    for(b=a;w[++b];)                   // iterate through the remaining input characters
                                       // b = character B index
      p+=                              // add 1 to p if true or 0 if false
        Math.abs(w[q](a)-w[q](b))==b-a // compare absolute difference of character codes
                                       //     to difference of indices
  }),
  p                                    // return p
)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~32~~ 16 bytes
```
ḢØaṣU1¦=
ṫJÇ€Fċ1
```
[Try it online!](https://tio.run/##ASoA1f9qZWxsef//4biiw5hh4bmjVTHCpj0K4bmrSsOH4oKsRsSLMf///2FiZWY "Jelly – Try It Online")
–16 when I learned how to reverse just the first element of a list.
### How?
```
ḢØaṣU1¦=  - helper monadic link, e.g. nature
Ḣ         - pop first character       n
 Øa       - lowercase alphabet        abcdefghijklmnopqrstuvwxyz
   ṣ      - split list                abcdefghijklm opqrstuvwxyz
    U1¦   - reverse first element     mlkjihgfedcba opqrstuvwxyz
       =  - equate with string        mlkjihgfedcba opqrstuvwxyz
                                    = ature         ature
                                   -> 00000hgfedcba 00010tuvwxyz
ṫJÇ€Fċ1   - main monadic link, e.g. nature
 J        - range                   1 2 3 4 5 6
ṫ         - tail; remove n-1 chars  nature ature ture ure re e
  Ç€      - map previous link       00000hgfedcba 00010tuvwxyz ...
    F     - flatten                 00000hgfedcba 00010tuvwxyz ...
     ċ1   - count 1s                4
```
[Answer]
# Python 2, 91 chars
```
lambda i:sum(y-x==abs(ord(i[y])-ord(i[x]))for x in range(len(i))for y in range(x+1,len(i)))
```
[Answer]
## MATLAB, 84 bytes
```
s=input('');disp(sum(diff(nchoosek(find(s),2),[],2)==abs(diff(nchoosek(s,2),[],2))))
```
This line asks for a string as input. It then creates all possible pairs of letters and does the same for their corresponding indices. Then we determine whether the (absolute) difference of the values matches to finally sum all cases where it does. The result is displayed in the command window.
[Answer]
# JavaScript ES7, 93
Using *array comprehension*. ES6 with `.map.map.map` is 2 bytes longer.
Test running the snippet below with Firefox
```
f=s=>[for(x of s)x.charCodeAt()].map((a,i,s)=>s.map((b,j)=>t+=j>i&(b>a?b-a:a-b)==j-i),t=0)&&t
document.write('nature'+'\n'+f('nature'))
```
[Answer]
## PowerShell, ~~114~~ 100 Bytes
```
param($a)$b=$a.length;0..($b-1)|%{$i=$_;($_+1)..$b|%{$o+=[math]::Abs(+$a[$_]-$a[$i])-eq($_-$i)}};+$o
```
Pretty straight-forward, but uses a couple tricks.
* `param(..)` takes our input, saves it to `$a`.
* We set a temp variable `$b` to be the `.length` of our input. This saves a byte later.
* `0..($b-1)|%{..}` is the equivalent of a `for($i=0;$i-le($b-1);$i++){..}` loop, but quite a lot shorter.
* However, we need to set variable `$i` in order to keep that going into ...
* `($_+1)..$b|%{..}` the next `for` loop, since `$_` is only positional to the inner loop.
* We then use a lengthy .NET call to check if the absolute value between our two characters (here we use implicit casting with prepending `+` to save a bunch of bytes) is `-eq`ual to the positional difference in the array. Since we're explicitly given lowercase input, we don't need to do case conversion. This statement will return either `True` or `False`.
* We blatantly abuse implicit casting again to accumulate that result into `$o`, so `True` will add 1, while `False` will add 0.
* Once the loops are finished, we output `$o`. Note we need to do the same tricksy-cast-to-int with `+` to avoid printing `False` if there were no matches.
[Answer]
# Ruby, 74
```
 ->s{[*0...s.size].permutation(2).count{|i,j|(s[i].ord-s[j].ord).abs==j-i}}
```
Nothing super interesting here. I would have loved to use `eval("s[i].#{["succ"]*(j-i)*?.}")` but... seemed too long.
[Answer]
## Matlab~~(94)~~(80)
> 
> Edit: I didnt take in case inversed alphabetic order,as (t,r) in 'nature', so more bytes to upweight :(
> 
> 
> 
```
@(a)sum(arrayfun(@(x)sum(1:nnz(find(a==fix(x/2)+(-1)^x*(1:1:nnz(a))))-1),2:244))
```
---
* ~~binomial function throws a stupid exception when k is bigger than n and I cant catch exceptions inside `arraycell` function, otherwise I could golf it more.~~ **Who needs a built in function ??** 
Now I could just do it by hand, simplifying
binomial(n,2)=n/(2(n-2)!)=n(n-1)/2. remark that this last value
reprensents sum of integers from 1 to n-1, this doesnt throw any
exception in matlab, God bless maths.
* Ps: this method is diferent than slvrbld's
## Execution
```
  >> ans('abef')
  ans =
       2
  >> ans('abcd')
  ans =
       6
  >> ans('nature')
  ans =
       4
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
ONƬ_JLƙ€c2SS
```
[Try it online!](https://tio.run/##y0rNyan8/9/f79iaeC@fYzMfNa1JNgoO/n@4HciK/P9fKS@xpLQoVUlHQSkxKRlMJSeBqPL8ohQwFwyUAA "Jelly – Try It Online")
Got too caught up in figuring out the best way to do this with `Ẇ` and forgot to post an answer at all, but now that I've remembered I think I might leave that as an exercise to @cjquines ;)
]