Comment on Proof You Can Become a Better ProgrammerparentComments−CydeWeys9yI'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.−sirn9yAssuming 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".
Comments
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:
Just because Ruby apparently allows you to do that much in a formatting directive doesn't mean you should.
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".