{"action":"created","comment":{"url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/comments/63643505","id":63643505,"diff_hunk":"@@ -1,24 +1,67 @@\n-def mergesort(a)\n-    # if the array size is 0|1 then the list is considered sorted, return sorted array\n-    # split the list into two halves\n-    # merge sort each half\n-    # combine the sorted halves\n+# precondition: a and b are sorted\n+def combine(a, b)\n+   result = []\n+\n+   while a.size > 0 && b.size > 0\n+     result << if a[0] <= b[0]\n+       a.shift\n+     else\n+       b.shift\n+     end\n+   end\n+\n+   result.concat(a).concat(b)\n end\n \n+\n+\n+\n+\n+# def combine(a, b)\n+#   print a\n+#   # create a results array\n+#   results_array = []\n+#   # counters pointing to the index of the smallest elements in each array\n+#   while a.size > 0 && b.size > 0\n+#     if a.shift < b.shift\n+#\n+#       results_array << a\n+#     else\n+#       results_array << b\n+#     end\n+#   results_array\n+#   end\n+#   # check that we have elements to compare\n+#   # push the smaller element onto the result array\n+#   # if there are elements left over in a, move them to result\n+#   # if there are elements left over in b, move them to result\n+# end\n+\n+\n def split_array(a)\n-    # find the middle index\n-    # split the array in half - take a look at take and drop in the ruby docs, or use ranges\n-    # return left and right halves of array as separate arrays - did you know a method can return multiple arrays? look it up\n+  # find the middle index\n+  # a.each_slice( (a.size/2.0).round ).to_a\n+  # split the array in half - take a look at take and drop in the ruby docs, or use ranges\n+  # return left and right halves of array as separate arrays - did you know a method can return multiple arrays? look it up\n+  left, right = a.each_slice((a.size/2.0).round).to_a\n+\n+  return  left, right\n+","path":"mergesort.rb","position":57,"original_position":57,"commit_id":"ed797121cafc47d0b07035e668ec5f8a24e965ac","original_commit_id":"ed797121cafc47d0b07035e668ec5f8a24e965ac","user":{"login":"malderi","id":19381681,"avatar_url":"https://avatars.githubusercontent.com/u/19381681?v=3","gravatar_id":"","url":"https://api.github.com/users/malderi","html_url":"https://github.com/malderi","followers_url":"https://api.github.com/users/malderi/followers","following_url":"https://api.github.com/users/malderi/following{/other_user}","gists_url":"https://api.github.com/users/malderi/gists{/gist_id}","starred_url":"https://api.github.com/users/malderi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malderi/subscriptions","organizations_url":"https://api.github.com/users/malderi/orgs","repos_url":"https://api.github.com/users/malderi/repos","events_url":"https://api.github.com/users/malderi/events{/privacy}","received_events_url":"https://api.github.com/users/malderi/received_events","type":"User","site_admin":false},"body":"It looks like your split_array function works, but it's not immediately obvious that line 46 is correct. In general, you don't get extra points for writing fewer lines of code. Code will written once but read many, many times, so even though it may take you a little more time to write a more readable solution, it will greatly help your fellow programmers. \r\n\r\n(There are \"code golf\" competitions where you do, in fact, get extra points for writing fewer lines of code, if that's your thing!)","created_at":"2016-05-18T04:28:12Z","updated_at":"2016-05-18T04:28:12Z","html_url":"https://github.com/Ada-C5/mergesort/pull/12#discussion_r63643505","pull_request_url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/comments/63643505"},"html":{"href":"https://github.com/Ada-C5/mergesort/pull/12#discussion_r63643505"},"pull_request":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12","id":69311641,"html_url":"https://github.com/Ada-C5/mergesort/pull/12","diff_url":"https://github.com/Ada-C5/mergesort/pull/12.diff","patch_url":"https://github.com/Ada-C5/mergesort/pull/12.patch","issue_url":"https://api.github.com/repos/Ada-C5/mergesort/issues/12","number":12,"state":"open","locked":false,"title":"forgot to make a pull request","user":{"login":"pottery123","id":13408340,"avatar_url":"https://avatars.githubusercontent.com/u/13408340?v=3","gravatar_id":"","url":"https://api.github.com/users/pottery123","html_url":"https://github.com/pottery123","followers_url":"https://api.github.com/users/pottery123/followers","following_url":"https://api.github.com/users/pottery123/following{/other_user}","gists_url":"https://api.github.com/users/pottery123/gists{/gist_id}","starred_url":"https://api.github.com/users/pottery123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pottery123/subscriptions","organizations_url":"https://api.github.com/users/pottery123/orgs","repos_url":"https://api.github.com/users/pottery123/repos","events_url":"https://api.github.com/users/pottery123/events{/privacy}","received_events_url":"https://api.github.com/users/pottery123/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-09T08:37:15Z","updated_at":"2016-05-18T04:28:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e91a24514637adc375f5de8d09f379e1798eafb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12/commits","review_comments_url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12/comments","review_comment_url":"https://api.github.com/repos/Ada-C5/mergesort/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Ada-C5/mergesort/issues/12/comments","statuses_url":"https://api.github.com/repos/Ada-C5/mergesort/statuses/ed797121cafc47d0b07035e668ec5f8a24e965ac","head":{"label":"pottery123:master","ref":"master","sha":"ed797121cafc47d0b07035e668ec5f8a24e965ac","user":{"login":"pottery123","id":13408340,"avatar_url":"https://avatars.githubusercontent.com/u/13408340?v=3","gravatar_id":"","url":"https://api.github.com/users/pottery123","html_url":"https://github.com/pottery123","followers_url":"https://api.github.com/users/pottery123/followers","following_url":"https://api.github.com/users/pottery123/following{/other_user}","gists_url":"https://api.github.com/users/pottery123/gists{/gist_id}","starred_url":"https://api.github.com/users/pottery123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pottery123/subscriptions","organizations_url":"https://api.github.com/users/pottery123/orgs","repos_url":"https://api.github.com/users/pottery123/repos","events_url":"https://api.github.com/users/pottery123/events{/privacy}","received_events_url":"https://api.github.com/users/pottery123/received_events","type":"User","site_admin":false},"repo":{"id":58361226,"name":"mergesort","full_name":"pottery123/mergesort","owner":{"login":"pottery123","id":13408340,"avatar_url":"https://avatars.githubusercontent.com/u/13408340?v=3","gravatar_id":"","url":"https://api.github.com/users/pottery123","html_url":"https://github.com/pottery123","followers_url":"https://api.github.com/users/pottery123/followers","following_url":"https://api.github.com/users/pottery123/following{/other_user}","gists_url":"https://api.github.com/users/pottery123/gists{/gist_id}","starred_url":"https://api.github.com/users/pottery123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pottery123/subscriptions","organizations_url":"https://api.github.com/users/pottery123/orgs","repos_url":"https://api.github.com/users/pottery123/repos","events_url":"https://api.github.com/users/pottery123/events{/privacy}","received_events_url":"https://api.github.com/users/pottery123/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pottery123/mergesort","description":"Practicing Mergesort","fork":true,"url":"https://api.github.com/repos/pottery123/mergesort","forks_url":"https://api.github.com/repos/pottery123/mergesort/forks","keys_url":"https://api.github.com/repos/pottery123/mergesort/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pottery123/mergesort/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pottery123/mergesort/teams","hooks_url":"https://api.github.com/repos/pottery123/mergesort/hooks","issue_events_url":"https://api.github.com/repos/pottery123/mergesort/issues/events{/number}","events_url":"https://api.github.com/repos/pottery123/mergesort/events","assignees_url":"https://api.github.com/repos/pottery123/mergesort/assignees{/user}","branches_url":"https://api.github.com/repos/pottery123/mergesort/branches{/branch}","tags_url":"https://api.github.com/repos/pottery123/mergesort/tags","blobs_url":"https://api.github.com/repos/pottery123/mergesort/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pottery123/mergesort/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pottery123/mergesort/git/refs{/sha}","trees_url":"https://api.github.com/repos/pottery123/mergesort/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pottery123/mergesort/statuses/{sha}","languages_url":"https://api.github.com/repos/pottery123/mergesort/languages","stargazers_url":"https://api.github.com/repos/pottery123/mergesort/stargazers","contributors_url":"https://api.github.com/repos/pottery123/mergesort/contributors","subscribers_url":"https://api.github.com/repos/pottery123/mergesort/subscribers","subscription_url":"https://api.github.com/repos/pottery123/mergesort/subscription","commits_url":"https://api.github.com/repos/pottery123/mergesort/commits{/sha}","git_commits_url":"https://api.github.com/repos/pottery123/mergesort/git/commits{/sha}","comments_url":"https://api.github.com/repos/pottery123/mergesort/comments{/number}","issue_comment_url":"https://api.github.com/repos/pottery123/mergesort/issues/comments{/number}","contents_url":"https://api.github.com/repos/pottery123/mergesort/contents/{+path}","compare_url":"https://api.github.com/repos/pottery123/mergesort/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pottery123/mergesort/merges","archive_url":"https://api.github.com/repos/pottery123/mergesort/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pottery123/mergesort/downloads","issues_url":"https://api.github.com/repos/pottery123/mergesort/issues{/number}","pulls_url":"https://api.github.com/repos/pottery123/mergesort/pulls{/number}","milestones_url":"https://api.github.com/repos/pottery123/mergesort/milestones{/number}","notifications_url":"https://api.github.com/repos/pottery123/mergesort/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pottery123/mergesort/labels{/name}","releases_url":"https://api.github.com/repos/pottery123/mergesort/releases{/id}","deployments_url":"https://api.github.com/repos/pottery123/mergesort/deployments","created_at":"2016-05-09T08:34:00Z","updated_at":"2016-05-09T08:34:01Z","pushed_at":"2016-05-09T08:36:50Z","git_url":"git://github.com/pottery123/mergesort.git","ssh_url":"git@github.com:pottery123/mergesort.git","clone_url":"https://github.com/pottery123/mergesort.git","svn_url":"https://github.com/pottery123/mergesort","homepage":null,"size":2,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"Ada-C5:master","ref":"master","sha":"5bc7e7ddaf9890d2d631297eadb3579b4595c38e","user":{"login":"Ada-C5","id":16655720,"avatar_url":"https://avatars.githubusercontent.com/u/16655720?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-C5","html_url":"https://github.com/Ada-C5","followers_url":"https://api.github.com/users/Ada-C5/followers","following_url":"https://api.github.com/users/Ada-C5/following{/other_user}","gists_url":"https://api.github.com/users/Ada-C5/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-C5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-C5/subscriptions","organizations_url":"https://api.github.com/users/Ada-C5/orgs","repos_url":"https://api.github.com/users/Ada-C5/repos","events_url":"https://api.github.com/users/Ada-C5/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-C5/received_events","type":"Organization","site_admin":false},"repo":{"id":58068083,"name":"mergesort","full_name":"Ada-C5/mergesort","owner":{"login":"Ada-C5","id":16655720,"avatar_url":"https://avatars.githubusercontent.com/u/16655720?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-C5","html_url":"https://github.com/Ada-C5","followers_url":"https://api.github.com/users/Ada-C5/followers","following_url":"https://api.github.com/users/Ada-C5/following{/other_user}","gists_url":"https://api.github.com/users/Ada-C5/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-C5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-C5/subscriptions","organizations_url":"https://api.github.com/users/Ada-C5/orgs","repos_url":"https://api.github.com/users/Ada-C5/repos","events_url":"https://api.github.com/users/Ada-C5/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-C5/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Ada-C5/mergesort","description":"Practicing Mergesort","fork":true,"url":"https://api.github.com/repos/Ada-C5/mergesort","forks_url":"https://api.github.com/repos/Ada-C5/mergesort/forks","keys_url":"https://api.github.com/repos/Ada-C5/mergesort/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ada-C5/mergesort/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ada-C5/mergesort/teams","hooks_url":"https://api.github.com/repos/Ada-C5/mergesort/hooks","issue_events_url":"https://api.github.com/repos/Ada-C5/mergesort/issues/events{/number}","events_url":"https://api.github.com/repos/Ada-C5/mergesort/events","assignees_url":"https://api.github.com/repos/Ada-C5/mergesort/assignees{/user}","branches_url":"https://api.github.com/repos/Ada-C5/mergesort/branches{/branch}","tags_url":"https://api.github.com/repos/Ada-C5/mergesort/tags","blobs_url":"https://api.github.com/repos/Ada-C5/mergesort/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ada-C5/mergesort/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ada-C5/mergesort/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ada-C5/mergesort/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ada-C5/mergesort/statuses/{sha}","languages_url":"https://api.github.com/repos/Ada-C5/mergesort/languages","stargazers_url":"https://api.github.com/repos/Ada-C5/mergesort/stargazers","contributors_url":"https://api.github.com/repos/Ada-C5/mergesort/contributors","subscribers_url":"https://api.github.com/repos/Ada-C5/mergesort/subscribers","subscription_url":"https://api.github.com/repos/Ada-C5/mergesort/subscription","commits_url":"https://api.github.com/repos/Ada-C5/mergesort/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ada-C5/mergesort/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ada-C5/mergesort/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ada-C5/mergesort/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ada-C5/mergesort/contents/{+path}","compare_url":"https://api.github.com/repos/Ada-C5/mergesort/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ada-C5/mergesort/merges","archive_url":"https://api.github.com/repos/Ada-C5/mergesort/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ada-C5/mergesort/downloads","issues_url":"https://api.github.com/repos/Ada-C5/mergesort/issues{/number}","pulls_url":"https://api.github.com/repos/Ada-C5/mergesort/pulls{/number}","milestones_url":"https://api.github.com/repos/Ada-C5/mergesort/milestones{/number}","notifications_url":"https://api.github.com/repos/Ada-C5/mergesort/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ada-C5/mergesort/labels{/name}","releases_url":"https://api.github.com/repos/Ada-C5/mergesort/releases{/id}","deployments_url":"https://api.github.com/repos/Ada-C5/mergesort/deployments","created_at":"2016-05-04T16:42:13Z","updated_at":"2016-05-04T16:42:14Z","pushed_at":"2016-05-10T16:03:24Z","git_url":"git://github.com/Ada-C5/mergesort.git","ssh_url":"git@github.com:Ada-C5/mergesort.git","clone_url":"https://github.com/Ada-C5/mergesort.git","svn_url":"https://github.com/Ada-C5/mergesort","homepage":null,"size":1,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":13,"forks":18,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12"},"html":{"href":"https://github.com/Ada-C5/mergesort/pull/12"},"issue":{"href":"https://api.github.com/repos/Ada-C5/mergesort/issues/12"},"comments":{"href":"https://api.github.com/repos/Ada-C5/mergesort/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Ada-C5/mergesort/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/Ada-C5/mergesort/statuses/ed797121cafc47d0b07035e668ec5f8a24e965ac"}}}}