{"action":"created","comment":{"url":"https://api.github.com/repos/innovia/training-exercise/pulls/comments/67997657","id":67997657,"diff_hunk":"@@ -0,0 +1,72 @@\n+# Copyright (c) 2016 Ami . All rights reserved\n+\n+from random import random\n+\n+def elect_in_region(election_result, candidate_chances):\n+    if election_result <= candidate_chances:\n+        return 'a'\n+    else:\n+        return 'b'\n+\n+def simulate_a_single_election():\n+    candidate_a_chances = {\n+        \"region1\": 87,\n+        \"region2\": 65,\n+        \"region3\": 17\n+    }\n+\n+    candidate_a_elected_count = 0\n+    candidate_b_elected_count = 0\n+\n+    for region in candidate_a_chances:\n+        elected = elect_in_region(election_result=int(random() * 100), candidate_chances=candidate_a_chances[region])\n+\n+        if elected == \"a\":\n+            candidate_a_elected_count += 1\n+        else:\n+            candidate_b_elected_count += 1\n+\n+    if candidate_a_elected_count > candidate_b_elected_count:\n+        return 'a'\n+    else:\n+        return 'b'\n+\n+def simulate_elections(elections_count):\n+    candidate_a_elections_count = 0\n+    candidate_b_elections_count = 0\n+\n+    for i in range(0, elections_count):\n+        election_result = simulate_a_single_election()\n+\n+        if election_result == 'a':\n+            candidate_a_elections_count += 1\n+        else:\n+            candidate_b_elections_count += 1\n+\n+    print(\"Candidate A won\", candidate_a_elections_count, \"times\")\n+\n+    print(\"Candidate B won\", candidate_b_elections_count, \"times\")\n+\n+    results = {\n+        'count': elections_count,\n+        'a': candidate_a_elections_count,\n+        'b': candidate_b_elections_count\n+    }\n+\n+    return results\n+\n+def calculate_probability(elections_count, candidate_winning_count):\n+    return (float(candidate_winning_count) / float(elections_count)) * 100\n+\n+\n+if __name__ == '__main__':\n+    elections_result = simulate_elections(10)\n+","path":"04-simulate-an-election/election.py","position":64,"original_position":64,"commit_id":"4046bed54928b8bc89a2bab0d4f324c34db7d2b9","original_commit_id":"4046bed54928b8bc89a2bab0d4f324c34db7d2b9","user":{"login":"boarik","id":4247190,"avatar_url":"https://avatars.githubusercontent.com/u/4247190?v=3","gravatar_id":"","url":"https://api.github.com/users/boarik","html_url":"https://github.com/boarik","followers_url":"https://api.github.com/users/boarik/followers","following_url":"https://api.github.com/users/boarik/following{/other_user}","gists_url":"https://api.github.com/users/boarik/gists{/gist_id}","starred_url":"https://api.github.com/users/boarik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boarik/subscriptions","organizations_url":"https://api.github.com/users/boarik/orgs","repos_url":"https://api.github.com/users/boarik/repos","events_url":"https://api.github.com/users/boarik/events{/privacy}","received_events_url":"https://api.github.com/users/boarik/received_events","type":"User","site_admin":false},"body":"Remove new line.","created_at":"2016-06-22T05:49:44Z","updated_at":"2016-06-22T05:49:44Z","html_url":"https://github.com/innovia/training-exercise/pull/6#discussion_r67997657","pull_request_url":"https://api.github.com/repos/innovia/training-exercise/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/comments/67997657"},"html":{"href":"https://github.com/innovia/training-exercise/pull/6#discussion_r67997657"},"pull_request":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/innovia/training-exercise/pulls/6","id":74633762,"html_url":"https://github.com/innovia/training-exercise/pull/6","diff_url":"https://github.com/innovia/training-exercise/pull/6.diff","patch_url":"https://github.com/innovia/training-exercise/pull/6.patch","issue_url":"https://api.github.com/repos/innovia/training-exercise/issues/6","number":6,"state":"open","locked":false,"title":"[master] 04-simulate elections","user":{"login":"innovia","id":112025,"avatar_url":"https://avatars.githubusercontent.com/u/112025?v=3","gravatar_id":"","url":"https://api.github.com/users/innovia","html_url":"https://github.com/innovia","followers_url":"https://api.github.com/users/innovia/followers","following_url":"https://api.github.com/users/innovia/following{/other_user}","gists_url":"https://api.github.com/users/innovia/gists{/gist_id}","starred_url":"https://api.github.com/users/innovia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innovia/subscriptions","organizations_url":"https://api.github.com/users/innovia/orgs","repos_url":"https://api.github.com/users/innovia/repos","events_url":"https://api.github.com/users/innovia/events{/privacy}","received_events_url":"https://api.github.com/users/innovia/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-21T15:30:47Z","updated_at":"2016-06-22T05:49:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6622a63e85b4aa49bde075eeb68a8ae3105b2d66","assignee":{"login":"boarik","id":4247190,"avatar_url":"https://avatars.githubusercontent.com/u/4247190?v=3","gravatar_id":"","url":"https://api.github.com/users/boarik","html_url":"https://github.com/boarik","followers_url":"https://api.github.com/users/boarik/followers","following_url":"https://api.github.com/users/boarik/following{/other_user}","gists_url":"https://api.github.com/users/boarik/gists{/gist_id}","starred_url":"https://api.github.com/users/boarik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boarik/subscriptions","organizations_url":"https://api.github.com/users/boarik/orgs","repos_url":"https://api.github.com/users/boarik/repos","events_url":"https://api.github.com/users/boarik/events{/privacy}","received_events_url":"https://api.github.com/users/boarik/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/innovia/training-exercise/pulls/6/commits","review_comments_url":"https://api.github.com/repos/innovia/training-exercise/pulls/6/comments","review_comment_url":"https://api.github.com/repos/innovia/training-exercise/pulls/comments{/number}","comments_url":"https://api.github.com/repos/innovia/training-exercise/issues/6/comments","statuses_url":"https://api.github.com/repos/innovia/training-exercise/statuses/4046bed54928b8bc89a2bab0d4f324c34db7d2b9","head":{"label":"innovia:04-simulate-an-election","ref":"04-simulate-an-election","sha":"4046bed54928b8bc89a2bab0d4f324c34db7d2b9","user":{"login":"innovia","id":112025,"avatar_url":"https://avatars.githubusercontent.com/u/112025?v=3","gravatar_id":"","url":"https://api.github.com/users/innovia","html_url":"https://github.com/innovia","followers_url":"https://api.github.com/users/innovia/followers","following_url":"https://api.github.com/users/innovia/following{/other_user}","gists_url":"https://api.github.com/users/innovia/gists{/gist_id}","starred_url":"https://api.github.com/users/innovia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innovia/subscriptions","organizations_url":"https://api.github.com/users/innovia/orgs","repos_url":"https://api.github.com/users/innovia/repos","events_url":"https://api.github.com/users/innovia/events{/privacy}","received_events_url":"https://api.github.com/users/innovia/received_events","type":"User","site_admin":false},"repo":{"id":61481262,"name":"training-exercise","full_name":"innovia/training-exercise","owner":{"login":"innovia","id":112025,"avatar_url":"https://avatars.githubusercontent.com/u/112025?v=3","gravatar_id":"","url":"https://api.github.com/users/innovia","html_url":"https://github.com/innovia","followers_url":"https://api.github.com/users/innovia/followers","following_url":"https://api.github.com/users/innovia/following{/other_user}","gists_url":"https://api.github.com/users/innovia/gists{/gist_id}","starred_url":"https://api.github.com/users/innovia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innovia/subscriptions","organizations_url":"https://api.github.com/users/innovia/orgs","repos_url":"https://api.github.com/users/innovia/repos","events_url":"https://api.github.com/users/innovia/events{/privacy}","received_events_url":"https://api.github.com/users/innovia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/innovia/training-exercise","description":"","fork":false,"url":"https://api.github.com/repos/innovia/training-exercise","forks_url":"https://api.github.com/repos/innovia/training-exercise/forks","keys_url":"https://api.github.com/repos/innovia/training-exercise/keys{/key_id}","collaborators_url":"https://api.github.com/repos/innovia/training-exercise/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/innovia/training-exercise/teams","hooks_url":"https://api.github.com/repos/innovia/training-exercise/hooks","issue_events_url":"https://api.github.com/repos/innovia/training-exercise/issues/events{/number}","events_url":"https://api.github.com/repos/innovia/training-exercise/events","assignees_url":"https://api.github.com/repos/innovia/training-exercise/assignees{/user}","branches_url":"https://api.github.com/repos/innovia/training-exercise/branches{/branch}","tags_url":"https://api.github.com/repos/innovia/training-exercise/tags","blobs_url":"https://api.github.com/repos/innovia/training-exercise/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/innovia/training-exercise/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/innovia/training-exercise/git/refs{/sha}","trees_url":"https://api.github.com/repos/innovia/training-exercise/git/trees{/sha}","statuses_url":"https://api.github.com/repos/innovia/training-exercise/statuses/{sha}","languages_url":"https://api.github.com/repos/innovia/training-exercise/languages","stargazers_url":"https://api.github.com/repos/innovia/training-exercise/stargazers","contributors_url":"https://api.github.com/repos/innovia/training-exercise/contributors","subscribers_url":"https://api.github.com/repos/innovia/training-exercise/subscribers","subscription_url":"https://api.github.com/repos/innovia/training-exercise/subscription","commits_url":"https://api.github.com/repos/innovia/training-exercise/commits{/sha}","git_commits_url":"https://api.github.com/repos/innovia/training-exercise/git/commits{/sha}","comments_url":"https://api.github.com/repos/innovia/training-exercise/comments{/number}","issue_comment_url":"https://api.github.com/repos/innovia/training-exercise/issues/comments{/number}","contents_url":"https://api.github.com/repos/innovia/training-exercise/contents/{+path}","compare_url":"https://api.github.com/repos/innovia/training-exercise/compare/{base}...{head}","merges_url":"https://api.github.com/repos/innovia/training-exercise/merges","archive_url":"https://api.github.com/repos/innovia/training-exercise/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/innovia/training-exercise/downloads","issues_url":"https://api.github.com/repos/innovia/training-exercise/issues{/number}","pulls_url":"https://api.github.com/repos/innovia/training-exercise/pulls{/number}","milestones_url":"https://api.github.com/repos/innovia/training-exercise/milestones{/number}","notifications_url":"https://api.github.com/repos/innovia/training-exercise/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/innovia/training-exercise/labels{/name}","releases_url":"https://api.github.com/repos/innovia/training-exercise/releases{/id}","deployments_url":"https://api.github.com/repos/innovia/training-exercise/deployments","created_at":"2016-06-19T13:21:38Z","updated_at":"2016-06-20T12:42:49Z","pushed_at":"2016-06-21T15:30:47Z","git_url":"git://github.com/innovia/training-exercise.git","ssh_url":"git@github.com:innovia/training-exercise.git","clone_url":"https://github.com/innovia/training-exercise.git","svn_url":"https://github.com/innovia/training-exercise","homepage":null,"size":17,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"innovia:master","ref":"master","sha":"63c04484300748de24525be8964aacf68384a7dd","user":{"login":"innovia","id":112025,"avatar_url":"https://avatars.githubusercontent.com/u/112025?v=3","gravatar_id":"","url":"https://api.github.com/users/innovia","html_url":"https://github.com/innovia","followers_url":"https://api.github.com/users/innovia/followers","following_url":"https://api.github.com/users/innovia/following{/other_user}","gists_url":"https://api.github.com/users/innovia/gists{/gist_id}","starred_url":"https://api.github.com/users/innovia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innovia/subscriptions","organizations_url":"https://api.github.com/users/innovia/orgs","repos_url":"https://api.github.com/users/innovia/repos","events_url":"https://api.github.com/users/innovia/events{/privacy}","received_events_url":"https://api.github.com/users/innovia/received_events","type":"User","site_admin":false},"repo":{"id":61481262,"name":"training-exercise","full_name":"innovia/training-exercise","owner":{"login":"innovia","id":112025,"avatar_url":"https://avatars.githubusercontent.com/u/112025?v=3","gravatar_id":"","url":"https://api.github.com/users/innovia","html_url":"https://github.com/innovia","followers_url":"https://api.github.com/users/innovia/followers","following_url":"https://api.github.com/users/innovia/following{/other_user}","gists_url":"https://api.github.com/users/innovia/gists{/gist_id}","starred_url":"https://api.github.com/users/innovia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innovia/subscriptions","organizations_url":"https://api.github.com/users/innovia/orgs","repos_url":"https://api.github.com/users/innovia/repos","events_url":"https://api.github.com/users/innovia/events{/privacy}","received_events_url":"https://api.github.com/users/innovia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/innovia/training-exercise","description":"","fork":false,"url":"https://api.github.com/repos/innovia/training-exercise","forks_url":"https://api.github.com/repos/innovia/training-exercise/forks","keys_url":"https://api.github.com/repos/innovia/training-exercise/keys{/key_id}","collaborators_url":"https://api.github.com/repos/innovia/training-exercise/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/innovia/training-exercise/teams","hooks_url":"https://api.github.com/repos/innovia/training-exercise/hooks","issue_events_url":"https://api.github.com/repos/innovia/training-exercise/issues/events{/number}","events_url":"https://api.github.com/repos/innovia/training-exercise/events","assignees_url":"https://api.github.com/repos/innovia/training-exercise/assignees{/user}","branches_url":"https://api.github.com/repos/innovia/training-exercise/branches{/branch}","tags_url":"https://api.github.com/repos/innovia/training-exercise/tags","blobs_url":"https://api.github.com/repos/innovia/training-exercise/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/innovia/training-exercise/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/innovia/training-exercise/git/refs{/sha}","trees_url":"https://api.github.com/repos/innovia/training-exercise/git/trees{/sha}","statuses_url":"https://api.github.com/repos/innovia/training-exercise/statuses/{sha}","languages_url":"https://api.github.com/repos/innovia/training-exercise/languages","stargazers_url":"https://api.github.com/repos/innovia/training-exercise/stargazers","contributors_url":"https://api.github.com/repos/innovia/training-exercise/contributors","subscribers_url":"https://api.github.com/repos/innovia/training-exercise/subscribers","subscription_url":"https://api.github.com/repos/innovia/training-exercise/subscription","commits_url":"https://api.github.com/repos/innovia/training-exercise/commits{/sha}","git_commits_url":"https://api.github.com/repos/innovia/training-exercise/git/commits{/sha}","comments_url":"https://api.github.com/repos/innovia/training-exercise/comments{/number}","issue_comment_url":"https://api.github.com/repos/innovia/training-exercise/issues/comments{/number}","contents_url":"https://api.github.com/repos/innovia/training-exercise/contents/{+path}","compare_url":"https://api.github.com/repos/innovia/training-exercise/compare/{base}...{head}","merges_url":"https://api.github.com/repos/innovia/training-exercise/merges","archive_url":"https://api.github.com/repos/innovia/training-exercise/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/innovia/training-exercise/downloads","issues_url":"https://api.github.com/repos/innovia/training-exercise/issues{/number}","pulls_url":"https://api.github.com/repos/innovia/training-exercise/pulls{/number}","milestones_url":"https://api.github.com/repos/innovia/training-exercise/milestones{/number}","notifications_url":"https://api.github.com/repos/innovia/training-exercise/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/innovia/training-exercise/labels{/name}","releases_url":"https://api.github.com/repos/innovia/training-exercise/releases{/id}","deployments_url":"https://api.github.com/repos/innovia/training-exercise/deployments","created_at":"2016-06-19T13:21:38Z","updated_at":"2016-06-20T12:42:49Z","pushed_at":"2016-06-21T15:30:47Z","git_url":"git://github.com/innovia/training-exercise.git","ssh_url":"git@github.com:innovia/training-exercise.git","clone_url":"https://github.com/innovia/training-exercise.git","svn_url":"https://github.com/innovia/training-exercise","homepage":null,"size":17,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/6"},"html":{"href":"https://github.com/innovia/training-exercise/pull/6"},"issue":{"href":"https://api.github.com/repos/innovia/training-exercise/issues/6"},"comments":{"href":"https://api.github.com/repos/innovia/training-exercise/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/innovia/training-exercise/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/innovia/training-exercise/statuses/4046bed54928b8bc89a2bab0d4f324c34db7d2b9"}}}}
{"actor":{"display_login":"boarik"}}