A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
I am trying ps 6 and I am stuck in problem 4. I don't know how to find all the subset of a string, can anyone tell me?
anonymous
 4 years ago
I am trying ps 6 and I am stuck in problem 4. I don't know how to find all the subset of a string, can anyone tell me?

This Question is Closed

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.0When I read that question, I was a bit afraid too. Then I thought that this problem had probably been solved by someone else. And I was right: in Python, you can use the itertools library to solve this kind of problems: http://docs.python.org/library/itertools.html#moduleitertools And that's how I used it: http://pastebin.com/L42X6DP6

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Thank you maitre_kaio

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0i just found another cool one, it is hard to parse but it looks like implements the algorithm listed in the wikipedia powerset entry http://dpaste.com/694742/

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Is it the point to just find a tool that does the work you want?How deeply should you understand how each works? I cannot tell from the pset wording.Seems you could just find an example or previous tool/module to do whatever you like without really knowing the innards.I do that to some extent but feel like I am missing the basics.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0i like to understand all that i can. at least one of the 'lessons' for this pset is to show how different data types can affect execution and how preprocessing data can affect execution. Itertools.combinations and permutations were not available when this course was taught  but everyone taking the course could have easily searched the internet or the library for algorithms. Never hurts to try it yourself and learn something doing it.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Maitre_kaio, I have a similar piece to yours but why do you need .join?I am using itertools.combination on a the list,current_hand, is your 'word' a string?Seems the results from each result of itertools will be a string which can be appended to the list,letter_combinations.OK,tell me what I am doing and thinking incorrectly. http://codepad.org/IpGN88Sr

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0@gambit did you read the documentation for itertools.combination?
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.