{"id":427531,"date":"2024-07-26T21:03:33","date_gmt":"2024-07-26T21:03:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=427531"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=427531","title":{"rendered":"<span>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0430\u043f\u0451\u0440\u0430 \u0432 100 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0447\u0438\u0441\u0442\u043e\u0433\u043e Ruby<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/830778\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/pu\/b7\/pl\/pub7pl9oc3rsrtdjk8g6rgqsd10.png\" data-src=\"https:\/\/habrastorage.org\/webt\/pu\/b7\/pl\/pub7pl9oc3rsrtdjk8g6rgqsd10.png\"\/><\/div>\n<p><\/a><br \/> <a name=\"anchorid11\"><\/a>Ruby \u2014 \u0432\u0435\u0441\u044c\u043c\u0430 \u044d\u043a\u0441\u043f\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432 \u0441\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0442\u0430\u043a \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u0436\u0430\u0442\u043e\u043c \u0432\u0438\u0434\u0435.<a href=\"#anchorid1\"><sup>1<\/sup><\/a><\/p>\n<p> \u0421\u0440\u0430\u0437\u0443 \u0432\u043d\u0435\u0441\u0443 \u044f\u0441\u043d\u043e\u0441\u0442\u044c: \u044f \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e \u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Code_golf\">\u043a\u043e\u0434-\u0433\u043e\u043b\u044c\u0444\u0438\u043d\u0433\u0435<\/a>, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u0442\u043e\u0436\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c. \u042f \u0438\u043c\u0435\u044e \u0432 \u0432\u0438\u0434\u0443 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 Ruby \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p> \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u00ab\u0421\u0430\u043f\u0451\u0440\u0430\u00bb. \u041f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u0438\u0433\u0440\u0430\u043b \u0432 \u043d\u0435\u0433\u043e \u043d\u0430 Windows XP \u0435\u0449\u0451 \u043f\u0430\u0446\u0430\u043d\u043e\u043c. \u0415\u0441\u043b\u0438 \u0438 \u0432\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f, \u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0430\u0441, \u043c\u043e\u0438 \u0434\u0440\u0443\u0437\u044c\u044f-\u043c\u0438\u043b\u043b\u0435\u043d\u0438\u0430\u043b\u044b! <a name=\"habracut\"><\/a><\/p>\n<p> \u0420\u0430\u0434\u0438 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Ruby. \u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 <a href=\"https:\/\/github.com\/radanskoric\/minesweeper\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u0438, \u0442\u043e \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435\u0441\u044c \u0437\u0434\u0435\u0441\u044c \u0438 \u0432\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043f\u043e\u0437\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u0447\u0438\u0441\u0442\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u0440\u043e\u0432\u043d\u043e 100 \u0441\u0442\u0440\u043e\u043a (\u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>lib<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code><a href=\"https:\/\/github.com\/AlDanial\/cloc\">cloc<\/a><\/code>). \u041f\u0440\u0438\u0447\u0451\u043c \u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u043c\u0443\u0445\u043b\u0435\u0432\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u043e\u043a\u0440\u0443\u0433\u043b\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e. \u042f, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0432\u0441\u0451 \u043f\u043e\u0434\u043e\u0433\u043d\u0430\u0442\u044c, \u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c.<\/p>\n<p> \u041f\u043e\u043f\u0443\u0442\u043d\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0432\u0435\u0436\u0438\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Ruby. \u042f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u0432\u0430\u043a\u0443\u0443\u043c\u0435. \u041c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u0438\u043d\u0438-\u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f<\/font><\/h2>\n<p> \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u043b\u0430\u0441\u0441 <code>Board<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0435. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u043b\u044f \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0448\u0438\u0440\u0438\u043d\u0430, \u0432\u044b\u0441\u043e\u0442\u0430 \u0438 \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043c\u0438\u043d.<\/p>\n<pre><code class=\"ruby\">class Board &lt; Data.define(:width, :height, :mines)   # \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 ... end<\/code><\/pre>\n<p> \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u0432 Ruby 3.2, <a href=\"https:\/\/docs.ruby-lang.org\/en\/3.2\/Data.html\"><code>\u043a\u043b\u0430\u0441\u0441 Data<\/code><\/a>. \u041e\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u0442\u0435\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u043d\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>Board = Data.define(...) do ... end<\/code>, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e. \u041e\u0431\u044a\u044f\u0441\u043d\u044e \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p> \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043e\u0441\u043a\u0443, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0432 \u043d\u0430 \u043d\u0435\u0439 \u043c\u0438\u043d\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0438\u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u043f\u0430\u0440\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u043e\u0433\u0434\u0430 \u0434\u0432\u0435 \u043c\u0438\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0435. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0434\u043e\u0441\u043a\u0438 \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043d\u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. <\/p>\n<p> \u041a \u043d\u0430\u0448\u0435\u043c\u0443 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443, \u0432 Ruby \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u0431\u043b\u0438\u0437\u043a\u043e\u0439 \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0444\u043e\u0440\u043c\u0435:<\/p>\n<pre><code class=\"ruby\">class Board &lt; Data.define(:width, :height, :mines)     # ...     def self.generate_random(width, height, mines_count)       full_board = Enumerator.product(width.times, height.times)         .map { |x, y| Coordinate.new(x, y) }       self.new(width, height, full_board.sample(mines_count))     end     # ... end<\/code><\/pre>\n<p> <code><a href=\"https:\/\/docs.ruby-lang.org\/en\/master\/Enumerator.html#method-c-product\">Enumerator.product<\/a><\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0432\u0430 \u043d\u0443\u043c\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445 \u043f\u0440\u044f\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u041d\u0430 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u0442\u0430\u043a: \u00ab\u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0441\u043e\u0432\u043c\u0435\u0449\u0451\u043d\u043d\u044b\u0439 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u00bb. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>sample<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u042f \u043c\u043e\u0433 \u0431\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u0441\u0442\u0440\u043e\u043a, \u043d\u043e \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>full_board<\/code> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u0430\u043c\u043e\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p> \u041a\u043b\u0430\u0441\u0441 <code>Coordinate<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Data<\/code>:<\/p>\n<pre><code class=\"ruby\">Coordinate = Data.define(:x, :y)<\/code><\/pre>\n<p> <code>Board<\/code> \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u043c\u0438\u043d\u0430, \u0438\u043b\u0438 \u0436\u0435 \u044d\u0442\u0430 \u043a\u043b\u0435\u0442\u043a\u0430 \u043f\u0443\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0443\u0441\u0442\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0437\u0430\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0435\u0442\u043e\u043a. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>mines<\/code> \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>Coordinate<\/code>, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<pre><code class=\"ruby\">class Board &lt; Data.define(:width, :height, :mines)     # ...     class Mine; end;     Empty = Data.define(:neighbour_mines)      def cell(coordinate)       mines.include?(coordinate) ? Mine.new : Empty.new(count_neighbours(coordinate))     end      private      def count_neighbours(coordinate)       mines.count { |mine| mine.neighbour?(coordinate) }     end   end<\/code><\/pre>\n<p> \u0412\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b <code>Mine<\/code> \u0438 <code>Empty<\/code> \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0451\u043b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Data<\/code>. \u041e\u043d\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432\u043d\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u042d\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u0438\u043c\u044b \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 <code>Data.define do; end<\/code>.<\/p>\n<p> \u0414\u0430, \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0432\u0441\u0435 \u043c\u0438\u043d\u044b. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u0443 \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0451 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p> \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>mine<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e <code>coordinate<\/code>, \u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>neighbour?<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0451 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u044b \u0435\u0433\u043e \u043f\u0443\u0442\u0451\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u043e\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u044b\u043c 1:<\/p>\n<pre><code class=\"ruby\">Coordinate = Data.define(:x, :y) do     def neighbour?(other)       [(self.x - other.x).abs, (self.y - other.y).abs].max &lt;= 1     end end<\/code><\/pre>\n<p> \u041d\u0430 \u044d\u0442\u043e\u043c \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>Board<\/code> \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0418\u0433\u0440\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/font><\/h2>\n<p> \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043c\u044b \u043f\u043e\u0440\u0443\u0447\u0438\u043c \u043d\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0441 \u0448\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>Game<\/code>. \u0415\u043c\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u043e\u0441\u043a\u0438 \u0438 \u043a\u0430\u0440\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043a\u043b\u0435\u0442\u043e\u043a:<\/p>\n<pre><code class=\"ruby\">class Game     def initialize(board)       @cells = Array.new(board.height * board.width, nil)       @board = board     end     # ... end<\/code><\/pre>\n<p> \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0435\u0449\u0451 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0434\u043e\u0441\u043a\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 <code>nil<\/code>.<\/p>\n<p> \u041c\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>reveal<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u00ab\u043a\u043b\u0438\u043a\u0435\u00bb \u043f\u043e \u044f\u0447\u0435\u0439\u043a\u0435 \u0434\u043b\u044f \u0435\u0451 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043b\u0435\u0442\u043a\u0438, \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0442 \u043c\u0438\u043d, \u0438\u0433\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Recursion_%28computer_science%29\">\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e<\/a> \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043a\u0438, \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u044f \u0437\u0430 \u0440\u0430\u0437 \u0446\u0435\u043b\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0442\u0430\u043a \u0440\u0430\u0434\u0443\u0435\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0433\u0440\u044b. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c, \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u0438 \u0441\u043a\u0430\u0437\u0430\u043b, \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044f \u0432\u0441\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043a\u0438:<\/p>\n<pre><code class=\"ruby\">class Game   # ...   CELL_WITH_NO_ADJACENT_MINES = Board::Empty.new(0)    def reveal(coordinate)     index = cell_index(coordinate)     return :play if @cells[index]      (@cells[index] = @board.cell(coordinate)).tap do |cell|       return :lose if cell.is_a?(Board::Mine)       reveal_neighbours(coordinate) if cell == CELL_WITH_NO_ADJACENT_MINES     end     @cells.count(&amp;:nil?) == @board.mines.size ? :win : :play   end    private    def cell_index(coordinate)= coordinate.y * @board.width + coordinate.x    def reveal_neighbours(coordinate)     coordinate.neighbours(width, height).each { |n| reveal(n) }   end end <\/code><\/pre>\n<p> \u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0430, \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0442 \u043c\u0438\u043d, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e \u0434\u043e\u0441\u043a\u0435 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0435\u0436\u0438\u0442 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\u0420\u0430\u043d\u043d\u0438\u0439 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0435\u0442\u043a\u0430 \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0430.<\/li>\n<li>\u041f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 <code>reveal<\/code> \u0434\u043b\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043a\u043b\u0435\u0442\u043e\u043a. \u042d\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u043e\u0441\u0435\u0434 \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0431\u044b \u0441\u043b\u0435\u0434\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043a\u043b\u0435\u0442\u043a\u0443.<\/li>\n<\/ol>\n<p> \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0442\u044b\u043a\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0443, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0440\u0430\u043d\u043d\u0438\u0439 \u0432\u044b\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>:lose<\/code>. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0441\u0435 \u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043a\u043b\u0435\u0442\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438, \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>:win<\/code>. \u0412\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>:play<\/code>.<\/p>\n<p> \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0435\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>neighbours<\/code> \u0434\u043b\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0414\u043b\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 8 \u0441\u043e\u0441\u0435\u0434\u0435\u0439:<\/p>\n<pre><code class=\"ruby\">Coordinate = Data.define(:x, :y) do   NEIGHBOURS = (Enumerator.product([-1, 0, 1], [-1, 0, 1]).to_a - [0, 0]).map { |x, y| self.new(x, y) }   # ... end<\/code><\/pre>\n<p> \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>product<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c <code>centre<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 <code>[0, 0]<\/code>.<\/p>\n<p> \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0445 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u0432 <code>Coordinate<\/code> \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0434\u043e\u0441\u043a\u0438:<\/p>\n<pre><code class=\"ruby\">Coordinate = Data.define(:x, :y) do   # ...   def +(other)     self.class.new(self.x + other.x, self.y + other.y)   end    def neighbours(board_width, board_height)     NEIGHBOURS       .map { |n| self + n }       .reject { |n| n.x &lt; 0 || n.x &gt;= board_width || n.y &lt; 0 || n.y &gt;= board_height }   end end<\/code><\/pre>\n<p> <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u043a\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ASCII<\/font><\/h2>\n<p> \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u043e\u0441\u043a\u0438 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0435\u0442\u043a\u0443, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044b ASCII:<\/p>\n<pre><code class=\"ruby\">AsciiRenderer = Data.define(:grid) do   def render(output = $stdout)     grid.height.times do |y|       grid.width.times do |x|         output.print case cell = grid.cell(Coordinate.new(x, y))                       when nil then \"#\"                       when Board::Mine then \"*\"                       else cell.neighbour_mines.zero? ? \"_\" : cell.neighbour_mines                       end       end       output.puts     end   end end<\/code><\/pre>\n<p> \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e:<\/p>\n<pre><code class=\"bash\">___1#1_______1#1___1#1__1#1___ ___111_______111___1#1__1#1___ 11_________________111__1#211_ #21111_______111111_____1###1_ #####1_______1####311___12#21_ ###211__111__111####1____111__ ###1____2#2____1#2211_______11 ###1____2#2____1#1__________1#<\/code><\/pre>\n<p> \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043a\u043e\u0434 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b <code>width<\/code>, <code>height<\/code> \u0438 <code>cell<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432 <code>Board<\/code>, \u043d\u043e \u043d\u0435 \u0432 <code>Game<\/code>. \u0410 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b <code>Game<\/code>. \u0422\u0430\u043a \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0438\u0445:<\/p>\n<pre><code class=\"ruby\">class Game   # ...   def width = @board.width   def height = @board.height   def cell(coordinate) = @cells[cell_index(coordinate)]   # ... end<\/code><\/pre>\n<p> \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0414\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u043f\u043e 2 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430, \u043f\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u0432 \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u0433\u0440\u0430 \u0443\u043c\u0435\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u0432 100 \u0441\u0442\u0440\u043e\u043a, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044f \u0438\u0445 \u043d\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u2014 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0442\u0435\u043b\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u0441\u0442\u0440\u043e\u043a \u043e\u043d\u043e \u043d\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u043e. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 <code>Coordinate<\/code> \u0438 <code>Board<\/code> \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438. \u042f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0438\u0445 \u0437\u0434\u0435\u0441\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0441\u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c. \u0412\u0441\u0451 \u0436\u0435 \u044d\u0441\u0442\u0435\u0442\u0438\u043a\u0430 \u0432\u0430\u0436\u043d\u0430.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0421\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u043c \u0432\u0441\u0451 \u0432\u043e\u0435\u0434\u0438\u043d\u043e<\/font><\/h2>\n<p> \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0436\u0438\u0437\u043d\u0435\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u0438\u0433\u0440\u0443 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<br \/> \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ruby lib\/play.rb 20, 10, 20<\/code> \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u0448\u0438\u0440\u0438\u043d\u0443, \u0432\u044b\u0441\u043e\u0442\u0443 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043f\u0430\u0440\u0441\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"ruby\">if ARGV.size == 3   Minesweeper.play(*ARGV.map(&amp;:to_i)) else   puts \"Usage: ruby lib\/play.rb width, height, mines_count (e.g. 'play.rb 12 6 6')\" end<\/code><\/pre>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0438\u0433\u0440\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c <code>ReadLine<\/code> \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f. \u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c Ruby (IRB) \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c.<\/p>\n<pre><code class=\"ruby\">module Minesweeper   module_function def play(...)     game = Game.new(Board.generate_random(...))     renderer = AsciiRenderer.new(game)     renderer.render      while input = Readline.readline(\"Type click coordinate as 'x, y' (0 based)&gt; \")       result = game.reveal(Coordinate.new(*input.split(\",\").map(&amp;:to_i)))       renderer.render       if [:win, :lose].include?(result)         puts \"You #{result == :win ? \"win\" : \"lose\"}!\"         return       end     end   end end<\/code><\/pre>\n<p> \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0437\u0434\u0435\u0441\u044c <code>def play(...)<\/code>. \u042d\u0442\u043e\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 Ruby 2.7 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 <code>Board.generate_random<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u0443\u0436\u0435 \u043e\u043a\u0440\u0443\u0436\u0438\u043c \u0438\u0445 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/font><\/h2>\n<p> \u041f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0433\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 <a href=\"https:\/\/github.com\/radanskoric\/minesweeper\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0432\u043e\u044e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u0442\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0435\u0439 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. <\/p>\n<p> \u0421\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u00ab\u0421\u0430\u043f\u0451\u0440\u0430\u00bb, \u043d\u043e \u043f\u043e\u043a\u0430 \u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u043d\u0435\u0451 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0432\u0435\u0441\u0435\u043b\u043e. \u0412\u0441\u0451 \u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u2014 \u043d\u0435 \u043b\u0443\u0447\u0448\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e \u0435\u0451 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0443 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Rails + Hotwire. \u0418 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0434\u0438 \u0444\u0430\u043d\u0430 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0433\u0440\u0443 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439, \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442? <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0421\u043d\u043e\u0441\u043a\u0430<\/font><\/h2>\n<p> <a name=\"anchorid1\"><\/a>1. \u0415\u0441\u043b\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0433\u043e\u0432 \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u0435\u0442 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043a\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0451\u043c\u0430 \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u0451\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c.<a href=\"#anchorid11\">\u21a9<\/a><\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/t.me\/ruvds_community\">Telegram-\u043a\u0430\u043d\u0430\u043b \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438, \u0440\u043e\u0437\u044b\u0433\u0440\u044b\u0448\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043e\u0432 \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u044f\u043c\u0438 IT ?<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=realizaciya_sapyora_v_100_strokax_chistogo_ruby\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/tp\/sk\/z-\/tpskz-7w7a8e74isoowuep40xeg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/tp\/sk\/z-\/tpskz-7w7a8e74isoowuep40xeg.png\"\/><\/a><\/div>\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\/830778\/\"> https:\/\/habr.com\/ru\/articles\/830778\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/830778\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/pu\/b7\/pl\/pub7pl9oc3rsrtdjk8g6rgqsd10.png\" data-src=\"https:\/\/habrastorage.org\/webt\/pu\/b7\/pl\/pub7pl9oc3rsrtdjk8g6rgqsd10.png\"\/><\/div>\n<p><\/a><br \/> <a name=\"anchorid11\"><\/a>Ruby \u2014 \u0432\u0435\u0441\u044c\u043c\u0430 \u044d\u043a\u0441\u043f\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432 \u0441\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043a\u043e\u0434\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0442\u0430\u043a \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u0436\u0430\u0442\u043e\u043c \u0432\u0438\u0434\u0435.<a href=\"#anchorid1\"><sup>1<\/sup><\/a><\/p>\n<p> \u0421\u0440\u0430\u0437\u0443 \u0432\u043d\u0435\u0441\u0443 \u044f\u0441\u043d\u043e\u0441\u0442\u044c: \u044f \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044e \u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Code_golf\">\u043a\u043e\u0434-\u0433\u043e\u043b\u044c\u0444\u0438\u043d\u0433\u0435<\/a>, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u0442\u043e\u0436\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c. \u042f \u0438\u043c\u0435\u044e \u0432 \u0432\u0438\u0434\u0443 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 Ruby \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p> \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u00ab\u0421\u0430\u043f\u0451\u0440\u0430\u00bb. \u041f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u0438\u0433\u0440\u0430\u043b \u0432 \u043d\u0435\u0433\u043e \u043d\u0430 Windows XP \u0435\u0449\u0451 \u043f\u0430\u0446\u0430\u043d\u043e\u043c. \u0415\u0441\u043b\u0438 \u0438 \u0432\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f, \u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0430\u0441, \u043c\u043e\u0438 \u0434\u0440\u0443\u0437\u044c\u044f-\u043c\u0438\u043b\u043b\u0435\u043d\u0438\u0430\u043b\u044b! <\/p>\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-427531","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427531","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=427531"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427531\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}