{"id":1123,"date":"2018-06-03T22:31:11","date_gmt":"2018-06-03T21:31:11","guid":{"rendered":"http:\/\/piatkosia.k4be.pl\/wordpress\/?p=1123"},"modified":"2018-06-03T22:38:09","modified_gmt":"2018-06-03T21:38:09","slug":"unbelievable-but-true-chapter-1","status":"publish","type":"post","link":"https:\/\/piatkosia.k4be.pl\/wordpress\/en\/2018\/06\/03\/unbelievable-but-true-chapter-1\/","title":{"rendered":"Unbelievable but true, chapter 1"},"content":{"rendered":"<p style=\"text-align: justify;\">I have such a colleague, let&#8217;s call him a footballer with a guitar because he wanted to be anonymous (but he allowed the publication of tasks and solutions).<br \/>\nAt some point, he went to the board and wrote &#8222;Sum (1) (2) (3) ()) -&gt; has to return the number&#8221; and said that we have 10 minutes from now. He also mentioned that it has the potential to be a recruitment task for seniors, because you have to think a little outside the box.<br \/>\n<!--more--><\/p>\n<p>It seems impossible? I thought so too. Solutions have been delivered in 2 languages.<\/p>\n<p>And the answer looks like this:<\/p>\n<pre class=\"brush: csharp; collapse: false\">[C#]\r\n\r\n        private delegate dynamic F(int x = 0);\r\n\r\n        private static dynamic Sum(int n = 0)\r\n        {\r\n            if (n == 0)\r\n            {\r\n                return 0;\r\n            }\r\n            F f = x =&gt; x == 0 ? n : Sum(x + n);\r\n            return f;\r\n        }\r\n            Console.WriteLine(Sum());\r\n            Console.WriteLine(Sum(1)());\r\n            Console.WriteLine(Sum(1)(2)());\r\n            Console.WriteLine(Sum(1)(2)(3)());\r\n<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<pre class=\"brush: python; collapse: false\">[PY]\r\ndef sum(n = None):\r\n    if n == None:\r\n        return 0\r\n    return lambda x = None: n if x == None else sum(n + x)\r\nprint(sum(1)(2)(3)())\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have such a colleague, let&#8217;s call him a footballer with a guitar because he wanted to be anonymous (but he allowed the publication of<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/piatkosia.k4be.pl\/wordpress\/en\/2018\/06\/03\/unbelievable-but-true-chapter-1\/\">Lecim dalej<span class=\"screen-reader-text\">Unbelievable but true, chapter 1<\/span> <i class=\"fas fa-angle-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[583,581,585],"tags":[590,588,592],"class_list":["post-1123","post","type-post","status-publish","format-standard","hentry","category-c_sharp-en","category-programming","category-python-en","tag-c_sharp-en","tag-eng_post","tag-python-en","entry"],"_links":{"self":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/comments?post=1123"}],"version-history":[{"count":3,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1126,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1123\/revisions\/1126"}],"wp:attachment":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/media?parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/categories?post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/tags?post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}