{"action":"created","comment":{"url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/comments/56732789","id":56732789,"diff_hunk":"@@ -12,28 +12,30 @@ def __init__(self, user_input=None):\n             print('Argument is not iterable.')\n \n     def _sift_up(self):\n-        idx = len(self.heap) - 1\n-        print('**************** sift up')\n-        start = idx\n-        while start > 0:\n-            print('**** outer while')\n-            idx = start\n-            while idx > 0:\n-                print('idx: ', idx, '  idx//2: ', idx//2)\n-                print(self.heap[idx], '**', self.heap[idx//2])\n-                if self.heap[idx] > self.heap[idx//2]:\n-                    self.heap[idx], self.heap[idx//2] = self.heap[idx//2], self.heap[idx]\n-                idx = idx//2\n-            start = start//2\n+        idx = self.length() - 1\n+        while idx > 0:\n+            child = idx\n+            parent = (idx - 1) // 2\n+            if self.heap[child] > self.heap[parent]:\n+                self.heap[child], self.heap[parent] = self.heap[parent], self.heap[child]\n+                idx = (idx - 1) // 2\n+                continue\n+            break\n \n     def _sift_down(self):\n         idx = 0\n-        while idx < (len(self.heap) - 1)//2:\n-            if self.heap[idx] < self.heap[idx*2] or self.heap[idx] < self.heap[(idx*2) + 1]:\n-                bigger_child = max(self.heap[idx*2], self.heap[(idx*2) + 1])\n-                child_idx = self.heap.index(bigger_child)\n-                self.heap[idx], bigger_child = bigger_child, self.heap[idx]\n-            idx = child_idx\n+        while idx < (self.length() - 1) // 2:\n+            print(idx)\n+            parent = idx\n+            child_l = idx * 2 + 1\n+            child_r = idx * 2 + 2\n+            idx += 1\n+            print(self.heap)\n+            if self.heap[parent] < self.heap[child_l]:\n+                self.heap[parent], self.heap[child_l] = self.heap[child_l], self.heap[parent]\n+            if self.heap[parent] < self.heap[child_r]:\n+                self.heap[parent], self.heap[child_r] = self.heap[child_r], self.heap[parent]\n+            continue\n \n     def push(self, val):","path":"src/heap.py","position":48,"original_position":48,"commit_id":"8a43446d4e64b21b56bfd1ed2ad0e0d5073a596a","original_commit_id":"8a43446d4e64b21b56bfd1ed2ad0e0d5073a596a","user":{"login":"joelstanner","id":3937302,"avatar_url":"https://avatars.githubusercontent.com/u/3937302?v=3","gravatar_id":"","url":"https://api.github.com/users/joelstanner","html_url":"https://github.com/joelstanner","followers_url":"https://api.github.com/users/joelstanner/followers","following_url":"https://api.github.com/users/joelstanner/following{/other_user}","gists_url":"https://api.github.com/users/joelstanner/gists{/gist_id}","starred_url":"https://api.github.com/users/joelstanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelstanner/subscriptions","organizations_url":"https://api.github.com/users/joelstanner/orgs","repos_url":"https://api.github.com/users/joelstanner/repos","events_url":"https://api.github.com/users/joelstanner/events{/privacy}","received_events_url":"https://api.github.com/users/joelstanner/received_events","type":"User","site_admin":false},"body":"Make sure to add well formed docstrings to your methods.","created_at":"2016-03-18T22:47:10Z","updated_at":"2016-03-18T22:47:10Z","html_url":"https://github.com/paulsheridan/data-structures/pull/7#discussion_r56732789","pull_request_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/comments/56732789"},"html":{"href":"https://github.com/paulsheridan/data-structures/pull/7#discussion_r56732789"},"pull_request":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7","id":63297502,"html_url":"https://github.com/paulsheridan/data-structures/pull/7","diff_url":"https://github.com/paulsheridan/data-structures/pull/7.diff","patch_url":"https://github.com/paulsheridan/data-structures/pull/7.patch","issue_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/7","number":7,"state":"closed","locked":false,"title":"heap working and all tests passing","user":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-17T21:43:41Z","updated_at":"2016-03-18T22:47:10Z","closed_at":"2016-03-17T21:43:55Z","merged_at":"2016-03-17T21:43:55Z","merge_commit_sha":"b0274d38d3004c9f5a43b57b4d8ae0d329563293","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7/commits","review_comments_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7/comments","review_comment_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/7/comments","statuses_url":"https://api.github.com/repos/paulsheridan/data-structures/statuses/8a43446d4e64b21b56bfd1ed2ad0e0d5073a596a","head":{"label":"paulsheridan:heap","ref":"heap","sha":"8a43446d4e64b21b56bfd1ed2ad0e0d5073a596a","user":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"repo":{"id":53360655,"name":"data-structures","full_name":"paulsheridan/data-structures","owner":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paulsheridan/data-structures","description":"A repository that will hold sample code for a number of classic data structures implemented in Python","fork":false,"url":"https://api.github.com/repos/paulsheridan/data-structures","forks_url":"https://api.github.com/repos/paulsheridan/data-structures/forks","keys_url":"https://api.github.com/repos/paulsheridan/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulsheridan/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulsheridan/data-structures/teams","hooks_url":"https://api.github.com/repos/paulsheridan/data-structures/hooks","issue_events_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/paulsheridan/data-structures/events","assignees_url":"https://api.github.com/repos/paulsheridan/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/paulsheridan/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/paulsheridan/data-structures/tags","blobs_url":"https://api.github.com/repos/paulsheridan/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulsheridan/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulsheridan/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulsheridan/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulsheridan/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/paulsheridan/data-structures/languages","stargazers_url":"https://api.github.com/repos/paulsheridan/data-structures/stargazers","contributors_url":"https://api.github.com/repos/paulsheridan/data-structures/contributors","subscribers_url":"https://api.github.com/repos/paulsheridan/data-structures/subscribers","subscription_url":"https://api.github.com/repos/paulsheridan/data-structures/subscription","commits_url":"https://api.github.com/repos/paulsheridan/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulsheridan/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulsheridan/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulsheridan/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/paulsheridan/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulsheridan/data-structures/merges","archive_url":"https://api.github.com/repos/paulsheridan/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulsheridan/data-structures/downloads","issues_url":"https://api.github.com/repos/paulsheridan/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/paulsheridan/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/paulsheridan/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulsheridan/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/paulsheridan/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/paulsheridan/data-structures/deployments","created_at":"2016-03-07T21:31:21Z","updated_at":"2016-03-08T21:42:48Z","pushed_at":"2016-03-18T21:32:32Z","git_url":"git://github.com/paulsheridan/data-structures.git","ssh_url":"git@github.com:paulsheridan/data-structures.git","clone_url":"https://github.com/paulsheridan/data-structures.git","svn_url":"https://github.com/paulsheridan/data-structures","homepage":null,"size":25,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"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":"paulsheridan:master","ref":"master","sha":"984044e2b70c3fac6fdcb740b392642720ab2ccc","user":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"repo":{"id":53360655,"name":"data-structures","full_name":"paulsheridan/data-structures","owner":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paulsheridan/data-structures","description":"A repository that will hold sample code for a number of classic data structures implemented in Python","fork":false,"url":"https://api.github.com/repos/paulsheridan/data-structures","forks_url":"https://api.github.com/repos/paulsheridan/data-structures/forks","keys_url":"https://api.github.com/repos/paulsheridan/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulsheridan/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulsheridan/data-structures/teams","hooks_url":"https://api.github.com/repos/paulsheridan/data-structures/hooks","issue_events_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/paulsheridan/data-structures/events","assignees_url":"https://api.github.com/repos/paulsheridan/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/paulsheridan/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/paulsheridan/data-structures/tags","blobs_url":"https://api.github.com/repos/paulsheridan/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulsheridan/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulsheridan/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulsheridan/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulsheridan/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/paulsheridan/data-structures/languages","stargazers_url":"https://api.github.com/repos/paulsheridan/data-structures/stargazers","contributors_url":"https://api.github.com/repos/paulsheridan/data-structures/contributors","subscribers_url":"https://api.github.com/repos/paulsheridan/data-structures/subscribers","subscription_url":"https://api.github.com/repos/paulsheridan/data-structures/subscription","commits_url":"https://api.github.com/repos/paulsheridan/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulsheridan/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulsheridan/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulsheridan/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulsheridan/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/paulsheridan/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulsheridan/data-structures/merges","archive_url":"https://api.github.com/repos/paulsheridan/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulsheridan/data-structures/downloads","issues_url":"https://api.github.com/repos/paulsheridan/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/paulsheridan/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/paulsheridan/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/paulsheridan/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulsheridan/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/paulsheridan/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/paulsheridan/data-structures/deployments","created_at":"2016-03-07T21:31:21Z","updated_at":"2016-03-08T21:42:48Z","pushed_at":"2016-03-18T21:32:32Z","git_url":"git://github.com/paulsheridan/data-structures.git","ssh_url":"git@github.com:paulsheridan/data-structures.git","clone_url":"https://github.com/paulsheridan/data-structures.git","svn_url":"https://github.com/paulsheridan/data-structures","homepage":null,"size":25,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"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"}},"_links":{"self":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7"},"html":{"href":"https://github.com/paulsheridan/data-structures/pull/7"},"issue":{"href":"https://api.github.com/repos/paulsheridan/data-structures/issues/7"},"comments":{"href":"https://api.github.com/repos/paulsheridan/data-structures/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paulsheridan/data-structures/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/paulsheridan/data-structures/statuses/8a43446d4e64b21b56bfd1ed2ad0e0d5073a596a"}}}}