posté le 06/02/2008 à 16:32re : DEFI 200 : L'aérodrome Ader.


posté par : Cellix
Contenus : 3, 6, 10, 11, 15, 17, 23, 25, 30.
Soit e, le contenu en eau, l, le contenu en lait, et a, le contenu en alcool.
On a, d'après l'énoncé:
l = 2.a
e = 3.l = 3.2.a = 6.a
Soit un total de liquide de 9.a
Total du contenant : C = 3+6+10+11+15+17+23+25+30 = 140 L
Or, les récipients étant tous des entiers de litres, et étant entièrement remplis, a doit être un entier. Par conséquent, le total en L de liquide récupéré est un multiple de 9.
Le seul moyen, à supposer que les liquides ne sont pas mélangés, est que le récipient de 23L soit vide.
Cela nous fait un total de liquide de T = 117 L.
9.a = T, soit:
a = 13,
l = 26,
e = 78
On aboutit à une solution unique:
- Pour l'alcool : Récipients (en L) : 3 et 10,
- Pour le lait : Récipients (en L) : 11 et 15,
- Pour l'eau : Récipients (en L) : 6, 17, 35 et 30.
posté le 12/02/2008 à 15:492 bosses.
posté par : meak
Extraction des données de l'énoncé:
lait 2x L
eau 6x L
alcool x L
Donc la quantité transporté totale est un multiple de 6+2+1 = 9.
Or la somme des contenances fait 140 litres, qui vaut 5 modulo 9.
Le seau vide doit donc aussi avoir une contenance de 5litres modulo 9, i.e. la somme de ses chiffres vaut 5.
Donc c'est le seau 23 qui est vide.
Et il reste donc une contenance totale de 117 litres à partager:
Alcool : 13 Litres
Lait: 26 litres
eau: 78 litres
3, 6, 10, 11, 15, 17, 25, 30
Pour faire 13 litres d'alcool, il n'y a que la possibilité 3+10.
Il reste: 6, 11, 15, 17, 25, 30
Pour faire 26 litres de lait, on prend les seaux 11+15.
Les seaux restants 6+17+25+30 = 78 litres, on retombe sur nos pas!
Au final:
3 => alcool
6 => eau
10 => alcool
11 => lait de chamelle
15 => lait de chamelle
17 => eau
25 => eau
30 => eau
et le 23 est vide
posté le 18/02/2008 à 14:10Réponse
posté par : Tolokoban
Je propose cette solution :
- Bidon vide : 23 litres
- Bidons pleins d'eau : 6, 17, 25, 30
- Bidons pleins de lait : 11, 15
- Bidons pleins d'alcool : 3, 10
Le programme JAVA suivant donne la réponse en 1 seconde :
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
private final int[] bidons = {3, 6, 10, 11, 15, 17, 23, 25, 30};
public void process() {
List<Integer[]> candidats = new ArrayList<Integer[]>();
int contenanceTotale = 0;
for (int i=0 ; i<bidons.length ; i++) {
contenanceTotale += bidons[i];
}
System.out.println("Contenance totale : " + contenanceTotale);
for (int i=0 ; i<bidons.length ; i++) {
int contenance = contenanceTotale - bidons[i];
if (contenance % 9 == 0) {
System.out.println("Candidat pour être un bidon vide : " + bidons[i]);
Integer[] candidat = new Integer[bidons.length - 1];
int k = 0;
for (int j=0 ; j<bidons.length ; j++) {
if (i != j) {
candidat[k] = bidons[j];
k++;
}
}
candidats.add(candidat);
}
}
for (Integer[] candidat : candidats) {
findPossibleAlcoolList(candidat);
}
}
private void findPossibleAlcoolList(Integer[] candidat) {
int totalVolume = 0;
for (int i=0 ; i<candidat.length ; i++) {
totalVolume += candidat[i];
}
findPossibleAlcoolList(candidat, totalVolume, 0, new ArrayList<Integer>());
}
private void findPossibleAlcoolList(Integer[] candidat,
int totalVolume,
int firstIndex,
ArrayList<Integer> possibleList) {
int level = possibleList.size();
if (level > 0) {
int volume = 0;
for (Integer index : possibleList) {
volume += candidat[index.intValue()];
}
if (9*volume == totalVolume) {
System.out.print("Candidats pour l'alcool :");
for (Integer index : possibleList) {
System.out.print(" " + candidat[index.intValue()]);
}
System.out.println("");
findPossibleMilkList(candidat, possibleList);
return;
}
}
for (int i=firstIndex ; i<candidat.length ; i++) {
Integer index = new Integer(i);
possibleList.add(index);
findPossibleAlcoolList(candidat, totalVolume, i + 1, possibleList);
possibleList.remove(index);
}
}
private void findPossibleMilkList(Integer[] candidat, ArrayList<Integer> alcoolList) {
Integer[] newCandidat = new Integer[candidat.length - alcoolList.size()];
int k = 0; // indice sur newCandidat
int j = 0; // indice sur alcoolList
int i = 0; // indice sur candidat
while (j < alcoolList.size()) {
for ( ; i<alcoolList.get(j).intValue() ; i++) {
newCandidat[k] = candidat[i];
k++;
}
i++;
j++;
}
for ( ; i<candidat.length ; i++) {
newCandidat[k] = candidat[i];
k++;
}
int totalVolume = 0;
for (i=0 ; i<newCandidat.length ; i++) {
totalVolume += newCandidat[i];
}
findPossibleMilkList(newCandidat, totalVolume, 0, new ArrayList<Integer>());
}
private void findPossibleMilkList(Integer[] candidat,
int totalVolume,
int firstIndex,
ArrayList<Integer> possibleList) {
int level = possibleList.size();
if (level > 0) {
int volume = 0;
for (Integer index : possibleList) {
volume += candidat[index.intValue()];
}
if (4*volume == totalVolume) {
System.out.print("Candidats pour le lait :");
for (Integer index : possibleList) {
System.out.print(" " + candidat[index.intValue()]);
}
System.out.println("");
return;
}
}
for (int i=firstIndex ; i<candidat.length ; i++) {
Integer index = new Integer(i);
possibleList.add(index);
findPossibleMilkList(candidat, totalVolume, i + 1, possibleList);
possibleList.remove(index);
}
}
public static void main(String[] args) {
Main main = new Main();
main.process();
}
}
posté le 20/02/2008 à 09:16re : DEFI 200 : L'aérodrome Ader.


