Re:Reddit is hiring. We're looking for 3 rockstar programmers.
by jedberg on Friday February 11, 2011 @12:14PM
(#2207179)
If you send it to me ([email protected]) I'll tell you how awesome you are. :)
[ Parent
| on HN ]
Re:Reddit is hiring. We're looking for 3 rockstar programmers.
by dpritchett on Friday February 11, 2011 @02:18PM
(#2207730)
Hey, this was actually easier and more fun than expected! I tried it out at the Python REPL and now I have a mostly-working implementation using os.path.getsize(), file.tell(), file.seek(), and file.readline(). The fun part is that I hadn't used the first three of those functions in Python before today. Layering a binary search on top of this looks as easy as
*REDACTED*
with some edge case checking and start-of-next-line seeking.I'd have thought there was more to this, but it seems pretty straightforward.
Lessons learned for me: Python standard library docs are great, repl development is great, and text files are fun.
Re:Reddit is hiring. We're looking for 3 rockstar programmers.
by e1ven on Friday February 11, 2011 @02:25PM
(#2207759)
I thought it would be fun to do it entirely using unix tools.
Sent it off using a recursive bash function, with du, dd, bc, and expr.
Re:Reddit is hiring. We're looking for 3 rockstar programmers.
by dpritchett on Friday February 11, 2011 @02:41PM
(#2207815)
Oh nice! I had thought about using a script to isolate a rough-but-inclusive range of bytes from inside the file and then piping that into grep, but your way is certainly purer and more fun.
edit And now I have a good reason to learn more about dd, du, and bc!