Skip to content

Google HashCode 2017, 2018 & 2019 practice problem: Pizza. Score: 959,202

License

Notifications You must be signed in to change notification settings

sagishporer/hashcode-practice-pizza

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hash Code 2017, 2018 & 2019 practice problem solution: Pizza

Problem definition & data files

Algorithm type: greedy.

  1. Scan the pizza for unsliced position.
  2. Find largest valid slice using this position. Grow from current position in all directions. Allow overslapping with existing slices, as long as the remaining part of the slice is valid after overlap.
  3. If valid slice found - clear all the ingredients contained in the slice & add slice. Update all overlapped slices.
  4. If scan not completed - go to 1.
  5. Rescan slices, retry growing the slices.

Solution score: 959,202

  • Example: 15
  • Small: 42
  • Medium: 49,576
  • Big: 909,569

Please ignore code style. The objective was to complete the task as fast as possible.

About

Google HashCode 2017, 2018 & 2019 practice problem: Pizza. Score: 959,202

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages