#!/usr/bin/env python3 # Read the data from the text file def read_data(file_name): data = {} with open(file_name, 'r') as file: lines = file.readlines() section = '' for line in lines: if line.strip(): if line.startswith('MASK'): section = 'MASK' data[section] = {} elif line.startswith('GAUNTLETS'): section = 'GAUNTLETS' data[section] = {} elif line.startswith('CHEST'): section = 'CHEST' data[section] = {} elif line.startswith('LEG'): section = 'LEG' data[section] = {} else: values = line.strip().split('\t') measurement = values[0] data[section][measurement] = list(map(int, values[1:])) return data # Calculate the total stats for a combination of sets def calculate_stats(sets): stats = {'Mobility': 0, 'Resilience': 0, 'Recovery': 0, 'Discipline': 0, 'Intellect': 0, 'Strength': 0} for section, set_number in sets.items(): for measurement, values in data[section].items(): stats[measurement] += values[set_number - 1] return stats # Find the best combinations of sets def find_best_combinations(data): combinations = [] for mask_set in range(1, len(data['MASK']['Mobility']) + 1): for gauntlets_set in range(1, len(data['GAUNTLETS']['Mobility']) + 1): for chest_set in range(1, len(data['CHEST']['Mobility']) + 1): for leg_set in range(1, len(data['LEG']['Mobility']) + 1): sets = { 'MASK': mask_set, 'GAUNTLETS': gauntlets_set, 'CHEST': chest_set, 'LEG': leg_set } stats = calculate_stats(sets) combinations.append((sets, stats)) # Sort the combinations based on the total stats combinations.sort(key=lambda x: sum(x[1].values()), reverse=True) return combinations[:5] # Main script data = read_data('data.txt') best_combinations = find_best_combinations(data) # Print the best combinations and their results for i, (sets, stats) in enumerate(best_combinations, 1): print(f'Combination {i}:') print(f'Sets: {sets}') print('Stats:') for measurement, value in stats.items(): print(f'{measurement}: {value}') print() input("Press enter to exit...")