|
|
|
|
|
by dri_ft
3496 days ago
|
|
I slightly prefer the 'worse' solution for the second problem, at least in terms of substance, not necessarily style. The trick the 'improved' version does with uniq seems a little hacky to me, somehow. The first problem has a clear improvement. I just checked ruby doc and 'reduce' and 'inject' seem to be synonyms, as far as I can tell. |
|
> "#{x}#{input.split('').count(x)}"
Just because Ruby apparently allows you to do that much in a formatting directive doesn't mean you should.