Template for Google Hash Code
to make it easier to deploy an incremental approach
solve.pyshould implement the function
solvethat takes the input as a string and returns an answer as a string.
score.pyshould implement a function
scorethat takes the input as
solvegot, and what
solvereturned, and then scores the submission. You should return the score as an integer.
main.pyreads the config files
main.cfgand then the argmuent applied config file, in that order, overwriting config-elements if the file exists. It then runs the scorer and solver that are specified. If you get a higher score than before on a test case the submission is saved in the
submissionfolder, and the
Run a testinstance on the format
in/$testcase.in with your own solver by:
python main.py $testcase, given that you have implemented the functions
score.py. If you want to name your files, solve and score-functions differently the module and function-names in the config-file
default.cfg can be modified, or set directly by arguments. For example if you want to run the pizza-solution, which has
score functions implemented in the module
python main.py -c pizza.cfg in/exaple_pizza.in or manually
python main.py --score module=pizza --solve module=pizza in/example_pizza.in
main.py will handle file-io, save the solution that gets maximal score to the
submission-folder, set up logging, set up randomization, etc.
How my team uses this:
We start by implementing a solver and a scorer in parallel. Usually we try to make a very dumb solver to have a baseline for improvements. After we have a system working were we get a score and the judge system reports the same score we continue on 2 or three different solvers that do things differently. Usually we opt for different greedy approaches that sort of different reasonable weight funtions.
A good idea is also to create an improver that you can apply after any solver. However it depends on the problem if there exists a reasonable improver. For the pizza problem there exists an improver that expands all the small pizza pieces, which usually gives quite a few extra points, depending on your solution.
Nice to have for the competition:
pypy2faster execution, because of JiT compilation to C
brew install pypy
sudo apt-get install pypy
sortedcontainerssorted datastructures for greedy approaches:
pypy -m pip install sortedcontainers