A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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?

  • This Question is Closed
  1. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    When 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#module-itertools And that's how I used it: http://pastebin.com/L42X6DP6

  2. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you maitre_kaio

  3. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i 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/

  4. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Is 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.

  5. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i 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 pre-processing 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.

  6. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Maitre_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

  7. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @gambit did you read the documentation for itertools.combination?

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.