{"action":"created","comment":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/45435414","id":45435414,"diff_hunk":"@@ -69,17 +119,27 @@ cdef void sub_update(FLOAT[:, ::1] XY,\n     ############################################################\n     # SUBPROBLEM 2: use the grid values to reduce the number of other\n     # objects to check for collisions.\n-    for j in range(i + 1, count):\n-        XY2 = &(XY[j, 0])\n-        V2 = &(V[j, 0])\n-        if overlapping(XY1, XY2, R):\n-            # SUBPROBLEM 4: Add locking\n-            if not moving_apart(XY1, V1, XY2, V2):\n-                collide(XY1, V1, XY2, V2)\n-\n-            # give a slight impulse to help separate them\n-            for dim in range(2):\n-                V2[dim] += eps * (XY2[dim] - XY1[dim])\n+    j_start = <int>(XY1[0] / grid_spacing - 2) if XY1[0] / grid_spacing - 2 > 0 else 0\n+    j_end = <int>(XY1[0] / grid_spacing + 3) if XY1[0] / grid_spacing + 3 < grid_size else grid_size\n+    k_start = <int>(XY1[1] / grid_spacing - 2) if XY1[1] / grid_spacing - 2 > 0 else 0\n+    k_end = <int>(XY1[1] / grid_spacing + 3) if XY1[1] / grid_spacing + 3 < grid_size else grid_size\n+    for j in range(j_start, j_end):\n+        for k in range(k_start, k_end):\n+            idx = Grid[j, k]\n+            if (idx != -1) and (idx > i):\n+                acquire(&(locks[idx]))\n+                XY2 = &(XY[idx, 0])\n+                V2 = &(V[idx, 0])\n+                if overlapping(XY1, XY2, R):\n+                    # SUBPROBLEM 4: Add locking\n+                    if not moving_apart(XY1, V1, XY2, V2):\n+                        collide(XY1, V1, XY2, V2)\n+\n+                    # give a slight impulse to help separate them\n+                    for dim in range(2):\n+                        V2[dim] += eps * (XY2[dim] - XY1[dim])\n+                release(&(locks[idx]))\n+    release(&(locks[i]))","path":"HW2/P5/physics.pyx","position":114,"original_position":114,"commit_id":"75198e78f2e5087db6160496c522d58ce595b668","original_commit_id":"75198e78f2e5087db6160496c522d58ce595b668","user":{"login":"rohitahuja","id":6694804,"avatar_url":"https://avatars.githubusercontent.com/u/6694804?v=3","gravatar_id":"","url":"https://api.github.com/users/rohitahuja","html_url":"https://github.com/rohitahuja","followers_url":"https://api.github.com/users/rohitahuja/followers","following_url":"https://api.github.com/users/rohitahuja/following{/other_user}","gists_url":"https://api.github.com/users/rohitahuja/gists{/gist_id}","starred_url":"https://api.github.com/users/rohitahuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohitahuja/subscriptions","organizations_url":"https://api.github.com/users/rohitahuja/orgs","repos_url":"https://api.github.com/users/rohitahuja/repos","events_url":"https://api.github.com/users/rohitahuja/events{/privacy}","received_events_url":"https://api.github.com/users/rohitahuja/received_events","type":"User","site_admin":false},"body":"Nice locking method. I did something similar.","created_at":"2015-11-20T04:41:25Z","updated_at":"2015-11-20T04:41:25Z","html_url":"https://github.com/harvard-cs205/cs205-homework/pull/314#discussion_r45435414","pull_request_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314","_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/45435414"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/314#discussion_r45435414"},"pull_request":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314"}}},"pull_request":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314","id":49575224,"html_url":"https://github.com/harvard-cs205/cs205-homework/pull/314","diff_url":"https://github.com/harvard-cs205/cs205-homework/pull/314.diff","patch_url":"https://github.com/harvard-cs205/cs205-homework/pull/314.patch","issue_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/314","number":314,"state":"open","locked":false,"title":"HW2 - Anna Whitney","user":{"login":"annawhitney","id":10450394,"avatar_url":"https://avatars.githubusercontent.com/u/10450394?v=3","gravatar_id":"","url":"https://api.github.com/users/annawhitney","html_url":"https://github.com/annawhitney","followers_url":"https://api.github.com/users/annawhitney/followers","following_url":"https://api.github.com/users/annawhitney/following{/other_user}","gists_url":"https://api.github.com/users/annawhitney/gists{/gist_id}","starred_url":"https://api.github.com/users/annawhitney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annawhitney/subscriptions","organizations_url":"https://api.github.com/users/annawhitney/orgs","repos_url":"https://api.github.com/users/annawhitney/repos","events_url":"https://api.github.com/users/annawhitney/events{/privacy}","received_events_url":"https://api.github.com/users/annawhitney/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-03T16:12:44Z","updated_at":"2015-11-20T04:41:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93298ebf7595d6767cbffa7dcfe76162d8e81545","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314/commits","review_comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314/comments","review_comment_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/314/comments","statuses_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/75198e78f2e5087db6160496c522d58ce595b668","head":{"label":"annawhitney:HW2","ref":"HW2","sha":"75198e78f2e5087db6160496c522d58ce595b668","user":{"login":"annawhitney","id":10450394,"avatar_url":"https://avatars.githubusercontent.com/u/10450394?v=3","gravatar_id":"","url":"https://api.github.com/users/annawhitney","html_url":"https://github.com/annawhitney","followers_url":"https://api.github.com/users/annawhitney/followers","following_url":"https://api.github.com/users/annawhitney/following{/other_user}","gists_url":"https://api.github.com/users/annawhitney/gists{/gist_id}","starred_url":"https://api.github.com/users/annawhitney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annawhitney/subscriptions","organizations_url":"https://api.github.com/users/annawhitney/orgs","repos_url":"https://api.github.com/users/annawhitney/repos","events_url":"https://api.github.com/users/annawhitney/events{/privacy}","received_events_url":"https://api.github.com/users/annawhitney/received_events","type":"User","site_admin":false},"repo":{"id":41937298,"name":"cs205-homework","full_name":"annawhitney/cs205-homework","owner":{"login":"annawhitney","id":10450394,"avatar_url":"https://avatars.githubusercontent.com/u/10450394?v=3","gravatar_id":"","url":"https://api.github.com/users/annawhitney","html_url":"https://github.com/annawhitney","followers_url":"https://api.github.com/users/annawhitney/followers","following_url":"https://api.github.com/users/annawhitney/following{/other_user}","gists_url":"https://api.github.com/users/annawhitney/gists{/gist_id}","starred_url":"https://api.github.com/users/annawhitney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annawhitney/subscriptions","organizations_url":"https://api.github.com/users/annawhitney/orgs","repos_url":"https://api.github.com/users/annawhitney/repos","events_url":"https://api.github.com/users/annawhitney/events{/privacy}","received_events_url":"https://api.github.com/users/annawhitney/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/annawhitney/cs205-homework","description":"","fork":true,"url":"https://api.github.com/repos/annawhitney/cs205-homework","forks_url":"https://api.github.com/repos/annawhitney/cs205-homework/forks","keys_url":"https://api.github.com/repos/annawhitney/cs205-homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/annawhitney/cs205-homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/annawhitney/cs205-homework/teams","hooks_url":"https://api.github.com/repos/annawhitney/cs205-homework/hooks","issue_events_url":"https://api.github.com/repos/annawhitney/cs205-homework/issues/events{/number}","events_url":"https://api.github.com/repos/annawhitney/cs205-homework/events","assignees_url":"https://api.github.com/repos/annawhitney/cs205-homework/assignees{/user}","branches_url":"https://api.github.com/repos/annawhitney/cs205-homework/branches{/branch}","tags_url":"https://api.github.com/repos/annawhitney/cs205-homework/tags","blobs_url":"https://api.github.com/repos/annawhitney/cs205-homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/annawhitney/cs205-homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/annawhitney/cs205-homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/annawhitney/cs205-homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/annawhitney/cs205-homework/statuses/{sha}","languages_url":"https://api.github.com/repos/annawhitney/cs205-homework/languages","stargazers_url":"https://api.github.com/repos/annawhitney/cs205-homework/stargazers","contributors_url":"https://api.github.com/repos/annawhitney/cs205-homework/contributors","subscribers_url":"https://api.github.com/repos/annawhitney/cs205-homework/subscribers","subscription_url":"https://api.github.com/repos/annawhitney/cs205-homework/subscription","commits_url":"https://api.github.com/repos/annawhitney/cs205-homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/annawhitney/cs205-homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/annawhitney/cs205-homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/annawhitney/cs205-homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/annawhitney/cs205-homework/contents/{+path}","compare_url":"https://api.github.com/repos/annawhitney/cs205-homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/annawhitney/cs205-homework/merges","archive_url":"https://api.github.com/repos/annawhitney/cs205-homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/annawhitney/cs205-homework/downloads","issues_url":"https://api.github.com/repos/annawhitney/cs205-homework/issues{/number}","pulls_url":"https://api.github.com/repos/annawhitney/cs205-homework/pulls{/number}","milestones_url":"https://api.github.com/repos/annawhitney/cs205-homework/milestones{/number}","notifications_url":"https://api.github.com/repos/annawhitney/cs205-homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/annawhitney/cs205-homework/labels{/name}","releases_url":"https://api.github.com/repos/annawhitney/cs205-homework/releases{/id}","created_at":"2015-09-04T20:53:26Z","updated_at":"2015-10-29T11:49:03Z","pushed_at":"2015-11-16T16:54:34Z","git_url":"git://github.com/annawhitney/cs205-homework.git","ssh_url":"git@github.com:annawhitney/cs205-homework.git","clone_url":"https://github.com/annawhitney/cs205-homework.git","svn_url":"https://github.com/annawhitney/cs205-homework","homepage":null,"size":853,"stargazers_count":0,"watchers_count":0,"language":"C","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":"harvard-cs205:master","ref":"master","sha":"ed6f0167fd1f6097ce9e454c2950c5db00a0c513","user":{"login":"harvard-cs205","id":13456002,"avatar_url":"https://avatars.githubusercontent.com/u/13456002?v=3","gravatar_id":"","url":"https://api.github.com/users/harvard-cs205","html_url":"https://github.com/harvard-cs205","followers_url":"https://api.github.com/users/harvard-cs205/followers","following_url":"https://api.github.com/users/harvard-cs205/following{/other_user}","gists_url":"https://api.github.com/users/harvard-cs205/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-cs205/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-cs205/subscriptions","organizations_url":"https://api.github.com/users/harvard-cs205/orgs","repos_url":"https://api.github.com/users/harvard-cs205/repos","events_url":"https://api.github.com/users/harvard-cs205/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-cs205/received_events","type":"Organization","site_admin":false},"repo":{"id":40614104,"name":"cs205-homework","full_name":"harvard-cs205/cs205-homework","owner":{"login":"harvard-cs205","id":13456002,"avatar_url":"https://avatars.githubusercontent.com/u/13456002?v=3","gravatar_id":"","url":"https://api.github.com/users/harvard-cs205","html_url":"https://github.com/harvard-cs205","followers_url":"https://api.github.com/users/harvard-cs205/followers","following_url":"https://api.github.com/users/harvard-cs205/following{/other_user}","gists_url":"https://api.github.com/users/harvard-cs205/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-cs205/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-cs205/subscriptions","organizations_url":"https://api.github.com/users/harvard-cs205/orgs","repos_url":"https://api.github.com/users/harvard-cs205/repos","events_url":"https://api.github.com/users/harvard-cs205/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-cs205/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/harvard-cs205/cs205-homework","description":"","fork":false,"url":"https://api.github.com/repos/harvard-cs205/cs205-homework","forks_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/forks","keys_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/teams","hooks_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/hooks","issue_events_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/events{/number}","events_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/events","assignees_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/assignees{/user}","branches_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/branches{/branch}","tags_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/tags","blobs_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/{sha}","languages_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/languages","stargazers_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/stargazers","contributors_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/contributors","subscribers_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/subscribers","subscription_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/subscription","commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/contents/{+path}","compare_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/merges","archive_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/downloads","issues_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues{/number}","pulls_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls{/number}","milestones_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/milestones{/number}","notifications_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/labels{/name}","releases_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/releases{/id}","created_at":"2015-08-12T17:18:15Z","updated_at":"2015-10-21T19:21:28Z","pushed_at":"2015-11-20T03:44:10Z","git_url":"git://github.com/harvard-cs205/cs205-homework.git","ssh_url":"git@github.com:harvard-cs205/cs205-homework.git","clone_url":"https://github.com/harvard-cs205/cs205-homework.git","svn_url":"https://github.com/harvard-cs205/cs205-homework","homepage":null,"size":162893,"stargazers_count":5,"watchers_count":5,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":99,"mirror_url":null,"open_issues_count":393,"forks":99,"open_issues":393,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/314"},"issue":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/314"},"comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/314/comments"},"review_comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314/comments"},"review_comment":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/314/commits"},"statuses":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/75198e78f2e5087db6160496c522d58ce595b668"}}}}