diff --git a/README.md b/README.md index 6a066368..acf72d82 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # AdaGrams +## Collaboration Plan: + + - EST Time Zone/ Best time to meet are Ada Breaks & Evenings + - WRAP UP at 9PM. Hard Stop at 10 PM. + - Preferred Method of Contact: Slack or Email(defer to Slack for contact details) + - Keep each other informed on time block status + - Body-Doubling w/ or w/o Music + - DUE FRIDAY 11:30 EST + - Meeting times shared via Google Calendar + - + ## Skills Assessed - Following directions and reading comprehension @@ -95,16 +106,16 @@ $ pip install -r requirements.txt Summary of one-time project setup: One person: -- [ ] Fork the project respository -- [ ] Invite team members to the respository +- [X] Fork the project respository +- [X] Invite team members to the respository All team members: -- [ ] `cd` into your `projects` folder -- [ ] Clone the project onto your machine -- [ ] `cd` into the `adagrams-py` folder -- [ ] Create the virtual environment `venv` -- [ ] Activate the virtual environment `venv` -- [ ] Install the dependencies with `pip` +- [X] `cd` into your `projects` folder +- [X] Clone the project onto your machine +- [X] `cd` into the `adagrams-py` folder +- [X] Create the virtual environment `venv` +- [X] Activate the virtual environment `venv` +- [X] Install the dependencies with `pip` ## Project Development Workflow @@ -289,5 +300,5 @@ Implement a function called `get_highest_word_score` in `game.py`. This method s - If the there are multiple words that are the same score and the same length, pick the first one in the supplied list - +- Here is a test line. diff --git a/adagrams/game.py b/adagrams/game.py index 5fb37b11..cd20adb6 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,11 +1,128 @@ -def draw_letters(): - pass +def mystery(numbers): + index = 0 + while index < len(numbers): + numbers[index] *= 2 + index += 1 + + return numbers -def uses_available_letters(word, letter_bank): - pass +nums = [1, 2, 3, 4, 5] +mystery(nums) -def score_word(word): - pass +print(nums[3]) -def get_highest_word_score(word_list): - pass \ No newline at end of file + + + + + +# def get_fire_students(students): +# ''' +# INPUT: A list of dictionaries with the "name" and "class" key-value pairs. +# Example: get_fire_students([{ "name": "Ada", "class": "fire"}, { "name": "Taylor", "class": "earth" }]) +# RETURN VALUE: A list of dictionaries with **only** the students in the "fire" class. +# ''' +# temp = [] +# students = students.copy() +# +# while students: +# student = students.pop() +# if student["class"] == "fire": +# temp.append(student) +# # +# # while temp: +# # students.append(temp.pop()) +# print(students) +# return students +# +# +# get_fire_students([{ "name": "Ada", "class": "fire"}, { "name": "Taylor", "class": "earth" }]) + + cur_score = score_word(word) + word_len = -len(word) + has_10 = word_len == -10 # True if word length is 10. + +# def hamming_distance(strand1, strand2): +# count_of_differences = 0 +# index = 0 +# +# +# if len(strand1) == 0 or len(strand2) == 0: +# raise ValueError("One of your inputs is invalid, please try again.") +# +# +# for letter in strand2: +# # if letter[index] not in strand2[index]: +# count_of_differences += 1 +# index += 1 +# +# +# return count_of_differences +# +# print(hamming_distance("GAGCCTACTAACGGGAT", "CATCGTAATGACGGCCT")) +# print(hamming_distance("GAG", "GAG")) +# print(hamming_distance("GAG", "")) + + +# def score(word): +# +# point_system = { +# ("A", "E", "I", "O", "U", "L", "N", "R", "S", "T"): 1, +# ("D", "G"): 2, +# ("B", "C", "M", "P"): 3, +# ("F", "H", "V", "W", "Y"): 4, +# "K": 5, +# ("J", "X"): 8, +# ("Q", "Z"): 10 +# } +# +# total_score = 0 +# +# try: +# word = word.upper() +# except AttributeError as err: +# return "You've entered a number, please enter a letter and try again." +# except Exception: +# print("You've entered a number, please enter a letter and try again.") +# raise +# +# letters_of_word = list(word) +# +# if len(letters_of_word) == 0: +# return None +# +# else: +# for letter in letters_of_word: +# for key,value in point_system.items(): +# if letter in key: +# total_score += value +# return total_score +# +# +# # print(score("Dog")) +# # print(score(123)) +# print(score("supercalifragilisticexpialidocious")) +# print(score('')) + + +# example input 1: "supercalifragilisticexpialidocious" +# expected output 1: 56 + +# example input 2: "Français" +# expected output 2: +# +# def test_ridiculous_words(): +# # arrange +# word = "supercalifragilisticexpialidocious" +# # act +# result = score(word) +# # assert +# assert result = 56 +# +# def test_letter_not_in_English(): +# # arrange +# word = "Français" +# # act +# result = score(word) +# # assert +# result = \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 203b773f..4fa80ac8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,11 @@ attrs==20.3.0 iniconfig==1.1.1 +numpy==1.23.3 packaging==20.8 pluggy==0.13.1 py==1.10.0 pyparsing==2.4.7 pytest==7.1.1 +scipy==1.9.1 toml==0.10.2 +tomli==2.0.1 diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 25ef73e7..6304e024 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -1,4 +1,7 @@ import pytest +from scipy import stats as stats +from pprint import pprint +from collections import Counter from adagrams.game import draw_letters @@ -65,3 +68,64 @@ def test_letter_not_selected_too_many_times(): # Assert for letter in letters: assert letter_freq[letter] <= LETTER_POOL[letter] + +def test_chi_square_frequencies(): + + # this *should* work + # technique adapted from + # http://practicalcryptography.com/cryptanalysis/text-characterisation/chi-squared-statistic/ + # TODO: get someone with better stats experience to + # double-check this + + # arrange/act + + + # normalize LETTER_POOL frequencies + pool_sum = sum(LETTER_POOL.values()) + pool_freqs = {letter : (value / pool_sum) for letter,value in LETTER_POOL.items()} + + # collect our sample + sample_counter = Counter() + for i in range (500): + letters = draw_letters() + for letter in letters: + sample_counter[letter] += 1 + + # ------------- + # Test the test + # ------------- + # + # Uncomment for big fail! + + # Add a bunch of extra "Q" tiles! + # sample_counter['Q'] *= 2 + + # Take away some "E" tiles! + # sample_counter['E'] /= 2 + + # organize our expected and sample + # into parallel lists + expected = [] + sample = [] + total = sample_counter.total() + for letter, freq in pool_freqs.items(): + expected.append(freq * total) + sample.append(sample_counter[letter]) + + # pprint(sample) + # pprint(expected) + # pprint(sum(expected)) + chi = stats.chisquare(sample, expected) + pprint(chi.pvalue) + + # low is bad, high is good + assert chi.pvalue > 0.05 + + + + + + + + + diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index a5170d8a..bf39d899 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -13,6 +13,8 @@ def test_uses_available_letters_true_word_in_letter_bank(): # Assert assert is_valid == True + # Passes + def test_uses_available_letters_false_word_in_letter_bank(): # Arrange letters = ["D", "O", "X", "X", "X", "X", "X", "X", "X", "X"] @@ -24,6 +26,8 @@ def test_uses_available_letters_false_word_in_letter_bank(): # Assert assert is_valid == False + # Passes + def test_uses_available_letters_false_word_overuses_letter(): # Arrange letters = ["A", "X", "X", "X", "X", "X", "X", "X", "X", "X"]