-
Notifications
You must be signed in to change notification settings - Fork 8
Heuristic approach for pizza cutting
seajer edited this page Jan 22, 2017
·
4 revisions
- Read file and transform it to out pizza (
List<Cell>
pizza). - While we read file, founding Сells, which ingradien is minority.
Second step : generate all available methods for pizza cuting (using data from file about max cells in one sliece)
- now we shoud hawe bunch of methods:
- We have minimum one minority ingradient in all available positions and from one to (max - 1) other ingradients in all other pisitions.
- Methods shoud return from 2 to max Cells in slice.
- For 6 cells in piece we shoud have 60 variants of difference slices.
- Start brute forcing for get all variants of slices with start in minor ingradient cell.
- Found first minority ingradient.
- Use it as start for geting slice.
- Check if method, that we gona use are available (did we have enough cells?).
- If prevoius condition are true - go next, else - use next method.
- Cut slice from pizza.
- Continue until pizza have at least one minority ingradient.
- We have
List<List<List<Cell>>>
- it's means that we hawe all variants of transposal all available variants for cutting pizza. - For each variant checks cells that left in main pizza and wasn't cutted.
- Found variant with minimun cells in pizza (in ideal it shoud be zero value).
- Mark this variant as optimal and get his
List<List<Cells>>
. - Use founded
List<List<Cell>>
as base object for output file formater. - Enjoy your work.
This algoritm shoud be optimized in future.