Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCC02 packdl #810

Open
wants to merge 1 commit into
base: community
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions 02/packdl/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from collections import namedtuple

Letter = namedtuple("Letter", "name amount value")


def _load_words():
with open("dictionary.txt") as f:
return set([word.strip().lower() for word in f.read().split()])


DICTIONARY = _load_words()
assert len(DICTIONARY) == 234371


# generated with https://github.com/pybites/blog_code/blob/master/BeautifulSoup/scrabble_distribution.py
distribution = [
Letter(name="A", amount="9", value="1"),
Letter(name="B", amount="2", value="3"),
Letter(name="C", amount="2", value="3"),
Letter(name="D", amount="4", value="2"),
Letter(name="E", amount="12", value="1"),
Letter(name="F", amount="2", value="4"),
Letter(name="G", amount="3", value="2"),
Letter(name="H", amount="2", value="4"),
Letter(name="I", amount="9", value="1"),
Letter(name="J", amount="1", value="8"),
Letter(name="K", amount="1", value="5"),
Letter(name="L", amount="4", value="1"),
Letter(name="M", amount="2", value="3"),
Letter(name="N", amount="6", value="1"),
Letter(name="O", amount="8", value="1"),
Letter(name="P", amount="2", value="3"),
Letter(name="Q", amount="1", value="10"),
Letter(name="R", amount="6", value="1"),
Letter(name="S", amount="4", value="1"),
Letter(name="T", amount="6", value="1"),
Letter(name="U", amount="4", value="1"),
Letter(name="V", amount="2", value="4"),
Letter(name="W", amount="2", value="4"),
Letter(name="X", amount="1", value="8"),
Letter(name="Y", amount="2", value="4"),
Letter(name="Z", amount="1", value="10"),
]

POUCH = list("".join(list(letter.name * int(letter.amount) for letter in distribution)))
assert len(POUCH) == 98 # no wildcards in this simple game


LETTER_SCORES = dict(
zip(
[letter.name for letter in distribution],
[int(letter.value) for letter in distribution],
)
)

assert LETTER_SCORES["A"] == 1
assert LETTER_SCORES["Q"] == 10
assert sum(LETTER_SCORES.values()) == 87
Loading