{"id":350764,"date":"2023-07-25T21:00:43","date_gmt":"2023-07-25T21:00:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350764"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350764","title":{"rendered":"<span>\u0418\u0433\u0440\u0430 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0432 \u043e\u0434\u043d\u043e\u043c \u0442\u0432\u0438\u0442\u0435<\/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<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u0441\u043a\u0443\u0447\u043d\u043e, \u044f \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u044e \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0433\u0443 \u043f\u043e\u0431\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u044f \u0431\u043e\u043a\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u043c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043f\u0438\u0432\u0430. \u0418\u043d\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0434\u0435\u0433\u0443\u0441\u0442\u0430\u0446\u0438\u0438 \u043c\u043d\u0435 \u043d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u0434\u0435\u0438, \u0438 \u043c\u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f: \u043d\u0435\u043c\u0438\u043d\u0443\u0435\u043c\u043e \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439, \u043d\u043e \u0432\u0435\u0441\u0451\u043b\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0412 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0435 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435, \u043f\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u044f \u043f\u0438\u0432\u043e \u0438 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u0436\u0438\u0437\u043d\u0438, \u044f \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u0434\u0443\u043c\u0430\u043b: \u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0433\u0440\u044b \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0432 \u043e\u0434\u0438\u043d \u0442\u0432\u0438\u0442? \u0418 \u043d\u0435 \u0441\u043c\u043e\u0433 \u0443\u0441\u0442\u043e\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0436\u0435\u043b\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/32f\/1f8\/1f7\/32f1f81f7cd470113e92618e749535bd.png\" width=\"720\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/32f\/1f8\/1f7\/32f1f81f7cd470113e92618e749535bd.png\"\/><\/figure>\n<h2>\u042d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043e\u0431 \u0438\u0433\u0440\u0435 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0438 \u0432\u0434\u0440\u0443\u0433 \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 \u0432 Google \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u043e\u0435. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0435\u0440\u0432\u044b\u043c, \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0435\u0442\u0441\u044f \u0432\u0430\u043c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430, \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u043a\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2da\/5b3\/e8b\/2da5b3e8b2bfc0d559b1cac127dafc0e.png\" alt=\"\u041d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430 The Game of Life, \u0438\u0437\u0434\u0430\u043d\u0438\u0435 1991 \u0433\u043e\u0434\u0430 (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a: amazon.com)\" title=\"\u041d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430 The Game of Life, \u0438\u0437\u0434\u0430\u043d\u0438\u0435 1991 \u0433\u043e\u0434\u0430 (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a: amazon.com)\" width=\"720\" height=\"428\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2da\/5b3\/e8b\/2da5b3e8b2bfc0d559b1cac127dafc0e.png\"\/><\/p>\n<div><figcaption><em>\u041d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430 The Game of Life, \u0438\u0437\u0434\u0430\u043d\u0438\u0435 1991 \u0433\u043e\u0434\u0430 (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"http:\/\/amazon.com\"><em>amazon.com<\/em><\/a><em>)<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0421 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0430\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439, \u0438 \u0432\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u2014 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0432\u0442\u0438\u0441\u043d\u0443\u0442\u044c \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0432 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043a\u043e\u0434\u0430? \u0422\u0430\u043a \u0432\u043e\u0442. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430 \u0438\u0433\u0440\u0430 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb, \u0447\u0442\u043e \u0432\u044b \u0438\u0449\u0435\u0442\u0435.\u00a0<\/p>\n<p>\u0418\u0433\u0440\u0430 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0414\u0436\u043e\u043d\u0430 \u041a\u043e\u043d\u0432\u0435\u044f (Game Of Life) \u2014 \u0432\u043e\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u043e \u043d\u0435\u0439 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0412\u0441\u0451 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u043e\u043b\u0435 \u0441 \u043a\u043b\u0435\u0442\u043a\u0430\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u043c\u0435\u0440\u0442\u0432\u043e\u0439, \u043b\u0438\u0431\u043e \u0436\u0438\u0432\u043e\u0439. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0435\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u043a\u043b\u0435\u0442\u043e\u043a, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u043c \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438, \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 \u0438\u043b\u0438 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438):<\/p>\n<ul>\n<li>\n<p>\u0436\u0438\u0432\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0436\u0438\u0432\u043e\u0439 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0438\u043b\u0438 \u0442\u0440\u0438 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0443\u043c\u0438\u0440\u0430\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0440\u0442\u0432\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0436\u0438\u0432\u043e\u0439 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0440\u0438 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0440\u0442\u0432\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/699\/ddd\/7b6\/699ddd7b65d7c3e8437075c98d8bd5a0.gif\" alt=\"\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\" title=\"\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\" width=\"1464\" height=\"872\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/699\/ddd\/7b6\/699ddd7b65d7c3e8437075c98d8bd5a0.gif\"\/><\/p>\n<div><figcaption><em>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0435. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u0433\u0440\u0443 \u0431\u043e\u043b\u044c\u0448\u0435, \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0432 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conway%27s_Game_of_Life\"><u>\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/u><\/a>.<\/p>\n<h2>\u041e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430<\/h2>\n<p>\u0427\u0442\u043e \u044f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u043c\u0435\u044e \u0432 \u0432\u0438\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044e \u043e JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0433\u0440\u044b \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb? \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043c\u043e\u0433 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b, \u0442\u0432\u043e\u0440\u0438\u0442 \u043d\u0435\u043a\u0443\u044e \u043c\u0430\u0433\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0435\u0439\u0442 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430. \u041e\u043d\u0430 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0442\u0432\u0438\u0442\u0435. \u041d\u043e \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0435 \u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 (\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435) \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430.<\/p>\n<p>\u042f \u0441\u0435\u043b \u0437\u0430 \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0438 \u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434. \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b.<\/p>\n<pre><code class=\"javascript\">function gameOfLife(sizeX, sizeY) {     let state = [];      for (let y = 0; y &lt; sizeY; y++) {         state.push([])          for (let x = 0; x &lt; sizeX; x++) {             const alive = !!(Math.random() &lt; 0.5);             state[y].push(alive)         }     }      setInterval(() => {         console.clear()                  const consoleOutput = state.map(row => {             return row.map(cell => cell ? 'X' : ' ').join('')         }).join('\\n')          console.log(consoleOutput)          const newState = []          for (let y = 0; y &lt; sizeY; y++) {             newState.push([])              for (let x = 0; x &lt; sizeX; x++) {                 let aliveNeighbours = 0                  for (let ny = y - 1; ny &lt;= y + 1; ny++) {                     if (state[ny]) {                         for (let nx = x - 1; nx &lt;= x + 1; nx++) {                             if (!(nx === x &amp;&amp; ny === y) &amp;&amp; state[ny][nx]) {                                 aliveNeighbours++                             }                         }                     }                 }                  if (state[y][x] &amp;&amp; (aliveNeighbours &lt; 2 || aliveNeighbours > 3)) {                     newState[y].push(false)                 } else if (!state[y][x] &amp;&amp; aliveNeighbours === 3) {                     newState[y].push(true)                 } else {                     newState[y].push(state[y][x])                 }             }         }          state = newState     }, 1000) }  gameOfLife(20, 20)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0448\u0435? \u0414\u0430, \u043f\u043e\u0436\u0430\u043b\u0443\u0439. \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0438\u0434\u0435\u0430\u043b\u0430. \u042f \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0433\u0440\u044b. \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043b\u0438\u0448\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf8\/a0c\/80c\/cf8a0c80c92e0539e1fe61532725083f.gif\" alt=\"\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Node.js \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u044f\u0442\" title=\"\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Node.js \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u044f\u0442\" width=\"784\" height=\"436\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf8\/a0c\/80c\/cf8a0c80c92e0539e1fe61532725083f.gif\"\/><\/p>\n<div><figcaption><em>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Node.js \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u044f\u0442<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>gameOfLife<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: <code>sizeX<\/code> \u0438 <code>sizeY<\/code>. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>state<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0431\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u0430\u0445 <code>for<\/code>. <code>True<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0435\u0442\u043a\u0430 \u0436\u0438\u0432\u0430, <code>false<\/code> \u2014 \u0447\u0442\u043e \u043c\u0435\u0440\u0442\u0432\u0430).<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>setInterval<\/code> \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041e\u043d\u0430 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c <code>X<\/code> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u0436\u0438\u0432\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438, \u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u2014 \u043c\u0435\u0440\u0442\u0432\u044b\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 for \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (<code>newState<\/code>). \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438 (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 x, y) \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u043e\u0442 x-1 \u0434\u043e x+1 \u0438 \u043e\u0442 y-1 \u0434\u043e y+1) \u0438 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0432\u044b\u0445 (<code>aliveNeighbours<\/code>). \u0414\u043b\u044f \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, x=-1, y=-1). \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u0418\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 <code>newState<\/code>.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>gameOfLife<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 20 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 20 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435.<\/p>\n<h2>\u0426\u0435\u043b\u044c<\/h2>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u043e\u044f\u0441\u043d\u044e. \u041f\u043e\u0434 \u0442\u0432\u0438\u0442\u043e\u043c \u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e \u043f\u043e\u0441\u0442 \u0432 Twitter (\u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0441 \u043f\u0442\u0438\u0447\u043a\u043e\u0439), \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d 280 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u043d\u0435\u0433\u043e \u043c\u043d\u0435 \u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0438\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c <a href=\"https:\/\/www.npmjs.com\/package\/uglify-js\">uglify-js<\/a> \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432\/\u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435).<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 uglifier \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u0438\u043d\u043e\u0439 549 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0442\u0432\u0438\u0442, \u043c\u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435.<\/p>\n<pre><code class=\"javascript\">function gameOfLife(t,f){let s=[];for(let o=0;o&lt;f;o++){s.push([]);for(let e=0;e&lt;t;e++){const l=!!(Math.random()&lt;.5);s[o].push(l)}}setInterval(()=>{console.clear();const e=s.map(e=>{return e.map(e=>e?\"X\":\" \").join(\"\")}).join(\"\\n\");console.log(e);const o=[];for(let l=0;l&lt;f;l++){o.push([]);for(let f=0;f&lt;t;f++){let t=0;for(let o=l-1;o&lt;=l+1;o++){if(s[o]){for(let e=f-1;e&lt;=f+1;e++){if(!(e===f&amp;&amp;o===l)&amp;&amp;s[o][e]){t++}}}}if(s[l][f]&amp;&amp;(t&lt;2||t>3)){o[l].push(false)}else if(!s[l][f]&amp;&amp;t===3){o[l].push(true)}else{o[l].push(s[l][f])}}}s=o},1e3)}gameOfLife(20,20);<\/code><\/pre>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u0440\u044f\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u2014 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430!<\/p>\n<h3>\u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0435. \u042f \u043c\u043e\u0433\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u0441\u0430\u043c\u043e\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>((sizeX, sizeY) => {...})(20, 20)<\/code> \u2014 \u044d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0438 \u043c\u0435\u0441\u0442\u0430 \u043e\u043d\u0430 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0432 \u043a\u043e\u0434\u0435 <code>let<\/code> \u0438 <code>const<\/code> (\u0441\u043b\u043e\u0432 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 \u0446\u0435\u043b\u044b\u0445 5 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c \u0434\u043e\u0431\u0440\u044b\u043c &#8216;<code>var<\/code>&#8216; \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">((sizeX, sizeY) => {     var state = [],     y, x, consoleOutput, ny, nx, aliveNeighbours, newState;     ... })(20, 20)<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u0441\u0442\u044c uglify-js \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0438&#8230; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c 499 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432! \u042d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 Twitter, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f Mastodon (\u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0434\u0438\u0430\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430 Twitter).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/03e\/b26\/6a3\/03eb266a392d890ba73c775274933d99.png\" alt=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 Mastodon \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0433\u0440\u044b\" title=\"\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 Mastodon \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0433\u0440\u044b\" width=\"720\" height=\"318\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03e\/b26\/6a3\/03eb266a392d890ba73c775274933d99.png\"\/><\/p>\n<div><figcaption><em>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 Mastodon \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0433\u0440\u044b<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0430\u043c \u043f\u043e\u0441\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/mastodon.social\/@mihauco\/110710999992666947\"><u>\u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>.<\/p>\n<pre><code class=\"javascript\">((o,e)=>{var r=[],s,f,n,a,l,p,u;for(s=0;s&lt;e;s++){r.push([]);for(f=0;f&lt;o;f++){const h=!!(Math.random()&lt;.5);r[s].push(h)}}setInterval(()=>{console.clear();n=r.map(o=>{return o.map(o=>o?\"X\":\" \").join(\"\")}).join(\"\\n\");console.log(n);u=[];for(s=0;s&lt;e;s++){u.push([]);for(f=0;f&lt;o;f++){p=0;for(a=s-1;a&lt;=s+1;a++){if(r[a]){for(l=f-1;l&lt;=f+1;l++){if(!(l===f&amp;&amp;a===s)&amp;&amp;r[a][l]){p++}}}}if(r[s][f]&amp;&amp;(p&lt;2||p>3)){u[s].push(false)}else if(!r[s][f]&amp;&amp;p===3){u[s].push(true)}else{u[s].push(r[s][f])}}}r=u},1e3)})(20,20);<\/code><\/pre>\n<h3>\u041f\u0440\u0438\u0447\u0435\u0441\u044b\u0432\u0430\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 for \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Array.from<\/code>.<\/p>\n<pre><code class=\"javascript\">var state = Array.from(Array(sizeY), () => Array.from(Array(sizeX), () => Math.random() &lt; .5 ? 'X' : ' ' ))<\/code><\/pre>\n<p><code>Array.from<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u0412\u0442\u043e\u0440\u043e\u0439, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 callback. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 callback, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. <code>Array(n)<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u0438\u043d\u044b n, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u043e callback \u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438 <code>Array.from<\/code>, \u0438 <code>Array<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b, \u044f \u043c\u043e\u0433\u0443 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"javascript\">var array = Array, arrayFrom = array.from, state = arrayFrom(array(sizeY), () => arrayFrom(array(sizeX), () => Math.random() &lt; .5 ? 'X' : ' ' )),<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0443\u0440\u043e\u0434\u043e\u0432\u0430\u043d\u044b uglifier\u2019\u043e\u043c, \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043a\u043e\u0440\u043e\u0447\u0435.<\/p>\n<p>\u0412\u044b, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0443\u043b\u0435\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u044b X \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u0430, \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0438 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">console.clear() console.log(state.map(row => row.join('')).join('\\n'))<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u044f \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0441\u044f \u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>consoleOutput<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043c\u0430\u043d\u0433\u043b\u0438\u043d\u0433\u0430 \u044f \u043c\u043e\u0433\u0443 \u0437\u0430\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0434\u0432\u0430\u0436\u0434\u044b:<\/p>\n<pre><code class=\"javascript\">... conzole = console, ... conzole.clear() conzole.log(...)<\/code><\/pre>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043e\u043a (\u0438\u0437-\u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f X \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439), \u0438 \u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442&#8230; 448 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0443\u0431\u0440\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 200.<\/p>\n<pre><code class=\"javascript\">((r,o)=>{var e=Array,f=e.from,s=console,a=f(e(o),()=>f(e(r),()=>Math.random()&lt;.5?\"X\":\" \")),i,l,n,h,p,m,t;setInterval(()=>{s.clear();s.log(a.map(r=>r.join(\"\")).join(\"\\n\"));t=[];for(i=0;i&lt;o;i++){t.push([]);for(l=0;l&lt;r;l++){m=0;for(n=i-1;n&lt;=i+1;n++){if(a[n]){for(h=l-1;h&lt;=l+1;h++){if(!(h===l&amp;&amp;n===i)&amp;&amp;a[n][h]===\"X\"){m++}}}}p=a[i][l].trim();if(p&amp;&amp;(m&lt;2||m>3)){t[i].push(\" \")}else if(!p&amp;&amp;m===3){t[i].push(\"X\")}else{t[i].push(a[i][l])}}}a=t},1e3)})(20,20);<\/code><\/pre>\n<h3>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/h3>\n<p>\u0421 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>newState<\/code>. \u042f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c <code>reduce<\/code> \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u043a\u043b\u043e\u0432 <code>for<\/code>. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (\u0441\u0438\u043c\u0432\u043e\u043b\u044b X \/ \u043f\u0440\u043e\u0431\u0435\u043b) \u043d\u043e\u0432\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043b\u0435\u0442\u043e\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u2014 \u0437\u0430\u043c\u0435\u043d\u0430 \u0442\u0440\u043e\u0439\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u043a\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 (===) \u043d\u0430 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 (==) \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"javascript\">... alive = 'X', dead = ' ' ... setInterval(() => {   ...   state = state.map((row, y) => row.reduce((newRow, cell, x) => {     aliveNeighbours = 0      for (ny = y - 1; ny &lt;= y + 1; ny++) {         for (nx = x - 1; nx &lt;= x + 1; nx++) {             if (!(nx == x &amp;&amp; ny == y) &amp;&amp; state[ny]?.[nx] == alive) aliveNeighbours++          }     }      newRow.push(cell.trim()         ? [2,3].includes(aliveNeighbours) ? alive : dead         : aliveNeighbours == 3 ? alive : dead     )      return newRow   }, [])) }, 1000)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 367 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435). \u041d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0435\u043c\u043a\u043e \u0434\u043b\u044f Twitter.<\/p>\n<h3>\u0426\u0435\u043d\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c<\/h3>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e <code>reduce<\/code>). \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438 <code>map<\/code>, \u0438 <code>reduce<\/code>, \u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430. \u0412\u044b\u0448\u0435 \u044f \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b <code>Array.from<\/code> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0440\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u043d\u0443\u0442 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043c\u0435\u0441\u0442\u043e <code>map<\/code> \u0438 <code>reduce<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">state = arrayFrom(state, (row, y) => arrayFrom(row, (cell, x) => {     aliveNeighbours = 0      for (ny = y - 1; ny &lt;= y + 1; ny++) {         for (nx = x - 1; nx &lt;= x + 1; nx++) {             if (!(nx == x &amp;&amp; ny == y) &amp;&amp; state[ny]?.[nx] == alive) aliveNeighbours++          }     }      return cell.trim()         ? [2,3].includes(aliveNeighbours) ? alive : dead         : aliveNeighbours == 3 ? alive : dead     ) }))<\/code><\/pre>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043a\u043e\u0434, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438, \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f (\u0445\u043e\u0442\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">return aliveNeighbours == 3   ? alive   : aliveNeighbours == 2 ? cell : dead<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043c\u0438\u043d\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043a\u043e\u0434 \u0434\u043b\u0438\u043d\u043e\u0439 321 \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<pre><code class=\"javascript\">((r,o)=>{var a=Array,n=a.from,e=console,f=\"X\",l=\" \",t=n(a(o),()=>n(a(r),()=>Math.random()&lt;.5?f:l)),i,m,c;setInterval(()=>{e.clear();e.log(t.map(r=>r.join(\"\")).join(\"\\n\"));t=n(t,(r,a)=>n(r,(r,o)=>{c=0;for(i=a-1;i&lt;=a+1;i++){for(m=o-1;m&lt;=o+1;m++){if(!(m==o&amp;&amp;i==a)&amp;&amp;t[i]?.[m]==f)c++}}return c===3?f:c===2?r:l}))},1e3)})(20,20);<\/code><\/pre>\n<h3>\u041f\u043e\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0441\u044f \u0435\u0449\u0451 \u0433\u043b\u0443\u0431\u0436\u0435\u00a0<\/h3>\n<p>\u0427\u0442\u043e \u0436, \u0432\u043e\u0442 \u044f \u0434\u043e\u0448\u0435\u043b \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 40 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441\u0442\u0430\u043b\u0438 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043c\u043d\u0435 \u0446\u0435\u043b\u043e\u0439 \u043a\u043d\u0438\u0433\u043e\u0439. \u0427\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c? \u0421\u043b\u0435\u0434\u0443\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (<code>Array.from<\/code>), \u044f \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"javascript\">conzole.log(state.map(row => row.join('')).join('\\n'))<\/code><\/pre>\n<p>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">conzole.log(arrayFrom(state, (row) => row.join('')).join('\\n'))<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u043d\u0435\u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u043c\u0438\u043d\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u043d \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0434\u043e 319 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u044f \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b \u0446\u0435\u043b\u044b\u0445 2 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u2014 \u044d\u0442\u043e, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0435\u0449\u0435 38.<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c size \u043a\u0430\u043a \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u2014 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u043a \u0434\u043b\u044f x, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f y. \u0418 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043c\u0435\u0441\u0442\u043e 20 \u044f \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 9, \u0447\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b. \u0418\u0442\u0430\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u043c\u044b \u0432\u044b\u0438\u0433\u0440\u0430\u043b\u0438? 311 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u044f \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u2014 0 \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0440\u0442\u0432\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438 \u0438 1 \u0434\u043b\u044f \u0436\u0438\u0432\u043e\u0439. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u043c\u0435\u0441\u0442\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e\u0433\u043e \u0442\u0440\u0435\u0445\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (0 \u0432\u043c\u0435\u0441\u0442\u043e &#8216; &#8216; \u0438 1 \u0432\u043c\u0435\u0441\u0442\u043e &#8216;X&#8217;). \u0418 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b, \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. 299 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041f\u043e\u0431\u0435\u0434\u0430 \u0431\u043b\u0438\u0437\u043a\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0447\u0438\u0441\u043b\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u044f \u043c\u043e\u0433\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 <code>aliveNeightbours<\/code>:<\/p>\n<pre><code class=\"javascript\">... for (ny = y - 1; ny &lt; y + 2; ny++) {     for (nx = x - 1; nx &lt; x + 2; nx++) {         if (state[ny]?.[nx] == 1) aliveNeighbours++      } }  return aliveNeighbours - cell == 3     ? 1     : aliveNeighbours - cell == 2 ? cell : 0<\/code><\/pre>\n<p>\u042f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043e\u0441\u0435\u0434 \u0442\u0435 \u0436\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0447\u0442\u043e \u0438 \u043a\u043b\u0435\u0442\u043a\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u044b\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u0437 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0439 \u0441\u0443\u043c\u043c\u044b. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043b <code>nx &lt;= x + 1<\/code> \u043d\u0430 <code>nx &lt; x + 2<\/code> (\u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f y) \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0442 \u0436\u0435, \u043d\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u043a\u043e\u0440\u043e\u0447\u0435. 286 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e 6!<\/p>\n<p>\u042f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043d\u0430 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 uglify-js, \u0438 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u043e\u0432 <code>for - for (...){for(...){...}}<\/code>. \u041d\u043e \u0432\u0435\u0434\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">for (ny = y - 1; ny &lt; y + 2; ny++) for (nx = x - 1; nx &lt; x + 2; nx++) state[ny]?.[nx] == 1 &amp;&amp; aliveNeighbours++<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u043e\u043d\u0438\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 uglify-js, \u0438&#8230;<\/p>\n<h2>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e<\/h2>\n<p>\u0420\u043e\u0432\u043d\u043e 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041d\u0443, \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 281 \u0441\u0438\u043c\u0432\u043e\u043b, \u043d\u043e uglify-js \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435, \u0430 \u043e\u043d\u0430 \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c-\u0442\u043e \u0438 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u0412\u043e\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">((size) => {   var array = Array,   arrayFrom = array.from,   conzole = console,   state = arrayFrom(array(size), () => arrayFrom(array(size), () => Math.random() &lt; .5 ? 1 : 0 )),   ny, nx, aliveNeighbours;    setInterval(() => {     conzole.clear()        conzole.log(arrayFrom(state, (row) => row.join('')).join('\\n'))        state = arrayFrom(state, (row, y) => arrayFrom(row, (cell, x) => {       aliveNeighbours = 0        for (ny = y - 1; ny &lt; y + 2; ny++) for (nx = x - 1; nx &lt; x + 2; nx++) state[ny]?.[nx] == 1 &amp;&amp; aliveNeighbours++        return aliveNeighbours - cell == 3         ? 1         : aliveNeighbours - cell == 2 ? cell : 0     }))   }, 1000) })(9)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9b3\/737\/f4f\/9b3737f4ff6b1d1d00f5b1aa5c706097.gif\" alt=\"\u0412 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0432\u0441\u0435\u0433\u043e 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!\" title=\"\u0412 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0432\u0441\u0435\u0433\u043e 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!\" width=\"784\" height=\"436\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9b3\/737\/f4f\/9b3737f4ff6b1d1d00f5b1aa5c706097.gif\"\/><\/p>\n<div><figcaption><em>\u0412 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0432\u0441\u0435\u0433\u043e 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/em><\/figcaption><\/div>\n<\/figure>\n<h2>\u0422\u0432\u0438\u0442<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de3\/d60\/253\/de3d60253447df9f78207c24cb016aae.png\" alt=\"\u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c \u0442\u0432\u0438\u0442\" title=\"\u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c \u0442\u0432\u0438\u0442\" width=\"720\" height=\"213\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de3\/d60\/253\/de3d60253447df9f78207c24cb016aae.png\"\/><\/p>\n<div><figcaption>\u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c <a href=\"https:\/\/twitter.com\/mihauco\/status\/1679744290182897665\"><u>\u0442\u0432\u0438\u0442<\/u><\/a><\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0435\u0434\u0432\u043e\u0441\u0445\u0438\u0449\u0430\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u2014 \u0443\u0432\u0435\u0440\u0435\u043d, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u00ab\u0441\u0440\u0435\u0437\u0430\u0442\u044c\u00bb \u0435\u0449\u0435 \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443 \u0432\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0443 \u043c\u0435\u043d\u044f!<\/p>\n<\/p>\n<\/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\/companies\/ispsystem\/articles\/750314\/\"> https:\/\/habr.com\/ru\/companies\/ispsystem\/articles\/750314\/<\/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<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u0441\u043a\u0443\u0447\u043d\u043e, \u044f \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u044e \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0433\u0443 \u043f\u043e\u0431\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u044f \u0431\u043e\u043a\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u043c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043f\u0438\u0432\u0430. \u0418\u043d\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0434\u0435\u0433\u0443\u0441\u0442\u0430\u0446\u0438\u0438 \u043c\u043d\u0435 \u043d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u0434\u0435\u0438, \u0438 \u043c\u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f: \u043d\u0435\u043c\u0438\u043d\u0443\u0435\u043c\u043e \u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439, \u043d\u043e \u0432\u0435\u0441\u0451\u043b\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0412 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0435 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435, \u043f\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u044f \u043f\u0438\u0432\u043e \u0438 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u0436\u0438\u0437\u043d\u0438, \u044f \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u0434\u0443\u043c\u0430\u043b: \u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0433\u0440\u044b \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0432 \u043e\u0434\u0438\u043d \u0442\u0432\u0438\u0442? \u0418 \u043d\u0435 \u0441\u043c\u043e\u0433 \u0443\u0441\u0442\u043e\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0436\u0435\u043b\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b.\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u042d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043e\u0431 \u0438\u0433\u0440\u0435 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0438 \u0432\u0434\u0440\u0443\u0433 \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 \u0432 Google \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u043e\u0435. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0435\u0440\u0432\u044b\u043c, \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0435\u0442\u0441\u044f \u0432\u0430\u043c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430, \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u043a\u0430.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u041d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u0433\u0440\u0430 The Game of Life, \u0438\u0437\u0434\u0430\u043d\u0438\u0435 1991 \u0433\u043e\u0434\u0430 (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"http:\/\/amazon.com\"><em>amazon.com<\/em><\/a><em>)<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0421 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u043d\u0430 \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0430\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439, \u0438 \u0432\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u2014 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0432\u0442\u0438\u0441\u043d\u0443\u0442\u044c \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0432 280 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043a\u043e\u0434\u0430? \u0422\u0430\u043a \u0432\u043e\u0442. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430 \u0438\u0433\u0440\u0430 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb, \u0447\u0442\u043e \u0432\u044b \u0438\u0449\u0435\u0442\u0435.\u00a0<\/p>\n<p>\u0418\u0433\u0440\u0430 \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb \u0414\u0436\u043e\u043d\u0430 \u041a\u043e\u043d\u0432\u0435\u044f (Game Of Life) \u2014 \u0432\u043e\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u043e \u043d\u0435\u0439 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0412\u0441\u0451 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u043e\u043b\u0435 \u0441 \u043a\u043b\u0435\u0442\u043a\u0430\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u043c\u0435\u0440\u0442\u0432\u043e\u0439, \u043b\u0438\u0431\u043e \u0436\u0438\u0432\u043e\u0439. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0435\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u043a\u043b\u0435\u0442\u043e\u043a, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u043c \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438, \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 \u0438\u043b\u0438 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438):<\/p>\n<ul>\n<li>\n<p>\u0436\u0438\u0432\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0436\u0438\u0432\u043e\u0439 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0438\u043b\u0438 \u0442\u0440\u0438 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0443\u043c\u0438\u0440\u0430\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0440\u0442\u0432\u0430\u044f \u043a\u043b\u0435\u0442\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0436\u0438\u0432\u043e\u0439 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0440\u0438 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0440\u0442\u0432\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0435. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u0433\u0440\u0443 \u0431\u043e\u043b\u044c\u0448\u0435, \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0432 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conway%27s_Game_of_Life\"><u>\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/u><\/a>.<\/p>\n<h2>\u041e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430<\/h2>\n<p>\u0427\u0442\u043e \u044f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u043c\u0435\u044e \u0432 \u0432\u0438\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044e \u043e JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0433\u0440\u044b \u00ab\u0416\u0438\u0437\u043d\u044c\u00bb? \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u043c\u043e\u0433 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b, \u0442\u0432\u043e\u0440\u0438\u0442 \u043d\u0435\u043a\u0443\u044e \u043c\u0430\u0433\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0435\u0439\u0442 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430. \u041e\u043d\u0430 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0442\u0432\u0438\u0442\u0435. \u041d\u043e \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0435 \u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u0412 \u043c\u043e\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 (\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435) \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0443\u043d\u0434\u0430.<\/p>\n<p>\u042f \u0441\u0435\u043b \u0437\u0430 \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0438 \u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434. \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430\u044f JavaScript-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b.<\/p>\n<pre><code class=\"javascript\">function gameOfLife(sizeX, sizeY) {     let state = [];      for (let y = 0; y &lt; sizeY; y++) {         state.push([])          for (let x = 0; x &lt; sizeX; x++) {             const alive = !!(Math.random() &lt; 0.5);             state[y].push(alive)         }     }      setInterval(() => {         console.clear()                  const consoleOutput = state.map(row => {             return row.map(cell => cell ? 'X' : ' ').join('')         }).join('\\n')          console.log(consoleOutput)          const newState = []          for (let y = 0; y &lt; sizeY; y++) {             newState.push([])              for (let x = 0; x &lt; sizeX; x++) {                 let aliveNeighbours = 0                  for (let ny = y - 1; ny &lt;= y + 1; ny++) {                     if (state[ny]) {                         for (let nx = x - 1; nx &lt;= x + 1; nx++) {                             if (!(nx === x &amp;&amp; ny === y) &amp;&amp; state[ny][nx]) {                                 aliveNeighbours++                             }                         }                     }                 }                  if (state[y][x] &amp;&amp; (aliveNeighbours &lt; 2 || aliveNeighbours > 3)) {                     newState[y].push(false)                 } else if (!state[y][x] &amp;&amp; aliveNeighbours === 3) {                     newState[y].push(true)                 } else {                     newState[y].push(state[y][x])                 }             }         }          state = newState     }, 1000) }  gameOfLife(20, 20)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0448\u0435? \u0414\u0430, \u043f\u043e\u0436\u0430\u043b\u0443\u0439. \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0438\u0434\u0435\u0430\u043b\u0430. \u042f \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0433\u0440\u044b. \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043b\u0438\u0448\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Node.js \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u044f\u0442<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u044f \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>gameOfLife<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: <code>sizeX<\/code> \u0438 <code>sizeY<\/code>. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>state<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0431\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (\u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u0430\u0445 <code>for<\/code>. <code>True<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0435\u0442\u043a\u0430 \u0436\u0438\u0432\u0430, <code>false<\/code> \u2014 \u0447\u0442\u043e \u043c\u0435\u0440\u0442\u0432\u0430).<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>setInterval<\/code> \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041e\u043d\u0430 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c <code>X<\/code> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u0436\u0438\u0432\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438, \u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u2014 \u043c\u0435\u0440\u0442\u0432\u044b\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 for \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (<code>newState<\/code>). \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438 (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 x, y) \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u043e\u0442 x-1 \u0434\u043e x+1 \u0438 \u043e\u0442 y-1 \u0434\u043e y+1) \u0438 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0432\u044b\u0445 (<code>aliveNeighbours<\/code>). \u0414\u043b\u044f \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, x=-1, y=-1). \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0436\u0438\u0432\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u0418\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 <code>newState<\/code>.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>gameOfLife<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 20 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 20 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435.<\/p>\n<h2>\u0426\u0435\u043b\u044c<\/h2>\n<p>\u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u043e\u044f\u0441\u043d\u044e. \u041f\u043e\u0434 \u0442\u0432\u0438\u0442\u043e\u043c \u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e \u043f\u043e\u0441\u0442 \u0432 Twitter (\u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0441 \u043f\u0442\u0438\u0447\u043a\u043e\u0439), \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d 280 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u043d\u0435\u0433\u043e \u043c\u043d\u0435 \u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0438\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c <a href=\"https:\/\/www.npmjs.com\/package\/uglify-js\">uglify-js<\/a> \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432\/\u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435).<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 uglifier \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u0438\u043d\u043e\u0439 549 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u0442\u0432\u0438\u0442, \u043c\u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435.<\/p>\n<pre><code class=\"javascript\">function gameOfLife(t,f){let s=[];for(let o=0;o&lt;f;o++){s.push([]);for(let e=0;e&lt;t;e++){const l=!!(Math.random()&lt;.5);s[o].push(l)}}setInterval(()=>{console.clear();const e=s.map(e=>{return e.map(e=>e?\"X\":\" \").join(\"\")}).join(\"\\n\");console.log(e);const o=[];for(let l=0;l&lt;f;l++){o.push([]);for(let f=0;f&lt;t;f++){let t=0;for(let o=l-1;o&lt;=l+1;o++){if(s[o]){for(let e=f-1;e&lt;=f+1;e++){if(!(e===f&amp;&amp;o===l)&amp;&amp;s[o][e]){t++}}}}if(s[l][f]&amp;&amp;(t&lt;2||t>3)){o[l].push(false)}else if(!s[l][f]&amp;&amp;t===3){o[l].push(true)}else{o[l].push(s[l][f])}}}s=o},1e3)}gameOfLife(20,20);<\/code><\/pre>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u0440\u044f\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u2014 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430!<\/p>\n<h3>\u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0435. \u042f \u043c\u043e\u0433\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u0441\u0430\u043c\u043e\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>((sizeX, sizeY) => {...})(20, 20)<\/code> \u2014 \u044d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0438 \u043c\u0435\u0441\u0442\u0430 \u043e\u043d\u0430 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0432 \u043a\u043e\u0434\u0435 <code>let<\/code> \u0438 <code>const<\/code> (\u0441\u043b\u043e\u0432 \u0434\u043b\u0438\u043d\u043e\u0439 \u0432 \u0446\u0435\u043b\u044b\u0445 5 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u043c \u0434\u043e\u0431\u0440\u044b\u043c &#8216;<code>var<\/code>&#8216; \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">((sizeX, sizeY) => {     var state = [],     y, x, consoleOutput, ny, nx, aliveNeighbours, newState;     ... })(20, 20)<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u0441\u0442\u044c uglify-js \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0438&#8230; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c 499 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432! \u042d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 Twitter, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f Mastodon (\u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0434\u0438\u0430\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430 Twitter).<\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u043e\u0441\u0442\u0430 \u043d\u0430 Mastodon \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0433\u0440\u044b<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0430\u043c \u043f\u043e\u0441\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/mastodon.social\/@mihauco\/110710999992666947\"><u>\u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>.<\/p>\n<pre><code class=\"javascript\">((o,e)=>{var r=[],s,f,n,a,l,p,u;for(s=0;s&lt;e;s++){r.push([]);for(f=0;f&lt;o;f++){const h=!!(Math.random()&lt;.5);r[s].push(h)}}setInterval(()=>{console.clear();n=r.map(o=>{return o.map(o=>o?\"X\":\" \").join(\"\")}).join(\"\\n\");console.log(n);u=[];for(s=0;s&lt;e;s++){u.push([]);for(f=0;f&lt;o;f++){p=0;for(a=s-1;a&lt;=s+1;a++){if(r[a]){for(l=f-1;l&lt;=f+1;l++){if(!(l===f&amp;&amp;a===s)&amp;&amp;r[a][l]){p++}}}}if(r[s][f]&amp;&amp;(p&lt;2||p>3)){u[s].push(false)}else if(!r[s][f]&amp;&amp;p===3){u[s].push(true)}else{u[s].push(r[s][f])}}}r=u},1e3)})(20,20);<\/code><\/pre>\n<h3>\u041f\u0440\u0438\u0447\u0435\u0441\u044b\u0432\u0430\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 for \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Array.from<\/code>.<\/p>\n<pre><code class=\"javascript\">var state = Array.from(Array(sizeY), () => Array.from(Array(sizeX), () => Math.random() &lt; .5 ? 'X' : ' ' ))<\/code><\/pre>\n<p><code>Array.from<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u0412\u0442\u043e\u0440\u043e\u0439, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 callback. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 callback, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. <code>Array(n)<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u0438\u043d\u044b n, \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u043e callback \u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438 <code>Array.from<\/code>, \u0438 <code>Array<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b, \u044f \u043c\u043e\u0433\u0443 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"javascript\">var array = Array, arrayFrom = array.from, state = arrayFrom(array(sizeY), () => arrayFrom(array(sizeX), () => Math.random() &lt; .5 ? 'X' : ' ' )),<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0443\u0440\u043e\u0434\u043e\u0432\u0430\u043d\u044b uglifier\u2019\u043e\u043c, \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043a\u043e\u0440\u043e\u0447\u0435.<\/p>\n<p>\u0412\u044b, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0443\u043b\u0435\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u044b X \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u0430, \u043f\u0440\u043e\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0438 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">console.clear() console.log(state.map(row => row.join('')).join('\\n'))<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u044f \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0441\u044f \u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>consoleOutput<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043c\u0430\u043d\u0433\u043b\u0438\u043d\u0433\u0430 \u044f \u043c\u043e\u0433\u0443 \u0437\u0430\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0434\u0432\u0430\u0436\u0434\u044b:<\/p>\n<pre><code class=\"javascript\">... conzole = console, ... conzole.clear() conzole.log(...)<\/code><\/pre>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043e\u043a (\u0438\u0437-\u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f X \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0431\u0443\u043b\u0435\u0432\u044b\u0445<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-350764","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350764","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=350764"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350764\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}