File size: 4,037 Bytes
369a349
 
 
743de20
00f210c
743de20
e78e45b
743de20
 
 
 
 
8400f85
743de20
 
eb2291e
743de20
c754616
743de20
eb2291e
743de20
eb2291e
743de20
eb2291e
c754616
eb2291e
c754616
eb2291e
743de20
c754616
 
 
 
 
 
743de20
ba06c9f
c754616
743de20
 
c754616
 
 
 
 
 
 
 
 
 
 
 
 
743de20
f1073c0
008996e
 
 
 
 
 
f1073c0
c754616
 
f1073c0
c754616
 
 
2ee8757
c754616
 
 
2ee8757
c754616
743de20
c754616
2ee8757
c754616
 
 
2ee8757
c754616
 
 
2ee8757
c754616
 
ba06c9f
 
cc2c129
 
ba06c9f
2b816f9
cc2c129
ba06c9f
2b816f9
cc2c129
ba06c9f
2b816f9
cc2c129
ba06c9f
2b816f9
cc2c129
ba06c9f
2b816f9
cc2c129
 
 
 
 
4ee3288
 
 
2f16975
4ee3288
19457ec
e78e45b
 
 
39bf55d
 
19457ec
6decdc5
 
8c1bc7e
b43c9d6
289ba75
 
39bf55d
 
289ba75
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import streamlit as st 
import nltk 
from nltk.corpus import words

st.title("Word Games") 

@st.cache # cache download processes so they only execute once with same inputs
def download():
    nltk.download('words')
download()


[a,b,c,d,e,f,g] = st.columns(7)

with a:
    first_letter = st.text_input(label="1st",value = 's')
with b:
    second_letter = st.text_input(label="2nd", value = 'e')
with c:
    third_letter = st.text_input(label="3rd", value = 'a')
with d:
    fourth_letter = st.text_input(label="4th", value = 'l')
with e:
    fifth_letter = st.text_input(label="5th", value = 'o')
with f:
    sixth_letter = st.text_input(label="6th", value = 't')
with g:
    seventh_letter = st.text_input(label="7th", value = 'c')

clue2 = first_letter+second_letter
clue3 = first_letter+second_letter+third_letter
clue4 = first_letter+second_letter+third_letter+fourth_letter
clue5 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
clue6 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter 
clue7 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter+seventh_letter 



exclusions = st.text_input(label="exclusions")

clue_result2 = []
clue_result3 = []
clue_result4 = []
clue_result5 = []
clue_result6 = []
clue_result7 = []

two_letters = [word for word in words.words() if len(word)==2 ]
three_letters = [word for word in words.words() if len(word)==3 ]
four_letters = [word for word in words.words() if len(word)==4 ]
five_letters = [word for word in words.words() if len(word)==5 ]
six_letters = [word for word in words.words() if len(word)==6 ]
seven_letters = [word for word in words.words() if len(word)==7 ]

#score
score2=0
score3=0
score4=0
score5=0
score6=0
score7=0

for word in two_letters:
 if all(c in word for c in clue2) and not any(c in word for c in exclusions):
   score2+=1
   clue_result2.append(word)
for word in three_letters:
 if all(c in word for c in clue3) and not any(c in word for c in exclusions):
   score3+=1
   clue_result3.append(word)
for word in four_letters:
 if all(c in word for c in clue4) and not any(c in word for c in exclusions):
   score4+=1
   clue_result4.append(word)
for word in five_letters:
 if all(c in word for c in clue5) and not any(c in word for c in exclusions):
   score5+=1
   clue_result5.append(word)
for word in six_letters:
 if all(c in word for c in clue6) and not any(c in word for c in exclusions):
   score6+=1
   clue_result6.append(word)
for word in seven_letters:
 if all(c in word for c in clue7) and not any(c in word for c in exclusions):
   score7+=1
   clue_result7.append(word)
   
st.markdown("### Words and Scores for Selected Letters")
st.write("Words for ",clue2, clue_result2)
tscore2=score2 * 2
st.write("Score for 2 letter words = ", (tscore2))
st.write("Words for ",clue3, clue_result3)
tscore3=score3 * 3
st.write("Score for 3 letter words = ", (tscore3))
st.write("Words for ",clue4, clue_result4)
tscore4=score4 * 4
st.write("Score for 4 letter words = ", (tscore4))
st.write("Words for ",clue5, clue_result5)
tscore5=score5 * 5
st.write("Score for 5 letter words = ", (tscore5))
st.write("Words for ",clue6, clue_result6)
tscore6=score6 * 6
st.write("Score for 6 letter words = ", (tscore6))
st.write("Words for ",clue7, clue_result7) 
tscore7=score7 * 7
st.write("Score for 7 letter words = ", (tscore7))
  
  
totalScore =tscore2 + tscore3 + tscore4 + tscore5 + tscore6 + tscore7
st.write("Total Score = ", (totalScore))
  
  
import requests
from bs4 import BeautifulSoup as soup
import lxml
import lxml.etree as xml


@st.cache # cache download processes so they only execute once with same inputs
def define(word):
  url = f'https://www.dictionary.com/browse/{word}?s=t'
  r=requests.get(url)
  s = soup(r.content, features="lxml")
  for tag in s.find_all("meta"):
    if tag.get("property", None) == "og:description":
        content = tag.get("content", None)
        return content

    
for word in clue_result7:
  content = define(word)
  st.write(content)