젤리 , 5 바이트
n2\׿
온라인으로 사용해보십시오!
작동 원리
n2\׿ Main link. Argument: s (string)
n2\ Reduce all overlapping slices of length two by non-equal.
For input "doorbell", this returns [1, 0, 1, 1, 1, 1, 0].
× Multiply the characters of s by the Booleans in the resulting array. This is
essentially a bug, but integer-by-string multiplication works as in Python.
For input "doorbell", this returns ['d', '', 'o', 'r', 'b', 'e', '', 'l'].
Note that the last character is always left unchanged, as the Boolean array
has one fewer element than s.
ż Zip the result with s, yielding an array of pairs.
For input "doorbell", this returns [['d', 'd'], [[], 'o'], ['o', 'o'],
['r', 'r'], ['b', 'b'], ['e', 'e'], [[], 'l'], ['l', 'l']].
(implicit) Print the flattened result.