{"id":331710,"date":"2022-04-08T21:00:15","date_gmt":"2022-04-08T21:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331710"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331710","title":{"rendered":"<span>\u0412\u043b\u0430\u0441\u0442\u0435\u043b\u0438\u043d \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/346\/dcf\/d7a\/346dcfd7a6f467364cd0082c3425b154.jpg\" width=\"1911\" height=\"1076\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/346\/dcf\/d7a\/346dcfd7a6f467364cd0082c3425b154.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u043d\u0435\u0435, \u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/655059\/\" rel=\"noopener noreferrer nofollow\">&#171;\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438&#187;<\/a> \u044f \u043f\u0440\u0438\u0432\u0451\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043c\u044b\u0441\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0445\u043e\u0442\u044c \u0442\u0430\u043a \u0438 \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u044b \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0435\u043c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u043e\u0439 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0441 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c.<\/p>\n<hr\/>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u043c\u0438 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0438 \u043c\u043e\u043d\u043e\u0438\u0434. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u043c \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c. \u0427\u0442\u043e\u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0438, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043d\u0430\u0434 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041d\u043e \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f?<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0432\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u044d\u0442\u043e\u0439 \u043d\u0430\u0443\u043a\u0435 \u0432\u043e\u0437\u043d\u0438\u043a \u0438\u0437-\u0437\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a\u0438\u0435 \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0434\u043b\u044f \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e. \u0412\u0430\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u043e\u0432\u043e &#171;\u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f&#187;. <\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0417\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u043c\u0435\u0435\u043c \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438 \u043d\u0435\u043a\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u0418\u043c\u0435\u0435\u043c \u043f\u0430\u0440\u0443 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(G, \\circ)\" alt=\"(G, \\circ)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/55c\/b2d\/324\/55cb2d3243c86fd6dc129ddd13b7afd4.svg\" width=\"49\" height=\"22\"\/>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u0437\u043e\u0432\u0451\u043c \u043c\u043e\u043d\u043e\u0438\u0434\u043e\u043c. \u0417\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u0438\u0437 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"G\" alt=\"G\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/daa\/93d\/13a\/daa93d13a0a4eb93f58771d66d913ebf.svg\" width=\"15\" height=\"17\"\/>\u043b\u044e\u0431\u044b\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a\" alt=\"a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7b6\/bbf\/eb1\/7b6bbfeb1660cc9fbd64c710b8576f6f.svg\" width=\"10\" height=\"12\"\/>\u0438  <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b\" alt=\"b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/089\/02f\/73c\/08902f73c3d7ba4701376f9b564e3279.svg\" width=\"8\" height=\"17\"\/>, \u0441\u0434\u0435\u043b\u0430\u0442\u044c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a \\circ b\" alt=\"a \\circ b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb3\/fa9\/050\/fb3fa9050cc870e6dade64ea9599a560.svg\" width=\"37\" height=\"17\"\/>\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"c \\in G\" alt=\"c \\in G\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/967\/c9d\/0be\/967c9d0be696c1f83904522337cb0ef8.svg\" width=\"48\" height=\"17\"\/>. \u0425\u043e\u0440\u043e\u0448\u043e. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u0437\u044f\u043b\u0438 \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441?<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"a \\circ x = b \\\\ a, x, b \\in G \\\\ x = \\; ?\" alt=\"a \\circ x = b \\\\ a, x, b \\in G \\\\ x = \\; ?\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/696\/da2\/37d\/696da237d7ae49146d0a805f53a83874.svg\" width=\"664\" height=\"66\"\/><\/p>\n<p>\u0410 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043c\u043e\u043d\u043e\u0438\u0434\u0435 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0443, \u0442\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"x = a^{-1} \\circ b\" alt=\"x = a^{-1} \\circ b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/873\/634\/49d\/87363449d1527a10d758d9c4830fb8a0.svg\" width=\"94\" height=\"21\"\/>, \u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a^{-1}\" alt=\"a^{-1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d6\/687\/7f6\/2d66877f67a54fac0e5e53316eb5ce92.svg\" width=\"30\" height=\"21\"\/>\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u0434\u043b\u044f <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a\" alt=\"a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1bf\/ba6\/d3c\/1bfba6d3cae3c24747713f019d739670.svg\" width=\"10\" height=\"12\"\/>\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0430 \u0441\u0430\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a\" alt=\"a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/82b\/a43\/ebd\/82ba43ebdfdddab4ad24a64f6dc58a56.svg\" width=\"10\" height=\"12\"\/>&#8212; \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u0439. \u0418\u043b\u0438, \u043f\u043e-\u043d\u0430\u0443\u0447\u043d\u043e\u043c\u0443, <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a\" alt=\"a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c0\/754\/086\/8c0754086a53d37b915793c7fd6d72b5.svg\" width=\"10\" height=\"12\"\/>\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\exists \\; h = a^{-1}: a \\circ h = h \\circ a = e\" alt=\"\\exists \\; h = a^{-1}: a \\circ h = h \\circ a = e\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fee\/d0e\/629\/feed0e6298d1de55d8103d749a866517.svg\" width=\"241\" height=\"21\"\/><\/p>\n<p>\u041d\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u043d\u043e\u0438\u0434\u0430. \u0425\u043e\u0442\u044f, \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438&#8230;<\/p>\n<h2>\u0413\u0440\u0443\u043f\u043f\u0430<\/h2>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u043d\u043e\u0438\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b. \u0418 \u0442\u0430\u043a\u0436\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u043d\u043e\u0438\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u043e\u043d\u0438 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &#171;\u0433\u0440\u0443\u043f\u043f\u0430&#187;. \u0413\u0440\u0443\u043f\u043f\u0430 \u044d\u0442\u043e \u043c\u043e\u043d\u043e\u0438\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0443\u0436\u0435 \u0442\u0440\u0435\u0442\u044c\u044f \u043f\u043e \u0441\u0447\u0451\u0442\u0443 \u0430\u043a\u0441\u0438\u043e\u043c\u0430.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\forall \\; g \\in G \\; \\exists \\; h=g^{-1} \\in G: g \\circ h = h \\circ g = e\" alt=\"\\forall \\; g \\in G \\; \\exists \\; h=g^{-1} \\in G: g \\circ h = h \\circ g = e\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/910\/18e\/acd\/91018eacd94fb5d79f373cf58852848f.svg\" width=\"348\" height=\"25\"\/><\/p>\n<pre><code class=\"cs\">public interface IGroup&lt;T> : IMonoid&lt;T> {     T Inverse(T item); }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a \\circ x = b\" alt=\"a \\circ x = b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2fd\/129\/c29\/2fd129c29c5e5417011fd58b20495d56.svg\" width=\"74\" height=\"17\"\/>, \u0431\u0443\u0434\u0443\u0447\u0438 \u043f\u043e\u043c\u0435\u0449\u0451\u043d\u043d\u044b\u043c \u0432 \u0433\u0440\u0443\u043f\u043f\u0443, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0427\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0433\u0440\u0443\u043f\u043f\u044b? \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0435\u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u043e\u043d \u043f\u0440\u0438\u0440\u043e\u0434\u044b, \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u0435\u0433\u043e \u0430\u043d\u0442\u0438\u043f\u043e\u0434. \u0415\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0415\u0433\u043e \u0440\u0435\u0432\u0435\u0440\u0441. \u0415\u0433\u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0433\u043b\u0438 \u0441\u043b\u044b\u0448\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043e\u0440\u0438\u044f \u0433\u0440\u0443\u043f\u043f &#8212; \u044d\u0442\u043e \u043d\u0430\u0443\u043a\u0430 \u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f\u0445. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0437\u0430\u0431\u0430\u0432\u043d\u043e, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"S_n\" alt=\"S_n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/504\/367\/a91\/504367a910eccd39f5bb2dff7c9351ba.svg\" width=\"22\" height=\"20\"\/>. \u042d\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0431\u0438\u0435\u043a\u0446\u0438\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n\" alt=\"n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8cd\/85a\/ffd\/8cd85affd018ecf6a515bfad2f514f51.svg\" width=\"11\" height=\"12\"\/>. \u0421\u0430\u043c\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b &#8212; \u044d\u0442\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0447\u0438\u0441\u0435\u043b. \u0412\u0435\u0440\u0445\u043d\u044f\u044f &#8212; \u0447\u0438\u0441\u043b\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"1...n\" alt=\"1...n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d1\/a72\/6f6\/2d1a726f60b492e273ea88f481cfc0f8.svg\" width=\"38\" height=\"17\"\/>, \u0430 \u0441\u043d\u0438\u0437\u0443 &#8212; \u043d\u0430 \u043a\u0430\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0442\u0430\u044e\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\phi \\in S_3\" alt=\"\\phi \\in S_3\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a04\/d3c\/33f\/a04d3c33f94fb96f0db49ea97124258d.svg\" width=\"56\" height=\"21\"\/>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\phi = \\begin{pmatrix} 1 &amp; 2&amp; 3 \\\\ 2&amp;3&amp;1 \\end{pmatrix}\" alt=\"\\phi = \\begin{pmatrix} 1 &amp; 2&amp; 3 \\\\ 2&amp;3&amp;1 \\end{pmatrix}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/79e\/8dc\/e9a\/79e8dce9a4aeec5bc35fee276b23ead9.svg\" width=\"141\" height=\"50\"\/><\/p>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0435. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e &#8212; <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(\\phi \\circ \\pi) (i) = \\pi (\\phi(i))\" alt=\"(\\phi \\circ \\pi) (i) = \\pi (\\phi(i))\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/027\/805\/61e\/02780561e4fffc46bca2b1704adc6b02.svg\" width=\"165\" height=\"22\"\/>. \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0442\u043e\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c &#8212;  <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\phi^{-1} = h \\implies h(i) = \\phi(\\phi(i))\" alt=\"\\phi^{-1} = h \\implies h(i) = \\phi(\\phi(i))\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/79d\/204\/5b4\/79d2045b4445048f3f1f06fe92a3b794.svg\" width=\"242\" height=\"25\"\/>.<\/p>\n<details class=\"spoiler\">\n<summary>Permutation.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public class Permutation : IEquatable&lt;Permutation> {     private readonly int[] _map;      public Permutation(params int[] map)     {         _map = new int[map.Length];         for (var i = 0; i &lt; map.Length; i++)         {             _map[i] = map[i];         }     }      public int this[int index] => _map[index];      public bool Equals(Permutation other)     {         if (other != null &amp;&amp; _map.Length == other._map.Length)         {             return _map.Zip(other._map)                 .All(pair => pair.First == pair.Second);         }          return false;     }      public override string ToString() =>         new StringBuilder()             .AppendJoin(' ', Enumerable.Range(1, _map.Length))             .Append('\\n')             .AppendJoin(' ', _map.Select(x => x + 1))             .ToString(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>SymmetricGroup.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public readonly struct SymmetricGroup : IGroup&lt;Permutation> {     private readonly int _length;      public SymmetricGroup(int length)     {         _length = length;     }      public Permutation Plus(Permutation left, Permutation right)     {         var newMap = new int[_length];         for (var i = 0; i &lt; _length; i++)         {             newMap[i] = right[left[i]];         }          return new Permutation(newMap);     }      public Permutation Zero =>         new(Enumerable.Range(0, _length).ToArray());      public Permutation Inverse(Permutation item)     {         var newMap = new int[_length];         for (var i = 0; i &lt; _length; i++)         {             newMap[item[i]] = i;         }          return new Permutation(newMap);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u043b\u043e \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"x = b \\circ a^{-1}\" alt=\"x = b \\circ a^{-1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/756\/839\/b06\/756839b06b41cd4b0eb8a2379063abfb.svg\" width=\"94\" height=\"21\"\/>, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f  <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\circ\" alt=\"\\circ\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a87\/dab\/562\/a87dab562df9d7f53cd99a077e60889d.svg\" width=\"10\" height=\"11\"\/>\u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 (\u0442\u043e \u0441\u0430\u043c\u043e\u0435 &#171;\u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u044b \u043c\u0435\u0441\u0442 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0441\u0443\u043c\u043c\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f&#187;). \u0418 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u0440\u0443\u043f\u043f \u043c\u043e\u0436\u043d\u043e \u0441\u0443\u0437\u0438\u0442\u044c \u0434\u043e \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0445, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0431\u0435\u043b\u0435\u0432\u044b\u0445 \u0433\u0440\u0443\u043f\u043f. \u0410\u0431\u0435\u043b\u0435\u0432\u0430 \u0433\u0440\u0443\u043f\u043f\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"G\" alt=\"G\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb2\/f44\/cf5\/fb2f44cf54cad5010ef14e73732fb5f4.svg\" width=\"15\" height=\"17\"\/>\u044d\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\forall \\; g, h \\in G : g \\circ h = h \\circ g\" alt=\"\\forall \\; g, h \\in G : g \\circ h = h \\circ g\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ed\/db5\/d3e\/7eddb5d3ea15be0835ea8ca6d97d3db3.svg\" width=\"205\" height=\"21\"\/><\/p>\n<p>\u041d\u043e \u044d\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u043e\u0442\u043e\u043a \u0441\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435 \u0440\u0443\u0441\u043b\u043e.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u0422\u0430\u043a\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\/\u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 append-only \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u041e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435.<\/p>\n<pre><code class=\"cs\">public record CatalogueEvent&lt;T>;  public record Add&lt;T>(T Data) : CatalogueEvent&lt;T>;  public record Remove&lt;T>(T Data) : CatalogueEvent&lt;T>;  public record Nothing&lt;T> : CatalogueEvent&lt;T>;<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443 \u0435\u0441\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0442. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u043e\u043d\u043e\u0438\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0438 \u0447\u0451\u043c \u0437\u0434\u0435\u0441\u044c \u0433\u0440\u0443\u043f\u043f\u044b? <\/p>\n<p>\u0412 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0441\u044e\u0436\u0435\u0442 \u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438. \u0422\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c, \u0430 \u043c\u043e\u0436\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. \u0418 \u043f\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<pre><code class=\"cs\">public class Catalogue&lt;T> : IEnumerable&lt;CatalogueEvent&lt;T>> {     private readonly List&lt;CatalogueEvent&lt;T>> _catalogueEvents = new();      public S Reduce&lt;S, G>(Func&lt;T, S> map, G group = default)         where G : struct, IGroup&lt;S>         => _catalogueEvents.Select(t =>             t switch             {                 Add&lt;T> add => map(add.Data),                 Remove&lt;T> rm => group.Inverse(map(rm.Data)),                 Nothing&lt;T> => group.Zero,                 _ => default             }         ).Sum&lt;S, G>();      public Catalogue&lt;T> Add(T item)     {         _catalogueEvents.Add(new Add&lt;T>(item));         return this;     }      public Catalogue&lt;T> Remove(T item)     {         _catalogueEvents.Add(new Remove&lt;T>(item));         return this;     }      public Catalogue&lt;T> Nothing()     {         _catalogueEvents.Add(new Nothing&lt;T>());         return this;     }      public IEnumerator&lt;CatalogueEvent&lt;T>> GetEnumerator() =>         _catalogueEvents.GetEnumerator();      IEnumerator IEnumerable.GetEnumerator() =>         GetEnumerator(); }<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Reduce<\/code> \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e, \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c: <code>map<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u043d\u043e\u0438\u0434, \u0438 \u0441\u0430\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <code>Sum<\/code>, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u043f\u043e \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0410 \u0437\u0430\u0442\u0435\u043c \u0441\u0443\u0436\u0430\u0435\u043c \u043c\u043e\u043d\u043e\u0438\u0434 \u0434\u043e \u0433\u0440\u0443\u043f\u043f\u044b \u0447\u0442\u043e\u0431\u044b <code>Remove<\/code> \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c &#171;\u0440\u0435\u0432\u0435\u0440\u0441&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0449\u0443\u043f\u0430\u0435\u043c \u043d\u0430\u0448 \u043a\u0430\u0442\u0430\u043b\u043e\u0433.<\/p>\n<pre><code class=\"cs\">var stringsCatalogue = new Catalogue&lt;string>()     .Add(\"abc\")     .Nothing()     .Remove(\"c\")     .Remove(\"a\")     .Add(\"ed\");<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>IntAddGroup.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">private struct IntAddGroup : IGroup&lt;int> {     public int Plus(int left, int right) => left + right;      public int Zero => 0;      public int Inverse(int item) => -item; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043c\u044b \u043a\u0430\u043a-\u0442\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439<\/p>\n<pre><code class=\"cs\">stringsCatalogue.Reduce&lt;int, IntAddGroup>(s => s.Length); \/\/ 3<\/code><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u0435\u043d, \u043f\u043e\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043d\u043e \u0437\u0430\u0442\u043e \u043e\u0442\u0447\u0451\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u043a, \u0430 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439? \u0414\u0430, \u0443 \u0441\u0442\u0440\u043e\u043a \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f, \u043d\u043e \u0441 \u043d\u0435\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043d\u043e\u0438\u0434. \u0422\u0440\u0443\u0434\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 &#171;\u043c\u0438\u043d\u0443\u0441&#187; \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u0431\u0435 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cs\">\"abc\" - \"c\" == \"ab\"<\/code><\/pre>\n<p>\u041d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0430\u043b\u0441\u044f \u043a\u0435\u0439\u0441 <code>\"abc\" - \"d\"<\/code>, \u0438\u043b\u0438 <code>\"\" - \"\",<\/code> \u0438\u043b\u0438 <code>\"\" - \"xyz\"<\/code>? \u041e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0445\u043e\u0434 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043c\u043e\u0433\u043b\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0438\u0434\u0435\u044f \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445. \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <code>string<\/code> \u044d\u0442\u043e <code>IEnumerable&lt;char><\/code>, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0451 \u0434\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p> \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043b\u0438\u0448\u044c \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u043e\u043d\u043e\u0438\u0434 <s>(\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e)<\/s>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0431\u0435\u043b\u0435\u0432\u0443 \u0433\u0440\u0443\u043f\u043f\u0443, \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443, \u043d\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u0442\u043e.<\/p>\n<p>\u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0441\u0442\u0438 \u0443\u0447\u0451\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0442\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u0434\u043e\u0431\u044c\u0451\u043c\u0441\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u044b \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432: \u0441\u043b\u0435\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c; \u0441\u043f\u0440\u0430\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>PairedHashSet.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public record PairedSet&lt;T>(HashSet&lt;T> First, HashSet&lt;T> Second) {     public PairedSet() : this(new(), new())     {     }      public PairedHashSet(IEnumerable&lt;T> single) : this(new(single), new())     {     } }  public static class PairedSetExtensions {     public static HashSet&lt;T> ToHashSet&lt;T>(this PairedSet&lt;T> pairedSet)     {         var (first, second) = pairedSet;         return first.Except(second);     } }  public static class HashSetExtensions {     public static HashSet&lt;T> Except&lt;T>(this HashSet&lt;T> first, HashSet&lt;T> second)     {         var result = new HashSet&lt;T>(first);         result.ExceptWith(second);         return result;     }          public static HashSet&lt;T> Union&lt;T>(this HashSet&lt;T> first, HashSet&lt;T> second)     {         var result = new HashSet&lt;T>(first);         result.UnionWith(second);         return result;     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"cs\">public struct PairedHashSetGroup&lt;T> : IGroup&lt;PairedHashSet&lt;T>> {     public PairedHashSet&lt;T> Plus(PairedHashSet&lt;T> left, PairedHashSet&lt;T> right)     {         var (left1, left2) = left;         var (right1, right2) = right;         var newLeft = left1.Except(right2).Union(right1.Except(left2));         var newRight = left2.Except(right1).Union(right2.Except(left1));         return new PairedHashSet&lt;T>(newLeft, newRight);     }      public PairedHashSet&lt;T> Zero => new ();          public PairedHashSet&lt;T> Inverse(PairedHashSet&lt;T> item)     {         var (first, second) = item;         return new PairedHashSet&lt;T>(second, first);     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u043f\u0438\u0441\u043a\u0438, \u043f\u0440\u0438 \u0447\u0451\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0441 \u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>PairedList.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public record PairedList&lt;T>(List&lt;T> First, List&lt;T> Second) {     public PairedList() : this(new(), new())     {     }      public PairedList(IEnumerable&lt;T> single) : this(new(single), new())     {     } }  public static class PairedListExtensions {     public static List&lt;T> ToList&lt;T>(this PairedList&lt;T> pairedList)     {         var (first, second) = pairedList;         return first.Except(second);     } }  public static class ListExtensions {     public static List&lt;T> Union&lt;T>(this List&lt;T> list, List&lt;T> items)     {         var result = new List&lt;T>(list);         result.AddRange(items);         return result;     }          public static List&lt;T> Except&lt;T>(this List&lt;T> first, List&lt;T> second)     {         var result = new List&lt;T>(first);         second.ForEach(item =>         {             var li = result.LastIndexOf(item);             if (li > -1)             {                 result.RemoveAt(li);             }         });         return result;     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>PairedListGroup.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public struct PairedListGroup&lt;T> : IGroup&lt;PairedList&lt;T>> {     public PairedList&lt;T> Plus(PairedList&lt;T> left, PairedList&lt;T> right)     {         var (left1, left2) = left;         var (right1, right2) = right;         var newLeft = left1.Except(right2).Union(right1.Except(left2));         var newRight = left2.Except(right1).Union(right2.Except(left1));         return new PairedList&lt;T>(newLeft, newRight);     }      public PairedList&lt;T> Zero => new ();          public PairedList&lt;T> Inverse(PairedList&lt;T> item)     {         var (first, second) = item;         return new PairedList&lt;T>(second, first);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>PairedEnumerable.cs<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/gist.github.com\/Stepami\/24acee3673f0e899cd5fc166d65cb0e2\" rel=\"noopener noreferrer nofollow\">\u0414\u0430, \u043a\u043b\u0430\u0441\u0441\u044b &#171;\u043f\u0430\u0440\u043d\u044b\u0445&#187; \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u043f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0435, \u043d\u043e \u043e\u0441\u043e\u0431\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043d\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u0448\u044c.<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c, \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435.<\/p>\n<pre><code class=\"cs\">var chars = stringsCatalogue.Reduce&lt;PairedList&lt;char>, PairedListGroup&lt;char>>(     s => new PairedList&lt;char>(s) ).ToList(); Console.WriteLine(string.Join(\"\", chars)); \/\/ bed<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043c\u0430\u0433\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e. \u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e, \u0442\u0430\u043a\u043e\u0439 \u0444\u0438\u043d\u0442 \u0442\u043e\u0436\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043c. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u043f\u0430\u0440\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<pre><code class=\"cs\">\/\/ \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 public record PairedList&lt;T>(List&lt;T> First, List&lt;T> Second) {     ...     public PairedList(T item) : this(new List&lt;T> {item})     {     } }<\/code><\/pre>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443.<\/p>\n<pre><code class=\"cs\">public static class CatalogueExtensions {     public static List&lt;T> Collect&lt;T>(this Catalogue&lt;T> catalogue) =>         catalogue.Reduce&lt;PairedList&lt;T>, PairedListGroup&lt;T>>(             x => new PairedList&lt;T>(x)         ).ToList(); }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c dto&#8217;\u0448\u043a\u0438.<\/p>\n<pre><code class=\"cs\">public record SomeDto(int Number, bool Flag, string Field) { }<\/code><\/pre>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0451 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0438 \u043f\u043e\u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043d\u0438\u043c.<\/p>\n<pre><code class=\"cs\">var someDtosCatalogue = new Catalogue&lt;SomeDto>()     .Add(new SomeDto(1, false, \"asa\"))     .Add(new SomeDto(2, true, \"asa\"))     .Remove(new SomeDto(1, false, \"asa\"));<\/code><\/pre>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e, \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (\u043d\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430).<\/p>\n<pre><code class=\"cs\">someDtosCatalogue.Reduce&lt;int, IntAddGroup>(_ => 1)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0430\u043c\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0438 \u0447\u0442\u043e-\u0442\u043e \u0441 \u043d\u0435\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cs\">var someDtosObjects = someDtosCatalogue.Collect(); someDtosObjects.ForEach(Console.WriteLine); \/\/ SomeDto { Number = 2, Flag = True, Field = asa }<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u043f\u043e\u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043b\u043e\u0433\u0438.<\/p>\n<pre><code class=\"cs\">var logs = someDtosCatalogue.ToList(); logs.ForEach(Console.WriteLine); \/\/ Add { Data = SomeDto { Number = 1, Flag = False, Field = asa } } \/\/ Add { Data = SomeDto { Number = 2, Flag = True, Field = asa } } \/\/ Remove { Data = SomeDto { Number = 1, Flag = False, Field = asa } }<\/code><\/pre>\n<p>\u0427\u0442\u043e-\u0442\u043e \u043d\u0430 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c, \u043f\u043e\u0440\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h2>\u041a\u043e\u043b\u044c\u0446\u043e<\/h2>\n<p>\u0421 \u0434\u0440\u0435\u0432\u043d\u0438\u0445 \u0432\u0440\u0435\u043c\u0451\u043d \u0434\u043e \u043d\u0430\u0448\u0438\u0445 \u0434\u043d\u0435\u0439 \u0434\u043e\u0448\u0451\u043b \u043e\u0447\u0435\u043d\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0444\u0430\u043a\u0442. \u0415\u0441\u043b\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a, b, c\" alt=\"a, b, c\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/861\/ef0\/bb1\/861ef0bb18a70cc900518fac8d87cc84.svg\" width=\"44\" height=\"20\"\/>, \u0442\u043e \u043e\u043d\u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a^2 + b^2 = c^2\" alt=\"a^2 + b^2 = c^2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c3\/284\/8b4\/9c32848b4a0e3ed394dbca2555fd0039.svg\" width=\"104\" height=\"22\"\/>. \u0414\u0430\u043d\u043d\u043e\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u041f\u0438\u0444\u0430\u0433\u043e\u0440\u0430, \u0437\u043d\u0430\u043a\u043e\u043c\u0430\u044f, \u043d\u0430\u0432\u0435\u0440\u043d\u043e, \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0448\u043a\u043e\u043b\u044c\u043d\u0438\u043a\u0443. <\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443 \u043b\u044e\u0434\u0435\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a  \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0446\u0435\u043b\u044b\u0435. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D0%B8%D1%84%D0%B0%D0%B3%D0%BE%D1%80%D0%BE%D0%B2%D0%B0_%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043f\u0443\u0441\u0442\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0442\u0430\u043a\u0438\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432<\/a>, \u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043d\u0430 \u044d\u0442\u043e\u043c \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. <\/p>\n<p>\u041b\u044e\u0431\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043e\u0431\u043e\u0431\u0449\u0430\u0442\u044c. \u0418 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043f\u043e\u0448\u0451\u043b \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u0438: \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0430 &#8212; \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0414\u0438\u043e\u0444\u0430\u043d\u0442\u043e\u0432\u0430 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"x^n + y^n = z^n\" alt=\"x^n + y^n = z^n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/884\/a9d\/689\/884a9d6897dbcec9700715984e601cd3.svg\" width=\"111\" height=\"22\"\/>. \u0418 \u0432 1637 \u0433\u043e\u0434\u0443, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a \u041f\u044c\u0435\u0440 \u0424\u0435\u0440\u043c\u0430 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0432\u043e\u044e \u0412\u0435\u043b\u0438\u043a\u0443\u044e \u0422\u0435\u043e\u0440\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u043e\u0435\u043a \u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u0434\u043b\u044f \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 <img class=\"formula inline\" source=\"n > 2&#8243; alt=&#187;n > 2&#8243; src=&#187;https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec3\/f0f\/ef4\/ec3f0fef42b09091a286b30ecba1b45c.svg&#187; width=&#187;47&#8243; height=&#187;17&#8243;\/>. \u042d\u0442\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u043a\u043e\u043b\u0435\u0446.<\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n\" alt=\"n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ddd\/e4f\/b62\/ddde4fb624ef569d7bfb8499e1e6794b.svg\" width=\"11\" height=\"12\"\/> \u0438 \u0431\u0430\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445 \u0432\u0438\u0434\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\mathbb{Z}[\\sqrt{-n}]= \\{ a + b\\sqrt{-n}: a,b \\in \\mathbb{Z} \\}\" alt=\"\\mathbb{Z}[\\sqrt{-n}]= \\{ a + b\\sqrt{-n}: a,b \\in \\mathbb{Z} \\}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a00\/0fc\/8ef\/a000fc8ef5ea0dbb0262f7aa7e4058be.svg\" width=\"279\" height=\"24\"\/>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0438 \u0438\u0445 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438. \u0422\u0430\u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043a\u043e\u043b\u044c\u0446\u0430.<\/p>\n<p>\u041a\u043e\u043b\u044c\u0446\u043e (\u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0435) &#8212; \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R\" alt=\"R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc3\/2dd\/860\/cc32dd860a65c09b7f8247ca1b822651.svg\" width=\"15\" height=\"17\"\/> \u0441 \u0434\u0432\u0443\u043c\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"+\" alt=\"+\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca3\/ef4\/b36\/ca3ef4b366b4ad4f5dce2d40d22d1fbb.svg\" width=\"15\" height=\"16\"\/> \u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\times\" alt=\"\\times\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cb3\/8d4\/fb6\/cb38d4fb62600868df4e32c1d6a76c73.svg\" width=\"15\" height=\"12\"\/> \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e:<\/p>\n<ul>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(R, +)\" alt=\"(R, +)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/305\/97f\/87f\/30597f87f01ffa1c331da1908d735b43.svg\" width=\"54\" height=\"22\"\/> &#8212; \u0430\u0431\u0435\u043b\u0435\u0432\u0430 \u0433\u0440\u0443\u043f\u043f\u0430;<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(R, \\times)\" alt=\"(R, \\times)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cdf\/fc4\/d49\/cdffc4d4914a875253d655bdd3e198f1.svg\" width=\"54\" height=\"22\"\/>&#8212; (\u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0439) \u043c\u043e\u043d\u043e\u0438\u0434;<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\times\" alt=\"\\times\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e82\/0e1\/883\/e820e1883fadbc80f2dc7cfff1f08ea6.svg\" width=\"15\" height=\"12\"\/>  \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"+\" alt=\"+\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b18\/61b\/daa\/b1861bdaab595f0317755eec4c5dcfc1.svg\" width=\"15\" height=\"16\"\/> &#8212; <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"  \\forall \\; a, b, c \\in R : (a + b) \\times c = a \\times c + b \\times c\" alt=\"  \\forall \\; a, b, c \\in R : (a + b) \\times c = a \\times c + b \\times c\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/721\/703\/a03\/721703a033f7c2ce2c62bba82d8adba4.svg\" width=\"340\" height=\"22\"\/> (\u043f\u0440\u0438 \u0447\u0451\u043c \u043a\u0430\u043a \u0441\u043b\u0435\u0432\u0430, \u0442\u0430\u043a \u0438 \u0441\u043f\u0440\u0430\u0432\u0430).<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public interface IRing&lt;T> : IGroup&lt;T> {     T One { get; }          T Times(T left, T right); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0430\u0436\u0435 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u043c\u0438, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u043e\u043b\u044c\u0446\u0430 \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0442\u043e \u0435\u0441\u0442\u044c, \u0438\u0445 \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0431\u0449\u0438\u0442\u044c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u043d\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430, \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c, \u043a\u0430\u043a <em>\u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c<\/em>. \u0413\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c &#8212;  \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(G, \\oplus)\" alt=\"(G, \\oplus)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4bb\/65c\/e26\/4bb65ce2664623e2a3718e6260beba0a.svg\" width=\"54\" height=\"22\"\/> \u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(H, \\otimes)\" alt=\"(H, \\otimes)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/826\/39f\/5ab\/82639f5abe0330503371fda35dc8c8f1.svg\" width=\"56\" height=\"22\"\/>\u0422\u043e\u0433\u0434\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\phi: G \\to H\" alt=\"\\phi: G \\to H\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/750\/5f9\/d98\/7505f9d986c18a91e03bbd62202b7688.svg\" width=\"91\" height=\"21\"\/> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u043e\u043c, \u0435\u0441\u043b\u0438<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\forall \\; x, y \\in X \\; \\phi(x \\oplus y) = \\phi(x) \\otimes \\phi(y)\" alt=\"\\forall \\; x, y \\in X \\; \\phi(x \\oplus y) = \\phi(x) \\otimes \\phi(y)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4e8\/c8e\/f05\/4e8c8ef0555e0d66e9002b1ce8d494e3.svg\" width=\"288\" height=\"22\"\/><\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e, \u0447\u0442\u043e \u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c &#8212; \u044d\u0442\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u044e\u0440\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u0438\u043d\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u0432 \u0441\u0435\u0431\u044f \u0438 \u0442. \u0434. <\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c(\u0431\u0438\u0435\u043a\u0446\u0438\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0449\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e). \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0435\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u043e-\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0435\u0451 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u044b\u0433\u0430\u0442\u044c \u0442\u0443\u0434\u0430-\u0441\u044e\u0434\u0430. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(\\mathbb{R}, +)\" alt=\"(\\mathbb{R}, +)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/377\/13a\/f7c\/37713af7c4ce71700bd80442b64615c0.svg\" width=\"53\" height=\"22\"\/> \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0433\u0440\u0443\u043f\u043f\u0443, \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(\\mathbb{R}_+^*, *)\" alt=\"(\\mathbb{R}_+^*, *)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/42a\/c67\/15d\/42ac6715dc280fd7f70695d2f52efc0a.svg\" width=\"60\" height=\"23\"\/>\u0442\u043e\u0436\u0435. \u041c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\u00a0x \\mapsto e^x\" alt=\"\u00a0x \\mapsto e^x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/396\/233\/272\/3962332724dd4dc1525ea501bd51c478.svg\" width=\"60\" height=\"18\"\/> (\u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u0430\u044f \u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f).<\/p>\n<p>\u0418 \u043d\u0430\u0434\u043e \u043b\u0438 \u043d\u0430\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u043d\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f <em>\u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e \u0438\u0437\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430<\/em>? \u0412\u043e\u043f\u0440\u043e\u0441 \u0440\u0438\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u043e\u0432, \u044d\u0442\u043e \u044d\u043d\u0434\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u044b. \u042d\u043d\u0434\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c &#8212; \u044d\u0442\u043e \u0433\u043e\u043c\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c \u0432 \u0441\u0435\u0431\u044f. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435\u0445 \u044d\u043d\u0434\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u043e\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"S\" alt=\"S\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/822\/b1b\/be8\/822b1bbe805696d0de04d8771a5e1518.svg\" width=\"12\" height=\"17\"\/> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"End(S)\" alt=\"End(S)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e5\/ce4\/24e\/7e5ce424ed3365f014ce87f953adadd3.svg\" width=\"65\" height=\"22\"\/>,  \u0430 \u0435\u0441\u043b\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"S\" alt=\"S\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/445\/398\/bf9\/445398bf9e46239946ab2b4035788745.svg\" width=\"12\" height=\"17\"\/> &#8212; \u0430\u0431\u0435\u043b\u0435\u0432\u0430 \u0433\u0440\u0443\u043f\u043f\u0430, \u0442\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"End(S)\" alt=\"End(S)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a12\/f1f\/8c2\/a12f1f8c20e0c7c98e9ae784b5b83e1b.svg\" width=\"65\" height=\"22\"\/> &#8212; \u043a\u043e\u043b\u044c\u0446\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u0447\u0435\u0447\u043d\u043e, \u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0437\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<pre><code class=\"cs\">public struct End&lt;T, G> : IRing&lt;Func&lt;T, T>>     where G : struct, IGroup&lt;T> {     public Func&lt;T, T> Plus(Func&lt;T, T> left, Func&lt;T, T> right) =>          x => default(G).Plus(left(x), right(x));      public Func&lt;T, T> Zero => _ => default(G).Zero;      public Func&lt;T, T> Inverse(Func&lt;T, T> item) =>         x => default(G).Inverse(x);      public Func&lt;T, T> One => x => x;      public Func&lt;T, T> Times(Func&lt;T, T> left, Func&lt;T, T> right) =>         x => left(right(x)); }<\/code><\/pre>\n<p>\u041f\u043e\u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441 <code>End&lt;T, G><\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439 \u0434\u0432\u043e\u0439\u043a\u0438. \u041f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432 <code>PairedHashSet&lt;T><\/code> \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043b\u044c\u0446\u0430, \u0441\u0447\u0438\u0442\u0430\u044e\u0449\u0435\u0435 \u0441\u0442\u0435\u043f\u0435\u043d\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>RingExtensions.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public static class RingExtensions {     public static T Power&lt;T>(this IRing&lt;T> ring, T item, int n)     {         var result = item;         for (var i = 1; i &lt; n; i++)         {             result = ring.Times(result, item);         }          return result;     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"cs\">var end = default(End&lt;PairedHashSet&lt;int>, PairedHashSetGroup&lt;int>>); var id = end.One; Func&lt;PairedHashSet&lt;int>, PairedHashSet&lt;int>> x2 =      s => new (s.ToHashSet().Select(i => i * 2)); var idPlusX2 = end.Plus(id, x2); var pows = end.Power(idPlusX2, 6)(new (1)); \/\/ {1, 2, 4, 8, 16, 32, 64}<\/code><\/pre>\n<h2>\u041f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u043e<\/h2>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0433\u0440\u0443\u043f\u043f\u043e\u0439 \u0443 \u043a\u043e\u043b\u044c\u0446\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 &#171;\u043f\u043e\u043b\u0443&#187; \u0430\u043d\u0430\u043b\u043e\u0433. \u0412\u0441\u0451 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0442\u0440\u043e\u0439\u043a\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(S, +, \\times)\" alt=\"(S, +, \\times)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/507\/f3c\/429\/507f3c42989d18bfed6c7a153951925c.svg\" width=\"75\" height=\"22\"\/>, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442 \u043d\u0435\u0451 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(S, +)\" alt=\"(S, +)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d0\/9a8\/aba\/3d09a8aba03611fafc759622fc29eb1c.svg\" width=\"52\" height=\"22\"\/> &#8212; \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u043e\u043d\u043e\u0438\u0434;<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(S, \\times)\" alt=\"(S, \\times)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b2\/277\/e39\/1b2277e39af5abe592857d70601c5d63.svg\" width=\"52\" height=\"22\"\/> &#8212; \u043c\u043e\u043d\u043e\u0438\u0434;<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0433\u043b\u043e\u0449\u0430\u044e\u0449\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u044f: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\forall \\; x \\in S \\; x \\times 0 = 0 = 0 \\times x\" alt=\"\\forall \\; x \\in S \\; x \\times 0 = 0 = 0 \\times x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8f1\/8e9\/cd3\/8f18e9cd37867c140de22d80e056ca70.svg\" width=\"221\" height=\"17\"\/>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public interface ISemiRing&lt;T> : IMonoid&lt;T> {     T One { get; }      T Times(T left, T right); }<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043e\u043b\u044c\u0446\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u0430 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0443\u043b\u044f \u0432\u044b\u0442\u0435\u043a\u0430\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438\u0437 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0438\u043d\u0443\u0441\u0430. <a href=\"https:\/\/math.stackexchange.com\/questions\/1186702\/examples-for-almost-semirings-without-absorbing-zero\" rel=\"noopener noreferrer nofollow\">\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u0433\u0434\u0435 \u043e\u043d\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f<\/a>.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u0431\u0449\u0438\u0445 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043e \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e <a href=\"https:\/\/math.stackexchange.com\/a\/451284\" rel=\"noopener noreferrer nofollow\">\u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/a>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/epdf.tips\/graphs-dioids-and-semirings-new-models-and-algorithms.html\" rel=\"noopener noreferrer nofollow\">\u0432 \u044d\u0442\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0435<\/a> \u043d\u0430\u0443\u0447\u043d\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f (\u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438) \u0438 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043d\u0435\u0435 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0437\u0430 \u0441\u0447\u0451\u0442 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0435 \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0447\u0438\u0441\u0435\u043b, \u0430 \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u043b\u0433\u0435\u0431\u0440\u0443. \u0422\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"M_n(S)\" alt=\"M_n(S)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5dc\/c3e\/3b5\/5dcc3e3b5a981d03f6e46138a3104968.svg\" width=\"57\" height=\"22\"\/> \u0432\u0441\u0435\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n \\times n\" alt=\"n \\times n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b8b\/02c\/f17\/b8b02cf17149678e3c577789d54d70b9.svg\" width=\"47\" height=\"13\"\/>, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(S, \\oplus, \\otimes)\" alt=\"(S, \\oplus, \\otimes)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87d\/978\/685\/87d978685bdb8a0adfc6f407ef1131e7.svg\" width=\"75\" height=\"22\"\/>. \u0422\u043e\u0433\u0434\u0430 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"c_{ij} = \\bigoplus_{k = 1}^n a_{ik} \\otimes b_{kj}\" alt=\"c_{ij} = \\bigoplus_{k = 1}^n a_{ik} \\otimes b_{kj}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/caa\/4c5\/04e\/caa4c504e5de8a2437fb86f19cbb6b75.svg\" width=\"151\" height=\"57\"\/><\/p>\n<pre><code class=\"cs\">public class SquareMatrix&lt;T, S> : IEnumerable&lt;SquareMatrix&lt;T, S>.Vector>     where S : struct, ISemiRing&lt;T> {     private readonly int _size;     private readonly List&lt;Vector> _rows = new();      public SquareMatrix(int size)     {         _size = size;         for (var i = 0; i &lt; _size; i++)         {             _rows.Add(new Vector(                 Enumerable.Repeat(default(S).Zero, _size)             ));         }     }      public SquareMatrix(int size, params IEnumerable&lt;T>[] rows)     {         _size = size;         _rows.AddRange(rows.Select(x => new Vector(x)));     }      public T this[int i, int j]     {         get => _rows[i][j];         set => _rows[i][j] = value;     }      public SquareMatrix&lt;T, S> Transpose()     {         var columns = Enumerable             .Range(0, _size)             .Select(i => _rows.Select(col => col[i]));         return new (_size, columns.ToArray());     }      public SquareMatrix&lt;T, S> Product(SquareMatrix&lt;T, S> that)     {         var transposed = that.Transpose();         var rows = this             .Select(x => transposed.Select(x.Dot));         return new (_size, rows.ToArray());     }      public SquareMatrix&lt;T, S> Power(int n)     {         var result = this;         for (var i = 1; i &lt; n; i++)         {             result = result.Product(this);         }          return result;     }      public IEnumerator&lt;Vector> GetEnumerator() => _rows.GetEnumerator();      IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();      public override string ToString() =>         new StringBuilder()             .AppendJoin('\\n', _rows.Select(row =>                 new StringBuilder()                     .Append('|')                     .AppendJoin(\", \", row)                     .Append('|')))             .ToString();      public class Vector : IEnumerable&lt;T>     {         private readonly List&lt;T> _items;          public Vector(IEnumerable&lt;T> items)         {             _items = new List&lt;T>(items);         }          public T this[int index]         {             get=> _items[index];             set => _items[index] = value;         }          public T Dot(Vector that) => _items             .Zip(that._items)             .Select(pair => default(S).Times(pair.First, pair.Second))             .Sum&lt;T, S>();          public IEnumerator&lt;T> GetEnumerator() => _items.GetEnumerator();          IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();     } }<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(\\mathbb{R} \\cup \\{ + \\infty\\}, \\min, +)\" alt=\"(\\mathbb{R} \\cup \\{ + \\infty\\}, \\min, +)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/071\/5c8\/67f\/0715c867f2aa20a6f6610c8775ee298a.svg\" width=\"171\" height=\"22\"\/>, \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/32e\/e5e\/a65\/32ee5ea65235f26041c7e6b0902f93d1.svg\" width=\"7\" height=\"16\"\/> \u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"j\" alt=\"j\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/262\/68d\/1fe\/26268d1fe7ade62fa66f257f34fd2d00.svg\" width=\"8\" height=\"20\"\/> \u0437\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"k\" alt=\"k\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aad\/ee7\/58e\/aadee758e5abfd0116d1ce645233e00b.svg\" width=\"10\" height=\"17\"\/> \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u0433\u043e\u0432. \u0412 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0435 \u0436\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(\\mathbb{R} \\cup \\{ - \\infty\\}, \\max, +)\" alt=\"(\\mathbb{R} \\cup \\{ - \\infty\\}, \\max, +)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b3e\/084\/47d\/b3e08447dba3ad5229280cab45875eda.svg\" width=\"174\" height=\"22\"\/> \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>MinPlus.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public struct MinPlus : ISemiRing&lt;double> {     public double Plus(double left, double right) => Min(left, right);      public double Zero => double.PositiveInfinity;          public double One => 0;      public double Times(double left, double right) => left + right; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>MaxPlus.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public struct MaxPlus : ISemiRing&lt;double> {     public double Plus(double left, double right) => Max(left, right);      public double Zero => double.NegativeInfinity;          public double One => 0;      public double Times(double left, double right) => left + right; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432 \u043f\u043e\u043b\u0443\u043a\u043e\u043b\u044c\u0446\u0435 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<pre><code class=\"cs\">SquareMatrix&lt;int, IntSemiRing> testMatrix = new(3,     new[] {1, 0, 3},     new[] {0, 5, 0},     new[] {2, 0, 6} ); Console.WriteLine(testMatrix.Power(4));<\/code><\/pre>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\begin{pmatrix} 343 &amp; 0 &amp; 1029 \\\\ 0 &amp; 625 &amp; 0 \\\\ 686 &amp; 0 &amp; 2058 \\end{pmatrix}\" alt=\"\\begin{pmatrix} 343 &amp; 0 &amp; 1029 \\\\ 0 &amp; 625 &amp; 0 \\\\ 686 &amp; 0 &amp; 2058 \\end{pmatrix}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/35f\/874\/886\/35f874886d2bc9f5a012ccf0a7510c61.svg\" width=\"177\" height=\"78\"\/><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0433\u0440\u0430\u0444 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9c9\/798\/9a2\/9c97989a28530c5bb867837da118c972.png\" width=\"1566\" height=\"582\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c9\/798\/9a2\/9c97989a28530c5bb867837da118c972.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0431\u043e\u0431\u0449\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0432\u0443\u0445 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u0447, \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"A^k_{ij}\" alt=\"A^k_{ij}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c05\/e8d\/487\/c05e8d487bef205742c777cd7b2239bb.svg\" width=\"27\" height=\"28\"\/>.<\/p>\n<pre><code class=\"cs\">public class WeightedGraph {     private readonly int _size;     private readonly Dictionary&lt;int, List&lt;(int Vertex, double Weight)>> _adjancencyList = new();      public WeightedGraph(int size, params (int, List&lt;(int Vertex, double Weight)>)[] adjancencyList)     {         _size = size;         adjancencyList.ToList()             .ForEach(x => _adjancencyList[x.Item1] = x.Item2);     }      private SquareMatrix&lt;double, S> GetAdjacencyMatrix&lt;S>()          where S : struct, ISemiRing&lt;double>     {         var adjancencyMatrix = new SquareMatrix&lt;double, S>(_size);         for (var i = 0; i &lt; _size; i++)         {             adjancencyMatrix[i, i] = default(S).One;         }          foreach (var key in _adjancencyList.Keys)         {             foreach (var (vertex, weight) in _adjancencyList[key])             {                 adjancencyMatrix[key, vertex] = weight;             }         }          return adjancencyMatrix;     }          public double GetShortestPath(int i, int j, int k) =>          GetAdjacencyMatrix&lt;MinPlus>()             .Power(k)[i, j];      public double GetLongestPath(int i, int j, int k) =>         GetAdjacencyMatrix&lt;MaxPlus>()             .Power(k)[i, j]; }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a \\to d\" alt=\"a \\to d\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/225\/6c7\/f09\/2256c7f09f67b43e05a65e213c24121b.svg\" width=\"51\" height=\"17\"\/>  \u0437\u0430 3 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0448\u0430\u0433\u043e\u0432 \u0437\u0430\u0439\u043c\u0451\u0442 8 \u0435\u0434\u0438\u043d\u0438\u0446, \u0430 \u0434\u043b\u0438\u043d\u043d\u0435\u0439\u0448\u0438\u0439 \u0437\u0430 2 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0448\u0430\u0433\u043e\u0432 &#8212; 13.<\/p>\n<pre><code class=\"cs\">var weightedGraph = new WeightedGraph(4,     (0, new() {(1, 3), (2, 8), (3, 12)}),     (1, new() {(2, 2), (3, 10)}),     (2, new() {(3, 3)}) );  Console.WriteLine(weightedGraph.GetShortestPath(0, 3, 3)); \/\/ 8 Console.WriteLine(weightedGraph.GetLongestPath(0, 3, 2)); \/\/ 13<\/code><\/pre>\n<h2>\u0420\u0435\u0437\u044e\u043c\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u0440\u0438\u043d\u0451\u0441 \u0432\u0430\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439. \u0414\u0430, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0430\u0441 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u0433\u043e\u043d\u044f\u044e\u0442 json&#8217;\u044b, \u043a\u043b\u0435\u043f\u0430\u044e\u0442 \u0444\u043e\u0440\u043c\u043e\u0447\u043a\u0438, \u043d\u043e \u0440\u0430\u0437\u0432\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f? \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043f\u043e\u0440\u043e\u0439 \u043c\u044b \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043d\u0435\u0440\u0430\u0437\u0440\u044b\u0432\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0438 \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0437\u043c\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0438\u0442 \u0432\u0441\u044e \u044d\u0442\u0443 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412\u0441\u0451 \u0435\u0449\u0451 \u0432\u043f\u0435\u0440\u0435\u0434\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c <a href=\"https:\/\/www.youtube.com\/watch?v=3RcJ73pIqHI\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043e\u0442\u0441\u044e\u0434\u0430<\/a>. \u041b\u0443\u0447\u0448\u0435 \u0438 \u043d\u0435 \u0441\u043a\u0430\u0436\u0435\u0448\u044c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/656919\/\"> https:\/\/habr.com\/ru\/post\/656919\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u043d\u0435\u0435, \u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/655059\/\" rel=\"noopener noreferrer nofollow\">&#171;\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438&#187;<\/a> \u044f \u043f\u0440\u0438\u0432\u0451\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043c\u044b\u0441\u043b\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0445\u043e\u0442\u044c \u0442\u0430\u043a \u0438 \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u044b \u0430\u043b\u0433\u0435\u0431\u0440\u0430\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0435\u043c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u043e\u0439 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0441 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c.<\/p>\n<hr\/>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u043c\u0438 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0438 \u043c\u043e\u043d\u043e\u0438\u0434. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u043c \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c. \u0427\u0442\u043e\u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0438, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043d\u0430\u0434 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041d\u043e \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f?<\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435, \u0432\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u044d\u0442\u043e\u0439 \u043d\u0430\u0443\u043a\u0435 \u0432\u043e\u0437\u043d\u0438\u043a \u0438\u0437-\u0437\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a\u0438\u0435 \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0434\u043b\u044f \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e. \u0412\u0430\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u043e\u0432\u043e &#171;\u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f&#187;. <\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0417\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u043c\u0435\u0435\u043c \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438 \u043d\u0435\u043a\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u0418\u043c\u0435\u0435\u043c \u043f\u0430\u0440\u0443 , \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u0437\u043e\u0432\u0451\u043c \u043c\u043e\u043d\u043e\u0438\u0434\u043e\u043c. \u0417\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u043b\u044e\u0431\u044b\u0435 \u0438  , \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 . \u0425\u043e\u0440\u043e\u0448\u043e. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0432\u0437\u044f\u043b\u0438 \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441?<\/p>\n<p>\u0410 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043c\u043e\u043d\u043e\u0438\u0434\u0435 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0443, \u0442\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e , \u0433\u0434\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0430 \u0441\u0430\u043c &#8212; \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u0439. \u0418\u043b\u0438, \u043f\u043e-\u043d\u0430\u0443\u0447\u043d\u043e\u043c\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438:<\/p>\n<p>\u041d\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u043d\u043e\u0438\u0434\u0430. \u0425\u043e\u0442\u044f, \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438&#8230;<\/p>\n<h2>\u0413\u0440\u0443\u043f\u043f\u0430<\/h2>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u043d\u043e\u0438\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b. \u0418 \u0442\u0430\u043a\u0436\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u043d\u043e\u0438\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u043e\u043d\u0438 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043d\u0435\u043a\u043e\u0435 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &#171;\u0433\u0440\u0443\u043f\u043f\u0430&#187;. \u0413\u0440\u0443\u043f\u043f\u0430 \u044d\u0442\u043e \u043c\u043e\u043d\u043e\u0438\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0443\u0436\u0435 \u0442\u0440\u0435\u0442\u044c\u044f \u043f\u043e \u0441\u0447\u0451\u0442\u0443 \u0430\u043a\u0441\u0438\u043e\u043c\u0430.<\/p>\n<pre><code class=\"cs\">public interface IGroup&lt;T> : IMonoid&lt;T> {     T Inverse(T item); }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 , \u0431\u0443\u0434\u0443\u0447\u0438 \u043f\u043e\u043c\u0435\u0449\u0451\u043d\u043d\u044b\u043c \u0432 \u0433\u0440\u0443\u043f\u043f\u0443, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0427\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0433\u0440\u0443\u043f\u043f\u044b? \u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0435\u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u043e\u043d \u043f\u0440\u0438\u0440\u043e\u0434\u044b, \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f \u0435\u0433\u043e \u0430\u043d\u0442\u0438\u043f\u043e\u0434. \u0415\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0415\u0433\u043e \u0440\u0435\u0432\u0435\u0440\u0441. \u0415\u0433\u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0433\u043b\u0438 \u0441\u043b\u044b\u0448\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043e\u0440\u0438\u044f \u0433\u0440\u0443\u043f\u043f &#8212; \u044d\u0442\u043e \u043d\u0430\u0443\u043a\u0430 \u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f\u0445. <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0437\u0430\u0431\u0430\u0432\u043d\u043e, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 . \u042d\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0431\u0438\u0435\u043a\u0446\u0438\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 . \u0421\u0430\u043c\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b &#8212; \u044d\u0442\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0447\u0438\u0441\u0435\u043b. \u0412\u0435\u0440\u0445\u043d\u044f\u044f &#8212; \u0447\u0438\u0441\u043b\u0430 , \u0430 \u0441\u043d\u0438\u0437\u0443 &#8212; \u043d\u0430 \u043a\u0430\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0442\u0430\u044e\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 :<\/p>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0435. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e &#8212; . \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0442\u043e\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c &#8212;  .<\/p>\n<details class=\"spoiler\">\n<summary>Permutation.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public class Permutation : IEquatable&lt;Permutation> {     private readonly int[] _map;      public Permutation(params int[] map)     {         _map = new int[map.Length];         for (var i = 0; i &lt; map.Length; i++)         {             _map[i] = map[i];         }     }      public int this[int index] => _map[index];      public bool Equals(Permutation other)     {         if (other != null &amp;&amp; _map.Length == other._map.Length)         {             return _map.Zip(other._map)                 .All(pair => pair.First == pair.Second);         }          return false;     }      public override string ToString() =>         new StringBuilder()             .AppendJoin(' ', Enumerable.Range(1, _map.Length))             .Append('\\n')             .AppendJoin(' ', _map.Select(x => x + 1))             .ToString(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>SymmetricGroup.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public readonly struct SymmetricGroup : IGroup&lt;Permutation> {     private readonly int _length;      public SymmetricGroup(int length)     {         _length = length;     }      public Permutation Plus(Permutation left, Permutation right)     {         var newMap = new int[_length];         for (var i = 0; i &lt; _length; i++)         {             newMap[i] = right[left[i]];         }          return new Permutation(newMap);     }      public Permutation Zero =>         new(Enumerable.Range(0, _length).ToArray());      public Permutation Inverse(Permutation item)     {         var newMap = new int[_length];         for (var i = 0; i &lt; _length; i++)         {             newMap[item[i]] = i;         }          return new Permutation(newMap);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u043b\u043e \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 , \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f  \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 (\u0442\u043e \u0441\u0430\u043c\u043e\u0435 &#171;\u043e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u044b \u043c\u0435\u0441\u0442 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0441\u0443\u043c\u043c\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f&#187;). \u0418 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u0440\u0443\u043f\u043f \u043c\u043e\u0436\u043d\u043e \u0441\u0443\u0437\u0438\u0442\u044c \u0434\u043e \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0445, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0431\u0435\u043b\u0435\u0432\u044b\u0445 \u0433\u0440\u0443\u043f\u043f. \u0410\u0431\u0435\u043b\u0435\u0432\u0430 \u0433\u0440\u0443\u043f\u043f\u0430 \u044d\u0442\u043e \u0433\u0440\u0443\u043f\u043f\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439:<\/p>\n<p>\u041d\u043e \u044d\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u043e\u0442\u043e\u043a \u0441\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435 \u0440\u0443\u0441\u043b\u043e.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u0422\u0430\u043a\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\/\u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 append-only \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u041e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435.<\/p>\n<pre><code class=\"cs\">public record CatalogueEvent&lt;T>;  public record Add&lt;T>(T Data) : CatalogueEvent&lt;T>;  public record Remove&lt;T>(T Data) : CatalogueEvent&lt;T>;  public record Nothing&lt;T> : CatalogueEvent&lt;T>;<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443 \u0435\u0441\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0442. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u043e\u043d\u043e\u0438\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0438 \u0447\u0451\u043c \u0437\u0434\u0435\u0441\u044c \u0433\u0440\u0443\u043f\u043f\u044b? <\/p>\n<p>\u0412 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0441\u044e\u0436\u0435\u0442 \u043e \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438. \u0422\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c, \u0430 \u043c\u043e\u0436\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. \u0418 \u043f\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043d\u0435\u043a\u0438\u0439 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<pre><code class=\"cs\">public class Catalogue&lt;T> : IEnumerable&lt;CatalogueEvent&lt;T>> {     private readonly List&lt;CatalogueEvent&lt;T>> _catalogueEvents = new();      public S Reduce&lt;S, G>(Func&lt;T, S> map, G group = default)         where G : struct, IGroup&lt;S>         => _catalogueEvents.Select(t =>             t switch             {                 Add&lt;T> add => map(add.Data),                 Remove&lt;T> rm => group.Inverse(map(rm.Data)),                 Nothing&lt;T> => group.Zero,                 _ => default             }         ).Sum&lt;S, G>();      public Catalogue&lt;T> Add(T item)     {         _catalogueEvents.Add(new Add&lt;T>(item));         return this;     }      public Catalogue&lt;T> Remove(T item)     {         _catalogueEvents.Add(new Remove&lt;T>(item));         return this;     }      public Catalogue&lt;T> Nothing()     {         _catalogueEvents.Add(new Nothing&lt;T>());         return this;     }      public IEnumerator&lt;CatalogueEvent&lt;T>> GetEnumerator() =>         _catalogueEvents.GetEnumerator();      IEnumerator IEnumerable.GetEnumerator() =>         GetEnumerator(); }<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Reduce<\/code> \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e, \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c: <code>map<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u043d\u043e\u0438\u0434, \u0438 \u0441\u0430\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <code>Sum<\/code>, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u043f\u043e \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0410 \u0437\u0430\u0442\u0435\u043c \u0441\u0443\u0436\u0430\u0435\u043c \u043c\u043e\u043d\u043e\u0438\u0434 \u0434\u043e \u0433\u0440\u0443\u043f\u043f\u044b \u0447\u0442\u043e\u0431\u044b <code>Remove<\/code> \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c &#171;\u0440\u0435\u0432\u0435\u0440\u0441&#187; \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0449\u0443\u043f\u0430\u0435\u043c \u043d\u0430\u0448 \u043a\u0430\u0442\u0430\u043b\u043e\u0433.<\/p>\n<pre><code class=\"cs\">var stringsCatalogue = new Catalogue&lt;string>()     .Add(\"abc\")     .Nothing()     .Remove(\"c\")     .Remove(\"a\")     .Add(\"ed\");<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>IntAddGroup.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">private struct IntAddGroup : IGroup&lt;int> {     public int Plus(int left, int right) => left + right;      public int Zero => 0;      public int Inverse(int item) => -item; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043c\u044b \u043a\u0430\u043a-\u0442\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439<\/p>\n<pre><code class=\"cs\">stringsCatalogue.Reduce&lt;int, IntAddGroup>(s => s.Length); \/\/ 3<\/code><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u0435\u043d, \u043f\u043e\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043d\u043e \u0437\u0430\u0442\u043e \u043e\u0442\u0447\u0451\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u043a, \u0430 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439? \u0414\u0430, \u0443 \u0441\u0442\u0440\u043e\u043a \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f, \u043d\u043e \u0441 \u043d\u0435\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043d\u043e\u0438\u0434. \u0422\u0440\u0443\u0434\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 &#171;\u043c\u0438\u043d\u0443\u0441&#187; \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u0431\u0435 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cs\">\"abc\" - \"c\" == \"ab\"<\/code><\/pre>\n<p>\u041d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0430\u043b\u0441\u044f \u043a\u0435\u0439\u0441 <code>\"abc\" - \"d\"<\/code>, \u0438\u043b\u0438 <code>\"\" - \"\",<\/code> \u0438\u043b\u0438 <code>\"\" - \"xyz\"<\/code>? \u041e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0445\u043e\u0434 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043c\u043e\u0433\u043b\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0438\u0434\u0435\u044f \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445. \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <code>string<\/code> \u044d\u0442\u043e <code>IEnumerable&lt;char><\/code>, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0451 \u0434\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p> \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043b\u0438\u0448\u044c \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u043e\u043d\u043e\u0438\u0434 <s>(\u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e)<\/s>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0431\u0435\u043b\u0435\u0432\u0443 \u0433\u0440\u0443\u043f\u043f\u0443, \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443, \u043d\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u0442\u043e.<\/p>\n<p>\u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0441\u0442\u0438 \u0443\u0447\u0451\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0442\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u0434\u043e\u0431\u044c\u0451\u043c\u0441\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u044b \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432: \u0441\u043b\u0435\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c; \u0441\u043f\u0440\u0430\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>PairedHashSet.cs<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">public record PairedSet&lt;T>(HashSet&lt;T> First, HashSet&lt;T> Second) {     public PairedSet() : this(new(), new())     {     }      public PairedHashSet(IEnumerable&lt;T> single) : this(new(single), new())     {     } }  public static class PairedSetExtensions {     public static HashSet&lt;T> ToHashSet&lt;T>(this PairedSet&lt;T> pairedSet)     {         var (first, second) = pairedSet;         return first.Except(second);     } }  public static class HashSetExtensions {     public static HashSet&lt;T> Except&lt;T>(this HashSet&lt;T> first, HashSet&lt;T> second)     {         var result = new HashSet&lt;T>(first);         result.ExceptWith(second);         return result;     }          public static HashSet&lt;T> Union&lt;T>(this HashSet&lt;T> first, HashSet&lt;T> second)     {         var <\/code><\/pre>\n<\/div>\n<\/details>\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-331710","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331710","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=331710"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331710\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}