{"id":22012438,"url":"https://github.com/nikitaeverywhere/google-hash-code-2017-task","last_synced_at":"2025-07-14T03:09:23.071Z","repository":{"id":69125216,"uuid":"81690331","full_name":"nikitaeverywhere/google-hash-code-2017-task","owner":"nikitaeverywhere","description":"The qualification task for Google Hash Code 2017","archived":false,"fork":false,"pushed_at":"2018-02-25T15:44:37.000Z","size":853,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T08:16:04.570Z","etag":null,"topics":["algorithms","google","google-hash-code","google-hashcode","practical-tasks"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikitaeverywhere.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-11T23:40:01.000Z","updated_at":"2018-02-23T09:13:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"feb75148-8a33-4a16-9315-f97c6976466f","html_url":"https://github.com/nikitaeverywhere/google-hash-code-2017-task","commit_stats":null,"previous_names":["nikitaeverywhere/google-hash-code-2017-task"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikitaeverywhere/google-hash-code-2017-task","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaeverywhere%2Fgoogle-hash-code-2017-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaeverywhere%2Fgoogle-hash-code-2017-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaeverywhere%2Fgoogle-hash-code-2017-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaeverywhere%2Fgoogle-hash-code-2017-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikitaeverywhere","download_url":"https://codeload.github.com/nikitaeverywhere/google-hash-code-2017-task/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaeverywhere%2Fgoogle-hash-code-2017-task/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265236956,"owners_count":23732504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","google","google-hash-code","google-hashcode","practical-tasks"],"created_at":"2024-11-30T03:12:49.864Z","updated_at":"2025-07-14T03:09:23.043Z","avatar_url":"https://github.com/nikitaeverywhere.png","language":"JavaScript","readme":"# Google Hash Code 2017 Pizza Task \n\nThis is the solution for [Google Hash Code 2017](https://hashcode.withgoogle.com) practice task. The PDF with problem statement: [/pizza.pdf](https://github.com/ZitRos/google-hash-code-2017-task/blob/master/pizza.pdf).\n\nAverage results of this solution:\n\n+ 871136/1000000 on big data set\n+ 47997/50000 on medium data set\n+ 41/42 on small data set\n\nTotal average score is **919174**. The algorithm has randomization factor, so\nrunning it multiple times may yield **even better** results.\n\n### Algorithm\n\nThe algorithm to solve this task is following:\n\n1. Find all possible variants for each cell of the pizza. This will form 3-dimensional array `[x][y][variant]` with each value of available slice to cut `[x, y, width, height]`.\n2. Starting from the random cell in pizza (preferably picked up from ones which have the minimum variants available), find the slice of all available slices for this cell which has the minimum [weight](https://github.com/ZitRos/google-hash-code-2017-task/blob/da8916d289f832d084b27805885adad85b532a4f/app/slicer.js#L122). In short, the weight function calculates the number, which reflects the importance of the slice we are going to cut out. The most important slices are those ones which leave less available variants around the slice than others after being cut. The more slice is important, the bigger weight it has.\n3. Once the slice is cut, remove all its variants from variants array (this will also remove some of the variants from adjacent cells).\n4. Continue cutting slices until all the variants are processed.\n\n### How to Run\n\nYou need [Git](https://git-scm.com) and [NodeJS v6+](https://nodejs.org/uk/) installed to be in. After cloning the project with the next commands:\n\n```bash\ngit clone https://github.com/ZitRos/google-hash-code-2017-task.git\ncd google-hash-code-2017-task\n```\n\nExecute the Node program on [input files](https://github.com/ZitRos/google-hash-code-2017-task/tree/master/input) with the following command:\n\n```bash\nnode index input/small.in\n```\n\nThe last command-line parameter is the file name to process. The output will go to the `output` directory.\n\n### Example\n\nRunning slicer on the medium dataset.\n\n```bash\nParsing input/medium.in file...\nData read and parsed in 99ms\n100%\nLayers computed in 1947ms\nMaximum number of layers: 182, min variant pieces (except 0): 1\nOutput html file saved in 107ms\n100%\nSolution found in 14651ms\nSolution score: 48077/50000\n```\n\nThe results may vary each time as algorithm features randomization.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitaeverywhere%2Fgoogle-hash-code-2017-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikitaeverywhere%2Fgoogle-hash-code-2017-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitaeverywhere%2Fgoogle-hash-code-2017-task/lists"}