{"action":"created","comment":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/40052194","id":40052194,"diff_hunk":"@@ -1 +1,55 @@\n-# Your answers here.\n+\n+\n+1. If one cashier were to add the totals of 256 bags, how long would it take?\n+\n+\tWith one cashier, assuming 1 second per operation, it will take (N-1) seconds, or 255 seconds, where n is equal to the number of bags. \n+\n+2. Seven of the cashier’s coworkers approach to see this ridiculous sight. The bright (and perhaps a bit opportunistic) cashier recruits them to help count. By working together, can they verify the total sum faster than the original cashier by herself? \n+\n+\tYes, by working together they can verify the total sum faster than the original cashier by herself. \n+\n+If so, how fast can they do this?\n+\n+\tSince there is now 8 total cashiers counting, the cashiers can now split the bags into 8 equal groups.With this split, the cashiers will now each have 32 bags, which will require a total of 31 seconds (N-1) for all cashiers to total up their respective bags in parallel. Each cashier will now have a number representing their total penny counts, which must now be summed this will require log2(8) (employees counting = 8), or three more seconds to count, for a total of 34 seconds to count all 256 bags of pennies with 8 cashiers counting. \n+\n+3. Imagine the store is big. . . very big. As a matter of fact, the store has an infinite number of employees. How fast can the employees verify the sum?\n+\n+\tNo matter how many employees are present, the limiting factor is the number of bags and the addition operation which must be executed. This limiting number is (N/2) employees, where N is the number of bags. So in this case, even with unlimited or infinite employees, no more than 256 / 2 or 128 employees are neccessary to optimize the bag counting process. With 128 employees, which will be the same as unlimited, the counting the bags will require (256/128) - 1 + log2(128) seconds, or 8 seconds.This is the lowest number of seconds to count all the bags, no matter how many employees you have, as long as you have at least 128. \n+\n+4. If you were feeling especially frustrated, perhaps you may use more than 256 bags. Instead, assume there are N bags. How long will it take the infinite number of employees to count the total? \n+\n+\tWith N bags, the following formula can be used to determine the how long it will take to count the bags: (N / 128) - 1 + log2(N / 2)\n+\n+Using Python, plot the result with bag count on the horizontal and counting time on the vertical. \n+\n+\tSee plot P5.png\n+\n+On the same graph, plot the time it would take the lone cashier to do this by herself.\n+\n+\tSee plot P5.png\n+\n+5. We’ve been neglecting any overhead associated with people communicating. How does the answer for 256 bags change, if it takes one second to communicate a number between two employees?\n+\n+\tCommunication between employees will effect the model with an addition of log2(employees counting) time, when employee counting is less than the number of bags divided by 2 or N/2. The general equation for for 256 bags will be (256 / employees counting) - 1 + 2 log2(employees counting), where employees counting does not exceed N / 2. For the 8 employee case this will be 37 seconds and for the infinite number of employees, which does not exceed 128 employees counting, this will be 15 seconds. \n+\n+\n+6. Also assume it takes one second to hand a bag (or any number of bags) between two people (including from you to a cashier). How long will it take to verify 256 bags worth of coins if each cashier comes to you and takes 1 bag? What about 2 bags? Is there a better strategy? Assume you can’t be handing bags to more than one person at a time.\n+\n+\tFor one bag hand-off at a time, assuming 8 employees and 256 bags, it will first take 8 seconds to hand off the first round of bags, and then 8 seconds to handoff the second set of bags so that the employees have enough bags to count. We must add an additional second for the 8th employee to count his two bags. This will be 16 + 1 seconds total for the first 16 bags. 256 bags / 16 will be 16 rounds of full hand offs, which will take 16 * 16 + 1 seconds or 257 seconds total. We then add the communication and addition cost of the last computation which will be 2 * log2(8), which is 6, so this will take a total of 263 seconds. \n+\n+\tFor a two bag handoff, assuming 8 employees and 256 bags, it will first take (N / 2) seconds to count each round of bag handoff. We must add 2 seconds onto the final handoff number in order to account for the last employee to count his bag after the last round of handoffs. This leads us to (N / 2) + 1 seconds, plus the time to combine numbers which is 2 * log2(2). The complete calculation is (N / 2) + 2 * log2(employees) + 1 = 128 + 1 + 2 * 3 = 135 seconds. \n+\n+\tFor a better strategy, assuming 8 employees and 256 bags, we should evenly distribute the bags amongst the employees, at 32 bags per employee. As we hand out the bags, employees will begin counting in parallel to the handout operation. This allows us to form the following general calculation: ( N / employees) - 1 + employees, or in this specfic case, (256 / 8) - 1 + 8 = 39 seconds.  \n+\n+","path":"HW0/P5/P5.txt","position":45,"original_position":45,"commit_id":"7e5b1addc3bc771e6745de8679448095b99a3de1","original_commit_id":"7e5b1addc3bc771e6745de8679448095b99a3de1","user":{"login":"nicodri","id":6955136,"avatar_url":"https://avatars.githubusercontent.com/u/6955136?v=3","gravatar_id":"","url":"https://api.github.com/users/nicodri","html_url":"https://github.com/nicodri","followers_url":"https://api.github.com/users/nicodri/followers","following_url":"https://api.github.com/users/nicodri/following{/other_user}","gists_url":"https://api.github.com/users/nicodri/gists{/gist_id}","starred_url":"https://api.github.com/users/nicodri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicodri/subscriptions","organizations_url":"https://api.github.com/users/nicodri/orgs","repos_url":"https://api.github.com/users/nicodri/repos","events_url":"https://api.github.com/users/nicodri/events{/privacy}","received_events_url":"https://api.github.com/users/nicodri/received_events","type":"User","site_admin":false},"body":"We have a similar reasoning for this part so I guess we should be on the right path :)","created_at":"2015-09-22T04:25:21Z","updated_at":"2015-09-22T04:25:21Z","html_url":"https://github.com/harvard-cs205/cs205-homework/pull/189#discussion_r40052194","pull_request_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189","_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/40052194"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/189#discussion_r40052194"},"pull_request":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189"}}},"pull_request":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189","id":45421150,"html_url":"https://github.com/harvard-cs205/cs205-homework/pull/189","diff_url":"https://github.com/harvard-cs205/cs205-homework/pull/189.diff","patch_url":"https://github.com/harvard-cs205/cs205-homework/pull/189.patch","issue_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/189","number":189,"state":"open","locked":false,"title":"Hw0b","user":{"login":"x75093","id":8118738,"avatar_url":"https://avatars.githubusercontent.com/u/8118738?v=3","gravatar_id":"","url":"https://api.github.com/users/x75093","html_url":"https://github.com/x75093","followers_url":"https://api.github.com/users/x75093/followers","following_url":"https://api.github.com/users/x75093/following{/other_user}","gists_url":"https://api.github.com/users/x75093/gists{/gist_id}","starred_url":"https://api.github.com/users/x75093/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x75093/subscriptions","organizations_url":"https://api.github.com/users/x75093/orgs","repos_url":"https://api.github.com/users/x75093/repos","events_url":"https://api.github.com/users/x75093/events{/privacy}","received_events_url":"https://api.github.com/users/x75093/received_events","type":"User","site_admin":false},"body":"HW0b Submission","created_at":"2015-09-18T15:44:34Z","updated_at":"2015-09-22T04:25:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc488dcbcd730d571567b9faad7b5e2838ba1ee1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189/commits","review_comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189/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/189/comments","statuses_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/7e5b1addc3bc771e6745de8679448095b99a3de1","head":{"label":"x75093:HW0b","ref":"HW0b","sha":"7e5b1addc3bc771e6745de8679448095b99a3de1","user":{"login":"x75093","id":8118738,"avatar_url":"https://avatars.githubusercontent.com/u/8118738?v=3","gravatar_id":"","url":"https://api.github.com/users/x75093","html_url":"https://github.com/x75093","followers_url":"https://api.github.com/users/x75093/followers","following_url":"https://api.github.com/users/x75093/following{/other_user}","gists_url":"https://api.github.com/users/x75093/gists{/gist_id}","starred_url":"https://api.github.com/users/x75093/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x75093/subscriptions","organizations_url":"https://api.github.com/users/x75093/orgs","repos_url":"https://api.github.com/users/x75093/repos","events_url":"https://api.github.com/users/x75093/events{/privacy}","received_events_url":"https://api.github.com/users/x75093/received_events","type":"User","site_admin":false},"repo":{"id":41926670,"name":"cs205-homework","full_name":"x75093/cs205-homework","owner":{"login":"x75093","id":8118738,"avatar_url":"https://avatars.githubusercontent.com/u/8118738?v=3","gravatar_id":"","url":"https://api.github.com/users/x75093","html_url":"https://github.com/x75093","followers_url":"https://api.github.com/users/x75093/followers","following_url":"https://api.github.com/users/x75093/following{/other_user}","gists_url":"https://api.github.com/users/x75093/gists{/gist_id}","starred_url":"https://api.github.com/users/x75093/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x75093/subscriptions","organizations_url":"https://api.github.com/users/x75093/orgs","repos_url":"https://api.github.com/users/x75093/repos","events_url":"https://api.github.com/users/x75093/events{/privacy}","received_events_url":"https://api.github.com/users/x75093/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/x75093/cs205-homework","description":"","fork":true,"url":"https://api.github.com/repos/x75093/cs205-homework","forks_url":"https://api.github.com/repos/x75093/cs205-homework/forks","keys_url":"https://api.github.com/repos/x75093/cs205-homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/x75093/cs205-homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/x75093/cs205-homework/teams","hooks_url":"https://api.github.com/repos/x75093/cs205-homework/hooks","issue_events_url":"https://api.github.com/repos/x75093/cs205-homework/issues/events{/number}","events_url":"https://api.github.com/repos/x75093/cs205-homework/events","assignees_url":"https://api.github.com/repos/x75093/cs205-homework/assignees{/user}","branches_url":"https://api.github.com/repos/x75093/cs205-homework/branches{/branch}","tags_url":"https://api.github.com/repos/x75093/cs205-homework/tags","blobs_url":"https://api.github.com/repos/x75093/cs205-homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/x75093/cs205-homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/x75093/cs205-homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/x75093/cs205-homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/x75093/cs205-homework/statuses/{sha}","languages_url":"https://api.github.com/repos/x75093/cs205-homework/languages","stargazers_url":"https://api.github.com/repos/x75093/cs205-homework/stargazers","contributors_url":"https://api.github.com/repos/x75093/cs205-homework/contributors","subscribers_url":"https://api.github.com/repos/x75093/cs205-homework/subscribers","subscription_url":"https://api.github.com/repos/x75093/cs205-homework/subscription","commits_url":"https://api.github.com/repos/x75093/cs205-homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/x75093/cs205-homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/x75093/cs205-homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/x75093/cs205-homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/x75093/cs205-homework/contents/{+path}","compare_url":"https://api.github.com/repos/x75093/cs205-homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/x75093/cs205-homework/merges","archive_url":"https://api.github.com/repos/x75093/cs205-homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/x75093/cs205-homework/downloads","issues_url":"https://api.github.com/repos/x75093/cs205-homework/issues{/number}","pulls_url":"https://api.github.com/repos/x75093/cs205-homework/pulls{/number}","milestones_url":"https://api.github.com/repos/x75093/cs205-homework/milestones{/number}","notifications_url":"https://api.github.com/repos/x75093/cs205-homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/x75093/cs205-homework/labels{/name}","releases_url":"https://api.github.com/repos/x75093/cs205-homework/releases{/id}","created_at":"2015-09-04T16:39:37Z","updated_at":"2015-09-04T16:39:38Z","pushed_at":"2015-09-12T01:51:00Z","git_url":"git://github.com/x75093/cs205-homework.git","ssh_url":"git@github.com:x75093/cs205-homework.git","clone_url":"https://github.com/x75093/cs205-homework.git","svn_url":"https://github.com/x75093/cs205-homework","homepage":null,"size":335,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"406f864b38a6c8a3d89cba66cb5228e98907bab7","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-09-17T01:30:31Z","pushed_at":"2015-09-22T04:11:09Z","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":19830,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":99,"mirror_url":null,"open_issues_count":185,"forks":99,"open_issues":185,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/189"},"issue":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/189"},"comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/189/comments"},"review_comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/189/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/189/commits"},"statuses":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/7e5b1addc3bc771e6745de8679448095b99a3de1"}}}}