{"action":"opened","number":1,"pull_request":{"url":"https://api.github.com/repos/oredi/codility/pulls/1","id":29429641,"html_url":"https://github.com/oredi/codility/pull/1","diff_url":"https://github.com/oredi/codility/pull/1.diff","patch_url":"https://github.com/oredi/codility/pull/1.patch","issue_url":"https://api.github.com/repos/oredi/codility/issues/1","number":1,"state":"open","locked":false,"title":"Code for Sulphur Challenge","user":{"login":"sumanDev","id":8008631,"avatar_url":"https://avatars.githubusercontent.com/u/8008631?v=3","gravatar_id":"","url":"https://api.github.com/users/sumanDev","html_url":"https://github.com/sumanDev","followers_url":"https://api.github.com/users/sumanDev/followers","following_url":"https://api.github.com/users/sumanDev/following{/other_user}","gists_url":"https://api.github.com/users/sumanDev/gists{/gist_id}","starred_url":"https://api.github.com/users/sumanDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumanDev/subscriptions","organizations_url":"https://api.github.com/users/sumanDev/orgs","repos_url":"https://api.github.com/users/sumanDev/repos","events_url":"https://api.github.com/users/sumanDev/events{/privacy}","received_events_url":"https://api.github.com/users/sumanDev/received_events","type":"User","site_admin":false},"body":"using System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nclass Solution\r\n{\r\n    public int solution(int[] A, int[] B, int[] C)\r\n    {\r\n        int[] ropes = new int[A.Length * 2];\r\n        int i = 0;\r\n        List<int> tempList = new List<int>();\r\n        int tempDurability = int.MaxValue;\r\n \r\n        for (; i < A.Length; i++)\r\n        {\r\n            ropes[i * 2] = A[i] - B[i];\r\n            ropes[i * 2 + 1] = C[i];\r\n            if (ropes[i * 2] < 0)\r\n                break;\r\n \r\n            int currentParent = C[i];                \r\n \r\n            if (currentParent > -1 && currentParent == i - 1)\r\n            {\r\n                if (tempDurability == int.MaxValue)\r\n                {\r\n                    int tempParent = currentParent;\r\n                    int min = Int32.MaxValue;\r\n                    while (tempParent != -1)\r\n                    {\r\n                        if (ropes[tempParent * 2] < min)\r\n                        {\r\n                            min = ropes[tempParent * 2];\r\n                        }\r\n \r\n                        tempParent = ropes[tempParent * 2 + 1];\r\n                    }\r\n \r\n                    tempDurability = min;\r\n                }\r\n \r\n                if (ropes[i * 2] < (tempDurability - B[i]))\r\n                    tempDurability = ropes[i * 2];\r\n                else\r\n                    tempDurability -= B[i];\r\n \r\n                tempList.Add(i);\r\n \r\n                if (tempDurability < 0)\r\n                    break;\r\n            }\r\n            else\r\n            {\r\n                if (tempList.Count > 0)\r\n                {\r\n                    bool temp = true;\r\n                    foreach (int t in tempList)\r\n                    {\r\n                        temp = temp && UpdateParents(ropes, B, t);\r\n                    }\r\n \r\n                    if (!temp)\r\n                        break;\r\n \r\n                    tempList.Clear();\r\n                    tempDurability = int.MaxValue;\r\n                }\r\n \r\n                if (!UpdateParents(ropes, B, i))\r\n                    break;\r\n            }\r\n        }\r\n \r\n        return i;\r\n    }\r\n \r\n    public bool UpdateParents(int[] ropes, int[] B, int index)\r\n    {\r\n        int weight = B[index];\r\n        int currentParent = ropes[index * 2 + 1];\r\n \r\n        while (currentParent > -1)\r\n        {\r\n            ropes[currentParent * 2] -= weight;\r\n \r\n            if (ropes[currentParent * 2] < 0)\r\n                return false;\r\n \r\n            currentParent = ropes[currentParent * 2 + 1];\r\n        }\r\n \r\n        return true;\r\n    }\r\n}","created_at":"2015-02-17T10:00:46Z","updated_at":"2015-02-17T10:00:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4500da96a972e7b59eea69ed1776cbb25d0069c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/oredi/codility/pulls/1/commits","review_comments_url":"https://api.github.com/repos/oredi/codility/pulls/1/comments","review_comment_url":"https://api.github.com/repos/oredi/codility/pulls/comments/{number}","comments_url":"https://api.github.com/repos/oredi/codility/issues/1/comments","statuses_url":"https://api.github.com/repos/oredi/codility/statuses/1ceb74b018e873ff5928161024eee6455dc1cd3b","head":{"label":"sumanDev:patch-1","ref":"patch-1","sha":"1ceb74b018e873ff5928161024eee6455dc1cd3b","user":{"login":"sumanDev","id":8008631,"avatar_url":"https://avatars.githubusercontent.com/u/8008631?v=3","gravatar_id":"","url":"https://api.github.com/users/sumanDev","html_url":"https://github.com/sumanDev","followers_url":"https://api.github.com/users/sumanDev/followers","following_url":"https://api.github.com/users/sumanDev/following{/other_user}","gists_url":"https://api.github.com/users/sumanDev/gists{/gist_id}","starred_url":"https://api.github.com/users/sumanDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumanDev/subscriptions","organizations_url":"https://api.github.com/users/sumanDev/orgs","repos_url":"https://api.github.com/users/sumanDev/repos","events_url":"https://api.github.com/users/sumanDev/events{/privacy}","received_events_url":"https://api.github.com/users/sumanDev/received_events","type":"User","site_admin":false},"repo":{"id":30911350,"name":"codility","full_name":"sumanDev/codility","owner":{"login":"sumanDev","id":8008631,"avatar_url":"https://avatars.githubusercontent.com/u/8008631?v=3","gravatar_id":"","url":"https://api.github.com/users/sumanDev","html_url":"https://github.com/sumanDev","followers_url":"https://api.github.com/users/sumanDev/followers","following_url":"https://api.github.com/users/sumanDev/following{/other_user}","gists_url":"https://api.github.com/users/sumanDev/gists{/gist_id}","starred_url":"https://api.github.com/users/sumanDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumanDev/subscriptions","organizations_url":"https://api.github.com/users/sumanDev/orgs","repos_url":"https://api.github.com/users/sumanDev/repos","events_url":"https://api.github.com/users/sumanDev/events{/privacy}","received_events_url":"https://api.github.com/users/sumanDev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sumanDev/codility","description":"This repo stores all the code I wrote improving my programming knowledge on codility.com","fork":true,"url":"https://api.github.com/repos/sumanDev/codility","forks_url":"https://api.github.com/repos/sumanDev/codility/forks","keys_url":"https://api.github.com/repos/sumanDev/codility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sumanDev/codility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sumanDev/codility/teams","hooks_url":"https://api.github.com/repos/sumanDev/codility/hooks","issue_events_url":"https://api.github.com/repos/sumanDev/codility/issues/events{/number}","events_url":"https://api.github.com/repos/sumanDev/codility/events","assignees_url":"https://api.github.com/repos/sumanDev/codility/assignees{/user}","branches_url":"https://api.github.com/repos/sumanDev/codility/branches{/branch}","tags_url":"https://api.github.com/repos/sumanDev/codility/tags","blobs_url":"https://api.github.com/repos/sumanDev/codility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sumanDev/codility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sumanDev/codility/git/refs{/sha}","trees_url":"https://api.github.com/repos/sumanDev/codility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sumanDev/codility/statuses/{sha}","languages_url":"https://api.github.com/repos/sumanDev/codility/languages","stargazers_url":"https://api.github.com/repos/sumanDev/codility/stargazers","contributors_url":"https://api.github.com/repos/sumanDev/codility/contributors","subscribers_url":"https://api.github.com/repos/sumanDev/codility/subscribers","subscription_url":"https://api.github.com/repos/sumanDev/codility/subscription","commits_url":"https://api.github.com/repos/sumanDev/codility/commits{/sha}","git_commits_url":"https://api.github.com/repos/sumanDev/codility/git/commits{/sha}","comments_url":"https://api.github.com/repos/sumanDev/codility/comments{/number}","issue_comment_url":"https://api.github.com/repos/sumanDev/codility/issues/comments/{number}","contents_url":"https://api.github.com/repos/sumanDev/codility/contents/{+path}","compare_url":"https://api.github.com/repos/sumanDev/codility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sumanDev/codility/merges","archive_url":"https://api.github.com/repos/sumanDev/codility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sumanDev/codility/downloads","issues_url":"https://api.github.com/repos/sumanDev/codility/issues{/number}","pulls_url":"https://api.github.com/repos/sumanDev/codility/pulls{/number}","milestones_url":"https://api.github.com/repos/sumanDev/codility/milestones{/number}","notifications_url":"https://api.github.com/repos/sumanDev/codility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sumanDev/codility/labels{/name}","releases_url":"https://api.github.com/repos/sumanDev/codility/releases{/id}","created_at":"2015-02-17T09:57:13Z","updated_at":"2015-02-17T09:57:13Z","pushed_at":"2015-02-17T10:00:32Z","git_url":"git://github.com/sumanDev/codility.git","ssh_url":"git@github.com:sumanDev/codility.git","clone_url":"https://github.com/sumanDev/codility.git","svn_url":"https://github.com/sumanDev/codility","homepage":null,"size":3248,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"oredi:master","ref":"master","sha":"7e418a4fbf1dc8a03c34173d3218a93f514ccc89","user":{"login":"oredi","id":637249,"avatar_url":"https://avatars.githubusercontent.com/u/637249?v=3","gravatar_id":"","url":"https://api.github.com/users/oredi","html_url":"https://github.com/oredi","followers_url":"https://api.github.com/users/oredi/followers","following_url":"https://api.github.com/users/oredi/following{/other_user}","gists_url":"https://api.github.com/users/oredi/gists{/gist_id}","starred_url":"https://api.github.com/users/oredi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oredi/subscriptions","organizations_url":"https://api.github.com/users/oredi/orgs","repos_url":"https://api.github.com/users/oredi/repos","events_url":"https://api.github.com/users/oredi/events{/privacy}","received_events_url":"https://api.github.com/users/oredi/received_events","type":"User","site_admin":false},"repo":{"id":15647113,"name":"codility","full_name":"oredi/codility","owner":{"login":"oredi","id":637249,"avatar_url":"https://avatars.githubusercontent.com/u/637249?v=3","gravatar_id":"","url":"https://api.github.com/users/oredi","html_url":"https://github.com/oredi","followers_url":"https://api.github.com/users/oredi/followers","following_url":"https://api.github.com/users/oredi/following{/other_user}","gists_url":"https://api.github.com/users/oredi/gists{/gist_id}","starred_url":"https://api.github.com/users/oredi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oredi/subscriptions","organizations_url":"https://api.github.com/users/oredi/orgs","repos_url":"https://api.github.com/users/oredi/repos","events_url":"https://api.github.com/users/oredi/events{/privacy}","received_events_url":"https://api.github.com/users/oredi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oredi/codility","description":"This repo stores all the code I wrote improving my programming knowledge on codility.com","fork":false,"url":"https://api.github.com/repos/oredi/codility","forks_url":"https://api.github.com/repos/oredi/codility/forks","keys_url":"https://api.github.com/repos/oredi/codility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oredi/codility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oredi/codility/teams","hooks_url":"https://api.github.com/repos/oredi/codility/hooks","issue_events_url":"https://api.github.com/repos/oredi/codility/issues/events{/number}","events_url":"https://api.github.com/repos/oredi/codility/events","assignees_url":"https://api.github.com/repos/oredi/codility/assignees{/user}","branches_url":"https://api.github.com/repos/oredi/codility/branches{/branch}","tags_url":"https://api.github.com/repos/oredi/codility/tags","blobs_url":"https://api.github.com/repos/oredi/codility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oredi/codility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oredi/codility/git/refs{/sha}","trees_url":"https://api.github.com/repos/oredi/codility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oredi/codility/statuses/{sha}","languages_url":"https://api.github.com/repos/oredi/codility/languages","stargazers_url":"https://api.github.com/repos/oredi/codility/stargazers","contributors_url":"https://api.github.com/repos/oredi/codility/contributors","subscribers_url":"https://api.github.com/repos/oredi/codility/subscribers","subscription_url":"https://api.github.com/repos/oredi/codility/subscription","commits_url":"https://api.github.com/repos/oredi/codility/commits{/sha}","git_commits_url":"https://api.github.com/repos/oredi/codility/git/commits{/sha}","comments_url":"https://api.github.com/repos/oredi/codility/comments{/number}","issue_comment_url":"https://api.github.com/repos/oredi/codility/issues/comments/{number}","contents_url":"https://api.github.com/repos/oredi/codility/contents/{+path}","compare_url":"https://api.github.com/repos/oredi/codility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oredi/codility/merges","archive_url":"https://api.github.com/repos/oredi/codility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oredi/codility/downloads","issues_url":"https://api.github.com/repos/oredi/codility/issues{/number}","pulls_url":"https://api.github.com/repos/oredi/codility/pulls{/number}","milestones_url":"https://api.github.com/repos/oredi/codility/milestones{/number}","notifications_url":"https://api.github.com/repos/oredi/codility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oredi/codility/labels{/name}","releases_url":"https://api.github.com/repos/oredi/codility/releases{/id}","created_at":"2014-01-05T07:10:36Z","updated_at":"2014-12-24T08:32:04Z","pushed_at":"2014-08-14T05:13:51Z","git_url":"git://github.com/oredi/codility.git","ssh_url":"git@github.com:oredi/codility.git","clone_url":"https://github.com/oredi/codility.git","svn_url":"https://github.com/oredi/codility","homepage":null,"size":3248,"stargazers_count":1,"watchers_count":1,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/oredi/codility/pulls/1"},"html":{"href":"https://github.com/oredi/codility/pull/1"},"issue":{"href":"https://api.github.com/repos/oredi/codility/issues/1"},"comments":{"href":"https://api.github.com/repos/oredi/codility/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/oredi/codility/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/oredi/codility/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/oredi/codility/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/oredi/codility/statuses/1ceb74b018e873ff5928161024eee6455dc1cd3b"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":47,"deletions":0,"changed_files":1}}