Skip to main content
Saved 4 bytes, thanks to coltim.
Source Link
zgrep
  • 1.7k
  • 8
  • 9

k, 1717 13 bytes

-4 bytes thanks to coltim.

{`c$-1+x@&2=-':x*(`c$1+x)^x} 

Try it online!Try it online!

Explanation:

{  } /functiondef func(x) : # -':x should /createbe a list of differences/deltaschars 1+x 2= / above = /check[ord(c)+1 for equality with 2, result isc booleanin listx]   & (`c$ ) /get indices ofabove all 1s= [chr(there should only be onei)   for i in above]  x@ ^x /get letter at said index in our string -1+ result = [e for e in above if /goe backnot onein letterx]  `c$  * /cast to characterreturn result[0] 

k, 17 bytes

{`c$-1+x@&2=-':x} 

Try it online!

Explanation:

{  } /function(x)  -':x /create a list of differences/deltas 2= /check for equality with 2, result is boolean list   &  /get indices of all 1s (there should only be one)   x@ /get letter at said index in our string -1+  /go back one letter  `c$  /cast to character 

k, 17 13 bytes

-4 bytes thanks to coltim.

{*(`c$1+x)^x} 

Try it online!

Explanation:

{ } /def func(x): # x should be a list of chars 1+x / above = [ord(c)+1 for c in x] (`c$ ) / above = [chr(i) for i in above]  ^x / result = [e for e in above if e not in x] * / return result[0] 
Source Link
zgrep
  • 1.7k
  • 8
  • 9

k, 17 bytes

{`c$-1+x@&2=-':x} 

Try it online!

Explanation:

{ } /function(x) -':x /create a list of differences/deltas 2= /check for equality with 2, result is boolean list & /get indices of all 1s (there should only be one) x@ /get letter at said index in our string -1+ /go back one letter `c$ /cast to character