Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Latest commit

 

History

History
22 lines (14 loc) · 975 Bytes

PizzaPieces.md

File metadata and controls

22 lines (14 loc) · 975 Bytes

Back to README

Day #39: Pizza pieces

Description:

In her trip to Italy, Elizabeth Gilbert made it her duty to eat perfect pizza. One day, she ordered one for dinner. And then some Italian friends appeared at her room.

The problem is that there were many people who ask for a piece of pizza at that moment. And she had a knife that only cuts straight.

Given a number K (K<=45000), help her get the maximum of pieces possible (not necessarily of equal size) with K cuts. If K is a negative number, the result must be -1 (or Nothing in Haskell).

Examples

Pizza.maxPizza(0) == 1
Pizza.maxPizza(1) == 2
Pizza.maxPizza(3) == 7