{"id":330975,"date":"2022-03-23T09:00:41","date_gmt":"2022-03-23T09:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=330975"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=330975","title":{"rendered":"<span>N (\u041d\u0430\u0441\u0442\u0438) \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u041f\u0430\u043c\u044f\u0442\u0438 \u041d\u0430\u0441\u0442\u0438. \u041f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0447\u0435\u0440\u0438.<\/em><\/p>\n<p>\u0427\u0442\u043e \u0437\u043d\u0430\u0435\u043c \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 \u043f\u043e\u0438\u0441\u043a\u0430? \u0415\u0441\u0442\u044c \u0433\u0440\u0430\u0444. \u0427\u0430\u0449\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439. \u0418 \u043d\u0435\u043a\u043e\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442?<\/p>\n<p>\u041a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0431\u0435\u043d\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0441\u044f \u0432 \u043b\u0435\u0441\u0443? \u0412\u0435\u0434\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c, \u043d\u043e \u0438 \u043e\u043d \u0432\u0430\u0441.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e? \u0414\u0430. \u041d\u043e \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u0438. \u0415\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u0435\u0434\u044b? \u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u043d\u0438\u0445. \u041f\u043e\u0442\u0435\u0440\u044f\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u044b? \u0412\u043d\u043e\u0432\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<pre><code>while True:     if \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c:                      #N         \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c     else:         if \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0440\u0430\u0437\u043d\u043e\u0435:   #M             \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435         else:                                             #P             \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u044b\u0431\u043e\u0440 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432? \u041f\u0443\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f {12*, 11*, 14*, 212, 213, 221, 225}. \u0415\u0441\u043b\u0438 \u0446\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 218, \u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u0441 212, \u043b\u0438\u0431\u043e \u0441 213. \u0415\u0441\u043b\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u0447\u0442\u043e 213 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437, \u0442\u043e \u0432\u044b\u0431\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0439 \u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438 TIME. \u0425\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442, \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043b\u043e\u0436\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0421\u0430\u043c\u0430 \u0438\u0434\u0435\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 &#8212; \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (<a href=\"https:\/\/github.com\/bulygina07\/rp\/blob\/master\/random_path.py\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434<\/a> + <a href=\"https:\/\/soundcloud.com\/user-636259853\/rp-voice\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a\u043e\u0434\u0430 \u041d\u0430\u0441\u0442\u0438<\/a>). \u041c\u043e\u0436\u0435\u0442 \u043e\u0448\u0438\u0431\u0430\u044e\u0441\u044c, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b, \u043a\u0430\u043a \u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430. \u0411\u044b\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043e 10 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 J(P), \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 J(M). \u0417\u0434\u0435\u0441\u044c \u0436\u0435\u043b\u0442\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 J &#8212; \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. P &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. M &#8212; \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. N &#8212; \u0438\u0449\u0435\u0442 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td>\n<p><strong>J(P)<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<\/td>\n<td>\n<\/td>\n<td>\n<p><strong>J(M)<\/strong><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td>\n<p><strong>P<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p><strong>M<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p><strong>N<\/strong><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p><strong>P<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>M<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>N<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>1<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>31<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>7<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>20<\/p>\n<\/td>\n<td>\n<p>17<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>2<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>43<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>15<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>18<\/p>\n<\/td>\n<td>\n<p>38<\/p>\n<\/td>\n<td>\n<p>38<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>3<\/p>\n<\/td>\n<td>\n<p>32<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>12<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>25<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>36<\/p>\n<\/td>\n<td>\n<p>18<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>4<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>34<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>8<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>50<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>5<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>13<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>12<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>6<\/p>\n<\/td>\n<td>\n<p>39<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>8<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>23<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>24<\/p>\n<\/td>\n<td>\n<p>24<\/p>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>7<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>14<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>7<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>37<\/p>\n<\/td>\n<td>\n<p>11<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>8<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>29<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>13<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>29<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>9<\/p>\n<\/td>\n<td>\n<p>10<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>7<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>13<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>17<\/p>\n<\/td>\n<td>\n<p>26<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>10<\/p>\n<\/td>\n<td>\n<p>27<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>21<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>9<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p><em>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0434\u043e \u0446\u0435\u043b\u0438<\/em><\/p>\n<\/td>\n<td>\n<p><em>39.8<\/em><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p><em>21.2<\/em><\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p><em>13.2<\/em><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p><em>28.6<\/em><\/p>\n<\/td>\n<td>\n<p><em>25.1<\/em><\/p>\n<\/td>\n<td>\n<p><em>12.7<\/em><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0438\u043c\u0435\u043d\u043d\u043e N \u0432 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c P. \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0446\u0435\u043b\u044c J(M) \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e J(P) \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043b\u043e\u0449\u0430\u0434\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0441 P \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code>from tkinter import * import random  TIME = 10  class Z():     def __init__(self, root, maps, ban):         self.root = root         self.maps = maps         self.ban = ban         Z.time = {}         Z.hierarchy = {}         Z.neighbor = {}                    self.init_3_dict(self.maps, self.ban)              def init_3_dict(self, maps, ban):         def is_en(yx):             if yx[0] &lt; 0 or yx[0] > len(maps)-1: return             if yx[1] &lt; 0 or yx[1] > len(maps[0])-1: return             if yx in ban: return             return True                      for y in range(len(self.maps)):             for x in range(len(self.maps[0])):                 Z.hierarchy[(y,x)] = maps[y][x]                                  n = []                 if is_en((y-1,x)):                     n.append((y-1,x))                 if is_en((y+1,x)):                     n.append((y+1,x))                 if is_en((y,x-1)):                     n.append((y,x-1))                 if is_en((y,x+1)):                     n.append((y,x+1))                                      Z.neighbor[(y,x)] = n                                  self.time[(y,x)] = 0                 if (y, x) in self.ban:                     lb = Label(text=\" \", background = 'black')                     lb.configure(text=self.maps[y][x])                 else:                     lb = Label(text=\" \", background = 'white')                     lb.configure(text=self.maps[y][x])                 lb.grid(row=y, column=x, ipadx=10, ipady=5, padx=1, pady=1)                  self.update()                                  def update(self):         for y in range(len(self.maps)):             for x in range(len(self.maps[0])):                 if Z.time[(y,x)]:                     Z.time[(y,x)] -=1                 else:                    Z.hierarchy[(y,x)] = maps[y][x]                                         if not (y, x) in self.ban:                        lb = Label(text=\" \", background = 'white')                        lb.configure(text=Z.hierarchy[(y,x)])                        lb.grid(row=y, column=x, ipadx=10, ipady=5, padx=1, pady=1)                          self.root.after(500, self.update)                   class P():     def __init__(self, root, color, node, target, maps, ban):         self.root = root         self.color = color         self.y = node[0]         self.x = node[1]         self.target = target         self.count = 0                  self.visit = {}         P.neighbor = {}          self.visit[(self.y, self.x)] = 1         P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                      def update(self):         self.move()            self.root.after(500, self.update)      def show(self, y, x, color):         lb = Label(text=\" \", background = color)         lb.configure(text=Z.hierarchy[(y,x)] )         lb.grid(row=self.y, column=self.x, ipadx=10, ipady=5, padx=1, pady=1)              def choice(self, yx):         v = []                  for i in P.neighbor[yx]:              if not yx in self.visit:                 self.visit[yx] = 0             v.append(i)             return random.choice(v)              def move(self):         for i in Z.neighbor[(self.y, self.x)]:             if (self.y, self.x) not in P.neighbor:                 P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                      y,x = self.choice((self.y, self.x))                  self.show(self.y, self.x, 'white')             self.y = y         self.x = x         self.show(y, x, self.color)                  self.count +=1                           if self.target == Z.hierarchy[(self.y, self.x)]:             #J.disable = True             self.top_show()                        def update(self):         self.move()            self.root.after(500, self.update)              def top_show(self):         top = Toplevel()         lbt = Label(top, text=self.color + \" = \" + str(self.count))         lbt.pack()         top.mainloop()                   class M(P):     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         self.visit[node] += 1              def move(self):         yx = self.choice((self.y, self.x))                  self.show(self.y, self.x, 'white')             self.y = yx[0]         self.x = yx[1]         self.show(yx[0], yx[1], self.color)                  self.count +=1                  if self.target == Z.hierarchy[(self.y, self.x)]:             #J.disable = True             self.top_show()              def choice(self, yx):         v = []                  for i in Z.neighbor[yx]:             if (yx) not in P.neighbor:                 P.neighbor[yx] = Z.neighbor[yx]                          for i in P.neighbor[yx]:              if not i in self.visit:                 self.visit[i] = 0             v.append((i, self.visit[i]))                       v.sort(key = lambda x: x[1], reverse = False)         v = [i for i in v if v[0][1] == i[1]]         v = random.choice(v)         self.visit[v[0]] += 1         return v[0]                   class N(M):     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         self.coincidence = 0              def choice(self, yx):         v = []                  for i in Z.neighbor[yx]:             if (yx) not in P.neighbor:                 P.neighbor[yx] = Z.neighbor[yx]                          for i in P.neighbor[yx]:              if not i in self.visit:                 self.visit[i] = 0             v.append((i, self.visit[i]))                       d = []         for l in v:             c = Z.hierarchy[l[0]]                          r = 0             for i in range(len(self.target)):                 if c[i] == self.target[i]:                     r +=1                 else: break                               if r > self.coincidence:                 self.coincidence = r                 d = [l]             if r == self.coincidence:                 d.append(l)                  if d: v = d                      v.sort(key = lambda x: x[1], reverse = False)         v = [i for i in v if v[0][1] == i[1]]         v = random.choice(v)         self.visit[v[0]] += 1         return v[0]                      class J(P): #J(P) or J(M)     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         J.disable = False              def move(self):         if not J.disable:             v = []                          for i in Z.neighbor[(self.y, self.x)]:                 if (self.y, self.x) not in P.neighbor:                     P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                              y,x = self.choice((self.y, self.x))                          Z.hierarchy[(self.y, self.x)] = self.target[:-1] + \\               str(int(self.target[-1]) - 1) #'4288'             Z.time[(y, x)] = TIME                              self.show(self.y, self.x, 'white')                self.y = y             self.x = x             Z.hierarchy[(self.y, self.x)] = self.target             self.show(y, x, self.color)               #--------- main ---------#     if __name__ == \"__main__\":          root = Tk()          target = ('4289')     ban=[(1,1), (1,2), (2,3), (5,5)]           '''     maps = [ [\"011\", \"012\", \"013\", \"211\", \"212\", \"201\"],              [\"014\", \"015\", \"021\", \"213\", \"214\", \"202\"],              [\"022\", \"023\", \"024\", \"215\", \"216\", \"203\"],              [\"025\", \"026\", \"027\", \"213\", \"204\", \"205\"],              [\"101\", \"102\", \"103\", \"121\", \"122\", \"123\"],              [\"104\", \"105\", \"106\", \"124\", \"125\", \"126\"]     ]     '''          maps = [ [\"0111\", \"0121\", \"0132\", \"2112\", \"2121\", \"2013\", \"2011\"],              [\"0141\", \"0152\", \"0211\", \"2132\", \"2143\", \"2021\", \"2013\"],              [\"0221\", \"0231\", \"0242\", \"2151\", \"2162\", \"2031\", \"2033\"],              [\"0252\", \"0262\", \"0271\", \"2131\", \"2041\", \"2052\", \"2032\"],              [\"1011\", \"1022\", \"1032\", \"1212\", \"1231\", \"1231\", \"1233\"],              [\"1042\", \"1053\", \"1062\", \"1241\", \"1233\", \"1262\", \"1261\"],              [\"1041\", \"1052\", \"1064\", \"1245\", \"1255\", \"1266\", \"1264\"],     ]               def update():         z1.update()         p1.update()         m1.update()         n1.update()         j1.update()              z1 = Z(root, maps, ban)     p1 = P(root, 'red',  (1,0), target, z1.maps, z1.ban)     m1 = M(root, 'blue',  (1,0), target, z1.maps, z1.ban)     n1 = N(root, 'green',  (1,0), target, z1.maps, z1.ban)     j1 = J(root, 'yellow',  (4,4), target, z1.maps, z1.ban)          root.after(500, update)       root.mainloop()<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/656999\/\"> https:\/\/habr.com\/ru\/post\/656999\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u041f\u0430\u043c\u044f\u0442\u0438 \u041d\u0430\u0441\u0442\u0438. \u041f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0447\u0435\u0440\u0438.<\/em><\/p>\n<p>\u0427\u0442\u043e \u0437\u043d\u0430\u0435\u043c \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 \u043f\u043e\u0438\u0441\u043a\u0430? \u0415\u0441\u0442\u044c \u0433\u0440\u0430\u0444. \u0427\u0430\u0449\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439. \u0418 \u043d\u0435\u043a\u043e\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0424\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442?<\/p>\n<p>\u041a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0431\u0435\u043d\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0441\u044f \u0432 \u043b\u0435\u0441\u0443? \u0412\u0435\u0434\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c, \u043d\u043e \u0438 \u043e\u043d \u0432\u0430\u0441.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e? \u0414\u0430. \u041d\u043e \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u0438. \u0415\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u0435\u0434\u044b? \u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u043d\u0438\u0445. \u041f\u043e\u0442\u0435\u0440\u044f\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u044b? \u0412\u043d\u043e\u0432\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<pre><code>while True:     if \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c:                      #N         \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c     else:         if \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0440\u0430\u0437\u043d\u043e\u0435:   #M             \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435         else:                                             #P             \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u044b\u0431\u043e\u0440 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432? \u041f\u0443\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f {12*, 11*, 14*, 212, 213, 221, 225}. \u0415\u0441\u043b\u0438 \u0446\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 218, \u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u0441 212, \u043b\u0438\u0431\u043e \u0441 213. \u0415\u0441\u043b\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u0447\u0442\u043e 213 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437, \u0442\u043e \u0432\u044b\u0431\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0439 \u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438 TIME. \u0425\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442, \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043b\u043e\u0436\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0421\u0430\u043c\u0430 \u0438\u0434\u0435\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 &#8212; \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (<a href=\"https:\/\/github.com\/bulygina07\/rp\/blob\/master\/random_path.py\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434<\/a> + <a href=\"https:\/\/soundcloud.com\/user-636259853\/rp-voice\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a\u043e\u0434\u0430 \u041d\u0430\u0441\u0442\u0438<\/a>). \u041c\u043e\u0436\u0435\u0442 \u043e\u0448\u0438\u0431\u0430\u044e\u0441\u044c, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b, \u043a\u0430\u043a \u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430. \u0411\u044b\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043e 10 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 J(P), \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 J(M). \u0417\u0434\u0435\u0441\u044c \u0436\u0435\u043b\u0442\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 J &#8212; \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. P &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. M &#8212; \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. N &#8212; \u0438\u0449\u0435\u0442 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td>\n<p><strong>J(P)<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<\/td>\n<td>\n<\/td>\n<td>\n<p><strong>J(M)<\/strong><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<\/td>\n<td>\n<p><strong>P<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p><strong>M<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p><strong>N<\/strong><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p><strong>P<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>M<\/strong><\/p>\n<\/td>\n<td>\n<p><strong>N<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>1<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>31<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>7<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>20<\/p>\n<\/td>\n<td>\n<p>17<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>2<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>43<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>15<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>18<\/p>\n<\/td>\n<td>\n<p>38<\/p>\n<\/td>\n<td>\n<p>38<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>3<\/p>\n<\/td>\n<td>\n<p>32<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>12<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>25<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>36<\/p>\n<\/td>\n<td>\n<p>18<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>4<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>34<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>8<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>50<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>5<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>13<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>12<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>6<\/p>\n<\/td>\n<td>\n<p>39<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>8<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>23<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>24<\/p>\n<\/td>\n<td>\n<p>24<\/p>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>7<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>14<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>7<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td>\n<p>37<\/p>\n<\/td>\n<td>\n<p>11<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>8<\/p>\n<\/td>\n<td>\n<p>>50<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>29<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>13<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>29<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>9<\/p>\n<\/td>\n<td>\n<p>10<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>7<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>13<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>17<\/p>\n<\/td>\n<td>\n<p>26<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p>10<\/p>\n<\/td>\n<td>\n<p>27<\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p>21<\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p>9<\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p>15<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"83\" width=\"83\">\n<p><em>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0434\u043e \u0446\u0435\u043b\u0438<\/em><\/p>\n<\/td>\n<td>\n<p><em>39.8<\/em><\/p>\n<\/td>\n<td data-colwidth=\"83\" width=\"83\">\n<p><em>21.2<\/em><\/p>\n<\/td>\n<td data-colwidth=\"84\" width=\"84\">\n<p><em>13.2<\/em><\/p>\n<\/td>\n<td>\n<\/td>\n<td>\n<p><em>28.6<\/em><\/p>\n<\/td>\n<td>\n<p><em>25.1<\/em><\/p>\n<\/td>\n<td>\n<p><em>12.7<\/em><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0438\u043c\u0435\u043d\u043d\u043e N \u0432 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0435 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c P. \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0446\u0435\u043b\u044c J(M) \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e J(P) \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043b\u043e\u0449\u0430\u0434\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0441 P \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code>from tkinter import * import random  TIME = 10  class Z():     def __init__(self, root, maps, ban):         self.root = root         self.maps = maps         self.ban = ban         Z.time = {}         Z.hierarchy = {}         Z.neighbor = {}                    self.init_3_dict(self.maps, self.ban)              def init_3_dict(self, maps, ban):         def is_en(yx):             if yx[0] &lt; 0 or yx[0] > len(maps)-1: return             if yx[1] &lt; 0 or yx[1] > len(maps[0])-1: return             if yx in ban: return             return True                      for y in range(len(self.maps)):             for x in range(len(self.maps[0])):                 Z.hierarchy[(y,x)] = maps[y][x]                                  n = []                 if is_en((y-1,x)):                     n.append((y-1,x))                 if is_en((y+1,x)):                     n.append((y+1,x))                 if is_en((y,x-1)):                     n.append((y,x-1))                 if is_en((y,x+1)):                     n.append((y,x+1))                                      Z.neighbor[(y,x)] = n                                  self.time[(y,x)] = 0                 if (y, x) in self.ban:                     lb = Label(text=\" \", background = 'black')                     lb.configure(text=self.maps[y][x])                 else:                     lb = Label(text=\" \", background = 'white')                     lb.configure(text=self.maps[y][x])                 lb.grid(row=y, column=x, ipadx=10, ipady=5, padx=1, pady=1)                  self.update()                                  def update(self):         for y in range(len(self.maps)):             for x in range(len(self.maps[0])):                 if Z.time[(y,x)]:                     Z.time[(y,x)] -=1                 else:                    Z.hierarchy[(y,x)] = maps[y][x]                                         if not (y, x) in self.ban:                        lb = Label(text=\" \", background = 'white')                        lb.configure(text=Z.hierarchy[(y,x)])                        lb.grid(row=y, column=x, ipadx=10, ipady=5, padx=1, pady=1)                          self.root.after(500, self.update)                   class P():     def __init__(self, root, color, node, target, maps, ban):         self.root = root         self.color = color         self.y = node[0]         self.x = node[1]         self.target = target         self.count = 0                  self.visit = {}         P.neighbor = {}          self.visit[(self.y, self.x)] = 1         P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                      def update(self):         self.move()            self.root.after(500, self.update)      def show(self, y, x, color):         lb = Label(text=\" \", background = color)         lb.configure(text=Z.hierarchy[(y,x)] )         lb.grid(row=self.y, column=self.x, ipadx=10, ipady=5, padx=1, pady=1)              def choice(self, yx):         v = []                  for i in P.neighbor[yx]:              if not yx in self.visit:                 self.visit[yx] = 0             v.append(i)             return random.choice(v)              def move(self):         for i in Z.neighbor[(self.y, self.x)]:             if (self.y, self.x) not in P.neighbor:                 P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                      y,x = self.choice((self.y, self.x))                  self.show(self.y, self.x, 'white')             self.y = y         self.x = x         self.show(y, x, self.color)                  self.count +=1                           if self.target == Z.hierarchy[(self.y, self.x)]:             #J.disable = True             self.top_show()                        def update(self):         self.move()            self.root.after(500, self.update)              def top_show(self):         top = Toplevel()         lbt = Label(top, text=self.color + \" = \" + str(self.count))         lbt.pack()         top.mainloop()                   class M(P):     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         self.visit[node] += 1              def move(self):         yx = self.choice((self.y, self.x))                  self.show(self.y, self.x, 'white')             self.y = yx[0]         self.x = yx[1]         self.show(yx[0], yx[1], self.color)                  self.count +=1                  if self.target == Z.hierarchy[(self.y, self.x)]:             #J.disable = True             self.top_show()              def choice(self, yx):         v = []                  for i in Z.neighbor[yx]:             if (yx) not in P.neighbor:                 P.neighbor[yx] = Z.neighbor[yx]                          for i in P.neighbor[yx]:              if not i in self.visit:                 self.visit[i] = 0             v.append((i, self.visit[i]))                       v.sort(key = lambda x: x[1], reverse = False)         v = [i for i in v if v[0][1] == i[1]]         v = random.choice(v)         self.visit[v[0]] += 1         return v[0]                   class N(M):     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         self.coincidence = 0              def choice(self, yx):         v = []                  for i in Z.neighbor[yx]:             if (yx) not in P.neighbor:                 P.neighbor[yx] = Z.neighbor[yx]                          for i in P.neighbor[yx]:              if not i in self.visit:                 self.visit[i] = 0             v.append((i, self.visit[i]))                       d = []         for l in v:             c = Z.hierarchy[l[0]]                          r = 0             for i in range(len(self.target)):                 if c[i] == self.target[i]:                     r +=1                 else: break                               if r > self.coincidence:                 self.coincidence = r                 d = [l]             if r == self.coincidence:                 d.append(l)                  if d: v = d                      v.sort(key = lambda x: x[1], reverse = False)         v = [i for i in v if v[0][1] == i[1]]         v = random.choice(v)         self.visit[v[0]] += 1         return v[0]                      class J(P): #J(P) or J(M)     def __init__(self, root, color, node, target, maps, ban):         super().__init__(root, color, node, target, maps, ban)         J.disable = False              def move(self):         if not J.disable:             v = []                          for i in Z.neighbor[(self.y, self.x)]:                 if (self.y, self.x) not in P.neighbor:                     P.neighbor[(self.y, self.x)] = Z.neighbor[(self.y, self.x)]                              y,x = self.choice((self.y, self.x))                          Z.hierarchy[(self.y, self.x)] = self.target[:-1] + \\               str(int(self.target[-1]) - 1) #'4288'             Z.time[(y, x)] = TIME                              self.show(self.y, self.x, 'white')                self.y = y             self.x = x             Z.hierarchy[(self.y, self.x)] = self.target             self.show(y, x, self.color)               #--------- main ---------#     if __name__ == \"__main__\":          root = Tk()          target = ('4289')     ban=[(1,1), (1,2), (2,3), (5,5)]           '''     maps = [ [\"011\", \"012\", \"013\", \"211\", \"212\", \"201\"],              [\"014\", \"015\", \"021\", \"213\", \"214\", \"202\"],              [\"022\", \"023\", \"024\", \"215\", \"216\", \"203\"],              [\"025\", \"026\", \"027\", \"213\", \"204\", \"205\"],              [\"101\", \"102\", \"103\", \"121\", \"122\", \"123\"],              [\"104\", \"105\", \"106\", \"124\", \"125\", \"126\"]     ]     '''          maps = [<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-330975","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=330975"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330975\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=330975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=330975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=330975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}