Skip to main content
added 55 characters in body
Source Link
maple_shaft
  • 431
  • 3
  • 11

Haskell, 75 bytes 95 bytes 91 7979 61 bytes

b=(`notElem`['0'..'9'])
r=reverse
d#e|b$last$d=d++e|2>1=rd#e=r(snd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

UPDATE2: After some great feedback, more bytes were golfed!

Haskell, 75 bytes 95 bytes 91 79 bytes

b=(`notElem`['0'..'9'])
r=reverse
d#e|b$last$d=d++e|2>1=r(snd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

Haskell, 75 bytes 95 bytes 91 79 61 bytes

b=(`notElem`['0'..'9'])
r=reverse
d#e=r(snd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

UPDATE2: After some great feedback, more bytes were golfed!

deleted 6 characters in body
Source Link
maple_shaft
  • 431
  • 3
  • 11

Haskell, 75 bytes 95 bytes 9191 79 bytes

import Datab=(`notElem`['0'.Char
b=isDigit.'9'])
r=reverse
d#e|(not.b$last$d)=d++e|2>1=(r.dropWhiled#e|b$last$d=d++e|2>1=r(b)$r$dsnd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

Haskell, 75 bytes 95 bytes 91 bytes

import Data.Char
b=isDigit
r=reverse
d#e|(not.b$last$d)=d++e|2>1=(r.dropWhile(b)$r$d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

Haskell, 75 bytes 95 bytes 91 79 bytes

b=(`notElem`['0'..'9'])
r=reverse
d#e|b$last$d=d++e|2>1=r(snd$break b$r d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

added 12 characters in body
Source Link
maple_shaft
  • 431
  • 3
  • 11

Haskell, 75 bytes 9595 bytes 91 bytes

import Data.Char
b=not.isDigitb=isDigit
r=reverse
d#e|(not.b$last$d)=d++e|2>1=(r.dropWhile(not.b)$r$d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

Haskell, 75 bytes 95 bytes

import Data.Char
b=not.isDigit
r=reverse
d#e|(b$last$d)=d++e|2>1=(r.dropWhile(not.b)$r$d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

Haskell, 75 bytes 95 bytes 91 bytes

import Data.Char
b=isDigit
r=reverse
d#e|(not.b$last$d)=d++e|2>1=(r.dropWhile(b)$r$d)++e

I tried doing this without regex so maybe that would be a dramatically improved answer. Also there are a couple ways I could go about this so I am unsure if I can shave a few bytes with a different approach.

UPDATE: I went up in bytes because I realized I was failing the test case where numbers exist in the string that are not the suffix. Now I am sure that regex would provide a much better answer.

added 242 characters in body
Source Link
maple_shaft
  • 431
  • 3
  • 11
Loading
Source Link
maple_shaft
  • 431
  • 3
  • 11
Loading