{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/comments/146106949","pull_request_review_id":71008888,"id":146106949,"diff_hunk":"@@ -44,7 +59,184 @@ exports.getAppropriateMoment = function (schedule, duration, workingHours) {\n          * @returns {Boolean}\n          */\n         tryLater: function () {\n+            currentRobberyIndex++;\n+            if (this.exists()) {\n+                return true;\n+            }\n+            currentRobberyIndex--;\n+\n             return false;\n         }\n     };\n };\n+\n+function getRobberyTimesFromFreeSegment(segment, robberyDuration) {\n+    let times = [];\n+    let currentTime = segment.from;\n+    while (currentTime + robberyDuration <= segment.to) {\n+        times.push(currentTime);\n+        currentTime += ROBBERY_INTERVAL;\n+    }\n+\n+    return times;\n+}\n+\n+function searchFreeSegments(timePoints) {\n+    let currentNesting = 0;\n+    let freeSegments = [];\n+    let currentStartTime = 0;\n+    for (let timePoint of timePoints) {\n+        if (currentNesting === 0) {\n+            freeSegments.push({ from: currentStartTime, to: timePoint.minutes });\n+        }\n+        if (timePoint.isStart) {\n+            currentNesting++;\n+        } else {\n+            currentNesting--;\n+        }\n+        currentStartTime = timePoint.minutes;\n+    }\n+\n+    return freeSegments;\n+}\n+\n+function compareTimes(time1, time2) {\n+    return time1.minutes - time2.minutes;\n+}\n+\n+function searchFreeDates(timePoints, duration) {\n+    timePoints.sort(compareTimes);\n+    let freeSegments = searchFreeSegments(timePoints);\n+    let robberyTimes = freeSegments.reduce(\n+        (prev, segment) => prev.concat(getRobberyTimesFromFreeSegment(segment, duration)),\n+        []\n+    );\n+    let freeDates = robberyTimes.map(convertMinutesToDate);\n+\n+    return freeDates;\n+}\n+\n+function formatTime(time, template) {\n+    return template\n+        .replace(/%HH/, zfill(time.hours, 2))\n+        .replace(/%MM/, zfill(time.minutes, 2))\n+        .replace(/%DD/, time.day);\n+}\n+\n+function zfill(number, maxLen) {","path":"robbery.js","position":117,"original_position":117,"commit_id":"56b90c194bba782d5e784cac1967dd988cf9ce3a","original_commit_id":"56b90c194bba782d5e784cac1967dd988cf9ce3a","user":{"login":"Admirallll","id":18427275,"avatar_url":"https://avatars2.githubusercontent.com/u/18427275?v=4","gravatar_id":"","url":"https://api.github.com/users/Admirallll","html_url":"https://github.com/Admirallll","followers_url":"https://api.github.com/users/Admirallll/followers","following_url":"https://api.github.com/users/Admirallll/following{/other_user}","gists_url":"https://api.github.com/users/Admirallll/gists{/gist_id}","starred_url":"https://api.github.com/users/Admirallll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Admirallll/subscriptions","organizations_url":"https://api.github.com/users/Admirallll/orgs","repos_url":"https://api.github.com/users/Admirallll/repos","events_url":"https://api.github.com/users/Admirallll/events{/privacy}","received_events_url":"https://api.github.com/users/Admirallll/received_events","type":"User","site_admin":false},"body":"да, наверное, тут было лишним, но править, думаю, нет смысла, с замечанием согласен","created_at":"2017-10-21T14:40:16Z","updated_at":"2017-10-21T14:40:16Z","html_url":"https://github.com/urfu-2017/javascript-task-3/pull/58#discussion_r146106949","pull_request_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/comments/146106949"},"html":{"href":"https://github.com/urfu-2017/javascript-task-3/pull/58#discussion_r146106949"},"pull_request":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58"}},"in_reply_to_id":146106915},"pull_request":{"url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58","id":147403605,"html_url":"https://github.com/urfu-2017/javascript-task-3/pull/58","diff_url":"https://github.com/urfu-2017/javascript-task-3/pull/58.diff","patch_url":"https://github.com/urfu-2017/javascript-task-3/pull/58.patch","issue_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/58","number":58,"state":"open","locked":false,"title":"Яркеев Станислав","user":{"login":"Admirallll","id":18427275,"avatar_url":"https://avatars2.githubusercontent.com/u/18427275?v=4","gravatar_id":"","url":"https://api.github.com/users/Admirallll","html_url":"https://github.com/Admirallll","followers_url":"https://api.github.com/users/Admirallll/followers","following_url":"https://api.github.com/users/Admirallll/following{/other_user}","gists_url":"https://api.github.com/users/Admirallll/gists{/gist_id}","starred_url":"https://api.github.com/users/Admirallll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Admirallll/subscriptions","organizations_url":"https://api.github.com/users/Admirallll/orgs","repos_url":"https://api.github.com/users/Admirallll/repos","events_url":"https://api.github.com/users/Admirallll/events{/privacy}","received_events_url":"https://api.github.com/users/Admirallll/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-10-18T20:34:19Z","updated_at":"2017-10-21T14:40:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc06bd6647d391ab62a05673f6d2d87dea889a4d","assignee":{"login":"Vittly","id":1221916,"avatar_url":"https://avatars0.githubusercontent.com/u/1221916?v=4","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://avatars0.githubusercontent.com/u/1221916?v=4","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}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58/commits","review_comments_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58/comments","review_comment_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/58/comments","statuses_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/statuses/56b90c194bba782d5e784cac1967dd988cf9ce3a","head":{"label":"Admirallll:master","ref":"master","sha":"56b90c194bba782d5e784cac1967dd988cf9ce3a","user":{"login":"Admirallll","id":18427275,"avatar_url":"https://avatars2.githubusercontent.com/u/18427275?v=4","gravatar_id":"","url":"https://api.github.com/users/Admirallll","html_url":"https://github.com/Admirallll","followers_url":"https://api.github.com/users/Admirallll/followers","following_url":"https://api.github.com/users/Admirallll/following{/other_user}","gists_url":"https://api.github.com/users/Admirallll/gists{/gist_id}","starred_url":"https://api.github.com/users/Admirallll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Admirallll/subscriptions","organizations_url":"https://api.github.com/users/Admirallll/orgs","repos_url":"https://api.github.com/users/Admirallll/repos","events_url":"https://api.github.com/users/Admirallll/events{/privacy}","received_events_url":"https://api.github.com/users/Admirallll/received_events","type":"User","site_admin":false},"repo":{"id":106847842,"name":"javascript-task-3","full_name":"Admirallll/javascript-task-3","owner":{"login":"Admirallll","id":18427275,"avatar_url":"https://avatars2.githubusercontent.com/u/18427275?v=4","gravatar_id":"","url":"https://api.github.com/users/Admirallll","html_url":"https://github.com/Admirallll","followers_url":"https://api.github.com/users/Admirallll/followers","following_url":"https://api.github.com/users/Admirallll/following{/other_user}","gists_url":"https://api.github.com/users/Admirallll/gists{/gist_id}","starred_url":"https://api.github.com/users/Admirallll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Admirallll/subscriptions","organizations_url":"https://api.github.com/users/Admirallll/orgs","repos_url":"https://api.github.com/users/Admirallll/repos","events_url":"https://api.github.com/users/Admirallll/events{/privacy}","received_events_url":"https://api.github.com/users/Admirallll/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Admirallll/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":true,"url":"https://api.github.com/repos/Admirallll/javascript-task-3","forks_url":"https://api.github.com/repos/Admirallll/javascript-task-3/forks","keys_url":"https://api.github.com/repos/Admirallll/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Admirallll/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Admirallll/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/Admirallll/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/Admirallll/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/Admirallll/javascript-task-3/events","assignees_url":"https://api.github.com/repos/Admirallll/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/Admirallll/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/Admirallll/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/Admirallll/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Admirallll/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Admirallll/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Admirallll/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Admirallll/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/Admirallll/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/Admirallll/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/Admirallll/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/Admirallll/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/Admirallll/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/Admirallll/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Admirallll/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Admirallll/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Admirallll/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Admirallll/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/Admirallll/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Admirallll/javascript-task-3/merges","archive_url":"https://api.github.com/repos/Admirallll/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Admirallll/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/Admirallll/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/Admirallll/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/Admirallll/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/Admirallll/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Admirallll/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/Admirallll/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/Admirallll/javascript-task-3/deployments","created_at":"2017-10-13T16:25:01Z","updated_at":"2017-10-13T16:25:02Z","pushed_at":"2017-10-21T14:21:36Z","git_url":"git://github.com/Admirallll/javascript-task-3.git","ssh_url":"git@github.com:Admirallll/javascript-task-3.git","clone_url":"https://github.com/Admirallll/javascript-task-3.git","svn_url":"https://github.com/Admirallll/javascript-task-3","homepage":null,"size":21,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urfu-2017:master","ref":"master","sha":"88ade5e7397f7070f10e80917d200a7d1517253c","user":{"login":"urfu-2017","id":31925391,"avatar_url":"https://avatars1.githubusercontent.com/u/31925391?v=4","gravatar_id":"","url":"https://api.github.com/users/urfu-2017","html_url":"https://github.com/urfu-2017","followers_url":"https://api.github.com/users/urfu-2017/followers","following_url":"https://api.github.com/users/urfu-2017/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2017/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2017/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2017/subscriptions","organizations_url":"https://api.github.com/users/urfu-2017/orgs","repos_url":"https://api.github.com/users/urfu-2017/repos","events_url":"https://api.github.com/users/urfu-2017/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2017/received_events","type":"Organization","site_admin":false},"repo":{"id":106695607,"name":"javascript-task-3","full_name":"urfu-2017/javascript-task-3","owner":{"login":"urfu-2017","id":31925391,"avatar_url":"https://avatars1.githubusercontent.com/u/31925391?v=4","gravatar_id":"","url":"https://api.github.com/users/urfu-2017","html_url":"https://github.com/urfu-2017","followers_url":"https://api.github.com/users/urfu-2017/followers","following_url":"https://api.github.com/users/urfu-2017/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2017/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2017/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2017/subscriptions","organizations_url":"https://api.github.com/users/urfu-2017/orgs","repos_url":"https://api.github.com/users/urfu-2017/repos","events_url":"https://api.github.com/users/urfu-2017/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2017/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2017/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":false,"url":"https://api.github.com/repos/urfu-2017/javascript-task-3","forks_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/forks","keys_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/events","assignees_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/merges","archive_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2017/javascript-task-3/deployments","created_at":"2017-10-12T13:20:33Z","updated_at":"2017-10-12T14:04:22Z","pushed_at":"2017-10-21T14:21:37Z","git_url":"git://github.com/urfu-2017/javascript-task-3.git","ssh_url":"git@github.com:urfu-2017/javascript-task-3.git","clone_url":"https://github.com/urfu-2017/javascript-task-3.git","svn_url":"https://github.com/urfu-2017/javascript-task-3","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"archived":false,"open_issues_count":50,"forks":97,"open_issues":50,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58"},"html":{"href":"https://github.com/urfu-2017/javascript-task-3/pull/58"},"issue":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/58"},"comments":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2017/javascript-task-3/statuses/56b90c194bba782d5e784cac1967dd988cf9ce3a"}},"author_association":"NONE"}}
{"actor":{"display_login":"Admirallll"}}