Apr-12-2020, 06:05 PM
Hello Guys,
I have a issue with this problem :
nbEleveEcole : number of students in the school. First input
nbClasse : number of classes. Second input
Your program must determine a distribution of students in classes such that the enrollment of two separate classes differs by at most 1. It will display the enrollment of each of the classes, starting with the most heavily loaded classes.
Example
Input :
39
6
Output :
7
7
7
6
6
6
Here is my code :
./répartition_des_classes.py
36
6
6
6
6
6
6
6
If I test with 39 and 6, my second if does not work properly, I don't know why. It returns me 7 six time instead of 3 times.
./répartition_des_classes.py
39
6
7
7
7
7
7
7
Does anyone have an idea of the error please ?
I have a issue with this problem :
nbEleveEcole : number of students in the school. First input
nbClasse : number of classes. Second input
Your program must determine a distribution of students in classes such that the enrollment of two separate classes differs by at most 1. It will display the enrollment of each of the classes, starting with the most heavily loaded classes.
Example
Input :
39
6
Output :
7
7
7
6
6
6
Here is my code :
nbEleveEcole = int(input()) nbClasse = int(input()) for i in range(nbClasse): if nbEleveEcole % nbClasse == 0: nbEleve = nbEleveEcole // nbClasse print(nbEleve) if nbEleveEcole % nbClasse != 0: nbEleve = nbEleveEcole // nbClasse reste = nbEleveEcole % nbClasse if reste != 0: nbEleve = nbEleve + 1 reste = reste - 1 print(nbEleve)If I test with 36 and 6, my first if is working
./répartition_des_classes.py
36
6
6
6
6
6
6
6
If I test with 39 and 6, my second if does not work properly, I don't know why. It returns me 7 six time instead of 3 times.
./répartition_des_classes.py
39
6
7
7
7
7
7
7
Does anyone have an idea of the error please ?