{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/85582574","pull_request_review_id":6292708,"id":85582574,"diff_hunk":"@@ -1,5 +1,158 @@\n 'use strict';\n \n+var DAYS = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];\n+var BANK_DAYS = 3;\n+var MINUTE = 1;\n+var HOUR = 60 * MINUTE;\n+var DAY = 24 * HOUR;\n+var DAY_START = 0;\n+var DAY_END = 3 * DAY - MINUTE;\n+var HALF_HOUR = MINUTE * 30;\n+\n+\n+function getTimezone(time) {\n+    time = /(\\d{2}):(\\d{2})\\+(\\d+)/.exec(time);\n+\n+    return parseInt(time[3], 10) * HOUR;\n+}\n+\n+function convertTime(time, timezone) {\n+    time = /(\\d{2}):(\\d{2})\\+(\\d+)/.exec(time);\n+\n+    return parseInt(time[1], 10) * HOUR +\n+           parseInt(time[2], 10) * MINUTE -\n+           parseInt(time[3], 10) * HOUR +\n+           timezone;\n+}\n+\n+function convertDate(date, timezone) {\n+    date = date.split(' ');\n+\n+    return DAYS.indexOf(date[0]) * DAY +\n+           convertTime(date[1], timezone);\n+}\n+\n+function convertWorkingHours(workingHours, timezone) {\n+    var newWorkingHours = [];\n+    var timeFrom = convertTime(workingHours.from, timezone);\n+    var timeTo = convertTime(workingHours.to, timezone);\n+\n+    for (var i = 0; i < BANK_DAYS; ++i) {\n+        newWorkingHours.push([\n+            timeFrom + i * DAY,\n+            timeTo + i * DAY\n+        ]);\n+    }\n+\n+    return newWorkingHours;\n+}\n+\n+function getTimeInterval(persSchedule) {\n+    var start = DAY_START;\n+    var result = persSchedule.map(function (item) {\n+        var time = [start, item[0]];\n+        start = item[1];\n+\n+        return time;\n+    });\n+\n+    result.push([start, DAY_END]);\n+\n+    return result;\n+}\n+\n+function convertSchedule(schedule, timezone) {\n+    var newSchedule = [];\n+    for (var name in schedule) {\n+        if (schedule.hasOwnProperty(name)) {\n+            var persSchedule = schedule[name]\n+                .map(function (item) {\n+                    return [\n+                        convertDate(item.from, timezone),\n+                        convertDate(item.to, timezone)\n+                    ];\n+                })\n+                .sort(function (i, j) {\n+                    return i[0] < j[0] ? -1 : 1;\n+                });\n+            newSchedule.push(getTimeInterval(persSchedule));\n+        }\n+    }\n+\n+    return newSchedule;\n+}\n+\n+function incIter(iter, iterMax) {\n+    var incFirst = true;\n+    for (var i = iter.length - 1; i > 0; --i) {\n+        if (++iter[i] === iterMax[i]) {\n+            iter[i] = 0;\n+        } else {\n+            incFirst = false;\n+            break;\n+        }\n+    }\n+\n+    if (incFirst) {\n+        ++iter[0];\n+    }\n+\n+    return iter;\n+}\n+\n+function getRobberyInterval(start, finish, duration) {\n+    var robberyInterval = [];\n+\n+    while (start + duration <= finish) {\n+        robberyInterval.push([start, start + duration]);\n+        start += HALF_HOUR;\n+    }\n+\n+    return robberyInterval;\n+}\n+\n+function getMinMax(fullSchedule, iter) {\n+    var result = [\n+        fullSchedule[0][iter[0]][0],\n+        fullSchedule[0][iter[0]][1]\n+    ];\n+\n+    for (var i = 1; i < fullSchedule.length; ++i) {\n+        result[0] = Math.max(result[0], fullSchedule[i][iter[i]][0]);\n+        result[1] = Math.min(result[1], fullSchedule[i][iter[i]][1]);\n+    }\n+\n+    return result;\n+}\n+\n+function getIters(iter, iterMax, fullSchedule) {\n+    for (var i = 0; i < fullSchedule.length; ++i) {\n+        iter.push(0);\n+        iterMax.push(fullSchedule[i].length);\n+    }\n+}\n+\n+function getRobberyTimes(fullSchedule, duration) {\n+    var robberyTimes = [];\n+    var iter = [];\n+    var iterMax = [];\n+\n+    getIters(iter, iterMax, fullSchedule);\n+\n+    while (iter[0] < iterMax[0]) {\n+        var minMax = getMinMax(fullSchedule, iter);","path":"robbery.js","position":143,"original_position":143,"commit_id":"08d4787735e448201386f8907e56adfd4a2ba036","original_commit_id":"08d4787735e448201386f8907e56adfd4a2ba036","user":{"login":"FrodoTheTrue","id":9107905,"avatar_url":"https://avatars.githubusercontent.com/u/9107905?v=3","gravatar_id":"","url":"https://api.github.com/users/FrodoTheTrue","html_url":"https://github.com/FrodoTheTrue","followers_url":"https://api.github.com/users/FrodoTheTrue/followers","following_url":"https://api.github.com/users/FrodoTheTrue/following{/other_user}","gists_url":"https://api.github.com/users/FrodoTheTrue/gists{/gist_id}","starred_url":"https://api.github.com/users/FrodoTheTrue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrodoTheTrue/subscriptions","organizations_url":"https://api.github.com/users/FrodoTheTrue/orgs","repos_url":"https://api.github.com/users/FrodoTheTrue/repos","events_url":"https://api.github.com/users/FrodoTheTrue/events{/privacy}","received_events_url":"https://api.github.com/users/FrodoTheTrue/received_events","type":"User","site_admin":false},"body":"странное название для функции","created_at":"2016-10-28T18:14:08Z","updated_at":"2016-10-28T18:14:08Z","html_url":"https://github.com/urfu-2016/javascript-task-3/pull/6#discussion_r85582574","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/85582574"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/6#discussion_r85582574"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6","id":90411988,"html_url":"https://github.com/urfu-2016/javascript-task-3/pull/6","diff_url":"https://github.com/urfu-2016/javascript-task-3/pull/6.diff","patch_url":"https://github.com/urfu-2016/javascript-task-3/pull/6.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/6","number":6,"state":"open","locked":false,"title":"Махалин Николай","user":{"login":"kobolok","id":2647652,"avatar_url":"https://avatars.githubusercontent.com/u/2647652?v=3","gravatar_id":"","url":"https://api.github.com/users/kobolok","html_url":"https://github.com/kobolok","followers_url":"https://api.github.com/users/kobolok/followers","following_url":"https://api.github.com/users/kobolok/following{/other_user}","gists_url":"https://api.github.com/users/kobolok/gists{/gist_id}","starred_url":"https://api.github.com/users/kobolok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kobolok/subscriptions","organizations_url":"https://api.github.com/users/kobolok/orgs","repos_url":"https://api.github.com/users/kobolok/repos","events_url":"https://api.github.com/users/kobolok/events{/privacy}","received_events_url":"https://api.github.com/users/kobolok/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-21T16:15:54Z","updated_at":"2016-10-28T18:14:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"820eb45f18f95d2d868eb5e8cd7d2f1260ba5473","assignee":{"login":"FrodoTheTrue","id":9107905,"avatar_url":"https://avatars.githubusercontent.com/u/9107905?v=3","gravatar_id":"","url":"https://api.github.com/users/FrodoTheTrue","html_url":"https://github.com/FrodoTheTrue","followers_url":"https://api.github.com/users/FrodoTheTrue/followers","following_url":"https://api.github.com/users/FrodoTheTrue/following{/other_user}","gists_url":"https://api.github.com/users/FrodoTheTrue/gists{/gist_id}","starred_url":"https://api.github.com/users/FrodoTheTrue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrodoTheTrue/subscriptions","organizations_url":"https://api.github.com/users/FrodoTheTrue/orgs","repos_url":"https://api.github.com/users/FrodoTheTrue/repos","events_url":"https://api.github.com/users/FrodoTheTrue/events{/privacy}","received_events_url":"https://api.github.com/users/FrodoTheTrue/received_events","type":"User","site_admin":false},"assignees":[{"login":"FrodoTheTrue","id":9107905,"avatar_url":"https://avatars.githubusercontent.com/u/9107905?v=3","gravatar_id":"","url":"https://api.github.com/users/FrodoTheTrue","html_url":"https://github.com/FrodoTheTrue","followers_url":"https://api.github.com/users/FrodoTheTrue/followers","following_url":"https://api.github.com/users/FrodoTheTrue/following{/other_user}","gists_url":"https://api.github.com/users/FrodoTheTrue/gists{/gist_id}","starred_url":"https://api.github.com/users/FrodoTheTrue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrodoTheTrue/subscriptions","organizations_url":"https://api.github.com/users/FrodoTheTrue/orgs","repos_url":"https://api.github.com/users/FrodoTheTrue/repos","events_url":"https://api.github.com/users/FrodoTheTrue/events{/privacy}","received_events_url":"https://api.github.com/users/FrodoTheTrue/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6/comments","review_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/6/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/08d4787735e448201386f8907e56adfd4a2ba036","head":{"label":"kobolok:master","ref":"master","sha":"08d4787735e448201386f8907e56adfd4a2ba036","user":{"login":"kobolok","id":2647652,"avatar_url":"https://avatars.githubusercontent.com/u/2647652?v=3","gravatar_id":"","url":"https://api.github.com/users/kobolok","html_url":"https://github.com/kobolok","followers_url":"https://api.github.com/users/kobolok/followers","following_url":"https://api.github.com/users/kobolok/following{/other_user}","gists_url":"https://api.github.com/users/kobolok/gists{/gist_id}","starred_url":"https://api.github.com/users/kobolok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kobolok/subscriptions","organizations_url":"https://api.github.com/users/kobolok/orgs","repos_url":"https://api.github.com/users/kobolok/repos","events_url":"https://api.github.com/users/kobolok/events{/privacy}","received_events_url":"https://api.github.com/users/kobolok/received_events","type":"User","site_admin":false},"repo":{"id":71478620,"name":"javascript-task-3","full_name":"kobolok/javascript-task-3","owner":{"login":"kobolok","id":2647652,"avatar_url":"https://avatars.githubusercontent.com/u/2647652?v=3","gravatar_id":"","url":"https://api.github.com/users/kobolok","html_url":"https://github.com/kobolok","followers_url":"https://api.github.com/users/kobolok/followers","following_url":"https://api.github.com/users/kobolok/following{/other_user}","gists_url":"https://api.github.com/users/kobolok/gists{/gist_id}","starred_url":"https://api.github.com/users/kobolok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kobolok/subscriptions","organizations_url":"https://api.github.com/users/kobolok/orgs","repos_url":"https://api.github.com/users/kobolok/repos","events_url":"https://api.github.com/users/kobolok/events{/privacy}","received_events_url":"https://api.github.com/users/kobolok/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kobolok/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":true,"url":"https://api.github.com/repos/kobolok/javascript-task-3","forks_url":"https://api.github.com/repos/kobolok/javascript-task-3/forks","keys_url":"https://api.github.com/repos/kobolok/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kobolok/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kobolok/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/kobolok/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/kobolok/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/kobolok/javascript-task-3/events","assignees_url":"https://api.github.com/repos/kobolok/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/kobolok/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/kobolok/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/kobolok/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kobolok/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kobolok/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/kobolok/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kobolok/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/kobolok/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/kobolok/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/kobolok/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/kobolok/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/kobolok/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/kobolok/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/kobolok/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/kobolok/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/kobolok/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/kobolok/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/kobolok/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kobolok/javascript-task-3/merges","archive_url":"https://api.github.com/repos/kobolok/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kobolok/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/kobolok/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/kobolok/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/kobolok/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/kobolok/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kobolok/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/kobolok/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/kobolok/javascript-task-3/deployments","created_at":"2016-10-20T15:45:27Z","updated_at":"2016-10-20T15:45:28Z","pushed_at":"2016-10-27T10:06:15Z","git_url":"git://github.com/kobolok/javascript-task-3.git","ssh_url":"git@github.com:kobolok/javascript-task-3.git","clone_url":"https://github.com/kobolok/javascript-task-3.git","svn_url":"https://github.com/kobolok/javascript-task-3","homepage":"","size":15,"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":"64ecd1ed227f56eda591afe15cc7927ddce1cf31","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":71448848,"name":"javascript-task-3","full_name":"urfu-2016/javascript-task-3","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-3","description":"Задача «0b11 друзей Оушена»","fork":false,"url":"https://api.github.com/repos/urfu-2016/javascript-task-3","forks_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/forks","keys_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/events","assignees_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/merges","archive_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/deployments","created_at":"2016-10-20T09:49:39Z","updated_at":"2016-10-23T04:31:46Z","pushed_at":"2016-10-28T18:05:05Z","git_url":"git://github.com/urfu-2016/javascript-task-3.git","ssh_url":"git@github.com:urfu-2016/javascript-task-3.git","clone_url":"https://github.com/urfu-2016/javascript-task-3.git","svn_url":"https://github.com/urfu-2016/javascript-task-3","homepage":"","size":111,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":53,"forks":94,"open_issues":53,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/6"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/6"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/08d4787735e448201386f8907e56adfd4a2ba036"}}}}
{"actor":{"display_login":"FrodoTheTrue"}}