My solutions for Stripe's Capture the Flag. The resulting scores are here. Here is a brief description of how each solution works:
Simply using a Ruby set to store the dictionary is enough to clear this level. Lots of optimizations are possible - for e.g. loading an offline-generated dictionary index.
Modified the supplied miner script to fork a python script to do the hashing. The Python script (gitcoin-miner.py) uses the multiprocessing module to parallelize hashing.
Simply allowing one concurrent connection at a time from each unique IP address was good enough to block most elephants. This is an interesting problem but sadly I didn't have enough time to work on it!
I spent a fair amount of time trying different indexes to improve my score. However, the first two simple changes I made gave me the best score:
- Shard the index across the servers based on document id.
- Instead of reading files from disk at query time, build a line-based in memory index.
This was the most painful level to get working and there is a fair bunch of copy-paste code. These were the major changes:
- Integrate the goraft library by following the raftd reference implementation.
- Change the provide solution to use unix transport instead of http.
- Implement leader forwarding to route queries to the current leader.
- Use an in-memory sqlite for the database to speed up queries/updates.