Note: I didn't have enough time to finish the "output" part so I am just printing a counter.
- will determine what are our deliverables here(a script or a library or a service). Provide an interface according to requirements(should the script read a file or should the library work with the string?).
- will try to think about the edge cases. For example: I treat '2d' as word but it's not a word in your original example. The other possible edge case is a huge file. I am saying "possible" because performance and "size of input" are not issues sometimes. Test it with a different sets of data(ideally provide automated tests)
- check that code satisfies all the "code" specific to the company/team(naming conventions, style, documentation etc)