"""Calculate resources koef""" def nth_root(num, root): """Calculte nth root""" answer = num ** (1/root) return answer def calc_resource_factor(resource_limit, koef_factor): """Calculate resource factor based on limit""" return pow(resource_limit * koef_factor / 10, 0.8) def calc_required_limit(koef, koef_factor): """Calculate amount of deep exploration points""" return (10 * nth_root(koef, 0.8)) / koef_factor def calc_deep_exploration(resource_limit, percentage, koef_factor, max_limit): """Calculate deep expo for resource""" initial_resource_factor = calc_resource_factor(resource_limit, koef_factor) new_resource_factor = initial_resource_factor * (percentage / 100 + 1) new_limit = calc_required_limit(new_resource_factor, koef_factor) if new_limit > max_limit: new_limit = max_limit new_resource_factor = calc_resource_factor(new_limit, koef_factor) percentage = 100 / initial_resource_factor * new_resource_factor - 100 print("{:5.2f} {:4.2f} {:4.2f} {:4.0f}".format( percentage, initial_resource_factor, new_resource_factor, new_limit - resource_limit )) if __name__ == "__main__": print("% old new deep") print('Noord-Nederland') calc_deep_exploration(379, 0, 0.4, 637) print('Oost-Nederland') calc_deep_exploration(359, 50, 0.4, 637) print('West-Nederland') calc_deep_exploration(372, 50, 0.4, 637) print('Zuid-Nederland') calc_deep_exploration(366, 50, 0.4, 637) print('Amsterdam') calc_deep_exploration(418, 45, 0.4, 637)