News for hackers. Stuff that matters.
Re:Proof You Can Become a Better Programmer by dri_ft on Sunday November 27, 2016 @10:55AM (#13049745)
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.

Re:Proof You Can Become a Better Programmer by CydeWeys on Sunday November 27, 2016 @11:16AM (#13049869)
I've never done Ruby, but what I don't like about that second solution is how much logic it puts into formatting directives in a string literal:

> "#{x}#{input.split('').count(x)}"

Just because Ruby apparently allows you to do that much in a formatting directive doesn't mean you should.

Re:Proof You Can Become a Better Programmer by sirn on Sunday November 27, 2016 @12:13PM (#13050162)
Assuming this is a variant of RLE-style compression, the implementation is also wrong, if the input is `aabbcccddaa`, it will return "a4b2c3d2" instead of "a2b2cc3d2a2".