Gegeben ist eine Tafel variabler Größe mit einer maximalen Größe von 5 mal 5 Feldern. Jedes Feld kann mit einem 'x' gefüllt werden. Wenn es nicht mit einem 'x' gefüllt ist, wird es mit einem 'o' gefüllt.
Der Ausgangszustand jeder Karte ist angegeben (siehe unten). Mit jedem Brett müssen 10 Runden gespielt werden (max. Bedingungen: siehe unten) und die Entwicklung des x muss beobachtet werden.
Eine Runde funktioniert folgendermaßen:
- Jedes 'x' breitet sich auf orthogonal angrenzende Felder aus, verschwindet jedoch von selbst
- Jedes Mal, wenn sich zwei 'x' auf einem Feld befinden, neutralisieren sie sich gegenseitig
Die Entwicklung aller 'x' in jeder Runde muss gleichzeitig erfolgen. Beispiel:
o o o o x o
o x o -> x o x
o o o o x o
Bei jeder Evolutionsrunde muss man sehen, ob das Brett von "x" geleert wird. Ist es nicht leer, könnte ein sich wiederholendes Muster vorliegen. Ist dies auch nicht der Fall, geben wir die Analyse der Evolution auf. Zusätzlich müssen Sie für jedes Startbrett den maximalen Prozentsatz an x Feldern ausdrucken (auf ganze Zahlen abgerundet).
Eingang:
Die Eingabedaten finden Sie hier (Pastebin) Diese Daten enthalten 100 Startzustände. Wie bereits erwähnt, variieren die Platten in der Größe. Die Anzahl der Zeilen wird mit der Nummer n von 1 bis 5 angegeben, gefolgt von n Zeilen, die nur 'x' und 'o' enthalten und das Startmuster darstellen. Jede Reihe einer Tafel hat 1 bis 5 Felder.
Ausgabe:
Das komplette Ergebnis muss ausgedruckt werden, eine gedruckte Reihe für jede Starttafel in der folgenden Form:
Round {0-10}: {repetition/empty/giveup}, {0-100} percent maximum-fill
Beispiele:
Beispiel 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
Beispiel 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
Nach acht Tagen werde ich die funktionierende Antwort mit den wenigsten Zeichen als Gewinner markieren. Zusätzlich werde ich den korrekten Output für die 100 Startboards (Input) posten.
Sie können Ihre bevorzugte Sprache (Programmierung / Scripting / was auch immer) verwenden.
Habe Spaß!
PS: Wenn Sie Fragen haben, können Sie diese gerne stellen.
PPS: In Bezug auf die ursprünglichen Schöpfer: Für Menschen, die in der Lage sind, Deutsch zu sprechen, wurde die Frage von NICHT KLICKEN, WENN SIE KEINE SPOILER WOLLEN, hier genommen . Da die offizielle Zeit für das Abschließen der Herausforderung abgelaufen ist, wollte ich sehen, ob jemand eine kurze und elegante Lösung finden kann.
22.04.2014:
Herausforderung erledigt! Gewinner als akzeptiert markiert. Richtige Ausgabe:
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