I finished problem set 5, and, surprisingly, it works:) http://pastebin.com/FX0tUHSq http://pastebin.com/zLiKsV9t
Congrats on finishing ps 5. I struggled with Ghost recently so my interest in it is still fresh...If I understand your code correctly, you are going through each word in wordlist and adding slices of those words (the size of which depends on the length of the fragment) to another list called player_wordlist. This is done each time a player adds another letter...Out of curiousity, why did you choose the iterative approach instead of the binary, recursive one?
Thank you @dbwonders Couldn't think of the problem recursively. This is why I implemented it iteratively. Have you done it recursively? Would be interesting to look at your implementation.
Can't claim any originality. ..The code is based on one of the class handouts dealing with different search options and Big Oh. http://pastebin.com/ZNeFjcVE. I originally had an argument to keep track of the number of calls as well as some print commands. If I remember correctly it took about 15 calls per 'fragment.'
@dbwonders I can't open your paste is it public?
thank you, now I can read it ah, you discovered the methon startswith() =)
Looking back, I can see places where things could be tidied up, but I was focused (obsessed?) on the search... http://pastebin.com/PXpvB1Qr by the way, 'first' and 'last' are declared in def ghost(). Sorry...
Join our real-time social learning platform and learn together with your friends!