Cho là một bảng có kích thước thay đổi với kích thước tối đa 5 lần 5 trường. Mỗi trường kann được điền với một 'x'. Nếu nó không được lấp đầy bằng 'x', thì nó chứa đầy 'o'.
Trạng thái bắt đầu của mỗi bảng được đưa ra (xem bên dưới). Với mỗi bảng, phải chơi 10 vòng (tối đa, điều kiện: xem bên dưới) và sự tiến hóa của x phải được theo dõi.
Một vòng hoạt động theo cách sau:
- mọi 'x' lan sang các trường có biên giới trực giao, nhưng tự biến mất
- mỗi lần hai 'x' nằm trên một trường, chúng trung hòa lẫn nhau
Sự tiến hóa của tất cả 'x' trong mỗi vòng phải diễn ra đồng thời. Thí dụ:
o o o o x o
o x o -> x o x
o o o o x o
Với mỗi vòng tiến hóa, bạn phải xem liệu bảng có bị trống 'x' không. Nó không trống rỗng, một mô hình lặp đi lặp lại có thể có mặt. Nếu đây cũng không phải là trường hợp, chúng tôi từ bỏ phân tích về sự tiến hóa. Ngoài ra, bạn phải in ra phần trăm tối đa của các trường x cho mỗi bảng bắt đầu (làm tròn xuống thành toàn bộ số).
Đầu vào:
Dữ liệu đầu vào có thể được tìm thấy ở đây (Pastebin) Dữ liệu này chứa 100 trạng thái bắt đầu. Như đã đề cập, các bảng khác nhau về kích thước. Số lượng hàng được ghi với số n từ 1 đến 5, theo sau là n hàng chỉ chứa 'x' và 'o', đại diện cho mẫu bắt đầu. Mỗi hàng của một bảng có 1 đến 5 trường.
Đầu ra:
Kết quả hoàn chỉnh phải được in ra, một hàng được in cho mỗi bảng bắt đầu theo mẫu sau:
Round {0-10}: {repetition/empty/giveup}, {0-100} percent maximum-fill
Ví dụ:
Ví dụ 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
Ví dụ 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
Sau tám ngày, tôi sẽ đánh dấu câu trả lời làm việc với ít nhân vật nhất là người chiến thắng. Ngoài ra, tôi sẽ đăng đầu ra chính xác cho 100 bảng bắt đầu (đầu vào).
Bạn có thể sử dụng ngôn ngữ (lập trình / kịch bản / bất cứ thứ gì) ưa thích của bạn.
Chúc vui vẻ!
PS: Nếu bạn có câu hỏi, hãy hỏi.
PPS: Đối với những người sáng tạo ban đầu: Đối với những người có khả năng nói tiếng Đức, câu hỏi được đặt ra từ ĐỪNG NHẤP VÀO NẾU BẠN KHÔNG MUỐN SPOILERS ở đây . Vì thời gian chính thức để hoàn thành thử thách đã kết thúc, tôi muốn xem liệu ai đó có thể đưa ra một giải pháp ngắn gọn và thanh lịch hay không.
22.04.2014:
Thử thách đã xong! Người chiến thắng được đánh dấu là chấp nhận. Đầu ra đúng:
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