Your question is Word Count on Large Files. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given 1TB of a file, how to check the word count using any language?
Implement count_words(chunks), where chunks is a list of string fragments read sequentially from the file. Return the number of whitespace-delimited words without loading the entire file into memory. A word may span multiple non-empty chunks, while whitespace and empty chunks end the current word.
0 <= len(chunks)isspace() returns True.def count_words(chunks):