Blog 2018/8/29 (imported from my work account gist on 2020/4/22)
<- previous | index | next ->
As part of a weekly programming puzzle, I implemented a bowling scoring system (in Python), plus a test script.
To run the tests:
$ chmod +x bowling.py test.py
$ mkdir tests
$ mv tests_* tests/
$ ./test.py
Note that test.py
actually expects the test JSON files to be in a directory called tests.
Note: you can re-use test.py
and the test cases for your own implementation.
Just edit the line which says exe = './bowling.py'
.
Design your implementation to accept a single command-line argument which is a JSON string describing the frames,
and output a JSON string which describes the (running total) frame scores.
To conveniently TDD your implementation,
run this in a terminal: while true; do sleep 1; clear; ./test.py; done
.
Each time you save your source file, check the terminal to see if the tests passed.