The simple template to excel on Google Hashcode Competition
If you ever competed in the Google Hashcode Coding Competition, you already know the answer.
You have a few hours to solve the problem and nothing sucks more than starting late because your environment isn't set off. ๐ญ
This repository is here for you. ๐ผ
You can create the:
- file reader/writer,
- scorer,
- data model
in minutes, using the remaining time only to find the top class algorithm that will make you excel in the competition! ๐
... is as simple as
npm install
- Define your input data model populating the Input type on src/parser.ts:
export type Input = {}
- Write the input parser on src/parser.ts
const parse = (file : string) : Input => { const data = fs.readFileSync(file, 'ascii') //TODO: transform 'data' to the input dataset according to the problem specs return {} }
- Define your output data model populating the Solution type on src/solver.ts:
export type Solution = {}
- Write the output serializer on src/writer.ts
const write = (solution : Solution, file : string) => { const data : string = "test+" //TODO: map the solution to the output file according to the specs of the problem fs.writeFileSync(file, data) }
- Write your solution on src/solver.ts
const solve = (dataset : Input) : Solution => { //TODO: provide the best fucking solution in order to beat the competition return {} }
- Write the scorer for a solution on src/scorer.ts
const score = (input : Input, solution : Solution) => { //TODO: compute the score for the solution according to the problem specs return 1 }
- Put your test cases as
.in
files on inputs folder - Run your program with:
npm run start
- That's it! You will find:
- on outputs/: the output files as
.out
files; - on scores/ the scores of the solutions as
.score
files.
- on outputs/: the output files as
NB: The script saves, for every input file, the solution only if the computed score is greater or equal than the saved on for that file.
- Clone this repo
- Create a branch:
git checkout -b your-feature
- Make some changes
- Push your branch and open a Pull Request
This code is open source software licensed under the Apache 2.0 License.
Luigi Donadel - @luigidonadel - [email protected]
Project Link: https://github.com/donadev/hashcode_starter