{"id":163467,"date":"2012-12-21T11:25:02","date_gmt":"2012-12-21T07:25:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=163467"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=163467","title":{"rendered":"<span class=\"post_title\">\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u0442\u0443\u043f\u043d\u044f\u043a\u0443, \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e hollywar<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0443\u0441\u043b\u044b\u0448\u0430\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u043b\u0435\u0432\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e. \u0420\u0430\u0441\u0441\u043a\u0430\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u043f\u0430\u0433\u0430\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043b <b>perl<\/b>, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e\u0435, \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435.<br \/>  \u041d\u0435 \u0443\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u0438 \u0432\u0441\u0442\u0440\u044f\u043b, \u0441\u043a\u0430\u0437\u0430\u0432, \u0447\u0442\u043e <b>python<\/b> \u043f\u043e\u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435.<br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u0435\u043d\u044f \u0441\u043f\u0440\u043e\u0441\u0438\u043b\u0438, \u043a\u0430\u043a \u0432 <b>python<\/b> \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u0434\u0435\u043b\u0430 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u043c\u044b \u043a \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435:<\/p>\n<p>  <b>\u0415\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f N \u0440\u0430\u0437.<\/b><\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u043d\u044b\u0435 \u043c\u0438\u043d\u0443\u0442\u044b, \u043d\u043e \u044d\u0442\u043e\u0442 \u0442\u0443\u043f\u043d\u044f\u043a \u043f\u043e\u0433\u043b\u043e\u0442\u0438\u043b \u0432\u0441\u0435\u0445 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0434\u0430\u0435\u0442\u0435\u0441\u044c \u0442\u0443\u043f\u043d\u044f\u0447\u043a\u0430\u043c, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u0430\u0442<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438:<\/p>\n<p>  <b>test1.py<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 3 \u043c\u0438\u043d. \u00abwar and peace\u00bb \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0441\u0438\u043b\u0438\u043b\u043e  <\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python import re n = 5 with open(&quot;.\/input_file.txt&quot;, &quot;r&quot;) as f: \ts = f.read()  l = re.findall(r'\\w+',s) print repr([x for x in l if l.count(x) == n]) <\/code><\/pre>\n<p>  <b>test2.pl<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 30 \u043c\u0438\u043d (\u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432\u044b\u0442\u043a\u0430\u043b \u0434\u043e\u043b\u0433\u043e). \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u00abwar and peace\u00bb: 0m0.282s  <\/p>\n<pre><code class=\"perl\">#!\/usr\/bin\/perl  open FH, &quot;&lt;input_file.txt&quot;; local $\/; $str = &lt;FH&gt;; $n = 5;  %h = (); $h{$1}++ while $str =~ \/(\\w+)\/g;  print '['.(join &quot;, &quot;, grep {$h{$_} == 5} keys %h).']'; <\/code><\/pre>\n<p>  \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b\u043e \u0441\u043e\u0432\u0441\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u043e\u0442 \u044d\u0442\u043e:<br \/>  <b>test3.py<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 3 \u043c\u0438\u043d. \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u00abwar and peace\u00bb: 0m0.285s  <\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python import re n = 5 with open(&quot;.\/input_file.txt&quot;, &quot;r&quot;) as f: \ts = f.read()  d={} for x in re.findall(r'\\w+',s): \tif x in d: \t\td[x] += 1 \telse: \t\td[x] = 1 print repr([k for k,v in d.items() if v == n]) <\/code><\/pre>\n<p>  <b>test4.pl<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 30 \u043c\u0438\u043d (\u043e\u043f\u044f\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e). \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u00abwar and peace\u00bb: 0m0.221s<br \/>  \u041d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u0432\u044b \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439   <\/p>\n<pre><code class=\"perl\">#!\/usr\/bin\/perl  open FH, &quot;&lt;.\/input_file.txt&quot;; local $\/; $str = &lt;FH&gt;; $n = 5;  chomp($str); foreach(split(\/ \/, $str)){$h{$_}++;} my $res =&quot;[&quot;; foreach(keys(%h)) {if($h{$_} == $n){$res .= &quot;$_, &quot;;}} $res .=  &quot;]&quot;; print $res; <\/code><\/pre>\n<p>  <b>test5.hs<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 10 \u043c\u0438\u043d. \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u00abwar and peace\u00bb: 0m2.948s<br \/>  \u0427\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u043e\u043e\u0440\u0443\u0434\u0438\u043b \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u00ab\u0430 \u044f \u0435\u0449\u0435 \u0438 \u043d\u0430 \u0445\u0430\u0441\u043a\u0435\u043b\u0435 \u043c\u043e\u0433\u0443\u00bb, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u043b  <\/p>\n<pre><code class=\"haskell\">import Data.List import Data.Char  main = interact                          -- IO   $ unlines                              -- combine meta-data into string   . map (\\(n, w) -&gt; if (n == 5) then show w else &quot;&quot;)   . sort                                 -- sort meta-data by occurances   . map (\\s -&gt; (length s, head s))       -- transform to sublist meta-data   . group                                -- break into sublists of unique words   . sort                                 -- sort words   . words                                -- break into words   . map (\\c -&gt;                           -- simplify chars in input     if isAlpha c       then toLower c       else ' ') <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0440\u0430\u0437 \u0443\u0436 \u0442\u0430\u043a, \u0442\u043e \u0438 \u043d\u0430 C++ \u0442\u043e\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c<br \/>  <b>test6.cpp<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 5 \u043c\u0438\u043d. \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u00abwar and peace\u00bb: 0m0.640s  <\/p>\n<pre><code class=\"cpp\">#include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;errno.h&gt;  #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;set&gt;  std::multiset&lt;std::string&gt; words;  void prepare() {         char *p = 0;     int err = 1;     while ( 1 == scanf(&quot;%as&quot;, &p)) {         words.insert(p);         free(p);     }     if (errno) {         perror(&quot;scanf&quot;);         abort();     } }  void output(int n) {     std::multiset&lt;std::string&gt;::iterator it(words.begin());     std::string out;     for(;it!=words.end(); it = words.upper_bound(*it))  {         if ( words.count(*it) == n )             out.append(&quot; ,&quot; + *it);     }     if (out.find(&quot; ,&quot;) == 0 )         out.erase(0, 2);     std::cout&lt;&lt;&quot;[&quot;&lt;&lt;out&lt;&lt;&quot;]\\n&quot;; }  int main(int argc, char **argv) {     prepare();     output(atoi(argv[1]));     return 0; } <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u0442\u0443\u043f\u043d\u044f\u043a\u0443 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0437\u0430 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \ud83d\ude09<br \/>  <a href=\"http:\/\/www.gutenberg.org\/cache\/epub\/2600\/pg2600.txt\">\u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a input_file.txt<\/a>, \u044d\u0442\u043e \u00ab\u0412\u043e\u0439\u043d\u0430 \u0438 \u043c\u0438\u0440\u00bb \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0413\u0443\u0442\u0435\u043d\u0431\u0435\u0440\u0433\u0430    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/163467\/\"> http:\/\/habrahabr.ru\/post\/163467\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0443\u0441\u043b\u044b\u0448\u0430\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u043b\u0435\u0432\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e. \u0420\u0430\u0441\u0441\u043a\u0430\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u043f\u0430\u0433\u0430\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043b <b>perl<\/b>, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e\u0435, \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435.<br \/>  \u041d\u0435 \u0443\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u0438 \u0432\u0441\u0442\u0440\u044f\u043b, \u0441\u043a\u0430\u0437\u0430\u0432, \u0447\u0442\u043e <b>python<\/b> \u043f\u043e\u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435.<br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u0435\u043d\u044f \u0441\u043f\u0440\u043e\u0441\u0438\u043b\u0438, \u043a\u0430\u043a \u0432 <b>python<\/b> \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u0434\u0435\u043b\u0430 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u043c\u044b \u043a \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435:<\/p>\n<p>  <b>\u0415\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u0432 \u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f N \u0440\u0430\u0437.<\/b><\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u043d\u044b\u0435 \u043c\u0438\u043d\u0443\u0442\u044b, \u043d\u043e \u044d\u0442\u043e\u0442 \u0442\u0443\u043f\u043d\u044f\u043a \u043f\u043e\u0433\u043b\u043e\u0442\u0438\u043b \u0432\u0441\u0435\u0445 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0434\u0430\u0435\u0442\u0435\u0441\u044c \u0442\u0443\u043f\u043d\u044f\u0447\u043a\u0430\u043c, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u0430\u0442  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-163467","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163467","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=163467"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163467\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}