3 ms·
`set` is a built-in. He probably didn't want to smash it. Defining a function and immediately calling it prevents pollution of module scope. Without it, `photo
by gary_bernhardt 9y ago
`set` is a built-in. He probably didn't want to smash it.
Defining a function and immediately calling it prevents pollution of module scope. Without it, `photo` would be exported.
The tests are in the same file because it makes the example self-contained, I assume.
The experiments are run 100,000 times because they have a random component and this exercises the system.
- dfee 9y agoPlease re-read my comment. I understand what he did, but my points stand. The name `SET` conveys little. Running the exercise in the same file is OK as it’s not in a module, but again - the work demonstrates algorithms well enough, but I can’t see this coding style as “smart” or “clean”. It’s not.
- gary_bernhardt 9y agoTop of the file: """ Game of Set (Peter Norvig 2010-2015) """ It's the name of the problem being solved.
- dfee 9y agoYeah, `game.py` would've been great!