Podana jest tablica o zmiennej wielkości z maksymalnym rozmiarem 5 razy 5 pól. Każde pole kann musi być wypełnione znakiem „x”. Jeśli nie jest wypełniony „x”, jest wypełniony „o”.
Podany jest stan początkowy każdej planszy (patrz poniżej). Na każdej planszy należy rozegrać 10 rund (maksymalnie, warunki: patrz poniżej) i obserwować ewolucję x.
Jedna runda działa w następujący sposób:
- każde „x” rozprzestrzenia się na pola graniczące z ortogonalnie, ale samo znika
- za każdym razem, gdy dwa „x” znajdują się na jednym polu, wzajemnie się neutralizują
Ewolucja wszystkich „x” w każdej rundzie musi odbywać się jednocześnie. Przykład:
o o o o x o
o x o -> x o x
o o o o x o
Z każdą rundą ewolucji musisz sprawdzić, czy tablica zostanie opróżniona z „x”. Jeśli nie jest pusty, może występować powtarzalny wzór. Jeśli tak nie jest, rezygnujemy z analizy ewolucji. Dodatkowo musisz wydrukować maksymalny procent x pól dla każdej planszy początkowej (zaokrąglony w dół do liczb całkowitych).
Wejście:
Dane wejściowe można znaleźć tutaj (Pastebin) Dane te zawierają 100 stanów początkowych. Jak już wspomniano, deski różnią się rozmiarem. Liczbę wierszy podano liczbą n od 1 do 5, a następnie n wierszy zawierających tylko „x” i „o” reprezentują wzorzec początkowy. Każdy rząd planszy ma od 1 do 5 pól.
Wynik:
Należy wydrukować pełny wynik, jeden wydrukowany rząd dla każdej planszy startowej w następującej formie:
Round {0-10}: {repetition/empty/giveup}, {0-100} percent maximum-fill
Przykłady:
Przykład 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
Przykład 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
Po ośmiu dniach zaznaczę roboczą odpowiedź jako najmniej zwycięskich postaci. Dodatkowo opublikuję poprawne dane wyjściowe dla 100 kart startowych (dane wejściowe).
Możesz użyć preferowanego języka (programowania / skryptów / cokolwiek).
Baw się dobrze!
PS: Jeśli masz pytania, możesz je zadać.
PPS: W odniesieniu do oryginalnych twórców: Dla osób mówiących po niemiecku pytanie pochodzi od NIE KLIKNIJ, JEŚLI NIE CHCESZ SPOILERÓW tutaj . Ponieważ oficjalny czas na ukończenie wyzwania dobiegł końca, chciałem sprawdzić, czy ktoś może wymyślić krótkie i eleganckie rozwiązanie.
22.04.2014:
Wyzwanie gotowe! Zwycięzca oznaczony jako zaakceptowany. Prawidłowa wydajność:
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