{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/comments/88798835","pull_request_review_id":9362135,"id":88798835,"diff_hunk":"@@ -1,15 +1,87 @@\n 'use strict';\n \n+function compareFriends(one, another) {\n+    if (one.level !== another.level) {\n+        return one.level > another.level ? 1 : -1;\n+    }\n+\n+    return one.friend.name > another.friend.name ? 1 : -1;\n+}\n+\n+function getFriendsWithLevels(friends) {\n+    var friendsWithLevel = [];\n+    var currentLevelFriends = [];\n+    var nameToFriend = {};\n+    var nextLevelFriends = [];\n+    var currentLevel = 2;\n+\n+    friends.forEach(function (friend) {\n+        var friendWithLevel = {\n+            friend: friend,\n+            level: friend.best ? 1 : 0\n+        };\n+\n+        if (friend.best) {\n+            currentLevelFriends.push(friendWithLevel);\n+        }\n+        friendsWithLevel.push(friendWithLevel);\n+        nameToFriend[friend.name] = friendWithLevel;\n+    });\n+\n+    var addNextLevelFriend = function (friendName) {\n+        var friendsFriend = nameToFriend[friendName];\n+\n+        if (!friendsFriend.level) {\n+            friendsFriend.level = currentLevel;\n+            nextLevelFriends.push(friendsFriend);\n+        }\n+    };\n+\n+    while (currentLevelFriends.length > 0 || nextLevelFriends.length > 0) {\n+        var friendWithLevel = currentLevelFriends.pop();\n+\n+        friendWithLevel.friend.friends.forEach(addNextLevelFriend);\n+        if (currentLevelFriends.length === 0) {\n+            currentLevel++;\n+            currentLevelFriends = nextLevelFriends;\n+            nextLevelFriends = [];\n+        }","path":"lib.js","position":48,"original_position":48,"commit_id":"b4a91a233867fe2bf1f3067f46a299bcb170ffbd","original_commit_id":"b4a91a233867fe2bf1f3067f46a299bcb170ffbd","user":{"login":"Vittly","id":1221916,"avatar_url":"https://avatars.githubusercontent.com/u/1221916?v=3","gravatar_id":"","url":"https://api.github.com/users/Vittly","html_url":"https://github.com/Vittly","followers_url":"https://api.github.com/users/Vittly/followers","following_url":"https://api.github.com/users/Vittly/following{/other_user}","gists_url":"https://api.github.com/users/Vittly/gists{/gist_id}","starred_url":"https://api.github.com/users/Vittly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vittly/subscriptions","organizations_url":"https://api.github.com/users/Vittly/orgs","repos_url":"https://api.github.com/users/Vittly/repos","events_url":"https://api.github.com/users/Vittly/events{/privacy}","received_events_url":"https://api.github.com/users/Vittly/received_events","type":"User","site_admin":false},"body":"сейчас еще есть избыточность","created_at":"2016-11-20T11:16:52Z","updated_at":"2016-11-20T11:16:53Z","html_url":"https://github.com/urfu-2016/javascript-task-7/pull/4#discussion_r88798835","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/comments/88798835"},"html":{"href":"https://github.com/urfu-2016/javascript-task-7/pull/4#discussion_r88798835"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4","id":94323981,"html_url":"https://github.com/urfu-2016/javascript-task-7/pull/4","diff_url":"https://github.com/urfu-2016/javascript-task-7/pull/4.diff","patch_url":"https://github.com/urfu-2016/javascript-task-7/pull/4.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/4","number":4,"state":"open","locked":false,"title":"Кошара Павел","user":{"login":"melanholy","id":10682553,"avatar_url":"https://avatars.githubusercontent.com/u/10682553?v=3","gravatar_id":"","url":"https://api.github.com/users/melanholy","html_url":"https://github.com/melanholy","followers_url":"https://api.github.com/users/melanholy/followers","following_url":"https://api.github.com/users/melanholy/following{/other_user}","gists_url":"https://api.github.com/users/melanholy/gists{/gist_id}","starred_url":"https://api.github.com/users/melanholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melanholy/subscriptions","organizations_url":"https://api.github.com/users/melanholy/orgs","repos_url":"https://api.github.com/users/melanholy/repos","events_url":"https://api.github.com/users/melanholy/events{/privacy}","received_events_url":"https://api.github.com/users/melanholy/received_events","type":"User","site_admin":false},"body":"тысяча и одно имя для переменной друга","created_at":"2016-11-18T08:55:47Z","updated_at":"2016-11-20T11:16:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59e3203c07c67021ec3eae309e67ed8785f1b032","assignee":{"login":"Vittly","id":1221916,"avatar_url":"https://avatars.githubusercontent.com/u/1221916?v=3","gravatar_id":"","url":"https://api.github.com/users/Vittly","html_url":"https://github.com/Vittly","followers_url":"https://api.github.com/users/Vittly/followers","following_url":"https://api.github.com/users/Vittly/following{/other_user}","gists_url":"https://api.github.com/users/Vittly/gists{/gist_id}","starred_url":"https://api.github.com/users/Vittly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vittly/subscriptions","organizations_url":"https://api.github.com/users/Vittly/orgs","repos_url":"https://api.github.com/users/Vittly/repos","events_url":"https://api.github.com/users/Vittly/events{/privacy}","received_events_url":"https://api.github.com/users/Vittly/received_events","type":"User","site_admin":false},"assignees":[{"login":"Vittly","id":1221916,"avatar_url":"https://avatars.githubusercontent.com/u/1221916?v=3","gravatar_id":"","url":"https://api.github.com/users/Vittly","html_url":"https://github.com/Vittly","followers_url":"https://api.github.com/users/Vittly/followers","following_url":"https://api.github.com/users/Vittly/following{/other_user}","gists_url":"https://api.github.com/users/Vittly/gists{/gist_id}","starred_url":"https://api.github.com/users/Vittly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vittly/subscriptions","organizations_url":"https://api.github.com/users/Vittly/orgs","repos_url":"https://api.github.com/users/Vittly/repos","events_url":"https://api.github.com/users/Vittly/events{/privacy}","received_events_url":"https://api.github.com/users/Vittly/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4/comments","review_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/4/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/statuses/b4a91a233867fe2bf1f3067f46a299bcb170ffbd","head":{"label":"melanholy:master","ref":"master","sha":"b4a91a233867fe2bf1f3067f46a299bcb170ffbd","user":{"login":"melanholy","id":10682553,"avatar_url":"https://avatars.githubusercontent.com/u/10682553?v=3","gravatar_id":"","url":"https://api.github.com/users/melanholy","html_url":"https://github.com/melanholy","followers_url":"https://api.github.com/users/melanholy/followers","following_url":"https://api.github.com/users/melanholy/following{/other_user}","gists_url":"https://api.github.com/users/melanholy/gists{/gist_id}","starred_url":"https://api.github.com/users/melanholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melanholy/subscriptions","organizations_url":"https://api.github.com/users/melanholy/orgs","repos_url":"https://api.github.com/users/melanholy/repos","events_url":"https://api.github.com/users/melanholy/events{/privacy}","received_events_url":"https://api.github.com/users/melanholy/received_events","type":"User","site_admin":false},"repo":{"id":74098100,"name":"javascript-task-7","full_name":"melanholy/javascript-task-7","owner":{"login":"melanholy","id":10682553,"avatar_url":"https://avatars.githubusercontent.com/u/10682553?v=3","gravatar_id":"","url":"https://api.github.com/users/melanholy","html_url":"https://github.com/melanholy","followers_url":"https://api.github.com/users/melanholy/followers","following_url":"https://api.github.com/users/melanholy/following{/other_user}","gists_url":"https://api.github.com/users/melanholy/gists{/gist_id}","starred_url":"https://api.github.com/users/melanholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melanholy/subscriptions","organizations_url":"https://api.github.com/users/melanholy/orgs","repos_url":"https://api.github.com/users/melanholy/repos","events_url":"https://api.github.com/users/melanholy/events{/privacy}","received_events_url":"https://api.github.com/users/melanholy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/melanholy/javascript-task-7","description":"Задача «Свадьба Билли»","fork":true,"url":"https://api.github.com/repos/melanholy/javascript-task-7","forks_url":"https://api.github.com/repos/melanholy/javascript-task-7/forks","keys_url":"https://api.github.com/repos/melanholy/javascript-task-7/keys{/key_id}","collaborators_url":"https://api.github.com/repos/melanholy/javascript-task-7/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/melanholy/javascript-task-7/teams","hooks_url":"https://api.github.com/repos/melanholy/javascript-task-7/hooks","issue_events_url":"https://api.github.com/repos/melanholy/javascript-task-7/issues/events{/number}","events_url":"https://api.github.com/repos/melanholy/javascript-task-7/events","assignees_url":"https://api.github.com/repos/melanholy/javascript-task-7/assignees{/user}","branches_url":"https://api.github.com/repos/melanholy/javascript-task-7/branches{/branch}","tags_url":"https://api.github.com/repos/melanholy/javascript-task-7/tags","blobs_url":"https://api.github.com/repos/melanholy/javascript-task-7/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/melanholy/javascript-task-7/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/melanholy/javascript-task-7/git/refs{/sha}","trees_url":"https://api.github.com/repos/melanholy/javascript-task-7/git/trees{/sha}","statuses_url":"https://api.github.com/repos/melanholy/javascript-task-7/statuses/{sha}","languages_url":"https://api.github.com/repos/melanholy/javascript-task-7/languages","stargazers_url":"https://api.github.com/repos/melanholy/javascript-task-7/stargazers","contributors_url":"https://api.github.com/repos/melanholy/javascript-task-7/contributors","subscribers_url":"https://api.github.com/repos/melanholy/javascript-task-7/subscribers","subscription_url":"https://api.github.com/repos/melanholy/javascript-task-7/subscription","commits_url":"https://api.github.com/repos/melanholy/javascript-task-7/commits{/sha}","git_commits_url":"https://api.github.com/repos/melanholy/javascript-task-7/git/commits{/sha}","comments_url":"https://api.github.com/repos/melanholy/javascript-task-7/comments{/number}","issue_comment_url":"https://api.github.com/repos/melanholy/javascript-task-7/issues/comments{/number}","contents_url":"https://api.github.com/repos/melanholy/javascript-task-7/contents/{+path}","compare_url":"https://api.github.com/repos/melanholy/javascript-task-7/compare/{base}...{head}","merges_url":"https://api.github.com/repos/melanholy/javascript-task-7/merges","archive_url":"https://api.github.com/repos/melanholy/javascript-task-7/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/melanholy/javascript-task-7/downloads","issues_url":"https://api.github.com/repos/melanholy/javascript-task-7/issues{/number}","pulls_url":"https://api.github.com/repos/melanholy/javascript-task-7/pulls{/number}","milestones_url":"https://api.github.com/repos/melanholy/javascript-task-7/milestones{/number}","notifications_url":"https://api.github.com/repos/melanholy/javascript-task-7/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/melanholy/javascript-task-7/labels{/name}","releases_url":"https://api.github.com/repos/melanholy/javascript-task-7/releases{/id}","deployments_url":"https://api.github.com/repos/melanholy/javascript-task-7/deployments","created_at":"2016-11-18T05:27:13Z","updated_at":"2016-11-18T05:27:14Z","pushed_at":"2016-11-19T18:47:53Z","git_url":"git://github.com/melanholy/javascript-task-7.git","ssh_url":"git@github.com:melanholy/javascript-task-7.git","clone_url":"https://github.com/melanholy/javascript-task-7.git","svn_url":"https://github.com/melanholy/javascript-task-7","homepage":"","size":11,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urfu-2016:master","ref":"master","sha":"4a22d2747c173e3a56c93789b501c871e3d20971","user":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":74001255,"name":"javascript-task-7","full_name":"urfu-2016/javascript-task-7","owner":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2016/javascript-task-7","description":"Задача «Свадьба Билли»","fork":false,"url":"https://api.github.com/repos/urfu-2016/javascript-task-7","forks_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/forks","keys_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/teams","hooks_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/hooks","issue_events_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/events","assignees_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/tags","blobs_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/languages","stargazers_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/stargazers","contributors_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/contributors","subscribers_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/subscribers","subscription_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/subscription","commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/merges","archive_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/downloads","issues_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2016/javascript-task-7/deployments","created_at":"2016-11-17T07:24:15Z","updated_at":"2016-11-17T14:07:08Z","pushed_at":"2016-11-20T06:12:23Z","git_url":"git://github.com/urfu-2016/javascript-task-7.git","ssh_url":"git@github.com:urfu-2016/javascript-task-7.git","clone_url":"https://github.com/urfu-2016/javascript-task-7.git","svn_url":"https://github.com/urfu-2016/javascript-task-7","homepage":"","size":12,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":6,"forks":22,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4"},"html":{"href":"https://github.com/urfu-2016/javascript-task-7/pull/4"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/4"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-7/statuses/b4a91a233867fe2bf1f3067f46a299bcb170ffbd"}}}}
{"actor":{"display_login":"Vittly"}}