to make worrd puzzle through python programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pythonlearner
    New Member
    • Sep 2014
    • 4

    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
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    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.
    Code:
    from itertools import permutations
    
    ##  ----- three letter words
    for item in permutations("asdfgho", 3):
        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.

    Comment

    • pythonlearner
      New Member
      • Sep 2014
      • 4

      #3
      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.

      Comment

      Working...