EX_03/level-2/permutations
2025-10-05 17:10:55 +01:00
..
Makefile added level-1 2025-09-23 08:41:21 +01:00
permutation_clean.c added better permutations 2025-09-30 17:59:58 +00:00
permutations.c Added permutations and powerset 2025-09-30 13:13:09 +00:00
README.md Edited README's, added broken_gnl exercise, LICENSE and main README 2025-10-05 17:10:55 +01:00
subject.txt added level-1 2025-09-23 08:41:21 +01:00

Permutations

What is a Permutation?

Imagine you have some letters, like the letters in your name. A permutation is just a fancy word for "all the different ways you can arrange those letters."

Think of it like this:

  • If you have the letters A and B, you can arrange them as AB or BA
  • If you have A, B, and C, you can make ABC, ACB, BAC, BCA, CAB, CBA

It's like having alphabet blocks and seeing how many different words you can spell by changing the order!

The Challenge

Your mission is to write a program that:

  1. Takes a word (like "abc")
  2. Shows ALL possible ways to rearrange the letters
  3. Shows them in alphabetical order (like in a dictionary)

Real Examples

Let's see what our program does:

Example 1: Single Letter

./permutations a

Output: a

Why? There's only one letter, so there's only one way to arrange it!

Example 2: Two Letters

./permutations ab

Output:

ab
ba

Why? We can put 'a' first or 'b' first. That's it!

Example 3: Three Letters

./permutations abc

Output:

abc
acb
bac
bca
cab
cba