Skip to main content
Post Undeleted by Flonk
Code that's actually working.
Source Link
Flonk
  • 7.9k
  • 3
  • 24
  • 25

Haskell, 6680

I'm surprised that it isn't longer!

a%b|g$take ba%b|b<1=0-1|(\x->x==reverse a++dropx)$take(b+1b-1)a=b+1|1<2=a%a++b`drop`a=b|1<2=a%(b+1b-1) gf a=a==reversea=a%length a f=(%0) 

This will not terminate if the input can't be made into a palindrome, butCalled like this is okay, right?:

λ> f "racercar" 45 

Haskell, 66

I'm surprised that it isn't longer!

a%b|g$take b a++drop(b+1)a=b+1|1<2=a%(b+1) g a=a==reverse a f=(%0) 

This will not terminate if the input can't be made into a palindrome, but this is okay, right?

λ> f "racercar" 4 

Haskell, 80

a%b|b<1=0-1|(\x->x==reverse x)$take(b-1)a++b`drop`a=b|1<2=a%(b-1) f a=a%length a 

Called like this:

λ> f "racercar" 5 
Post Deleted by Flonk
Source Link
Flonk
  • 7.9k
  • 3
  • 24
  • 25

Haskell, 66

I'm surprised that it isn't longer!

a%b|g$take b a++drop(b+1)a=b+1|1<2=a%(b+1) g a=a==reverse a f=(%0) 

This will not terminate if the input can't be made into a palindrome, but this is okay, right?

λ> f "racercar" 4