Created
November 11, 2013 05:19
Revisions
-
SharkIng created this gist
Nov 11, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import WordLookup def changeling(initial,goal,steps): first=initial last=goal ### The Word Check Function Part ### if WordLookup.lookup(initial) == False or WordLookup.lookup(goal) == False: return "Not in the List" if initial.islower() == False or goal.islower() == False: return "Not a lower case" if steps < 0: return "Steps is invaild!!" if len(first) != len(last): return "The Length of initial word and goal word is not same, cannot make any change..!!" if steps == 0: if first == last: return last else: return "No Steps" ### The Word Check Function Part END ### ### The changeling Function Start ### i=1 if WordLookup.lookup(last[0]+first[1:]) and last[0]+first[1:]!=first : initial=last[0]+first[1:] while i!=len(first): if WordLookup.lookup(first[:i-1]+last[i-1]+first[i:]) and first[:i-1]+last[i-1]+first[i:]!=first: initial=first[:i-1]+last[i-1]+first[i:] i+=1 if WordLookup.lookup(first[:len(first)-1]+last[len(initial)-1]) and first[:len(first)-1]+last[len(first)-1]!=first : initial=first[:len(first)-1]+last[len(initial)-1] new = changeling(initial,goal,steps-1) if new: return first +" , "+ changeling(initial,goal,steps-1) else: return None ### The changeling Function End ###