Bikarhêner:/Şêr/kombînasyon.py

# -*- coding: utf-8 -*-

def generate_combinations(characters, length, max_consecutive_consonants=2):
    def has_too_many_consecutive_consonants(combination):
        consecutive_consonants = 0
        max_consecutive_consonants_found = 0
        for char in combination:
            if char not in 'aeiou':
                consecutive_consonants += 1
                if consecutive_consonants > max_consecutive_consonants_found:
                    max_consecutive_consonants_found = consecutive_consonants
            else:
                consecutive_consonants = 0

        return max_consecutive_consonants_found > max_consecutive_consonants

    def has_too_many_initial_consonants(combination):
        initial_consonants = 0
        for char in combination:
            if char not in 'aeiou':
                initial_consonants += 1
                if initial_consonants > 2: 
                    return True
            else:
                break  
        return False

    def has_too_many_consecutive_vowels(combination):
        consecutive_vowels = 0
        for char in combination:
            if char in 'aeiou':
                consecutive_vowels += 1
                if consecutive_vowels > 1:
                    return True
            else:
                consecutive_vowels = 0

        return False

    if length == 0:
        return ['']
    else:
        smaller_combinations = generate_combinations(characters, length - 1, max_consecutive_consonants)
        result = []

        for char in characters:
            for smaller in smaller_combinations:
                current_combination = char + smaller
                if not has_too_many_initial_consonants(current_combination) and \
                   not has_too_many_consecutive_consonants(current_combination) and \
                   not has_too_many_consecutive_vowels(current_combination):
                    result.append(current_combination)

        return result

def generate_all_combinations(characters, max_length):
    all_combinations = []
    for length in range(1, max_length + 1):
        all_combinations.extend(generate_combinations(characters, length))
    return all_combinations

characters = 'abcçdeêfghiîjklmnopqrsştuûvwxyz'
max_length = 3
result = generate_all_combinations(characters, max_length)
with open('combinations_output.txt', 'w', encoding='utf-8') as file:
    for combination in result:
        file.write(combination + '\n')