Skip to main content
added 1 character in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 7071 bytes

def f(s,i=1):n=s[:i-1]+s[i:];return(n==n[::-1])*i-i//len(i>len(s))or f(s,i+1) 

Try it online!Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 70 bytes

def f(s,i=1):n=s[:i-1]+s[i:];return(n==n[::-1])*i-i//len(s)or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 71 bytes

def f(s,i=1):n=s[:i-1]+s[i:];return(n==n[::-1])*i-(i>len(s))or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

added 7 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 6670 bytes

f=lambdadef f(s,i=1):i*(s[n=s[:i-1]==s[1]+s[i:i-len];return(s)%2n==n[::-1])*i-i//len(s)or f(s,i+1) 

Try it online!Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 66 bytes

f=lambda s,i=1:i*(s[:i-1]==s[:i-len(s)%2:-1])-i//len(s)or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 70 bytes

def f(s,i=1):n=s[:i-1]+s[i:];return(n==n[::-1])*i-i//len(s)or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

added 4 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 6766 bytes

f=lambda s,i=1:i*(s[:i-1]==s[:i-len(s)%2:-1])-(i>leni//len(s))or f(s,i+1) 

Try it online!Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 67 bytes

f=lambda s,i=1:i*(s[:i-1]==s[:i-len(s)%2:-1])-(i>len(s))or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

Python 3, 66 bytes

f=lambda s,i=1:i*(s[:i-1]==s[:i-len(s)%2:-1])-i//len(s)or f(s,i+1) 

Try it online!

Returns the 1-indexed character if the operation can be done and -1 otherwise.

added 4 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
added 24 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
edited body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
deleted 9 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading