← Practice problem bank

Jan 11, 2026

The Potion Mixing Mastery

Daily Challenge Archive · Open

easygreedy

100 pts · 10000 ms · 128 MB · Practice only

Problem

Welcome to the Alchemist's Guild, an ancient institution where your skills in potion-making will be honed and tested. As an aspiring master alchemist, your task is to create potent potions by selecting three distinct magical ingredients from a given list. Each combination of ingredients must be unique, and your goal is to calculate the total number of these unique combinations. Here's what you need to do: 1. Input a list of magical ingredients provided to you. 2. Identify all possible unique sets of three ingredients from this list. 3. Calculate the total number of these unique combinations. For example, if your list is ['Phoenix Feather', 'Dragon Scale', 'Unicorn Horn', 'Mermaid Tear'], you should calculate how many combinations can be made by selecting three out of the four ingredients. Remember, the order of ingredients doesn't matter, so ['Phoenix Feather', 'Dragon Scale', 'Unicorn Horn'] is the same as ['Unicorn Horn', 'Phoenix Feather', 'Dragon Scale']. Consider edge cases such as lists with fewer than three ingredients, where no combinations can be formed.

Hints
  • Approach: Think about how you can systematically generate combinations. A combination formula might be useful.
  • Algorithm: Consider using a programming language's built-in functions or libraries that handle combinations.
  • Edge Cases: What happens if there are fewer than three ingredients?
  • Optimization: Aim for a solution that efficiently handles larger lists without recalculating unnecessary combinations.

Input format

The first line contains an integer n, the number of magical ingredients. The second line contains n distinct strings, each representing an ingredient name.

Output format

Output a single integer, the number of unique three-ingredient combinations that can be formed.

Constraints

3 <= n <= 100

Sample input

5
EyeOfNewt DragonScale PhoenixFeather UnicornHorn MandrakeRoot

Sample output

10

Sign in to submit solutions

Run your code against all test cases and get instant feedback.

Sign in