Conversation
Notices
-
I'm having a brain block; I need the quickest way to split the text in a file into groups of 10 letters. !bash !python
-
@ajpaulson /usr/bin/split -b10
-
@samatjain thank you! I didn't even know that existed! I owe you some internet points
-
now I just need to get it all back into one file with spaces at each split
-
@samatjain nevermind, using sed (motherfuckers act like they forgot about sed)
-
@ajpaulson ten = []; while text: ten.append(text[:10]); text = text[10:]
-
@ajpaulson but that’s off the question! (mock-angry :) ) sure, sed is shorter :)
-
@arnebab true, I specified bash and python and used neither :p sometimes you gotta break the rules
-
@arnebab Shorter and more efficient: ten = [text[i:i+10] for i in xrange(0, len(text), 10)]
-
@bj that’s nice! thanks! … 140 letter algorithms :)
-