affiche juste le code, pas d'explications !
- User
System: affiche juste le code, pas d'explications ! User: Tu es un développeur python3 expérimenté, et tu dois concevoir un programme en python (avec des commentaires en français, sans utiliser de librairies externes, sans
if __name__=="__main__":, avec type hints, et en privilégiant les algorythmes a complexité constante (O(1)) et/ou complexité linéaire (O(n))). Le programme va recevoir les données en entrée sur la stdin, et doit répondre sur la stdout. Fabrique moi un programme python qui résout le problème (énoncé en markdown) suivant :The best course
You are quickly making your mark in the Brigade. Since your exploits on climate change, you have been one of the most promising elements of the Order. But during your missions, you've noticed that a very powerful meta-human is moving faster than you, and anticipates certain disasters even better than the Brigade...
You don't tell your management yet, but you start your research on this mysterious and unknown benefactor of the Brigade. In your quest, you notice a strange pattern: it seems that he moves around minimizing his carbon footprint at all costs.
To begin your research, you decide to focus solely on the routes of the new underwater city, a flagship project to evaluate the possibility of building a city in space in the future.
In this underwater village of the future, each house is provided with x,y,z coordinates in 3 dimensions. To move from one house to another, we use an economical transport that follows a network of straight lines. Thus the distance between two points (x₁,y₁,z₁) and (x₂,y₂,z₂) is defined by the formula:
code|x₂-x₁| + |y₂-y₁| + |z₂-z₁|(the sum of the absolute values of the differences of each coordinate)
Find a route through the 8 houses in the village and back to its starting point that is as short as possible.
Data
Input
Line 1 to 8 : 3 integers x,y and z (between 0 and 10000) representing the coordinates of each house. Line 1 corresponds to house 0, until line 8 which corresponds to house 7.
Output
Line 1 A sequence of 8 integers (from 0 to 7) corresponding to the order in which the houses are located.
Example
For the input:
plaintext5 7 5 0 8 0 5 1 8 2 4 4 3 0 8 1 8 6 5 6 3 7 1 2The solution is :
plaintext0 5 1 3 4 2 7 6Here the total distance of the best solution is 54 = 6 (0 to 5) + 7 (5 to 1) + 10 (1 to 3) + 9 (3 to 4) + 3 (4 to 2) + 8 (2 to 7) + 8 (7 to 6) + 3 (6 to 0)
- Assistantpython