Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -54,8 +54,31 @@ def validate_word(word, board):
|
|
54 |
return True
|
55 |
return False
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
def
|
59 |
"""Main function for playing the Boggle game"""
|
60 |
st.title("Boggle Game")
|
61 |
st.write("Find as many words as possible by connecting adjacent letters on the board within the time limit.")
|
|
|
54 |
return True
|
55 |
return False
|
56 |
|
57 |
+
def boggle(size):
|
58 |
+
"""Main function for playing the Boggle game"""
|
59 |
+
st.title("Boggle Game")
|
60 |
+
st.write("Find as many words as possible by connecting adjacent letters on the board.")
|
61 |
+
st.write("Words must be at least three letters long and can only be used once.")
|
62 |
+
board = generate_board(size)
|
63 |
+
board_df = pd.DataFrame(board)
|
64 |
+
st.write(board_df)
|
65 |
+
words = set()
|
66 |
+
|
67 |
+
with st.form(key="new_word"):
|
68 |
+
new_word = st.text_input("Enter a new word:")
|
69 |
+
if st.form_submit_button("Submit"):
|
70 |
+
if len(new_word) >= 3 and new_word not in words and validate_word(new_word.upper(), board):
|
71 |
+
words.add(new_word)
|
72 |
+
st.write(f"Added {new_word} to the list of words!")
|
73 |
+
elif new_word in words:
|
74 |
+
st.write("Word already used!")
|
75 |
+
else:
|
76 |
+
st.write("Invalid word. Try again.")
|
77 |
+
|
78 |
+
st.write("Here are your words:")
|
79 |
+
st.write(words)
|
80 |
|
81 |
+
def boggle_old(size, time_limit):
|
82 |
"""Main function for playing the Boggle game"""
|
83 |
st.title("Boggle Game")
|
84 |
st.write("Find as many words as possible by connecting adjacent letters on the board within the time limit.")
|