Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wordsearch
#2
At the end of your code, you have a for loop on direction/tuple (BTW, you shouldn't name a variable tuple, tuple is a built in function that is lost when you do that). Within that, you have a for loop on words. You want to reverse that: you want the first/outer loop to be on words, and the second/inner loop to be on direction/tuple.

Now, that means you are going to be calculating the string variable a lot more than you were. If that is a problem, I would recommend calculating all of the strings ahead of time. You have a dictionary of directions to tuples, just make one of direction to string. Then you can just access them from the dictionary each loop rather than recalculating them.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
wordsearch - by rontoto - Nov-19-2019, 11:23 AM
RE: wordsearch - by ichabod801 - Nov-19-2019, 02:45 PM
RE: wordsearch - by rontoto - Nov-19-2019, 04:08 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020