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.
rjjjnfffr
? Would that be one pair (nr
) or two pairs (nr
andrn
)? And what aboutabzab
? Is that two pairs ofab
or one? \$\endgroup\$