{"action":"created","comment":{"url":"https://api.github.com/repos/rlenninger/codeguild/pulls/comments/72168562","id":72168562,"diff_hunk":"@@ -2,129 +2,135 @@\n year with most rain.\n \"\"\"\n # setup:\n-filename = 'sunnyside.txt'\n+FILENAME = 'sunnyside.txt'\n \n-\n-def each_line_of_file(filename):\n+def open_file_and_read_lines(filename):\n     \"\"\"Opens sunnyside.txt and reads it line by line.\"\"\"\n-    with open(filename, newline='') as f:\n+    with open(FILENAME, newline='') as f:\n         lines = f.readlines()\n+    header_removed = lines[11:-1]\n \n-    return lines\n-\n+    return header_removed\n \n-def split_lines(lines):\n-    r\"\"\"Strips and splits the lines into lists.\n \n-    >>> split_lines(['1 \\n', '2\\n', '3\\n', '4\\n', '5\\n', '6 \\n', '7 \\n', '8 \\n', '9 \\n', '10 \\n', '11 \\n', 'PARTY! \\n', 'TIME!'])\n-    [['PARTY!']]\n+def parse_relevant_lines_into_date_amount(lines):\n     \"\"\"\n-    listed_lines = [x.strip().split('\\n') for x in lines]\n-    listed_lines_reduced = listed_lines[11:-1]\n-    line_list = []\n-    for listed_lines_split in listed_lines_reduced:\n-        line_list += [y.split() for y in listed_lines_split]\n+    >>> parse_relevant_lines_into_date_amount(['01-JAN-9999 0 1 2 3 4', '02-JAN-9999 5 6 7 8 9', '03-JAN-9999 - - - - -'])\n+    [('01-JAN-9999', 0), ('02-JAN-9999', 5)]\n+    \"\"\"\n+    return [parse_line_into_date_amount(line) for line in lines if should_process_input_line(line)] # L\n \n-    return line_list\n \n+def should_process_input_line(line): # keep this separated for now\n+    \"\"\"\n+    >>> should_process_input_line('02-JAN-9999 5 6 7 8 9')\n+    True\n+    >>> should_process_input_line('03-JAN-9999 - - - - -')\n+    False\n+    \"\"\"\n+    return line.split()[1] != '-' # this one line can fo to where L is\n \n-def remove_junk(line_list):\n-    \"\"\"Cleans up the list and sets daily rain amount to an int.\n \n-    >>> remove_junk([['test', '1', '2', '3']])\n-    [['test', 1]]\n+def parse_line_into_date_amount(line):\n+    \"\"\"\n+    >>> parse_line_into_date_amount('01-JAN-9999 0 1 2 3 4')\n+    ('01-JAN-9999', 0)\n     \"\"\"\n-    temp_list = []\n-    for z in line_list:\n-        temp_list += [z[0:2]]\n-    temp_list2 = []\n-    for date, rain in temp_list:\n-        if rain != '-':\n-            int_rain = int(rain)\n-            temp_list2 += [[date, int_rain]]\n-    return temp_list2\n-\n-\n-def dict_dates(y):\n+    date_amount_tuple = tuple(line.split()[0:2])\n+    date_amount_tuple_int = date_amount_tuple[0], int(date_amount_tuple[1])\n+    return date_amount_tuple_int\n+\n+def create_dict_from_list_of_dates_and_rain(y):\n     \"\"\"Creates a dict from the list.\n \n-    >>> dict_dates([['test', 1]])\n-    {'test': 1}\n+    >>> create_dict_from_list_of_dates_and_rain([('12-MAY-1999', 3)])\n+    {'12-MAY-1999': 3}\n     \"\"\"\n     d = {key: value for (key, value) in y}\n-    d = {str(k): int(v) for k, v in d.items()}\n     return d\n \n \n-def most_rain(d):\n+def most_rain(p):\n     \"\"\"Returns the key for max of dict daily totals.\n \n-    >>> most_rain({'test': 1})\n-    'test'\n+    >>> most_rain([('10-DEC-1988', 1), ('14-JAN-1999', 10)])\n+    '14-JAN-1999'\n     \"\"\"\n-    day_with_most_rain = max(d, key=d.get)\n+    dict_of_parsed_lines = create_dict_from_list_of_dates_and_rain(p)\n+    day_with_most_rain = max(dict_of_parsed_lines, key=dict_of_parsed_lines.get)\n     return day_with_most_rain\n \n \n-def create_year_list(temp_list2):\n+def get_year_from_date_amount(date_amount):\n+    \"\"\"\n+    >>> get_year_from_date_amount(('10-DEC-1988', 1))\n+    '1988'\n+    \"\"\"\n+    year_key = date_amount[0][-4:]\n+    return year_key\n+\n+\n+def get_year_with_most_rain(parsed_lines):\n+    \"\"\"Returns year with max amount of rain.\n+\n+    >>> get_year_with_most_rain([('10-DEC-1988', 1), ('14-JAN-1999', 10), ('01-OCT-1988', 4), ('05-MAY-1999', 3)])\n+    '1999'\n+    \"\"\"\n+    total_by_year_list = create_year_list(parsed_lines)\n+    total_by_year_dict = create_year_dict(total_by_year_list)\n+\n+    total_by_year_max = max(total_by_year_dict, key=total_by_year_dict.get)\n+    return total_by_year_max\n+\n+\n+def create_year_list(parsed_lines):\n     \"\"\"Slices the list of dates into years\n \n-    >>> create_year_list([['Dec1999', 'Party over! OOPS! out of time']])\n+    >>> create_year_list([['DEC-1999', 'Party over! OOPS! out of time']])\n     [['1999', 'Party over! OOPS! out of time']]\n     \"\"\"\n-    temp_list3 = []\n-    for date, rain in temp_list2:\n+    list_of_years_and_rainfall = []\n+    for date, rain in parsed_lines:\n         date_sliced = date[-4:]\n-        temp_list3 += [[date_sliced, rain]]\n-    return temp_list3\n+        list_of_years_and_rainfall += [[date_sliced, rain]]\n+    return list_of_years_and_rainfall\n \n \n-def create_year_dict(temp_list3):\n+def create_year_dict(list_of_year_and_rainfall):\n     \"\"\"Creates a dict from year list and sums rain value.\n \n     >>> create_year_dict([['1999', 1], ['1999', 2]])\n     {'1999': [3]}\n     \"\"\"\n     yearly_totals = {}\n-    for date_sliced, rain in temp_list3:\n+    for date_sliced, rain in list_of_year_and_rainfall:\n         if date_sliced not in yearly_totals:\n             yearly_totals[date_sliced] = []\n         yearly_totals[date_sliced] += [rain]\n-        total_by_year = dict(zip(yearly_totals.keys(), [[sum(item)] for item in yearly_totals.values()]))\n+    total_by_year = dict(zip(yearly_totals.keys(), [[sum(item)] for item in yearly_totals.values()]))\n     return total_by_year","path":"practice/rain.py","position":null,"original_position":158,"commit_id":"6194322b7d7325acca27382877731f747aa20e24","original_commit_id":"6194322b7d7325acca27382877731f747aa20e24","user":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"body":" I tried working with the group_by and was left with a dict that contained extra information that seemed easer to remove at the time the dict was created rather then removing it later. \r\nThe group_by you provided seems to do the exact same thing as this function, only this one also sums the totals and gives me just a  year for a key and the total amount of rainfall. You also mention that the lookup function of the dict is never used, and is thus necessary, yet group_by creates a dict. Am I supposed to use group_by and then remove it from the dict?","created_at":"2016-07-26T00:15:16Z","updated_at":"2016-07-26T00:15:16Z","html_url":"https://github.com/rlenninger/codeguild/pull/4#discussion_r72168562","pull_request_url":"https://api.github.com/repos/rlenninger/codeguild/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/rlenninger/codeguild/pulls/comments/72168562"},"html":{"href":"https://github.com/rlenninger/codeguild/pull/4#discussion_r72168562"},"pull_request":{"href":"https://api.github.com/repos/rlenninger/codeguild/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/rlenninger/codeguild/pulls/4","id":78183308,"html_url":"https://github.com/rlenninger/codeguild/pull/4","diff_url":"https://github.com/rlenninger/codeguild/pull/4.diff","patch_url":"https://github.com/rlenninger/codeguild/pull/4.patch","issue_url":"https://api.github.com/repos/rlenninger/codeguild/issues/4","number":4,"state":"open","locked":false,"title":"Rain","user":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-20T17:02:56Z","updated_at":"2016-07-26T00:15:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15560e705177f945f5caffe49c1ab51963766386","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rlenninger/codeguild/pulls/4/commits","review_comments_url":"https://api.github.com/repos/rlenninger/codeguild/pulls/4/comments","review_comment_url":"https://api.github.com/repos/rlenninger/codeguild/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rlenninger/codeguild/issues/4/comments","statuses_url":"https://api.github.com/repos/rlenninger/codeguild/statuses/6194322b7d7325acca27382877731f747aa20e24","head":{"label":"rlenninger:rain","ref":"rain","sha":"6194322b7d7325acca27382877731f747aa20e24","user":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"repo":{"id":62911665,"name":"codeguild","full_name":"rlenninger/codeguild","owner":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rlenninger/codeguild","description":null,"fork":false,"url":"https://api.github.com/repos/rlenninger/codeguild","forks_url":"https://api.github.com/repos/rlenninger/codeguild/forks","keys_url":"https://api.github.com/repos/rlenninger/codeguild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rlenninger/codeguild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rlenninger/codeguild/teams","hooks_url":"https://api.github.com/repos/rlenninger/codeguild/hooks","issue_events_url":"https://api.github.com/repos/rlenninger/codeguild/issues/events{/number}","events_url":"https://api.github.com/repos/rlenninger/codeguild/events","assignees_url":"https://api.github.com/repos/rlenninger/codeguild/assignees{/user}","branches_url":"https://api.github.com/repos/rlenninger/codeguild/branches{/branch}","tags_url":"https://api.github.com/repos/rlenninger/codeguild/tags","blobs_url":"https://api.github.com/repos/rlenninger/codeguild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rlenninger/codeguild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rlenninger/codeguild/git/refs{/sha}","trees_url":"https://api.github.com/repos/rlenninger/codeguild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rlenninger/codeguild/statuses/{sha}","languages_url":"https://api.github.com/repos/rlenninger/codeguild/languages","stargazers_url":"https://api.github.com/repos/rlenninger/codeguild/stargazers","contributors_url":"https://api.github.com/repos/rlenninger/codeguild/contributors","subscribers_url":"https://api.github.com/repos/rlenninger/codeguild/subscribers","subscription_url":"https://api.github.com/repos/rlenninger/codeguild/subscription","commits_url":"https://api.github.com/repos/rlenninger/codeguild/commits{/sha}","git_commits_url":"https://api.github.com/repos/rlenninger/codeguild/git/commits{/sha}","comments_url":"https://api.github.com/repos/rlenninger/codeguild/comments{/number}","issue_comment_url":"https://api.github.com/repos/rlenninger/codeguild/issues/comments{/number}","contents_url":"https://api.github.com/repos/rlenninger/codeguild/contents/{+path}","compare_url":"https://api.github.com/repos/rlenninger/codeguild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rlenninger/codeguild/merges","archive_url":"https://api.github.com/repos/rlenninger/codeguild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rlenninger/codeguild/downloads","issues_url":"https://api.github.com/repos/rlenninger/codeguild/issues{/number}","pulls_url":"https://api.github.com/repos/rlenninger/codeguild/pulls{/number}","milestones_url":"https://api.github.com/repos/rlenninger/codeguild/milestones{/number}","notifications_url":"https://api.github.com/repos/rlenninger/codeguild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rlenninger/codeguild/labels{/name}","releases_url":"https://api.github.com/repos/rlenninger/codeguild/releases{/id}","deployments_url":"https://api.github.com/repos/rlenninger/codeguild/deployments","created_at":"2016-07-08T19:13:30Z","updated_at":"2016-07-08T19:20:32Z","pushed_at":"2016-07-25T16:47:36Z","git_url":"git://github.com/rlenninger/codeguild.git","ssh_url":"git@github.com:rlenninger/codeguild.git","clone_url":"https://github.com/rlenninger/codeguild.git","svn_url":"https://github.com/rlenninger/codeguild","homepage":null,"size":93,"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":"rlenninger:master","ref":"master","sha":"16a5eca05f057ea4b1db899e713d943e2f9e12c2","user":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"repo":{"id":62911665,"name":"codeguild","full_name":"rlenninger/codeguild","owner":{"login":"rlenninger","id":20361333,"avatar_url":"https://avatars.githubusercontent.com/u/20361333?v=3","gravatar_id":"","url":"https://api.github.com/users/rlenninger","html_url":"https://github.com/rlenninger","followers_url":"https://api.github.com/users/rlenninger/followers","following_url":"https://api.github.com/users/rlenninger/following{/other_user}","gists_url":"https://api.github.com/users/rlenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/rlenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlenninger/subscriptions","organizations_url":"https://api.github.com/users/rlenninger/orgs","repos_url":"https://api.github.com/users/rlenninger/repos","events_url":"https://api.github.com/users/rlenninger/events{/privacy}","received_events_url":"https://api.github.com/users/rlenninger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rlenninger/codeguild","description":null,"fork":false,"url":"https://api.github.com/repos/rlenninger/codeguild","forks_url":"https://api.github.com/repos/rlenninger/codeguild/forks","keys_url":"https://api.github.com/repos/rlenninger/codeguild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rlenninger/codeguild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rlenninger/codeguild/teams","hooks_url":"https://api.github.com/repos/rlenninger/codeguild/hooks","issue_events_url":"https://api.github.com/repos/rlenninger/codeguild/issues/events{/number}","events_url":"https://api.github.com/repos/rlenninger/codeguild/events","assignees_url":"https://api.github.com/repos/rlenninger/codeguild/assignees{/user}","branches_url":"https://api.github.com/repos/rlenninger/codeguild/branches{/branch}","tags_url":"https://api.github.com/repos/rlenninger/codeguild/tags","blobs_url":"https://api.github.com/repos/rlenninger/codeguild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rlenninger/codeguild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rlenninger/codeguild/git/refs{/sha}","trees_url":"https://api.github.com/repos/rlenninger/codeguild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rlenninger/codeguild/statuses/{sha}","languages_url":"https://api.github.com/repos/rlenninger/codeguild/languages","stargazers_url":"https://api.github.com/repos/rlenninger/codeguild/stargazers","contributors_url":"https://api.github.com/repos/rlenninger/codeguild/contributors","subscribers_url":"https://api.github.com/repos/rlenninger/codeguild/subscribers","subscription_url":"https://api.github.com/repos/rlenninger/codeguild/subscription","commits_url":"https://api.github.com/repos/rlenninger/codeguild/commits{/sha}","git_commits_url":"https://api.github.com/repos/rlenninger/codeguild/git/commits{/sha}","comments_url":"https://api.github.com/repos/rlenninger/codeguild/comments{/number}","issue_comment_url":"https://api.github.com/repos/rlenninger/codeguild/issues/comments{/number}","contents_url":"https://api.github.com/repos/rlenninger/codeguild/contents/{+path}","compare_url":"https://api.github.com/repos/rlenninger/codeguild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rlenninger/codeguild/merges","archive_url":"https://api.github.com/repos/rlenninger/codeguild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rlenninger/codeguild/downloads","issues_url":"https://api.github.com/repos/rlenninger/codeguild/issues{/number}","pulls_url":"https://api.github.com/repos/rlenninger/codeguild/pulls{/number}","milestones_url":"https://api.github.com/repos/rlenninger/codeguild/milestones{/number}","notifications_url":"https://api.github.com/repos/rlenninger/codeguild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rlenninger/codeguild/labels{/name}","releases_url":"https://api.github.com/repos/rlenninger/codeguild/releases{/id}","deployments_url":"https://api.github.com/repos/rlenninger/codeguild/deployments","created_at":"2016-07-08T19:13:30Z","updated_at":"2016-07-08T19:20:32Z","pushed_at":"2016-07-25T16:47:36Z","git_url":"git://github.com/rlenninger/codeguild.git","ssh_url":"git@github.com:rlenninger/codeguild.git","clone_url":"https://github.com/rlenninger/codeguild.git","svn_url":"https://github.com/rlenninger/codeguild","homepage":null,"size":93,"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/rlenninger/codeguild/pulls/4"},"html":{"href":"https://github.com/rlenninger/codeguild/pull/4"},"issue":{"href":"https://api.github.com/repos/rlenninger/codeguild/issues/4"},"comments":{"href":"https://api.github.com/repos/rlenninger/codeguild/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/rlenninger/codeguild/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/rlenninger/codeguild/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rlenninger/codeguild/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/rlenninger/codeguild/statuses/6194322b7d7325acca27382877731f747aa20e24"}}}}
{"actor":{"display_login":"rlenninger"}}