=== Поля і каміння — пошук довгого простого шляху
Введіть кількість рядків N (1..100): Введіть кількість стовпців M (1..100): Ймовірність каменю в клітинці (0..1), наприклад 0.25: Часовий ліміт пошуку в секундах (наприклад 1.5): Якщо потрібно — згенерувати поле заново, якщо шляху немає? (т/н) [т]:
Згенероване поле (вирівняне):
. . . . . # . . . # . . . # . . . . . . . . . . .
. . # . . . . . . # . . . . . # . . . # . . # . #
# . . . . # . # . . . . # . # # . # . . . # . . .
. . . # . # . # # . . # . # . . # # . . . # . . #
. . # . . # . . . . . . # . # # . . . . . . . . .
. # . # . . . . . . . . . . . . . . . . . . . . .
. # # . . # . # # . . . # . . # . . # . . # . . .
. . . . # # . # . . . # # . . . # . # . . . . # .
# . . . . # . . # . . . . . . . . . . . . # # # .
. . # . . . . . . . . . . . . . . . # . # # # . .
. . . # # # . # . # . . # # . # . . . . . . . # #
. . # . . . . # # . . . . . # . . . # . # . . . .
. . # . . # . . . . . . . . . . . . # . . . . # #
. . . # . # # # . . . . . . . # . . . # . . . # .
. . . . . . # # . . . . . . # # . . # . # . . . .
# . # . . # . . # # . . . . # . . . . . # # # . .
. . # # . . . # # . . . . . . . # . # . . . . # .
. . # . . . . . . # . # . # . # # . . . . . . . .
# # # . . . # . . . . . # . . # # . . # # . . . .
. . # . . . . . . # . . . . # . . # . # . . . . .
. . # . . . # . . . . . # # . . . . # . # . . . .
. . . . # # . . . . . . . # . . . . . . . . # . .
# . . # . . # # . . # . . . . . . . . # . # . # .
. . . . . . . . . . . # . . # # . # . # . . . . .
. . . . # # # # # . # . . . . . # . . # # . . . #
Починаємо пошук найдовшого простого шляху (таймаут = 1.5 сек)...
Знайдений шлях довжиною 297 (0 = старт).
Карта з пронумерованим шляхом:
174 175 176 177 . # . . . # 220 221 222 # 226 227 228 . . . 292 293 294 295 296
173 172 # 178 181 182 183 . . # 219 218 223 224 225 # 229 230 231 # 291 . # . #
# 171 . 179 180 # 184 # . 215 216 217 # . # # . # 232 289 290 # 276 275 .
169 170 . # . # 185 # # 214 213 # . # . . # # 233 288 287 # 277 274 #
168 . # . . # 186 187 190 191 212 . # . # # . . 234 285 286 279 278 273 272
167 # . # 159 158 157 188 189 192 211 208 207 206 239 238 237 236 235 284 281 280 267 268 271
166 # # 161 160 # 156 # # 193 210 209 # 205 240 # . . # 283 282 # 266 269 270
165 164 163 162 # # 155 # . 194 . # # 204 241 242 # . # . 263 264 265 # .
# 111 112 113 . # 154 153 # 195 196 197 . 203 202 243 . 259 260 261 262 # # # .
109 110 # 114 115 116 117 152 151 150 149 198 199 200 201 244 245 258 # . # # # . .
108 107 . # # # 118 # . # 148 . # # . # 246 257 . . . . . # #
105 106 # . . . 119 # # . 147 146 145 144 # 248 247 256 # . # . . . .
104 . # . . # 120 121 122 127 128 135 136 143 . 249 250 255 # . . . . # #
103 . . # . # # # 123 126 129 134 137 142 . # 251 254 . # . . . # .
102 101 100 99 . . # # 124 125 130 133 138 141 # # 252 253 # . # . . . .
# . # 98 97 # . . # # 131 132 139 140 # 72 71 70 . . # # # . .
. . # # 96 . . # # . 78 77 76 75 74 73 # 69 # . . . . # .
. . # 94 95 90 89 88 . # 79 # . # . # # 68 67 66 65 64 . . .
# # # 93 92 91 # 87 86 . 80 . # . . # # . . # # 63 . . .
. . # 14 15 18 19 20 85 # 81 . . . # . . # . # . 62 . . .
. . # 13 16 17 # 21 84 83 82 . # # . . . . # . # 61 60 59 .
. 10 11 12 # # . 22 23 28 29 30 . # 39 40 . 44 45 46 47 . # 58 57
# 9 8 # . . # # 24 27 # 31 32 37 38 41 42 43 . # 48 # . # 56
1 2 7 6 . . . . 25 26 . # 33 36 # # . # . # 49 50 53 54 55
0 3 4 5 # # # # # . # . 34 35 . . # . . # # 51 52 . #
Кроки шляху (1-based координати):
[(25, 1), (24, 1), (24, 2), (25, 2), (25, 3), (25, 4), (24, 4), (24, 3), (23, 3), (23, 2), (22, 2), (22, 3), (22, 4), (21, 4), (20, 4), (20, 5), (21, 5), (21, 6), (20, 6), (20, 7), (20, 8), (21, 8), (22, 8), (22, 9), (23, 9), (24, 9), (24, 10), (23, 10), (22, 10), (22, 11), (22, 12), (23, 12), (23, 13), (24, 13), (25, 13), (25, 14), (24, 14), (23, 14), (23, 15), (22, 15), (22, 16), (23, 16), (23, 17), (23, 18), (22, 18), (22, 19), (22, 20), (22, 21), (23, 21), (24, 21), (24, 22), (25, 22), (25, 23), (24, 23), (24, 24), (24, 25), (23, 25), (22, 25), (22, 24), (21, 24), (21, 23), (21, 22), (20, 22), (19, 22), (18, 22), (18, 21), (18, 20), (18, 19), (18, 18), (17, 18), (16, 18), (16, 17), (16, 16), (17, 16), (17, 15), (17, 14), (17, 13), (17, 12), (17, 11), (18, 11), (19, 11), (20, 11), (21, 11), (21, 10), (21, 9), (20, 9), (19, 9), (19, 8), (18, 8), (18, 7), (18, 6), (19, 6), (19, 5), (19, 4), (18, 4), (18, 5), (17, 5), (16, 5), (16, 4), (15, 4), (15, 3), (15, 2), (15, 1), (14, 1), (13, 1), (12, 1), (12, 2), (11, 2), (11, 1), (10, 1), (10, 2), (9, 2), (9, 3), (9, 4), (10, 4), (10, 5), (10, 6), (10, 7), (11, 7), (12, 7), (13, 7), (13, 8), (13, 9), (14, 9), (15, 9), (15, 10), (14, 10), (13, 10), (13, 11), (14, 11), (15, 11), (16, 11), (16, 12), (15, 12), (14, 12), (13, 12), (13, 13), (14, 13), (15, 13), (16, 13), (16, 14), (15, 14), (14, 14), (13, 14), (12, 14), (12, 13), (12, 12), (12, 11), (11, 11), (10, 11), (10, 10), (10, 9), (10, 8), (9, 8), (9, 7), (8, 7), (7, 7), (6, 7), (6, 6), (6, 5), (7, 5), (7, 4), (8, 4), (8, 3), (8, 2), (8, 1), (7, 1), (6, 1), (5, 1), (4, 1), (4, 2), (3, 2), (2, 2), (2, 1), (1, 1), (1, 2), (1, 3), (1, 4), (2, 4), (3, 4), (3, 5), (2, 5), (2, 6), (2, 7), (3, 7), (4, 7), (5, 7), (5, 8), (6, 8), (6, 9), (5, 9), (5, 10), (6, 10), (7, 10), (8, 10), (9, 10), (9, 11), (9, 12), (10, 12), (10, 13), (10, 14), (10, 15), (9, 15), (9, 14), (8, 14), (7, 14), (6, 14), (6, 13), (6, 12), (7, 12), (7, 11), (6, 11), (5, 11), (4, 11), (4, 10), (3, 10), (3, 11), (3, 12), (2, 12), (2, 11), (1, 11), (1, 12), (1, 13), (2, 13), (2, 14), (2, 15), (1, 15), (1, 16), (1, 17), (2, 17), (2, 18), (2, 19), (3, 19), (4, 19), (5, 19), (6, 19), (6, 18), (6, 17), (6, 16), (6, 15), (7, 15), (8, 15), (8, 16), (9, 16), (10, 16), (10, 17), (11, 17), (12, 17), (12, 16), (13, 16), (13, 17), (14, 17), (15, 17), (15, 18), (14, 18), (13, 18), (12, 18), (11, 18), (10, 18), (9, 18), (9, 19), (9, 20), (9, 21), (8, 21), (8, 22), (8, 23), (7, 23), (6, 23), (6, 24), (7, 24), (7, 25), (6, 25), (5, 25), (5, 24), (4, 24), (3, 24), (3, 23), (4, 23), (5, 23), (5, 22), (6, 22), (6, 21), (7, 21), (7, 20), (6, 20), (5, 20), (5, 21), (4, 21), (4, 20), (3, 20), (3, 21), (2, 21), (1, 21), (1, 22), (1, 23), (1, 24), (1, 25)]