Git Product home page Git Product logo

google-hash-code-2017-task's Introduction

Google Hash Code 2017 Pizza Task

This is the solution for Google Hash Code 2017 practice task. The PDF with problem statement: /pizza.pdf.

Average results of this solution:

  • 871136/1000000 on big data set
  • 47997/50000 on medium data set
  • 41/42 on small data set

Total average score is 919174. The algorithm has randomization factor, so running it multiple times may yield even better results.

Algorithm

The algorithm to solve this task is following:

  1. 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].
  2. 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. 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.
  3. Once the slice is cut, remove all its variants from variants array (this will also remove some of the variants from adjacent cells).
  4. Continue cutting slices until all the variants are processed.

How to Run

You need Git and NodeJS v6+ installed to be in. After cloning the project with the next commands:

git clone https://github.com/ZitRos/google-hash-code-2017-task.git
cd google-hash-code-2017-task

Execute the Node program on input files with the following command:

node index input/small.in

The last command-line parameter is the file name to process. The output will go to the output directory.

Example

Running slicer on the medium dataset.

Parsing input/medium.in file...
Data read and parsed in 99ms
100%
Layers computed in 1947ms
Maximum number of layers: 182, min variant pieces (except 0): 1
Output html file saved in 107ms
100%
Solution found in 14651ms
Solution score: 48077/50000

The results may vary each time as algorithm features randomization.

google-hash-code-2017-task's People

Contributors

nikitaeverywhere avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

kostyahrytsyuk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.