{"action":"created","comment":{"url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/comments/70629376","id":70629376,"diff_hunk":"@@ -1,5 +1,35 @@\n-\"\"\"\n-Write a program that prints only unique values\n-from sys.argv (without program name)\n-\"\"\"\n-\n+\"\"\"\r\n+Write a program that finds anagrams in a words file\r\n+Program takes a path to a words file, \r\n+reads the file and searches for words with the same letters.\r\n+All words with the same letters should be printed together\r\n+\"\"\"\r\n+\r\n+_author_ = 'mariag'\r\n+\r\n+import sys\r\n+from collections import Counter\r\n+\r\n+file_words = 'words.txt'\r\n+wordsDic = {}\r\n+\r\n+#load key=word|value=letter counter to dictionary\r\n+with open(file_words, 'r') as f_words:\r\n+    for word in f_words:\r\n+        wordsDic[word.rstrip('\\n')] = Counter(word.rstrip('\\n'))\r\n+\r\n+#print wordsDic\r\n+delList =[]\r\n+while len(wordsDic)>0:\r\n+    for i in delList:\r\n+        del wordsDic[i]\r\n+    delList = []\r\n+    print(\"\")\r\n+    word = wordsDic.keys()[0]\r\n+    counter_i = wordsDic.get(word)\r\n+    sys.stdout.write(word+\" \")\r\n+    del wordsDic[word]\r\n+    for word_i in wordsDic:\r\n+        if  counter_i == wordsDic.get(word_i):\r\n+            sys.stdout.write(word_i+\" \")\r\n+            delList.append(word_i)","path":"10_datastructures_lab/02.py","position":40,"original_position":40,"commit_id":"8ba6b7b17e252f06d693b9798bc838a46599aac9","original_commit_id":"8ba6b7b17e252f06d693b9798bc838a46599aac9","user":{"login":"szabgab","id":48833,"avatar_url":"https://avatars.githubusercontent.com/u/48833?v=3","gravatar_id":"","url":"https://api.github.com/users/szabgab","html_url":"https://github.com/szabgab","followers_url":"https://api.github.com/users/szabgab/followers","following_url":"https://api.github.com/users/szabgab/following{/other_user}","gists_url":"https://api.github.com/users/szabgab/gists{/gist_id}","starred_url":"https://api.github.com/users/szabgab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szabgab/subscriptions","organizations_url":"https://api.github.com/users/szabgab/orgs","repos_url":"https://api.github.com/users/szabgab/repos","events_url":"https://api.github.com/users/szabgab/events{/privacy}","received_events_url":"https://api.github.com/users/szabgab/received_events","type":"User","site_admin":false},"body":"This seems to be a bit too complex and as I can see it runs O(n^2)\r\nYou could make it simpler and faster by using a dictionary where the keys are the sorted version of each string and the values are the original strings. Each key that has more than one entry at the end has a list of anagrams.","created_at":"2016-07-13T13:57:35Z","updated_at":"2016-07-13T13:57:35Z","html_url":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117#discussion_r70629376","pull_request_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117","_links":{"self":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/comments/70629376"},"html":{"href":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117#discussion_r70629376"},"pull_request":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117","id":77264833,"html_url":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117","diff_url":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117.diff","patch_url":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117.patch","issue_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/117","number":117,"state":"open","locked":false,"title":"ToCode Solution: תרגול מבני נתונים","user":{"login":"mashaGC","id":20282505,"avatar_url":"https://avatars.githubusercontent.com/u/20282505?v=3","gravatar_id":"","url":"https://api.github.com/users/mashaGC","html_url":"https://github.com/mashaGC","followers_url":"https://api.github.com/users/mashaGC/followers","following_url":"https://api.github.com/users/mashaGC/following{/other_user}","gists_url":"https://api.github.com/users/mashaGC/gists{/gist_id}","starred_url":"https://api.github.com/users/mashaGC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mashaGC/subscriptions","organizations_url":"https://api.github.com/users/mashaGC/orgs","repos_url":"https://api.github.com/users/mashaGC/repos","events_url":"https://api.github.com/users/mashaGC/events{/privacy}","received_events_url":"https://api.github.com/users/mashaGC/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-07-13T10:24:59Z","updated_at":"2016-07-13T13:57:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117/commits","review_comments_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117/comments","review_comment_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/117/comments","statuses_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/statuses/8ba6b7b17e252f06d693b9798bc838a46599aac9","head":{"label":"mashaGC:sol-python-verint.datastructures-lab","ref":"sol-python-verint.datastructures-lab","sha":"8ba6b7b17e252f06d693b9798bc838a46599aac9","user":{"login":"mashaGC","id":20282505,"avatar_url":"https://avatars.githubusercontent.com/u/20282505?v=3","gravatar_id":"","url":"https://api.github.com/users/mashaGC","html_url":"https://github.com/mashaGC","followers_url":"https://api.github.com/users/mashaGC/followers","following_url":"https://api.github.com/users/mashaGC/following{/other_user}","gists_url":"https://api.github.com/users/mashaGC/gists{/gist_id}","starred_url":"https://api.github.com/users/mashaGC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mashaGC/subscriptions","organizations_url":"https://api.github.com/users/mashaGC/orgs","repos_url":"https://api.github.com/users/mashaGC/repos","events_url":"https://api.github.com/users/mashaGC/events{/privacy}","received_events_url":"https://api.github.com/users/mashaGC/received_events","type":"User","site_admin":false},"repo":{"id":62560642,"name":"python-examples-verint-2016-07","full_name":"mashaGC/python-examples-verint-2016-07","owner":{"login":"mashaGC","id":20282505,"avatar_url":"https://avatars.githubusercontent.com/u/20282505?v=3","gravatar_id":"","url":"https://api.github.com/users/mashaGC","html_url":"https://github.com/mashaGC","followers_url":"https://api.github.com/users/mashaGC/followers","following_url":"https://api.github.com/users/mashaGC/following{/other_user}","gists_url":"https://api.github.com/users/mashaGC/gists{/gist_id}","starred_url":"https://api.github.com/users/mashaGC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mashaGC/subscriptions","organizations_url":"https://api.github.com/users/mashaGC/orgs","repos_url":"https://api.github.com/users/mashaGC/repos","events_url":"https://api.github.com/users/mashaGC/events{/privacy}","received_events_url":"https://api.github.com/users/mashaGC/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mashaGC/python-examples-verint-2016-07","description":"Python examples and exercises","fork":true,"url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07","forks_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/forks","keys_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/teams","hooks_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/hooks","issue_events_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/issues/events{/number}","events_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/events","assignees_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/assignees{/user}","branches_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/branches{/branch}","tags_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/tags","blobs_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/git/refs{/sha}","trees_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/statuses/{sha}","languages_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/languages","stargazers_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/stargazers","contributors_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/contributors","subscribers_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/subscribers","subscription_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/subscription","commits_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/commits{/sha}","git_commits_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/git/commits{/sha}","comments_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/comments{/number}","issue_comment_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/issues/comments{/number}","contents_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/contents/{+path}","compare_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/merges","archive_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/downloads","issues_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/issues{/number}","pulls_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/pulls{/number}","milestones_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/milestones{/number}","notifications_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/labels{/name}","releases_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/releases{/id}","deployments_url":"https://api.github.com/repos/mashaGC/python-examples-verint-2016-07/deployments","created_at":"2016-07-04T12:31:31Z","updated_at":"2016-07-04T12:31:32Z","pushed_at":"2016-07-13T13:41:08Z","git_url":"git://github.com/mashaGC/python-examples-verint-2016-07.git","ssh_url":"git@github.com:mashaGC/python-examples-verint-2016-07.git","clone_url":"https://github.com/mashaGC/python-examples-verint-2016-07.git","svn_url":"https://github.com/mashaGC/python-examples-verint-2016-07","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"ynonp:master","ref":"master","sha":"7ecd83de5ed593f7627338fa885021af9d73028e","user":{"login":"ynonp","id":128594,"avatar_url":"https://avatars.githubusercontent.com/u/128594?v=3","gravatar_id":"","url":"https://api.github.com/users/ynonp","html_url":"https://github.com/ynonp","followers_url":"https://api.github.com/users/ynonp/followers","following_url":"https://api.github.com/users/ynonp/following{/other_user}","gists_url":"https://api.github.com/users/ynonp/gists{/gist_id}","starred_url":"https://api.github.com/users/ynonp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ynonp/subscriptions","organizations_url":"https://api.github.com/users/ynonp/orgs","repos_url":"https://api.github.com/users/ynonp/repos","events_url":"https://api.github.com/users/ynonp/events{/privacy}","received_events_url":"https://api.github.com/users/ynonp/received_events","type":"User","site_admin":false},"repo":{"id":62203857,"name":"python-examples-verint-2016-07","full_name":"ynonp/python-examples-verint-2016-07","owner":{"login":"ynonp","id":128594,"avatar_url":"https://avatars.githubusercontent.com/u/128594?v=3","gravatar_id":"","url":"https://api.github.com/users/ynonp","html_url":"https://github.com/ynonp","followers_url":"https://api.github.com/users/ynonp/followers","following_url":"https://api.github.com/users/ynonp/following{/other_user}","gists_url":"https://api.github.com/users/ynonp/gists{/gist_id}","starred_url":"https://api.github.com/users/ynonp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ynonp/subscriptions","organizations_url":"https://api.github.com/users/ynonp/orgs","repos_url":"https://api.github.com/users/ynonp/repos","events_url":"https://api.github.com/users/ynonp/events{/privacy}","received_events_url":"https://api.github.com/users/ynonp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ynonp/python-examples-verint-2016-07","description":"Python examples and exercises","fork":false,"url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07","forks_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/forks","keys_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/teams","hooks_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/hooks","issue_events_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/events{/number}","events_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/events","assignees_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/assignees{/user}","branches_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/branches{/branch}","tags_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/tags","blobs_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/git/refs{/sha}","trees_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/statuses/{sha}","languages_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/languages","stargazers_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/stargazers","contributors_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/contributors","subscribers_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/subscribers","subscription_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/subscription","commits_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/commits{/sha}","git_commits_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/git/commits{/sha}","comments_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/comments{/number}","issue_comment_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/comments{/number}","contents_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/contents/{+path}","compare_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/merges","archive_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/downloads","issues_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues{/number}","pulls_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls{/number}","milestones_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/milestones{/number}","notifications_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/labels{/name}","releases_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/releases{/id}","deployments_url":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/deployments","created_at":"2016-06-29T07:06:57Z","updated_at":"2016-07-06T08:47:02Z","pushed_at":"2016-07-13T13:49:00Z","git_url":"git://github.com/ynonp/python-examples-verint-2016-07.git","ssh_url":"git@github.com:ynonp/python-examples-verint-2016-07.git","clone_url":"https://github.com/ynonp/python-examples-verint-2016-07.git","svn_url":"https://github.com/ynonp/python-examples-verint-2016-07","homepage":null,"size":345,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":39,"forks":33,"open_issues":39,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117"},"html":{"href":"https://github.com/ynonp/python-examples-verint-2016-07/pull/117"},"issue":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/117"},"comments":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/ynonp/python-examples-verint-2016-07/statuses/8ba6b7b17e252f06d693b9798bc838a46599aac9"}}}}
{"actor":{"display_login":"szabgab"}}