Skip to content

Instantly share code, notes, and snippets.

@szemate
Last active October 15, 2022 05:23
Show Gist options
  • Save szemate/537792a6cf39008d51192fc8a3034d9a to your computer and use it in GitHub Desktop.
Save szemate/537792a6cf39008d51192fc8a3034d9a to your computer and use it in GitHub Desktop.
Pizza Generator

Pizza Generator

A pizza place offers the following toppings:

  • ham
  • salami
  • mushroom
  • spinach
  • artichoke

Create a function that generates all types of pizza that they can bake from the 5 toppings and calculates the price of each type of pizza. The name of the pizza should be made up of the chosen toppings in alphabetical order like "artichoke, ham and mushroom" (with "and" before the last element).

The pricing is as follows:

  • pizza base: €8
  • ham: €2
  • salami: €3
  • mushroom: €1
  • spinach: €1
  • artichoke: €2

1.

Each pizza has 3 different toppings.

There should be 10 types of pizza.

Expected output (in alphabetical order):

artichoke, ham and mushroom - €13
artichoke, ham and salami - €15
artichoke, ham and spinach - €13
artichoke, mushroom and salami - €14
artichoke, mushroom and spinach - €12
artichoke, salami and spinach - €14
ham, mushroom and salami - €14
ham, mushroom and spinach - €12
ham, salami and spinach - €14
mushroom, salami and spinach - €13

2.

Each pizza has 3 toppings and any topping can be selected multiple times. If a topping is selected twice, it should be called "double". If a topping is selected three times, it should be called "triple". E.g. "double ham and spinach" instead of "ham, ham and spinach" and "triple ham" instead of "ham, ham and ham".

There should be 35 types of pizza.

Expected output (in alphabetical order):

artichoke and double ham - €14
artichoke and double mushroom - €12
artichoke and double salami - €16
artichoke and double spinach - €12
artichoke, ham and mushroom - €13
artichoke, ham and salami - €15
artichoke, ham and spinach - €13
artichoke, mushroom and salami - €14
artichoke, mushroom and spinach - €12
artichoke, salami and spinach - €14
double artichoke and ham - €14
double artichoke and mushroom - €13
double artichoke and salami - €15
double artichoke and spinach - €13
double ham and mushroom - €13
double ham and salami - €15
double ham and spinach - €13
double mushroom and salami - €13
double mushroom and spinach - €11
double salami and spinach - €15
ham and double mushroom - €12
ham and double salami - €16
ham and double spinach - €12
ham, mushroom and salami - €14
ham, mushroom and spinach - €12
ham, salami and spinach - €14
mushroom and double salami - €15
mushroom and double spinach - €11
mushroom, salami and spinach - €13
salami and double spinach - €13
triple artichoke - €14
triple ham - €14
triple mushroom - €11
triple salami - €17
triple spinach - €11

3.

A topping can only be selected once, but any number of toppings can be selected (at least one).

There should be 31 types of pizza.

Expected output (in alphabetical order):

artichoke - €10
artichoke and ham - €12
artichoke and mushroom - €11
artichoke and salami - €13
artichoke and spinach - €11
artichoke, ham and mushroom - €13
artichoke, ham and salami - €15
artichoke, ham and spinach - €13
artichoke, ham, mushroom and salami - €16
artichoke, ham, mushroom and spinach - €14
artichoke, ham, mushroom, salami and spinach - €17
artichoke, ham, salami and spinach - €16
artichoke, mushroom and salami - €14
artichoke, mushroom and spinach - €12
artichoke, mushroom, salami and spinach - €15
artichoke, salami and spinach - €14
ham - €10
ham and mushroom - €11
ham and salami - €13
ham and spinach - €11
ham, mushroom and salami - €14
ham, mushroom and spinach - €12
ham, mushroom, salami and spinach - €15
ham, salami and spinach - €14
mushroom - €9
mushroom and salami - €12
mushroom and spinach - €10
mushroom, salami and spinach - €13
salami - €11
salami and spinach - €12
spinach - €9

You can find a solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment