Sorting database text output
Sometimes it is nice to be able to quickly take column-formatted text output from the SQL command line and turn it into a list of useful data. In this case we want a unique, sorted list of the values from the second column combined into one comma-separated list. What is the fewest strokes you can do this in?
Start file
0 | 1 0 | 24 1 | 1 1 | 2 1 | 3 1 | 4 1 | 15 1 | 24 1 | 62 1 | 107 2 | 1 2 | 2 2 | 8 2 | 15 2 | 18 2 | 25 2 | 28 2 | 47 2 | 65 2 | 69 2 | 76 2 | 99 2 | 103 2 | 110 2 | 153 3 | 3 3 | 32 3 | 49 3 | 65 3 | 76 3 | 96 4 | 2
End file
1, 2, 3, 4, 8, 15, 18, 24, 25, 28, 32, 47, 49, 62, 65, 69, 76, 96, 99, 103, 107, 110, 153
View Diff
1,32c1 < 0 | 1 < 0 | 24 < 1 | 1 < 1 | 2 < 1 | 3 < 1 | 4 < 1 | 15 < 1 | 24 < 1 | 62 < 1 | 107 < 2 | 1 < 2 | 2 < 2 | 8 < 2 | 15 < 2 | 18 < 2 | 25 < 2 | 28 < 2 | 47 < 2 | 65 < 2 | 69 < 2 | 76 < 2 | 99 < 2 | 103 < 2 | 110 < 2 | 153 < 3 | 3 < 3 | 32 < 3 | 49 < 3 | 65 < 3 | 76 < 3 | 96 < 4 | 2 --- > 1, 2, 3, 4, 8, 15, 18, 24, 25, 28, 32, 47, 49, 62, 65, 69, 76, 96, 99, 103, 107, 110, 153
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 82 remaining solutions by signing in and submitting your own entry