Skip to main content
added 406 characters in body
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 112112 81 bytes

f(s->,n=endof,l="$(x=[sumn(i->i==10,s))",endofg=r->lpad(n(split(s,r"\s",keep=1<0)r),sizeof(s)];join(map(i->lpad(i1,maximumn(ndigits,xl)),x),=g(r"\n")" ")"g(r"\S+")" "l

This is an anonymousa function that accepts a string and returns a string. To call it

We save the following as function arguments:

  • n = endof function, which gets the last index of an indexable collection (in this case is the length of the string)
  • l = "$(n(s)), the length of the input converted to a string using interpolation
  • A lambda function g that accepts a regular expression and returns the length - 1 of the input split on that regex, left padded with spaces to match the length of l.

We get the number of lines using g(r"\n") and the number of words using g(r"\S+"), assign it to a variablethen we join those together with l delimited by spaces.

My internet went out right before I was goingSaved 31 bytes thanks to post this so I'm posting from mobile. I'll add an explanation once my internet comes back. :/Dennis!

Julia, 112 bytes

s->(x=[sum(i->i==10,s),endof(split(s,r"\s",keep=1<0)),sizeof(s)];join(map(i->lpad(i,maximum(ndigits,x)),x)," "))

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

My internet went out right before I was going to post this so I'm posting from mobile. I'll add an explanation once my internet comes back. :/

Julia, 112 81 bytes

f(s,n=endof,l="$(n(s))",g=r->lpad(n(split(s,r))-1,n(l)))=g(r"\n")" "g(r"\S+")" "l

This is a function that accepts a string and returns a string.

We save the following as function arguments:

  • n = endof function, which gets the last index of an indexable collection (in this case is the length of the string)
  • l = "$(n(s)), the length of the input converted to a string using interpolation
  • A lambda function g that accepts a regular expression and returns the length - 1 of the input split on that regex, left padded with spaces to match the length of l.

We get the number of lines using g(r"\n") and the number of words using g(r"\S+"), then we join those together with l delimited by spaces.

Saved 31 bytes thanks to Dennis!

Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 112 bytes

s->(x=[sum(i->i==10,s),endof(split(s,r"\s",keep=1<0)),sizeof(s)];join(map(i->lpad(i,maximum(ndigits,x)),x)," "))

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

My internet went out right before I was going to post this so I'm posting from mobile. I'll add an explanation once my internet comes back. :/