By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

to make worrd puzzle through python programming

P: 4
is there any way we can make word puzzle using python programming in 2 dimensional way???
i made 'file_name.txt' containing (asdfghklo)
and i need to make some valid words from that txt file (sad,had,gas), which i saved on a 'input_word.txt', can we make our program that read these two files and ??
i got this so far:-


'''Original puzzle:
| a | s | d |
| f | g | h |
| k | l | o |
Valid words in the puzzle are:
sad
had
gas'''

AND IM TRYING TO GET WORD PUZZLE LIKE THIS TO FIND WORD PUZZLE HORIZONTALLY, VERTICALLY, AS WELL AS DIAGONALLY:-

'''Solved puzzle:
| G | S | |
| H | A | D |
| | D | S |'''



PLEASE HELP ME IF THERE IS SOME WAY TO DO SO...
THANK YOU IN ADVANCE
Oct 3 '14 #1

✓ answered by dwblas

What about dog and fog and log and dad and lad, etc. You will have to use a dictionary to tell if a word is valid or not since there are words that many of us wouldn't recognize. You can use permutations, so using the following code, every word would be checked against a dictionary to see it is a valid word.
Expand|Select|Wrap|Line Numbers
  1. from itertools import permutations
  2.  
  3. ##  ----- three letter words
  4. for item in permutations("asdfgho", 3):
  5.     print "".join(item) 
And a link to Python's Sudoku programs since I am not at all sure if you are asking about it or not.

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 618
What about dog and fog and log and dad and lad, etc. You will have to use a dictionary to tell if a word is valid or not since there are words that many of us wouldn't recognize. You can use permutations, so using the following code, every word would be checked against a dictionary to see it is a valid word.
Expand|Select|Wrap|Line Numbers
  1. from itertools import permutations
  2.  
  3. ##  ----- three letter words
  4. for item in permutations("asdfgho", 3):
  5.     print "".join(item) 
And a link to Python's Sudoku programs since I am not at all sure if you are asking about it or not.
Oct 3 '14 #2

P: 4
can we do this by using a function?im new to python, and i want to know if there is some way to do it by using function.
thank you.
Oct 8 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.