Timeline for python encoder and decoder
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 27, 2013 at 17:14 | vote | accept | John Ward | ||
| Jan 27, 2013 at 2:44 | comment | added | jfs |
+1: to offset the underserved downvote and for the decode()
|
|
| Jan 26, 2013 at 18:44 | comment | added | pyrrrat | @DSM I like the solution using groupby for the encoder, I was not aware of that function. For the decoder though, the one we were arguing about, I still think re.findall is perfectly suitable. I can't think of a nearly as readable solution using groupby. | |
| Jan 26, 2013 at 17:50 | comment | added | DSM |
@pyrrrat: there's a one-line groupby solution (two lines going the other way, although I guess I could pack it into one if I had to).
|
|
| Jan 26, 2013 at 17:44 | comment | added | pyrrrat | What's the alternative? Going through the string character by character, essentially building your own little parser? I would agree with you if the count could only be single digit, but clearly it can be of arbitrary length so you would have to parse it somehow. | |
| Jan 26, 2013 at 17:36 | history | edited | pyrrrat | CC BY-SA 3.0 |
more detailed explanation
|
| Jan 26, 2013 at 17:35 | comment | added | freakish | Yeah, I guess you're right about digits. As for regular expressions: I just find it a bit overkill in this scenario, especially if we exclude digits in input. | |
| Jan 26, 2013 at 17:30 | comment | added | pyrrrat | First of all the input could hardly contain digits to get that kind of output, otherwise you would need some sort of separator between the letter and the letter count. Secondly, yes, regular expressions, they get the job done – use your tools. And finally: thanks for clearing that up, I'll try to do better in the future. | |
| Jan 26, 2013 at 17:25 | comment | added | freakish | -1: First of all it assumes that input does not contain digits. Secondly: regular expressions? Seriously? And finally: giving solutions to such questions is an antistackoverflow behaviour. | |
| Jan 26, 2013 at 17:22 | history | answered | pyrrrat | CC BY-SA 3.0 |