0
Help for get permutations
Input = abc Output= a b c ab ac ...... Only by python
18 Answers
+ 6
Newrz ,
aspad🇮🇷 , ChaoticDawg ,
you are showing a really nice code to help someone solving a task. we all appreciate this very much!
(this is my personal statement - but it is not to criticize someone !!)
but there is an issue by giving a ready solution, when the op has not done and shown his attempt first.
as a part of the community i belive that learning by doing is more helpful, than just using a shared solution. we should act more as a mentor.
it is a very successful way when we are giving hints and help, so that the op is able to solve his task by himself. it would be great if you are going to help us to keep sololearn what it is:
▪︎a unique place to learn (we are a "self" learning platform!)
▪︎an absolutely great community that is willing to help other people
▪︎a great resource of people which has an unbelievable knowledge in coding and a long lasting experience
▪︎a place to meet people and to discuss with them all the possible points of view
thanks for your understanding
+ 3
name = 'abc'
lists = []
for i in name:
print(i)
lists.append(i)
try:
for m in lists:
print(m+lists[lists.index(m)+1])
except IndexError:
print(lists[0]+lists[-1])
print(name)
I think it will help you 🌹🌹🌹
+ 2
Yes
I think you want to get only
these result
a, b, c, ab, ac, bc, abc
I will work to solve it
Excuse me
+ 1
# Newrz from your previous post, where I give you a code answer for outputing all permutations without repetitions and outputing them in file(s):
from itertools import permutations
key = lambda v: (len(v), v)
s = input()
n = len(s)
print(*sorted(set(
''.join(v) for i in range(n)
for v in permutations(s,i+1)
),key=key),sep='\n')
# this one subset of previous code only output all permutations without repetitions...
+ 1
visph , Andrew Choi ,
thank you for your valuable comments to my post. there are different points of view, and that is great!
i always try to get people to be aktive and to do at least a try by themselves if they have questions or doubts. everything i work out for myself is valuable learning, and i will remember it also in future. and to be honest: google is quite good help, but it also takes some effort to pick out the right things. if i use just copy and paste, there is no need to dive into it, and it is worthless short-term information. that is information, but not knowledge.
i am saying this because i have a lot of experience in eduction (pupil, students, adults) , since i was 24 years working as s teacher for computer science in the field of programming and office applications.
I'm not giving up hope that sololearn will remain what it always was: a self-learner platform with a great community.
happy coding!
0
Newrz
Use itertools library to get permutations.
https://www.askpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK/permutations-and-combinations-using-python
0
I wonder how a manual implementation of this looks like.
0
aspad🇮🇷 This doesn't output all the permutations; bca, bac, etc. isn't displayed.
0
Lothar ,
i think how aspad🇮🇷 and ChaoticDawg in this post provides the most supportive way to respond to a question for help. i frequent stackoverflow quite often and i dont think i have ever seen anyone ask “show us your work” before providing an answer.
from a personal point of view when i see people post “show us your work” as the first response, it shows me that individual is more interested in policing other peoples post than helping, or imposing their thoughts and beliefs onto others.
i have personally gone through the lessons and more often than not the challenges have nothing to do with the lessons and i can understand why they are asking for help.
we all learn at different rates and i have personally learned best when someone provides me an answer with an explanation on how it works.
finally, everyone responding to a post is volunteering their own time and effort to help. i dont think anyone here has the right to tell them “you shouldnt post that because thats not right or that doesnt help”.
0
Andrew Choi I'm (and not) agree with you...
asking for showing attempt is basically a way to prevent lazy consumers to write code for them, without acquiring any knowmedge... the downside is that sometimes we doesn't help peoples who doesn't provide their code even if they trully deserve it ^^
however, my personal think is that's it's more important when the subjects are code coaches or other challenging tasks / homeworks... in the present case, I'm not sure if it was a homework or not (could sounds like), but I've also provided a ready made code (twice: one in the previous OP thread, and one here), even if that second thread would tend to prove that OP is lazy, as if he really would to learn he could have used my previous code at least for providing an attempt ;P
0
visph some and maybe most are lazy. if they decide to post something with minimal information and arent interested in learning, it only hurts them. a certificate from sololearn isnt going to earn anyone a six or seven figure job or allow them to monetize it. we all are volunteering our time and effort to respond to these posts. if i see a post that is lazy, i just ignore it. i dont wasted any time on their post. if they ask why they arent getting a response, i may then respond and let them know what they are missing. and if i really want to help someone that didnt provide all the information, i just politely ask them to provide so i can help them.
i have been on the learning side. its a hard cliff to climb when you dont know where to start, what programs to install, learning the syntax and structure. it is in itsef very daunting and discouraging. so when i see someone post “show us your work or effort” i find it very discouraging on a personal level and a waste of everyones time.
0
visph i know you are a frequent poster and i have found some of your responses very helpful. and i appreciate that you take time out of your day to respond.
0
And also OP is showing laziness to reply on our answers. 13 hours have been passed but OP didn't care about our answers. It is very weird when people behave like this.
0
Andrew Choi we all have been (and/or still be) on the learning side...
I agree to you that's isn't important for people wich are lazy to not let them know and let them in a no-learning path... however, that's important for the sake of Q&A discuss section to not let them more think that they could do so (else the Q&A mess will never end to grow ^^)
0
🅰🅹 🅐🅝🅐🅝🅣 that is unfornate that the op didnt respond. unfortunately we do not know the OP’s circumstances. maybe they had an emergency or a very long night/day. for me, i respond with the hope that i can help someone with a problem. if they respond with a thank or something nice that is wonderful. if they do not, i just move on and hope that one day the OP can pass their knowledge onto the next individual.
i personally have learned a tremendous amount from others in this community and others. many of them had no judgement or expectation in return and i hope i can contribute to others in the same way.
0
visph i agree that posts need to be moderated unfortunately. if the post gets removed, again that is unfortunate for the OP. not all of the posters are adults. some of them are kids or teens learning this for the first time. we know very little about the poster with the exception of what we see in their profile and question. while others are asking in english when it is not their first language. i understand moderators will remove messy questions, but being on the other side myself, “show me your work” doesnt move anything forward. their is no progression. just judgement that the OP is lazy and doesnt want to do the work.
- 2
Hello bro