{"action":"created","comment":{"url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/comments/59990722","id":59990722,"diff_hunk":"@@ -0,0 +1,81 @@\n+package ru.spbau.streams;\n+\n+import org.apache.commons.lang3.tuple.Pair;\n+import java.io.IOException;\n+import java.io.UncheckedIOException;\n+import java.nio.file.Files;\n+import java.nio.file.Paths;\n+import java.util.Comparator;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Random;\n+import java.util.function.Supplier;\n+import java.util.stream.Stream;\n+\n+import static java.util.stream.Collectors.*;\n+\n+public final class SecondPartTasks {\n+\n+    private SecondPartTasks() {}\n+\n+    // Найти строки из переданных файлов, в которых встречается указанная подстрока.\n+    public static List<String> findQuotes(List<String> paths, CharSequence sequence) {\n+        return paths\n+                .stream()\n+                .flatMap(path -> {\n+                        try {\n+                            return Files.lines(Paths.get(path));\n+                        } catch (IOException e) {\n+                            throw new UncheckedIOException(e);\n+                        }\n+                })\n+                .filter(line -> line.contains(sequence))\n+                .collect(toList());\n+    }\n+\n+    // В квадрат с длиной стороны 1 вписана мишень.\n+    // Стрелок атакует мишень и каждый раз попадает в произвольную точку квадрата.\n+    // Надо промоделировать этот процесс с помощью класса java.util.Random и посчитать, какова вероятность попасть в мишень.\n+    public static double piDividedBy4() {\n+        final int testSize  = 1_000_000;\n+\n+        final Random rand = new Random();\n+        final Supplier<Double> random = () -> rand.nextDouble() - 1;\n+\n+        final double hit = Stream\n+                .generate(() -> Pair.of(random.get(), random.get()))\n+                .limit(testSize)\n+                .filter(point -> Math.pow(point.getKey(), 2) + Math.pow(point.getValue(), 2) <= 1)\n+                .count();\n+\n+        return hit / testSize;\n+    }\n+\n+\n+    // Дано отображение из имени автора в список с содержанием его произведений.\n+    // Надо вычислить, чья общая длина произведений наибольшая.\n+    public static String findPrinter(Map<String, List<String>> compositions) {\n+        return compositions\n+                .entrySet()\n+                .stream()\n+                .map(item ->  Pair.of(item.getKey(), item\n+                        .getValue()\n+                        .stream()\n+                        .mapToInt(String::length)\n+                        .sum()))\n+                .max(Comparator.comparingInt(Pair::getValue))\n+                .orElse(Pair.of(\"\", 0))\n+                .getKey();","path":"src/main/java/ru/spbau/streams/SecondPartTasks.java","position":68,"original_position":68,"commit_id":"197b26e0b05d2462d76f31169a5be1c37af67d71","original_commit_id":"197b26e0b05d2462d76f31169a5be1c37af67d71","user":{"login":"sproshev","id":4990763,"avatar_url":"https://avatars.githubusercontent.com/u/4990763?v=3","gravatar_id":"","url":"https://api.github.com/users/sproshev","html_url":"https://github.com/sproshev","followers_url":"https://api.github.com/users/sproshev/followers","following_url":"https://api.github.com/users/sproshev/following{/other_user}","gists_url":"https://api.github.com/users/sproshev/gists{/gist_id}","starred_url":"https://api.github.com/users/sproshev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sproshev/subscriptions","organizations_url":"https://api.github.com/users/sproshev/orgs","repos_url":"https://api.github.com/users/sproshev/repos","events_url":"https://api.github.com/users/sproshev/events{/privacy}","received_events_url":"https://api.github.com/users/sproshev/received_events","type":"User","site_admin":false},"body":"compositions.entrySet().stream().max(...)....\r\n\r\nв качестве отсутствия результата лучше возвращать null","created_at":"2016-04-17T19:27:17Z","updated_at":"2016-04-17T19:27:17Z","html_url":"https://github.com/AirVan21/Java.AU/pull/5#discussion_r59990722","pull_request_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/comments/59990722"},"html":{"href":"https://github.com/AirVan21/Java.AU/pull/5#discussion_r59990722"},"pull_request":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5","id":65962079,"html_url":"https://github.com/AirVan21/Java.AU/pull/5","diff_url":"https://github.com/AirVan21/Java.AU/pull/5.diff","patch_url":"https://github.com/AirVan21/Java.AU/pull/5.patch","issue_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/5","number":5,"state":"open","locked":false,"title":"Java05.ДЗ04, Abramov Ivan","user":{"login":"AirVan21","id":1482730,"avatar_url":"https://avatars.githubusercontent.com/u/1482730?v=3","gravatar_id":"","url":"https://api.github.com/users/AirVan21","html_url":"https://github.com/AirVan21","followers_url":"https://api.github.com/users/AirVan21/followers","following_url":"https://api.github.com/users/AirVan21/following{/other_user}","gists_url":"https://api.github.com/users/AirVan21/gists{/gist_id}","starred_url":"https://api.github.com/users/AirVan21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirVan21/subscriptions","organizations_url":"https://api.github.com/users/AirVan21/orgs","repos_url":"https://api.github.com/users/AirVan21/repos","events_url":"https://api.github.com/users/AirVan21/events{/privacy}","received_events_url":"https://api.github.com/users/AirVan21/received_events","type":"User","site_admin":false},"body":"Привет @sproshev \r\n\r\nСделал HW4. \r\nМне интересно твое мнение по поводу final в тестах для локальных переменных (нужно ли так делать или нет?).","created_at":"2016-04-11T09:16:54Z","updated_at":"2016-04-17T19:27:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d259968037904a6141a330cc9ac3405337b86572","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5/commits","review_comments_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5/comments","review_comment_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/5/comments","statuses_url":"https://api.github.com/repos/AirVan21/Java.AU/statuses/197b26e0b05d2462d76f31169a5be1c37af67d71","head":{"label":"AirVan21:ha4","ref":"ha4","sha":"197b26e0b05d2462d76f31169a5be1c37af67d71","user":{"login":"AirVan21","id":1482730,"avatar_url":"https://avatars.githubusercontent.com/u/1482730?v=3","gravatar_id":"","url":"https://api.github.com/users/AirVan21","html_url":"https://github.com/AirVan21","followers_url":"https://api.github.com/users/AirVan21/followers","following_url":"https://api.github.com/users/AirVan21/following{/other_user}","gists_url":"https://api.github.com/users/AirVan21/gists{/gist_id}","starred_url":"https://api.github.com/users/AirVan21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirVan21/subscriptions","organizations_url":"https://api.github.com/users/AirVan21/orgs","repos_url":"https://api.github.com/users/AirVan21/repos","events_url":"https://api.github.com/users/AirVan21/events{/privacy}","received_events_url":"https://api.github.com/users/AirVan21/received_events","type":"User","site_admin":false},"repo":{"id":52214157,"name":"Java.AU","full_name":"AirVan21/Java.AU","owner":{"login":"AirVan21","id":1482730,"avatar_url":"https://avatars.githubusercontent.com/u/1482730?v=3","gravatar_id":"","url":"https://api.github.com/users/AirVan21","html_url":"https://github.com/AirVan21","followers_url":"https://api.github.com/users/AirVan21/followers","following_url":"https://api.github.com/users/AirVan21/following{/other_user}","gists_url":"https://api.github.com/users/AirVan21/gists{/gist_id}","starred_url":"https://api.github.com/users/AirVan21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirVan21/subscriptions","organizations_url":"https://api.github.com/users/AirVan21/orgs","repos_url":"https://api.github.com/users/AirVan21/repos","events_url":"https://api.github.com/users/AirVan21/events{/privacy}","received_events_url":"https://api.github.com/users/AirVan21/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AirVan21/Java.AU","description":"Homeworks for Java course","fork":false,"url":"https://api.github.com/repos/AirVan21/Java.AU","forks_url":"https://api.github.com/repos/AirVan21/Java.AU/forks","keys_url":"https://api.github.com/repos/AirVan21/Java.AU/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AirVan21/Java.AU/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AirVan21/Java.AU/teams","hooks_url":"https://api.github.com/repos/AirVan21/Java.AU/hooks","issue_events_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/events{/number}","events_url":"https://api.github.com/repos/AirVan21/Java.AU/events","assignees_url":"https://api.github.com/repos/AirVan21/Java.AU/assignees{/user}","branches_url":"https://api.github.com/repos/AirVan21/Java.AU/branches{/branch}","tags_url":"https://api.github.com/repos/AirVan21/Java.AU/tags","blobs_url":"https://api.github.com/repos/AirVan21/Java.AU/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AirVan21/Java.AU/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AirVan21/Java.AU/git/refs{/sha}","trees_url":"https://api.github.com/repos/AirVan21/Java.AU/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AirVan21/Java.AU/statuses/{sha}","languages_url":"https://api.github.com/repos/AirVan21/Java.AU/languages","stargazers_url":"https://api.github.com/repos/AirVan21/Java.AU/stargazers","contributors_url":"https://api.github.com/repos/AirVan21/Java.AU/contributors","subscribers_url":"https://api.github.com/repos/AirVan21/Java.AU/subscribers","subscription_url":"https://api.github.com/repos/AirVan21/Java.AU/subscription","commits_url":"https://api.github.com/repos/AirVan21/Java.AU/commits{/sha}","git_commits_url":"https://api.github.com/repos/AirVan21/Java.AU/git/commits{/sha}","comments_url":"https://api.github.com/repos/AirVan21/Java.AU/comments{/number}","issue_comment_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/comments{/number}","contents_url":"https://api.github.com/repos/AirVan21/Java.AU/contents/{+path}","compare_url":"https://api.github.com/repos/AirVan21/Java.AU/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AirVan21/Java.AU/merges","archive_url":"https://api.github.com/repos/AirVan21/Java.AU/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AirVan21/Java.AU/downloads","issues_url":"https://api.github.com/repos/AirVan21/Java.AU/issues{/number}","pulls_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls{/number}","milestones_url":"https://api.github.com/repos/AirVan21/Java.AU/milestones{/number}","notifications_url":"https://api.github.com/repos/AirVan21/Java.AU/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AirVan21/Java.AU/labels{/name}","releases_url":"https://api.github.com/repos/AirVan21/Java.AU/releases{/id}","deployments_url":"https://api.github.com/repos/AirVan21/Java.AU/deployments","created_at":"2016-02-21T15:56:15Z","updated_at":"2016-03-21T22:24:25Z","pushed_at":"2016-04-17T19:27:10Z","git_url":"git://github.com/AirVan21/Java.AU.git","ssh_url":"git@github.com:AirVan21/Java.AU.git","clone_url":"https://github.com/AirVan21/Java.AU.git","svn_url":"https://github.com/AirVan21/Java.AU","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"AirVan21:master","ref":"master","sha":"343871a930af74a263e3d82cfcaaa4a8fd95a790","user":{"login":"AirVan21","id":1482730,"avatar_url":"https://avatars.githubusercontent.com/u/1482730?v=3","gravatar_id":"","url":"https://api.github.com/users/AirVan21","html_url":"https://github.com/AirVan21","followers_url":"https://api.github.com/users/AirVan21/followers","following_url":"https://api.github.com/users/AirVan21/following{/other_user}","gists_url":"https://api.github.com/users/AirVan21/gists{/gist_id}","starred_url":"https://api.github.com/users/AirVan21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirVan21/subscriptions","organizations_url":"https://api.github.com/users/AirVan21/orgs","repos_url":"https://api.github.com/users/AirVan21/repos","events_url":"https://api.github.com/users/AirVan21/events{/privacy}","received_events_url":"https://api.github.com/users/AirVan21/received_events","type":"User","site_admin":false},"repo":{"id":52214157,"name":"Java.AU","full_name":"AirVan21/Java.AU","owner":{"login":"AirVan21","id":1482730,"avatar_url":"https://avatars.githubusercontent.com/u/1482730?v=3","gravatar_id":"","url":"https://api.github.com/users/AirVan21","html_url":"https://github.com/AirVan21","followers_url":"https://api.github.com/users/AirVan21/followers","following_url":"https://api.github.com/users/AirVan21/following{/other_user}","gists_url":"https://api.github.com/users/AirVan21/gists{/gist_id}","starred_url":"https://api.github.com/users/AirVan21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirVan21/subscriptions","organizations_url":"https://api.github.com/users/AirVan21/orgs","repos_url":"https://api.github.com/users/AirVan21/repos","events_url":"https://api.github.com/users/AirVan21/events{/privacy}","received_events_url":"https://api.github.com/users/AirVan21/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AirVan21/Java.AU","description":"Homeworks for Java course","fork":false,"url":"https://api.github.com/repos/AirVan21/Java.AU","forks_url":"https://api.github.com/repos/AirVan21/Java.AU/forks","keys_url":"https://api.github.com/repos/AirVan21/Java.AU/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AirVan21/Java.AU/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AirVan21/Java.AU/teams","hooks_url":"https://api.github.com/repos/AirVan21/Java.AU/hooks","issue_events_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/events{/number}","events_url":"https://api.github.com/repos/AirVan21/Java.AU/events","assignees_url":"https://api.github.com/repos/AirVan21/Java.AU/assignees{/user}","branches_url":"https://api.github.com/repos/AirVan21/Java.AU/branches{/branch}","tags_url":"https://api.github.com/repos/AirVan21/Java.AU/tags","blobs_url":"https://api.github.com/repos/AirVan21/Java.AU/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AirVan21/Java.AU/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AirVan21/Java.AU/git/refs{/sha}","trees_url":"https://api.github.com/repos/AirVan21/Java.AU/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AirVan21/Java.AU/statuses/{sha}","languages_url":"https://api.github.com/repos/AirVan21/Java.AU/languages","stargazers_url":"https://api.github.com/repos/AirVan21/Java.AU/stargazers","contributors_url":"https://api.github.com/repos/AirVan21/Java.AU/contributors","subscribers_url":"https://api.github.com/repos/AirVan21/Java.AU/subscribers","subscription_url":"https://api.github.com/repos/AirVan21/Java.AU/subscription","commits_url":"https://api.github.com/repos/AirVan21/Java.AU/commits{/sha}","git_commits_url":"https://api.github.com/repos/AirVan21/Java.AU/git/commits{/sha}","comments_url":"https://api.github.com/repos/AirVan21/Java.AU/comments{/number}","issue_comment_url":"https://api.github.com/repos/AirVan21/Java.AU/issues/comments{/number}","contents_url":"https://api.github.com/repos/AirVan21/Java.AU/contents/{+path}","compare_url":"https://api.github.com/repos/AirVan21/Java.AU/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AirVan21/Java.AU/merges","archive_url":"https://api.github.com/repos/AirVan21/Java.AU/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AirVan21/Java.AU/downloads","issues_url":"https://api.github.com/repos/AirVan21/Java.AU/issues{/number}","pulls_url":"https://api.github.com/repos/AirVan21/Java.AU/pulls{/number}","milestones_url":"https://api.github.com/repos/AirVan21/Java.AU/milestones{/number}","notifications_url":"https://api.github.com/repos/AirVan21/Java.AU/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AirVan21/Java.AU/labels{/name}","releases_url":"https://api.github.com/repos/AirVan21/Java.AU/releases{/id}","deployments_url":"https://api.github.com/repos/AirVan21/Java.AU/deployments","created_at":"2016-02-21T15:56:15Z","updated_at":"2016-03-21T22:24:25Z","pushed_at":"2016-04-17T19:27:10Z","git_url":"git://github.com/AirVan21/Java.AU.git","ssh_url":"git@github.com:AirVan21/Java.AU.git","clone_url":"https://github.com/AirVan21/Java.AU.git","svn_url":"https://github.com/AirVan21/Java.AU","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5"},"html":{"href":"https://github.com/AirVan21/Java.AU/pull/5"},"issue":{"href":"https://api.github.com/repos/AirVan21/Java.AU/issues/5"},"comments":{"href":"https://api.github.com/repos/AirVan21/Java.AU/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AirVan21/Java.AU/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/AirVan21/Java.AU/statuses/197b26e0b05d2462d76f31169a5be1c37af67d71"}}}}