posté par : mathématics
Bonjour
Soit x le seau vide. On a :
Alcool + Lait + Eau = 140 - x
Or Lait = Alcool * 2 et Eau = Alcool * 6. Donc :
Alcool * 9 = 140 - x
Il y a un nombre entier de litres d'alcool, donc 140-x est divisible par 9.
Le seul x de la liste répondant à ce critère est :
Alcool * 9 = 140 - 23 = 117
Donc x = 23 et Alcool = 117/9 = 13
La seule facon d'avoir 13 litres est de prendre les seaux de 10 et 3 L.
Lait = Alcool * 2 = 26
De même, on a 26L = 11L + 15L.
Eau = Lait * 3 = 78
De même, on a 78L = 6L + 17L + 25L + 30L.
La réponse est donc :
Le chameau a une bosse ainsi que deux pattes, comme le prouve la photo

.
posté le 07/03/2008 à 10:33re : DEFI 200 : L'aérodrome Ader.

posté par : minkus 
Salut,
| citation : |
|---|
Le programme JAVA suivant donne la réponse en 1 seconde :
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
private final int[] bidons = {3, 6, 10, 11, 15, 17, 23, 25, 30};
public void process() {
List<Integer[]> candidats = new ArrayList<Integer[]>();
int contenanceTotale = 0;
for (int i=0 ; i<bidons.length ; i++) {
contenanceTotale += bidons[i];
}
System.out.println("Contenance totale : " + contenanceTotale);
for (int i=0 ; i<bidons.length ; i++) {
int contenance = contenanceTotale - bidons[i];
if (contenance % 9 == 0) {
System.out.println("Candidat pour être un bidon vide : " + bidons[i]);
Integer[] candidat = new Integer[bidons.length - 1];
int k = 0;
for (int j=0 ; j<bidons.length ; j++) {
if (i != j) {
candidat[k] = bidons[j];
k++;
}
}
candidats.add(candidat);
}
}
for (Integer[] candidat : candidats) {
findPossibleAlcoolList(candidat);
}
}
private void findPossibleAlcoolList(Integer[] candidat) {
int totalVolume = 0;
for (int i=0 ; i<candidat.length ; i++) {
totalVolume += candidat[i];
}
findPossibleAlcoolList(candidat, totalVolume, 0, new ArrayList<Integer>());
}
private void findPossibleAlcoolList(Integer[] candidat,
int totalVolume,
int firstIndex,
ArrayList<Integer> possibleList) {
int level = possibleList.size();
if (level > 0) {
int volume = 0;
for (Integer index : possibleList) {
volume += candidat[index.intValue()];
}
if (9*volume == totalVolume) {
System.out.print("Candidats pour l'alcool :");
for (Integer index : possibleList) {
System.out.print(" " + candidat[index.intValue()]);
}
System.out.println("");
findPossibleMilkList(candidat, possibleList);
return;
}
}
for (int i=firstIndex ; i<candidat.length ; i++) {
Integer index = new Integer(i);
possibleList.add(index);
findPossibleAlcoolList(candidat, totalVolume, i + 1, possibleList);
possibleList.remove(index);
}
}
private void findPossibleMilkList(Integer[] candidat, ArrayList<Integer> alcoolList) {
Integer[] newCandidat = new Integer[candidat.length - alcoolList.size()];
int k = 0; // indice sur newCandidat
int j = 0; // indice sur alcoolList
int i = 0; // indice sur candidat
while (j < alcoolList.size()) {
for ( ; i<alcoolList.get(j).intValue() ; i++) {
newCandidat[k] = candidat[i];
k++;
}
i++;
j++;
}
for ( ; i<candidat.length ; i++) {
newCandidat[k] = candidat[i];
k++;
}
int totalVolume = 0;
for (i=0 ; i<newCandidat.length ; i++) {
totalVolume += newCandidat[i];
}
findPossibleMilkList(newCandidat, totalVolume, 0, new ArrayList<Integer>());
}
private void findPossibleMilkList(Integer[] candidat,
int totalVolume,
int firstIndex,
ArrayList<Integer> possibleList) {
int level = possibleList.size();
if (level > 0) {
int volume = 0;
for (Integer index : possibleList) {
volume += candidat[index.intValue()];
}
if (4*volume == totalVolume) {
System.out.print("Candidats pour le lait :");
for (Integer index : possibleList) {
System.out.print(" " + candidat[index.intValue()]);
}
System.out.println("");
return;
}
}
for (int i=firstIndex ; i<candidat.length ; i++) {
Integer index = new Integer(i);
possibleList.add(index);
findPossibleMilkList(candidat, totalVolume, i + 1, possibleList);
possibleList.remove(index);
}
}
public static void main(String[] args) {
Main main = new Main();
main.process();
}
} |
Sans commentaire.
minkus

posté le 07/03/2008 à 11:21re : DEFI 200 : L'aérodrome Ader.


posté par : lo5707
| citation : |
|---|
| Le programme JAVA suivant donne la réponse en 1 seconde |

