Skip to main content
added 247 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Retina, 4141 38 bytes

.*$
$*
!&`(.)+(?=.*¶(?<-1>.)+(?(1)(?!))$)

Try it online!Try it online!

Takes the string and count on separate lines. The first two lines are used to convert the count from decimal to unary, so if unary input is acceptable then the byte count would be reduced to 3434 31. Edit: Saved 3 bytes thanks to @FryAmTheEggman. Or, if you prefer, a 48-byte version that handles newlines in the string, although that does produce confusing output:

.*$
$*
!&`(\S|\s)+(?=[\S\s]*¶(?<-1>.)+(?(1)$.)$)

Retina, 41 bytes

.*$
$*
!&`(.)+(?=.*¶(?<-1>.)+(?(1)(?!))$)

Try it online!

Takes the string and count on separate lines. The first two lines are used to convert the count from decimal to unary, so if unary input is acceptable then the byte count would be reduced to 34.

Retina, 41 38 bytes

.*$
$*
!&`(.)+(?=.*¶(?<-1>.)+(?(1))$)

Try it online!

Takes the string and count on separate lines. The first two lines are used to convert the count from decimal to unary, so if unary input is acceptable then the byte count would be reduced to 34 31. Edit: Saved 3 bytes thanks to @FryAmTheEggman. Or, if you prefer, a 48-byte version that handles newlines in the string, although that does produce confusing output:

.*$
$*
!&`(\S|\s)+(?=[\S\s]*¶(?<-1>.)+(?(1)$.)$)
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Retina, 41 bytes

.*$
$*
!&`(.)+(?=.*¶(?<-1>.)+(?(1)(?!))$)

Try it online!

Takes the string and count on separate lines. The first two lines are used to convert the count from decimal to unary, so if unary input is acceptable then the byte count would be reduced to 34.