fork download
  1. from itertools import permutations
  2.  
  3. list1_words = [
  4. "APPEASE",
  5. "DENSITY",
  6. "MAURITIUS",
  7. "OUTRAGEOUS",
  8. "QUIETLY",
  9. "UNIQUENESS",
  10. "VOLLEYBALL"
  11. ]
  12.  
  13. list2_words = [
  14. "BELGRADE",
  15. "CHERRY",
  16. "FANTASTIC",
  17. "KEVLAR",
  18. "LITERATURE",
  19. "REFLECTION",
  20. "SURPRISE",
  21. "TSUNAMI"
  22. ]
  23.  
  24. vowels = set("AEIOU")
  25.  
  26. lets = "US"
  27. st1 = "FRAUDAMATEUR"
  28. st2 = "PRISTINE"
  29. def same_type(c1, c2):
  30. return (c1 in vowels and c2 in vowels) or (c1 not in vowels and c2 not in vowels)
  31.  
  32. def evaluate_order(order1, order2):
  33. counter = 0
  34. different_type_letters = []
  35.  
  36. for (a, b) in zip(concat1, concat2):
  37. if not same_type(a, b):
  38. different_type_letters.append(a + b)
  39. counter += 1
  40. if counter > 9:
  41. return []
  42.  
  43. return different_type_letters
  44.  
  45. for perm1 in permutations(list1_words):
  46. for perm2 in permutations(list2_words):
  47. concat1 = ''.join(perm1)
  48. concat2 = ''.join(perm2)
  49. full1 = st1 + concat1
  50. full2 = st2 + concat2
  51.  
  52. mismatches = evaluate_order(full1, full2)
  53. if mismatches:
  54. print(mismatches)
  55.  
  56.  
  57.  
Success #stdin #stdout 0.03s 25684KB
stdin
Standard input is empty
stdout
from itertools import permutations

list1_words = [
    "APPEASE",
    "DENSITY",
    "MAURITIUS",
    "OUTRAGEOUS",
    "QUIETLY",
    "UNIQUENESS",
    "VOLLEYBALL"
]

list2_words = [
    "BELGRADE",
    "CHERRY",
    "FANTASTIC",
    "KEVLAR",
    "LITERATURE",
    "REFLECTION",
    "SURPRISE",
    "TSUNAMI"
]

vowels = set("AEIOU")

lets = "US"
st1 = "FRAUDAMATEUR"
st2 = "PRISTINE"
def same_type(c1, c2):
    return (c1 in vowels and c2 in vowels) or (c1 not in vowels and c2 not in vowels)

def evaluate_order(order1, order2):
    counter = 0
    different_type_letters = []

    for (a, b) in zip(concat1, concat2):
        if not same_type(a, b):
            different_type_letters.append(a + b)
            counter += 1
        if counter > 9:
            return []

    return different_type_letters

for perm1 in permutations(list1_words):
    for perm2 in permutations(list2_words):
        concat1 = ''.join(perm1)
        concat2 = ''.join(perm2)
        full1 = st1 + concat1
        full2 = st2 + concat2

        mismatches = evaluate_order(full1, full2)
        if mismatches:
            print(mismatches)