aboutsummaryrefslogtreecommitdiff
path: root/challenge-154/paulo-custodio/python/ch-1.py
blob: 1b121593e605e855ebd871e0220edfa819158099 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3

# Challenge 154
#
# TASK #1 > Missing Permutation
# Submitted by: Mohammad S Anwar
# You are given possible permutations of the string 'PERL'.
#
# PELR, PREL, PERL, PRLE, PLER, PLRE, EPRL, EPLR, ERPL,
# ERLP, ELPR, ELRP, RPEL, RPLE, REPL, RELP, RLPE, RLEP,
# LPER, LPRE, LEPR, LRPE, LREP
# Write a script to find any permutations missing from the list.

from itertools import permutations

have = {
    "PELR", "PREL", "PERL", "PRLE", "PLER", "PLRE", "EPRL", "EPLR", "ERPL",
    "ERLP", "ELPR", "ELRP", "RPEL", "RPLE", "REPL", "RELP", "RLPE", "RLEP",
    "LPER", "LPRE", "LEPR", "LRPE", "LREP"
}

all_permutations = {''.join(p) for p in permutations("PERL")}
missing = sorted(set(all_permutations) - have)

print(", ".join(missing))