A simple framework which can make writing solvers to Facebook Hackercup problems a bit easier.
To add a solver for a problem you should:
- Create a python file
problemname.py
somewhere in theproblems
directory with the following functions:solver
andfetcher
. The fetcher should have one input argument: an iterator of input file strings, it should read as many strings as required for one task for given problem, preformat it and return all the data needed. The solver gets the fetcher's output as input argument and should return the answer as a string or any object that can be formatted to a string. - Create a text file
input_problemname.txt
in theinput
directory as taken from the Hackercup problem site. - Run
python runner.py problemname
(it is possible to enterproblemname
in the command prompt). - See the result at
output/output_problemname.txt
The problemname
string in the text above is an identifier to a task and should match for a solver and a corresponding
input file.
A fetcher
function should not read more strings than it is required: iterators are not reversible.
To make a zip package containing all necessary scripts to solve the problem, launch python packager.py problemname
. The package will be put in the packages
directory.