-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lance-Drane <ldraneutk@gmail.com>
- Loading branch information
1 parent
84d54ad
commit 9ac3b17
Showing
5 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
from itertools import pairwise | ||
|
||
total = 0 | ||
for line in sys.stdin.readlines(): | ||
ok = True | ||
for pair in pairwise(sorted(line.split())): | ||
if pair[0] == pair[1]: | ||
ok = False | ||
break | ||
if ok: | ||
total += 1 | ||
|
||
print(total) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
337 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
|
||
|
||
def get_anagram_hash(word: str) -> (int, int, int): | ||
str_hash = 0 | ||
str_sum = 0 | ||
for char in word: | ||
# input file has only lowercase letters and whitespace | ||
char2int = ord(char) - 97 | ||
str_hash += 1 << char2int | ||
str_sum += char2int | ||
return len(word), str_hash, str_sum | ||
|
||
|
||
total = 0 | ||
for line in sys.stdin.readlines(): | ||
anagram_hashes = set() | ||
ok = True | ||
for word in line.split(): | ||
anagram_hash = get_anagram_hash(word) | ||
if anagram_hash in anagram_hashes: | ||
ok = False | ||
break | ||
anagram_hashes.add(anagram_hash) | ||
if ok: | ||
total += 1 | ||
|
||
print(total) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
231 |
Oops, something went wrong.