{"id":347973,"date":"2023-05-28T09:01:02","date_gmt":"2023-05-28T09:01:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347973"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347973","title":{"rendered":"<span>\u0415\u0441\u0442\u044c \u0442\u0430\u043c \u043c\u043e\u043b\u043e\u0442, \u0435\u0441\u0442\u044c \u0442\u0430\u043c \u0441\u0435\u0440\u043f\u2026<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0433\u0440\u044b \u0441 \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043a\u043e\u0439, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0435\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/www.gimp.org\/\" rel=\"noopener noreferrer nofollow\">gimp<\/a>) \u0438 \u043f\u0435\u0440\u0435\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u0432 \u043d\u0451\u043c \u0432\u0441\u0435 \u043f\u043b\u0438\u0442\u043a\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 0 \u0434\u043e 7. \u0427\u0438\u0441\u043b\u043e\u043c 8 \u0437\u0430\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043f\u043b\u0438\u0442\u043a\u0443 (\u0434\u044b\u0440\u043a\u0443) :<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8b\/c26\/912\/a8bc26912f88004f0c7c76f82a622af3.png\" alt=\"\u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u0438\u0433\u0440\u044b. \u0420\u0430\u0437\u043c\u0435\u0440 741x741.\" title=\"\u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u0438\u0433\u0440\u044b. \u0420\u0430\u0437\u043c\u0435\u0440 741x741.\" width=\"741\" height=\"741\"><\/p>\n<div><figcaption>\u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u0438\u0433\u0440\u044b. \u0420\u0430\u0437\u043c\u0435\u0440 741&#215;741.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u0438\u0439 \u0438 \u0432\u0441\u0442\u0430\u0432\u043e\u043a. \u0423 \u043c\u0435\u043d\u044f \u0445\u043e\u0442\u044c \u043a\u0440\u0438\u0432\u043e \u0438 \u043a\u043e\u0441\u043e, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/019\/3d1\/66e\/0193d166e415dfbcb059a272857815d9.png\" alt=\"\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435\" title=\"\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435\" width=\"741\" height=\"741\"><\/p>\n<div><figcaption>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0430\u0431\u0443\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043b\u0438\u0442\u043e\u043a. \u0422\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3&#215;3, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 0 \u0434\u043e 8. \u041a\u0430\u0436\u0434\u044b\u043c \u0445\u043e\u0434\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 8 \u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0435\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u0438\u043b\u0438 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u043e\u0434\u043e\u0432, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>                        0<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    1<\/p>\n<\/td>\n<td>\n<p align=\"left\">                   2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    4        <\/p>\n<\/td>\n<td>\n<p align=\"left\">                   5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                        6<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    7<\/p>\n<\/td>\n<td>\n<p align=\"left\">                   8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">                      1<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  0<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                      6<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  3<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                      2<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  7<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0412\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u044d\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438 \u0432 \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442\u0435, \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u043b\u043d\u044b \u0432 \u043d\u0435\u043a\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c \u0413\u044e\u0439\u0433\u0435\u043d\u0441\u0430 &#8212; \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432\u043e\u043b\u043d\u044b. \u0421\u0440\u0435\u0434\u0430 \u0442\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f, \u0434\u0430\u0432\u0430\u0442\u044c \u0448\u0442\u0440\u0430\u0444\u044b \u0438\u043b\u0438 \u043f\u043e\u043e\u0449\u0440\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0438 \u0438 \u0442.\u043f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u043d\u0430\u043a\u043e\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u044e\u0434\u0443, \u0433\u0434\u0435 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0447\u043a\u0438 \u0410 \u0432 \u0442\u043e\u0447\u043a\u0443 \u0412 (\u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d). \u041e\u0442 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0438 \u0447\u0438\u043f\u043e\u0432, \u0434\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043e\u0444\u0438\u0441\u043d\u043e\u0439 \u0438\u0433\u0440\u044b Lines. <\/p>\n<p>\u0417\u0430\u0431\u0443\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043f\u0440\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0446\u0435\u043b\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c {0, 1, 2, 3, 4, 5, 6, 7, 8}, \u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f &#8212; {1, 0, 4, 6, 3, 5, 2, 7, 8}. \u0421\u0440\u0435\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0430 \u0432\u043e\u043b\u043d\u0430 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432. \u0422\u043e\u0447\u043d\u0435\u0435 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0430\u043a. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0443\u0441\u043f\u0435\u0445\u043e\u043c (\u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0438 \u043d\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e !), \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u0430  {1, 0, 4, 6, 3, 5, 2, 7, 8}. \u041d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043d\u0435 \u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0443\u0441\u043f\u0435\u0445\u0430, \u0430 \u043f\u0443\u0442\u044c \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443. \u0417\u043d\u0430\u0447\u0438\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u0440\u0435\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430  \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b (\u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u043b\u043d\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443). \u0414\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432) \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u043e\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c, \u043c\u044b \u0432\u044b\u0442\u0430\u0449\u0438\u043c \u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0435\u0434 \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c. \u041d\u0443 \u0438 \u0440\u0430\u0437 \u0443\u0436 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u0435\u043d \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u044b\u0445, \u0432 \u043d\u0451\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043e\u0434\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0435\u0449\u0451 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0411\u0443\u0434\u0435\u043c \u0442\u0430\u043c \u0437\u0430\u043e\u0434\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438 (\u0442.\u0435. \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0441 \u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u043e\u0439). \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 (\u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0451 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 java), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b:<\/p>\n<pre><code class=\"java\">class Node {   public int[] value;    \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a public Node  parent;   \/\/\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b public int act;        \/\/\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0430\u044f) \u043f\u043b\u0438\u0442\u043a\u0430 Node() {value=null; parent=null; act=-1;} }<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u043e\u0432\u0435\u0441\u043d\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0432 {0, 1, 2, 3, 4, 5, 6, 7, 8}, \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0443\u0441\u0442\u043e\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e:<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0438 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u0451 \u0441\u043e\u0441\u0435\u0434\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0442 \u0441\u043e\u0441\u0435\u0434 \u0438 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0430 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u0436\u0435 \u0431\u044b\u043b, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0435\u0449\u0451 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0441\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0443\u0437\u0435\u043b, \u0441 \u044d\u0442\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0443\u0437\u0435\u043b \u0438\u0437 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430. \u0418 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438 &#8212; \u0447\u0438\u0441\u043b\u043e, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0430 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0443\u0437\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u0435\u0432\u044b\u043c. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u043f\u0443\u0441\u0442, \u043d\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u0443\u0441\u0442, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0443\u043d\u043a\u0442\u0443 2.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 java \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0448\u0430\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u0435 \u043f\u0438\u043d\u0430\u0439\u0442\u0435 \u043d\u043e\u0433\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u0440\u044f\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043f\u043e-\u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443. \u041a\u0440\u043e\u043c\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043e\u043d\u0430 \u0435\u0449\u0451 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0445\u043e\u0434\u044b, \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b, \u0438 \u044f \u0438\u0445 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e. \u0414\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0435\u0439 \u043d\u0443\u0436\u0435\u043d \u0444\u0430\u0439\u043b puzzle.png. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c  \u043f\u0435\u0440\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>\u0422\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; import java.util.HashSet; import javax.imageio.ImageIO;  public class Main  { \/\/\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u043b\u0438\u0442\u043a\u0443 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c p0 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 img0 \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u044e p1 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f img1. \/\/\u0415\u0441\u043b\u0438 hl=true, \u043f\u043b\u0438\u0442\u043a\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f static void copy(int p0, BufferedImage img0, int p1, BufferedImage img1, boolean hl) { int ww=img0.getWidth()\/3; int hh=img0.getHeight()\/3; int y0=(p0\/3)*hh; int x0=(p0%3)*ww; int y1=(p1\/3)*hh; int x1=(p1%3)*ww; for(int i=0; i&lt;hh; i++) { for(int j=0; j&lt;ww; j++) { int rgb=img0.getRGB(x0+j, y0+i); if(hl) { int d=100; int r=((rgb&gt;&gt;16)&amp;255)+d, g=((rgb&gt;&gt;8)&amp;255)+d, b=(rgb&amp;255)+d; if(r&gt;255) r=255; if(g&gt;255) g=255; if(b&gt;255) b=255; rgb=(255&lt;&lt;24)+(r&lt;&lt;16)+(g&lt;&lt;8)+b;  } img1.setRGB(x1+j, y1+i, rgb); } } }  \/\/\u0421\u0442\u0440\u043e\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 img1 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f img0 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043f\u043b\u0438\u0442\u043e\u043a a. \/\/hl - \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438. static void makeAll(int[] a, BufferedImage img0, BufferedImage img1, int hl) { for(int i=0; i&lt;a.length; i++) { copy(a[i], img0, i, img1, (i==hl)); } }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043f\u043b\u0438\u0442\u043e\u043a a \u0432 \u0444\u0430\u0439\u043b \u043eut. \u041f\u043b\u0438\u0442\u043a\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c hl \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. static void outPosition(int[] a, String out, int hl) { try { BufferedImage img=ImageIO.read(new File(\"puzzle.png\")); int ww=img.getWidth(); int hh=img.getHeight(); int type=img.getType(); BufferedImage img1=new BufferedImage(ww, hh, type); makeAll(a, img, img1, hl); ImageIO.write(img1, \"png\", new File(out)); } catch (Exception e) { e.printStackTrace(); } }  \/\/\u041a\u043b\u0430\u0441\u0441 \u0443\u0437\u043b\u043e\u0432 \u0441\u0440\u0435\u0434\u044b static class Node { public int[] value;    \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a public Node  parent;   \/\/\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b public int act;        \/\/\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0430\u044f) \u043f\u043b\u0438\u0442\u043a\u0430 Node() {value=null; parent=null; act=-1;} } static String target;           \/\/\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 static HashSet&lt;String&gt; field;   \/\/\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0436\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a static ArrayList&lt;Node&gt; nodes;   \/\/\u041c\u0430\u0441\u0441\u0438\u0432 \u0443\u0437\u043b\u043e\u0432 static ArrayList&lt;Node&gt; front;   \/\/\u0424\u0440\u043e\u043d\u0442 \u0432\u043e\u043b\u043d\u044b  \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a (\u043f\u043e\u043b\u0435 value \u0443\u0437\u043b\u0430 Node) \/\/\u0412\u044b\u0434\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0447\u0438\u0441\u043b\u0430 8, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 - \u0441\u043e\u0441\u0435\u0434\u0438 \u0447\u0438\u0441\u043b\u0430 8. static int[] getNeibours(int[] val) { int pos=0; for(int i=0; i&lt;val.length; i++) { if(val[i]==8) {pos=i; break;} } if((pos&lt;0)||(pos&gt;8)) return null; int x=pos%3, y=pos\/3; int n=0; int[] a=new int[6]; a[n++]=pos; if(x-1 &gt;= 0) a[n++]=pos-1; if(x+1 &lt;  3) a[n++]=pos+1; if(y-1 &gt;= 0) a[n++]=pos-3; if(y+1 &lt;  3) a[n++]=pos+3; int[] b=new int[n]; for(int i=0; i&lt;n; i++) b[i]=a[i]; return b; }  \/\/\u041c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 static String toString(int[] val) { String s=\"\"; String a=\"012345678\"; for(int i=0; i&lt;val.length; i++) s+=a.charAt(val[i]); return s; }  \/\/\u0428\u0430\u0433 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 static int step() { ArrayList&lt;Node&gt; tmp=new ArrayList&lt;&gt;(); \/\/\u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 for(int i=0; i&lt;front.size(); i++)  {\/\/\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0441\u0442\u0430\u0440\u043e\u043c\u0443 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 Node nd=front.get(i); int[] neib=getNeibours(nd.value); \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432 int pos=neib[0]; if(neib != null) { for(int j=1; j&lt;neib.length; j++) {\/\/\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c 8 int[] val=new int[nd.value.length]; for(int k=0; k&lt;nd.value.length; k++) val[k]=nd.value[k]; int t=val[pos]; val[pos]=val[neib[j]]; val[neib[j]]=t; if(field.add(toString(val))) \/\/\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0438 \u043c\u044b \u0443\u0436\u0435 \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438\u043b\u0438 \u043d\u0435\u0442  {\/\/\u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0437\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442  Node nd1=new Node(); nd1.value=val; nd1.parent=nd; nd1.act=neib[j]; tmp.add(nd1); nodes.add(nd1); if(target.equals(toString(val)))  return 1; \/\/\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e } } } } if(tmp.size()==0)  return -1; \/\/\u0435\u0441\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u043f\u0443\u0441\u0442\u043e\u0439, \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d front=tmp; \/\/\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 return 0; }  \/\/\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u043a \u043d\u0430\u0447\u0430\u043b\u0443 static ArrayList&lt;Node&gt; extractPath() { ArrayList&lt;Node&gt; path=new ArrayList&lt;&gt;(); Node nd=nodes.get(nodes.size()-1); int act=-1; do { Node nd1=nd.parent; int act1=nd.act; nd.act=act; path.add(nd); nd=nd1; act=act1; } while(nd != null); return path; }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u0443 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 static void makeTotal() { try { BufferedImage img=ImageIO.read(new File(\"puzzle.png\")); int ww=img.getWidth(); int hh=img.getHeight(); int type=img.getType(); int gap=30; \/\/\u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 BufferedImage img1=new BufferedImage(5*ww+4*gap, 4*hh+3*gap, type); Graphics2D gr=img1.createGraphics(); gr.setPaint(new Color(255, 255, 255)); gr.fillRect ( 0, 0, img1.getWidth(), img1.getHeight());  int nn=1; int xx=0, yy=0; for(int i=0; i&lt;4; i++) { xx=0; for(int j=0; j&lt;5; j++) { String name=\".\/solution\/step_\"+nn+\".png\"; nn++; BufferedImage imgn=ImageIO.read(new File(name)); int w=imgn.getWidth(), h=imgn.getHeight(); for(int y=0; y&lt;h; y++) { for(int x=0; x&lt;w; x++) { int rgb=imgn.getRGB(x, y); img1.setRGB(x+xx, y+yy, rgb); } } xx+=ww+gap; } yy+=hh+gap; } ImageIO.write(img1, \"png\", new File(\".\/solution\/total.png\")); } catch (Exception e) { e.printStackTrace(); } }  static void solve() { field=new HashSet&lt;&gt;(); nodes=new ArrayList&lt;&gt;(); front=new ArrayList&lt;&gt;(); target=\"104635278\"; int[] a= new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; Node nd0 = new Node(); nd0.value=a; field.add(toString(a)); nodes.add(nd0); front.add(nd0); int res=0; while(res==0) res=step(); if(res==1)  { System.out.println(\"Puzzle solved. Now save pictures\"); ArrayList&lt;Node&gt; path=extractPath(); for(int i=0; i&lt;path.size(); i++) { outPosition(path.get(i).value, \".\/solution\/step_\"+(path.size()-i)+\".png\", path.get(i).act); } makeTotal(); System.out.println(\"Done\"); } else { System.out.println(\"Solution not found\"); } }  public static void main(String[] args)  {                      solve(); } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041f\u043e\u0437\u0438\u0446\u0438\u0438 \u0442\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437. \u041f\u0435\u0440\u0432\u0430\u044f \u0432 \u043b\u0435\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f &#8212; \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c. \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u0430 \u043f\u043b\u0438\u0442\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u043d\u0443\u0442\u044c. \u0412\u0441\u0435\u0433\u043e 20 \u0445\u043e\u0434\u043e\u0432 \u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u0442\u0430\u043b \u043a \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0443 \u0421\u0442\u0430\u043b\u0438\u043d\u0443. \u0423 \u043d\u0435\u0433\u043e \u043c\u044b \u0441\u0438\u0433\u0430\u0440\u0435\u0442\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u0436\u0438\u0432\u0435\u043c\u0441\u044f !<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/56b\/fc2\/200\/56bfc220070ed314f722e83b9573056e.png\" alt=\"\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0443. \u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430.\" title=\"\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0443. \u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430.\" width=\"1200\" height=\"958\"><\/p>\n<div><figcaption>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0443. \u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430.<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/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\/articles\/738044\/\"> https:\/\/habr.com\/ru\/articles\/738044\/<\/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 article-formatted-body_version-2\">\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0433\u0440\u044b \u0441 \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043a\u043e\u0439, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0435\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/www.gimp.org\/\" rel=\"noopener noreferrer nofollow\">gimp<\/a>) \u0438 \u043f\u0435\u0440\u0435\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u0432 \u043d\u0451\u043c \u0432\u0441\u0435 \u043f\u043b\u0438\u0442\u043a\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043e\u0442 0 \u0434\u043e 7. \u0427\u0438\u0441\u043b\u043e\u043c 8 \u0437\u0430\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043f\u043b\u0438\u0442\u043a\u0443 (\u0434\u044b\u0440\u043a\u0443) :<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0437 \u0438\u0433\u0440\u044b. \u0420\u0430\u0437\u043c\u0435\u0440 741&#215;741.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u0438\u0439 \u0438 \u0432\u0441\u0442\u0430\u0432\u043e\u043a. \u0423 \u043c\u0435\u043d\u044f \u0445\u043e\u0442\u044c \u043a\u0440\u0438\u0432\u043e \u0438 \u043a\u043e\u0441\u043e, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0430\u0431\u0443\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043b\u0438\u0442\u043e\u043a. \u0422\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3&#215;3, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 0 \u0434\u043e 8. \u041a\u0430\u0436\u0434\u044b\u043c \u0445\u043e\u0434\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 8 \u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0435\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u0438\u043b\u0438 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438. \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u043e\u0434\u043e\u0432, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>                        0<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    1<\/p>\n<\/td>\n<td>\n<p align=\"left\">                   2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    4        <\/p>\n<\/td>\n<td>\n<p align=\"left\">                   5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                        6<\/p>\n<\/td>\n<td>\n<p align=\"left\">                    7<\/p>\n<\/td>\n<td>\n<p align=\"left\">                   8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">                      1<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  0<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                      6<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  3<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">                      2<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  7<\/p>\n<\/td>\n<td>\n<p align=\"left\">                  8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0412\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u044d\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438 \u0432 \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442\u0435, \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u043b\u043d\u044b \u0432 \u043d\u0435\u043a\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c \u0413\u044e\u0439\u0433\u0435\u043d\u0441\u0430 &#8212; \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432\u043e\u043b\u043d\u044b. \u0421\u0440\u0435\u0434\u0430 \u0442\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f, \u0434\u0430\u0432\u0430\u0442\u044c \u0448\u0442\u0440\u0430\u0444\u044b \u0438\u043b\u0438 \u043f\u043e\u043e\u0449\u0440\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0438 \u0438 \u0442.\u043f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u043d\u0430\u043a\u043e\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0441\u044e\u0434\u0443, \u0433\u0434\u0435 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0438\u0437 \u0442\u043e\u0447\u043a\u0438 \u0410 \u0432 \u0442\u043e\u0447\u043a\u0443 \u0412 (\u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d). \u041e\u0442 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0438 \u0447\u0438\u043f\u043e\u0432, \u0434\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043e\u0444\u0438\u0441\u043d\u043e\u0439 \u0438\u0433\u0440\u044b Lines. <\/p>\n<p>\u0417\u0430\u0431\u0443\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043f\u0440\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0446\u0435\u043b\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e, \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c {0, 1, 2, 3, 4, 5, 6, 7, 8}, \u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f &#8212; {1, 0, 4, 6, 3, 5, 2, 7, 8}. \u0421\u0440\u0435\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0430 \u0432\u043e\u043b\u043d\u0430 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432. \u0422\u043e\u0447\u043d\u0435\u0435 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0430\u043a. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0443\u0441\u043f\u0435\u0445\u043e\u043c (\u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0438 \u043d\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e !), \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u0430  {1, 0, 4, 6, 3, 5, 2, 7, 8}. \u041d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043d\u0435 \u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0443\u0441\u043f\u0435\u0445\u0430, \u0430 \u043f\u0443\u0442\u044c \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443. \u0417\u043d\u0430\u0447\u0438\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u0440\u0435\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430  \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b (\u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043e\u043b\u043d\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443). \u0414\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432) \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u043e\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c, \u043c\u044b \u0432\u044b\u0442\u0430\u0449\u0438\u043c \u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0435\u0434 \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c. \u041d\u0443 \u0438 \u0440\u0430\u0437 \u0443\u0436 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u0435\u043d \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u044b\u0445, \u0432 \u043d\u0451\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043e\u0434\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0435\u0449\u0451 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0411\u0443\u0434\u0435\u043c \u0442\u0430\u043c \u0437\u0430\u043e\u0434\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u0435\u043c\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438 (\u0442.\u0435. \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0441 \u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u043e\u0439). \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 (\u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0451 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 java), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b:<\/p>\n<pre><code class=\"java\">class Node {   public int[] value;    \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a public Node  parent;   \/\/\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b public int act;        \/\/\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0430\u044f) \u043f\u043b\u0438\u0442\u043a\u0430 Node() {value=null; parent=null; act=-1;} }<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u043e\u0432\u0435\u0441\u043d\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b \u0441\u0440\u0435\u0434\u044b, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0432 {0, 1, 2, 3, 4, 5, 6, 7, 8}, \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0443\u0441\u0442\u043e\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e:<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0438 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u0451 \u0441\u043e\u0441\u0435\u0434\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0442 \u0441\u043e\u0441\u0435\u0434 \u0438 \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0430 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u0436\u0435 \u0431\u044b\u043b, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0435\u0449\u0451 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0441\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0443\u0437\u0435\u043b, \u0441 \u044d\u0442\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0443\u0437\u0435\u043b \u0438\u0437 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430. \u0418 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438 &#8212; \u0447\u0438\u0441\u043b\u043e, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u043e\u0441\u044c\u043c\u0435\u0440\u043a\u0430 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0443\u0437\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u0435\u0432\u044b\u043c. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u043f\u0443\u0441\u0442, \u043d\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u0443\u0441\u0442, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0443\u043d\u043a\u0442\u0443 2.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 java \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0448\u0430\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u0435 \u043f\u0438\u043d\u0430\u0439\u0442\u0435 \u043d\u043e\u0433\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u0440\u044f\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043f\u043e-\u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443. \u041a\u0440\u043e\u043c\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043e\u043d\u0430 \u0435\u0449\u0451 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0445\u043e\u0434\u044b, \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b, \u0438 \u044f \u0438\u0445 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e. \u0414\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0435\u0439 \u043d\u0443\u0436\u0435\u043d \u0444\u0430\u0439\u043b puzzle.png. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c  \u043f\u0435\u0440\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>\u0422\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; import java.util.HashSet; import javax.imageio.ImageIO;  public class Main  { \/\/\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u043b\u0438\u0442\u043a\u0443 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c p0 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 img0 \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u044e p1 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f img1. \/\/\u0415\u0441\u043b\u0438 hl=true, \u043f\u043b\u0438\u0442\u043a\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f static void copy(int p0, BufferedImage img0, int p1, BufferedImage img1, boolean hl) { int ww=img0.getWidth()\/3; int hh=img0.getHeight()\/3; int y0=(p0\/3)*hh; int x0=(p0%3)*ww; int y1=(p1\/3)*hh; int x1=(p1%3)*ww; for(int i=0; i&lt;hh; i++) { for(int j=0; j&lt;ww; j++) { int rgb=img0.getRGB(x0+j, y0+i); if(hl) { int d=100; int r=((rgb&gt;&gt;16)&amp;255)+d, g=((rgb&gt;&gt;8)&amp;255)+d, b=(rgb&amp;255)+d; if(r&gt;255) r=255; if(g&gt;255) g=255; if(b&gt;255) b=255; rgb=(255&lt;&lt;24)+(r&lt;&lt;16)+(g&lt;&lt;8)+b;  } img1.setRGB(x1+j, y1+i, rgb); } } }  \/\/\u0421\u0442\u0440\u043e\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 img1 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f img0 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043f\u043b\u0438\u0442\u043e\u043a a. \/\/hl - \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438. static void makeAll(int[] a, BufferedImage img0, BufferedImage img1, int hl) { for(int i=0; i&lt;a.length; i++) { copy(a[i], img0, i, img1, (i==hl)); } }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043f\u043b\u0438\u0442\u043e\u043a a \u0432 \u0444\u0430\u0439\u043b \u043eut. \u041f\u043b\u0438\u0442\u043a\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c hl \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. static void outPosition(int[] a, String out, int hl) { try { BufferedImage img=ImageIO.read(new File(\"puzzle.png\")); int ww=img.getWidth(); int hh=img.getHeight(); int type=img.getType(); BufferedImage img1=new BufferedImage(ww, hh, type); makeAll(a, img, img1, hl); ImageIO.write(img1, \"png\", new File(out)); } catch (Exception e) { e.printStackTrace(); } }  \/\/\u041a\u043b\u0430\u0441\u0441 \u0443\u0437\u043b\u043e\u0432 \u0441\u0440\u0435\u0434\u044b static class Node { public int[] value;    \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a public Node  parent;   \/\/\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0443\u0437\u0435\u043b public int act;        \/\/\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f (\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0430\u044f) \u043f\u043b\u0438\u0442\u043a\u0430 Node() {value=null; parent=null; act=-1;} } static String target;           \/\/\u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 static HashSet&lt;String&gt; field;   \/\/\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0436\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a static ArrayList&lt;Node&gt; nodes;   \/\/\u041c\u0430\u0441\u0441\u0438\u0432 \u0443\u0437\u043b\u043e\u0432 static ArrayList&lt;Node&gt; front;   \/\/\u0424\u0440\u043e\u043d\u0442 \u0432\u043e\u043b\u043d\u044b  \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a (\u043f\u043e\u043b\u0435 value \u0443\u0437\u043b\u0430 Node) \/\/\u0412\u044b\u0434\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0447\u0438\u0441\u043b\u0430 8, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 - \u0441\u043e\u0441\u0435\u0434\u0438 \u0447\u0438\u0441\u043b\u0430 8. static int[] getNeibours(int[] val) { int pos=0; for(int i=0; i&lt;val.length; i++) { if(val[i]==8) {pos=i; break;} } if((pos&lt;0)||(pos&gt;8)) return null; int x=pos%3, y=pos\/3; int n=0; int[] a=new int[6]; a[n++]=pos; if(x-1 &gt;= 0) a[n++]=pos-1; if(x+1 &lt;  3) a[n++]=pos+1; if(y-1 &gt;= 0) a[n++]=pos-3; if(y+1 &lt;  3) a[n++]=pos+3; int[] b=new int[n]; for(int i=0; i&lt;n; i++) b[i]=a[i]; return b; }  \/\/\u041c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 static String toString(int[] val) { String s=\"\"; String a=\"012345678\"; for(int i=0; i&lt;val.length; i++) s+=a.charAt(val[i]); return s; }  \/\/\u0428\u0430\u0433 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 static int step() { ArrayList&lt;Node&gt; tmp=new ArrayList&lt;&gt;(); \/\/\u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 for(int i=0; i&lt;front.size(); i++)  {\/\/\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0441\u0442\u0430\u0440\u043e\u043c\u0443 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u043c\u0443 \u0444\u0440\u043e\u043d\u0442\u0443 Node nd=front.get(i); int[] neib=getNeibours(nd.value); \/\/\u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432 int pos=neib[0]; if(neib != null) { for(int j=1; j&lt;neib.length; j++) {\/\/\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c 8 int[] val=new int[nd.value.length]; for(int k=0; k&lt;nd.value.length; k++) val[k]=nd.value[k]; int t=val[pos]; val[pos]=val[neib[j]]; val[neib[j]]=t; if(field.add(toString(val))) \/\/\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0438 \u043c\u044b \u0443\u0436\u0435 \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438\u043b\u0438 \u043d\u0435\u0442  {\/\/\u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0437\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0437\u043b\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442  Node nd1=new Node(); nd1.value=val; nd1.parent=nd; nd1.act=neib[j]; tmp.add(nd1); nodes.add(nd1); if(target.equals(toString(val)))  return 1; \/\/\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e } } } } if(tmp.size()==0)  return -1; \/\/\u0435\u0441\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 \u043f\u0443\u0441\u0442\u043e\u0439, \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d front=tmp; \/\/\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u043b\u043d\u043e\u0432\u043e\u0439 \u0444\u0440\u043e\u043d\u0442 return 0; }  \/\/\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u043a \u043d\u0430\u0447\u0430\u043b\u0443 static ArrayList&lt;Node&gt; extractPath() { ArrayList&lt;Node&gt; path=new ArrayList&lt;&gt;(); Node nd=nodes.get(nodes.size()-1); int act=-1; do { Node nd1=nd.parent; int act1=nd.act; nd.act=act; path.add(nd); nd=nd1; act=act1; } while(nd != null); return path; }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u0443 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 static void makeTotal() { try { BufferedImage img=ImageIO.read(new File(\"puzzle.png\")); int ww=img.getWidth(); int hh=img.getHeight(); int type=img.getType(); int gap=30; \/\/\u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 BufferedImage img1=new BufferedImage(5*ww+4*gap, 4*hh+3*gap, type); Graphics2D gr=img1.createGraphics(); gr.setPaint(new Color(255, 255, 255)); gr.fillRect ( 0, 0, img1.getWidth(), img1.getHeight());  int nn=1; int xx=0, yy=0; for(int i=0; i&lt;4; i++) { xx=0; for(int j=0; j&lt;5; j++) { String name=\".\/solution\/step_\"+nn+\".png\"; nn++; BufferedImage imgn=ImageIO.read(new File(name)); int w=imgn.getWidth(), h=imgn.getHeight(); for(int y=0; y&lt;h; y++) { for(int x=0; x&lt;w; x++) { int rgb=imgn.getRGB(x, y); img1.setRGB(x+xx, y+yy, rgb); } } xx+=ww+gap; } yy+=hh+gap; } ImageIO.write(img1, \"png\", new File(\".\/solution\/total.png\")); } catch (Exception e) { e.printStackTrace(); } }  static void solve() { field=new HashSet&lt;&gt;(); nodes=new ArrayList&lt;&gt;(); front=new ArrayList&lt;&gt;(); target=\"104635278\"; int[] a= new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; Node nd0 = new Node(); nd0.value=a; field.add(toString(a)); nodes.add(nd0); front.add(nd0); int res=0; while(res==0) res=step(); if(res==1)  { System.out.println(\"Puzzle solved. Now save pictures\"); ArrayList&lt;Node&gt; path=extractPath(); for(int <\/code><\/pre>\n<\/div>\n<\/details>\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-347973","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347973","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=347973"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347973\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}