Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:52:45+00:00 2026-05-31T22:52:45+00:00

I almost done my coding for a specific program i have. I just need

  • 0

I almost done my coding for a specific program i have. I just need help with one final piece.
The program takes a word and changes one letter to more closely resemble a target word.
The changed word must exist within a dictionary that I’ve been given.

my function is as such:

def changeling(word,target,steps):
    holderlist=[]
    i=0
    if steps==0 and word!=target:
        return None

        return holderlist
    if len(word)!=len(target):
        return None

    if steps!=-1:
        for items in wordList:
            if len(items)==len(word):
                i=0

                if items!=word:
                    for length in items:


                        if i==1:


                            if items[1]==target[1] and items[0]==word[0] and items[2:]==word[2:]:
                                if items==target:
                                    print "Target Achieved"


                                holderlist.append(items)
                                flatten_result(holderlist,target)



                                holderlist.append(changeling(items,target,steps-1))


                        elif i>0 and i<len(word)-1 and i!=1:
                            if items[i]==target[i] and items[0:i]==word[0:i] and items[i+1:]==word[i+1:]:
                                if items==target:
                                    print "Target Achieved"
                                holderlist.append(items)
                                flatten_result(holderlist,target)

                                holderlist.append(changeling(items,target,steps-1))



                        elif i==0:
                            if items[0]==target[0] and items[1:]==word[1:]:
                                if items==target:
                                    print "Target Achieved"
                                holderlist.append(items)
                                flatten_result(holderlist,target)

                                holderlist.append(changeling(items,target,steps-1))



                        elif i==len(word)-1:
                            if items[len(word)-1]==target[len(word)-1] and items[0:len(word)-1]==word[0:len(word)-1]:
                                if items==target:
                                    print "Target Achieved"

                                holderlist.append(items)

                                holderlist.append(changeling(items,target,steps-1))

                        else:
                            return None

                        i+=1

    return holderlist

my helper function is this:

def flatten_result(nested_list, target):
    if not nested_list:
        return None
    for word, children in zip(nested_list[::2], nested_list[1::2]):
        if word == target:
            return [word]
        children_result = flatten_result(children, target)
        if children_result:
            return [word] + children_result
    return None

the flatten_result function allows me to represent lists within lists as a single lists, and also backtracks through my program. How do I implement flatten result within changeling? I can only do it in the python shell as of yet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:52:46+00:00Added an answer on May 31, 2026 at 10:52 pm

    Basically,

    def word_chain(chain_so_far, target, dictionary):
        last_word = chain_so_far[-1]
        if last_word == target:
            print chain_so_far
            return True
        for word in dictionary:
            if have_one_different_letter(word, last_word) and word not in chain_so_far:
                word_chain(chain_so_far + [word], target)
    

    Call it like this word_chain(['love'], 'hate', your dict). Let us know if you need help with have_one_different_letter().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am almost done with my project, but have one final looming problem that
I'm almost done with this, just a few last hiccups. I now need to
I'm almost done coding my project and I have come across 1 to 2
When I am almost done with my application, one final thing is disturbing me.
I have a script and I'm almost done but I get this error and
I am creating one construction website in core PHP. It is almost done.But now
ok here we go last part almost done! one error to go hmmmmm. This
I am working on http://rubyquiz.com/quiz28.html and am almost done except for one little bug.
so I'm creating a menu, and I'm almost done with submenu, but I have
I have a simple CRUD website in development process, almost done. I was asked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.