Write Up Code Wars —
Permutations Solutions Python

Handhika Yanuar Pratama
1 min readAug 30, 2021

Code Wars is best platform for learning algorithm from programming language, here I want to write the solution for ‘Permutations’ challenge using Python. When it was written, the challenge is in kyu 4.

The Description

In this kata you have to create all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders.

Examples:

permutations('a'); # ['a']
permutations('ab'); # ['ab', 'ba']
permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']

The order of the permutations doesn’t matter.

The Answer

I’m really sorry for this, but I want to say, I don’t really get the answer by myself. My answer is here

My answer is based on Peter Liang solutions, after I trying to understand, the answer is based on multiple iterations inside the code. After I solve the answer, I got more great answer like this from rffrancon, sicknick323, temp lolololol

Also from Sebek, maxx_d2

I write this article because I want to share to the others how to solve this, this might be not true because I use another warrior answer. But I’m sorry for this, I will try my best next time. Thanks for reading.

--

--