473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

to make worrd puzzle through python programming

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.

2 1689
dwblas
626 Expert 512MB
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
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

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

Similar topics

2
by: asdf sdf | last post by:
i'm interested in using python for win32 COM automation and sysadmin scripts. many recommendations for Mark Hammond's Python Programming on Win32. but it was published four and half years ago....
2
by: dm | last post by:
Hi: I want to program using VB mixed python. who have any experience? and hwo to do ? thanks dm
4
by: Mark | last post by:
Hello. I am new to programming and Python and was wondering if someone could help get me started. I picked Python to start learning to prgram because of some things I have read about it (easy to...
0
by: Ram Ravi | last post by:
I would like to get the SourceCode for Rick Hightower book "Python programming with Java Classes" (jython book). I went to rickhightower.com and got Connection refused message. Does somebody...
13
by: Brian Quinlan | last post by:
I've decided that it would be be fun to host a weekly Python programming contest. The focus will be on algorithms that require a bit of thought to design but not much code to implement. I'm...
0
by: Tin | last post by:
Hi, I have listed Python Programming Patterns ISBN:0130409561 on ebay.co.uk A brand new with really cheap price-4.99 If you are interested, go and have a look at www.ebay.co.uk and locate...
23
by: herraotic | last post by:
I have been getting ready to learn programming for a long time, installed a GNU/Linux operating system, learnt the ins and outs but I think it is time to pick up a book and learn to now program. ...
11
by: John Coleman | last post by:
Greetings, My copy of the second edition of Chun's "Core Python Programming" just arrived from Amazon on Friday. What really jumped out at me is an interesting feature about how it sequences its...
2
by: Ali seaman | last post by:
Hi all, I have a question on how to Create a graphical user interface with Python programming language and integrate it with CATIA V5-API ?( I am working in the Field of Mechanical engineering...
1
by: PyGIS | last post by:
Hi friends : i'm beginner in python programming . i red learning python book ( o'relly) . it was very useful and interesting for me . now i want to read more advanced book (intermediate ) for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.