Skip to content

Commit

Permalink
duplicate char detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jensenpat committed Sep 28, 2021
1 parent 68646fb commit 1b29fca
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions wordsearch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os
import sys
import random
import _curses,curses
import curses
from copy import deepcopy
from curses.textpad import rectangle

Expand Down Expand Up @@ -282,6 +282,7 @@ def Main(window):

# Set up coordinates to track scoring and completed words
adjacent = 0
duplicate = 0
ScoreList = []
CompletedList = []

Expand Down Expand Up @@ -382,24 +383,32 @@ def Main(window):
elif key == ord(' '): # space bar
cy, cx = curses.getsyx() # get y/x
cur = [cy, cx]
cur2 = (cy, cx)
duplicate = 0

# Check for existing ScoreList, then check if we are y +/- 1, or x +/- 2 away
if ScoreList:
# Get list of adjacencies
res = list(adjac(ScoreList[-1]))

for member in res:
if cur in res:
if cur in res:
adjacent = 1
else:
else:
adjacent = 0
curses.beep()
curses.beep()
curses.beep()
else:
adjacent = 1

if adjacent == 1:
# Check for existing ScoreList, then check if this character is in it already
if ScoreList:
if cur2 in ScoreList:
curses.beep()
duplicate = 1

if adjacent == 1 and not duplicate == 1:
# Add coords for each letter we are adding
ScoreList.append((cy, cx))

Expand Down

0 comments on commit 1b29fca

Please sign in to comment.