Donné est un tableau de taille variable avec une taille maximale de 5 fois 5 champs. Chaque champ peut être rempli d'un «x». S'il n'est pas rempli d'un «x», il est rempli d'un «o».
L'état de départ de chaque planche est donné (voir ci-dessous). Avec chaque plateau, 10 tours doivent être joués (au maximum, conditions: voir ci-dessous) et l'évolution du x doit être surveillée.
Un tour fonctionne de la manière suivante:
- chaque «x» se propage à des champs bordant orthogonalement, mais disparaît
- chaque fois que deux «x» sont sur un champ, ils se neutralisent
L'évolution de tous les «x» à chaque tour doit se produire simultanément. Exemple:
o o o o x o
o x o -> x o x
o o o o x o
À chaque tour d'évolution, vous devez voir si le plateau se vide de «x». S'il n'est pas vide, un motif répétitif pourrait être présent. Si ce n'est pas non plus le cas, nous renonçons à l'analyse de l'évolution. De plus, vous devez imprimer le pourcentage maximum de champs x pour chaque planche de départ (arrondi aux nombres entiers).
Contribution:
Les données d'entrée peuvent être trouvées ici (Pastebin) Ces données contiennent 100 états de départ. Comme déjà mentionné, les planches varient en taille. Le nombre de lignes est indiqué avec le nombre n de 1 à 5, suivi de n lignes qui ne contiennent que «x» et «o», représentent le modèle de départ. Chaque ligne d'une planche a 1 à 5 champs.
Production:
Le résultat complet doit être imprimé, une ligne imprimée pour chaque planche de départ sous la forme suivante:
Round {0-10}: {repetition/empty/giveup}, {0-100} percent maximum-fill
Exemples:
Exemple 1:
Input: 2 Starting state: x o x
xox x x
xx
Round 1: x x o
o x
Round 2: x o x
o x
Round 3: o x o
o o
Round 4: x o x -> The pattern repeats:
o x It is the same as in round 2,
therefore we stop. Maximum fill was
in the starting state with four times 'x'
of 5 fields altogether,
so we have 4/5 = 80 %.
Output: Round 4: repetition, 80 percent maximum-fill
Exemple 2:
Input: 1 Starting state: x x
xx
Round 1: x x -> We already have a repetition, because
the pattern is the same as in the starting
state. The board is always filled 100 %.
Output: Round 1: repetition, 100 percent maximum-fill
Après huit jours, je marquerai la réponse de travail avec le moins de caractères comme gagnant. De plus, je publierai la sortie correcte pour les 100 planches de départ (entrée).
Vous pouvez utiliser votre langage préféré (programmation / scripting / autre).
S'amuser!
PS: Si vous avez des questions, n'hésitez pas à demander.
PPS: En ce qui concerne les créateurs originaux: Pour les personnes capables de parler allemand, la question est tirée de NE PAS CLIQUER SI VOUS NE VOULEZ PAS DE SPOILERS ici . Puisque le temps officiel pour terminer le défi est terminé, je voulais voir si quelqu'un pourrait trouver une solution courte et élégante.
22.04.2014:
Défi terminé! Le gagnant est marqué comme accepté. Sortie correcte:
Round 10: giveup, 50 percent maximum-fill
Round 5: empty, 66 percent maximum-fill
Round 1: repetition, 100 percent maximum-fill
Round 1: empty, 100 percent maximum-fill
Round 4: repetition, 100 percent maximum-fill
Round 4: repetition, 70 percent maximum-fill
Round 2: repetition, 60 percent maximum-fill
Round 4: empty, 88 percent maximum-fill
Round 10: giveup, 50 percent maximum-fill
Round 5: repetition, 80 percent maximum-fill
Round 10: repetition, 80 percent maximum-fill
Round 1: empty, 80 percent maximum-fill
Round 3: repetition, 60 percent maximum-fill
Round 4: repetition, 48 percent maximum-fill
Round 9: empty, 41 percent maximum-fill
Round 10: giveup, 92 percent maximum-fill
Round 10: giveup, 53 percent maximum-fill
Round 10: giveup, 66 percent maximum-fill
Round 6: repetition, 50 percent maximum-fill
Round 10: giveup, 88 percent maximum-fill
Round 10: giveup, 76 percent maximum-fill
Round 10: giveup, 68 percent maximum-fill
Round 10: giveup, 40 percent maximum-fill
Round 10: giveup, 100 percent maximum-fill
Round 10: giveup, 71 percent maximum-fill
Round 2: empty, 81 percent maximum-fill
Round 6: repetition, 36 percent maximum-fill
Round 10: giveup, 61 percent maximum-fill
Round 10: giveup, 60 percent maximum-fill
Round 4: repetition, 66 percent maximum-fill
Round 10: giveup, 72 percent maximum-fill
Round 3: empty, 80 percent maximum-fill
Round 10: giveup, 50 percent maximum-fill
Round 10: giveup, 83 percent maximum-fill
Round 7: repetition, 37 percent maximum-fill
Round 9: repetition, 85 percent maximum-fill
Round 5: repetition, 40 percent maximum-fill
Round 5: repetition, 60 percent maximum-fill
Round 4: empty, 80 percent maximum-fill
Round 10: giveup, 60 percent maximum-fill
Round 4: repetition, 46 percent maximum-fill
Round 6: repetition, 42 percent maximum-fill
Round 10: giveup, 72 percent maximum-fill
Round 4: repetition, 70 percent maximum-fill
Round 4: repetition, 80 percent maximum-fill
Round 6: repetition, 50 percent maximum-fill
Round 4: repetition, 56 percent maximum-fill
Round 10: giveup, 60 percent maximum-fill
Round 10: giveup, 54 percent maximum-fill
Round 10: giveup, 66 percent maximum-fill
Round 2: repetition, 40 percent maximum-fill
Round 2: repetition, 40 percent maximum-fill
Round 6: repetition, 75 percent maximum-fill
Round 7: empty, 85 percent maximum-fill
Round 10: giveup, 50 percent maximum-fill
Round 6: repetition, 70 percent maximum-fill
Round 2: empty, 66 percent maximum-fill
Round 1: empty, 66 percent maximum-fill
Round 3: empty, 100 percent maximum-fill
Round 3: empty, 66 percent maximum-fill
Round 8: repetition, 42 percent maximum-fill
Round 1: empty, 60 percent maximum-fill
Round 2: repetition, 100 percent maximum-fill
Round 2: repetition, 83 percent maximum-fill
Round 4: repetition, 66 percent maximum-fill
Round 6: repetition, 75 percent maximum-fill
Round 4: empty, 66 percent maximum-fill
Round 10: giveup, 61 percent maximum-fill
Round 10: giveup, 56 percent maximum-fill
Round 4: empty, 66 percent maximum-fill
Round 6: repetition, 33 percent maximum-fill
Round 3: empty, 57 percent maximum-fill
Round 3: repetition, 100 percent maximum-fill
Round 6: repetition, 73 percent maximum-fill
Round 10: giveup, 50 percent maximum-fill
Round 6: repetition, 50 percent maximum-fill
Round 10: giveup, 73 percent maximum-fill
Round 5: empty, 80 percent maximum-fill
Round 10: giveup, 61 percent maximum-fill
Round 3: repetition, 53 percent maximum-fill
Round 10: giveup, 33 percent maximum-fill
Round 10: giveup, 80 percent maximum-fill
Round 10: giveup, 63 percent maximum-fill
Round 10: giveup, 70 percent maximum-fill
Round 10: giveup, 84 percent maximum-fill
Round 7: repetition, 70 percent maximum-fill
Round 10: repetition, 57 percent maximum-fill
Round 10: giveup, 55 percent maximum-fill
Round 6: repetition, 36 percent maximum-fill
Round 4: repetition, 75 percent maximum-fill
Round 10: giveup, 72 percent maximum-fill
Round 10: giveup, 64 percent maximum-fill
Round 10: giveup, 84 percent maximum-fill
Round 10: giveup, 58 percent maximum-fill
Round 10: giveup, 60 percent maximum-fill
Round 10: giveup, 53 percent maximum-fill
Round 4: repetition, 40 percent maximum-fill
Round 4: empty, 40 percent maximum-fill
Round 10: giveup, 50 percent maximum-fill
Round 10: giveup, 68 percent maximum-fill