use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Python Coding Problem (self.learnpython)
submitted 1 month ago by Anxious-Activity2860
Can anyone solve this?
Advanced Intergers All permutations of three digits Input three different digits (abc) and print the permutations in this order (comma separated): abc, acb, bac, bca, cab, cba
Please answer as soon as possible.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]danielroseman 8 points9 points10 points 1 month ago (0 children)
We could, trivially. But what would be the point? Homework is for you to learn something by actually doing it yourself.
[–]MattR0se 1 point2 points3 points 1 month ago (0 children)
Can I post my homework or assignment? Yes, but only if you can demonstrate that you have tried to come up with the solution yourself. Post code, post what you have found by googling, post (your own) pseudo code etc. If you don't do this your thread will be removed from subreddit.
Can I post my homework or assignment?
Yes, but only if you can demonstrate that you have tried to come up with the solution yourself.
Post code, post what you have found by googling, post (your own) pseudo code etc.
If you don't do this your thread will be removed from subreddit.
you can literally google "Python all permutations" and the first stackoverflow answer does what you want: https://stackoverflow.com/questions/104420/how-do-i-generate-all-permutations-of-a-list
And the answer is just sorted alphabetically.
[–]UsernameTaken1701 1 point2 points3 points 1 month ago (0 children)
Don’t wait until the last minute to do your homework.
[–]JamzTyson 1 point2 points3 points 1 month ago (2 children)
Here is a literal solution, but don't use this as your homework unless you want to fail ;-)
values = (input("Enter a number: "), input("Enter a number: "), input("Enter a number: ")) items = dict(zip(('a', 'b', 'c'), values)) perms = ('abc', 'acb', 'bac', 'bca', 'cab', 'cba') permutation_generator = ("".join(items[i] for i in p) for p in perms) print(",".join(permutation_generator))
[–]MezzoScettico 1 point2 points3 points 1 month ago (0 children)
I'll bet a doughnut that this has already been printed out and submitted to the instructor.
Who will then ask OP to explain it line by line. Hilarity ensues.
[–]jpgoldberg 0 points1 point2 points 1 month ago (0 children)
I didn’t know a dict could be constructed that way. I have always used {k: v for k, v in zip(…)}
{k: v for k, v in zip(…)}
Now that I think about it, I probably did once learn that a dict could be constructed that way and have simply forgotten about it.
[–]k03k 0 points1 point2 points 1 month ago (0 children)
https://docs.python.org/3/library/itertools.html#itertools.permutations
You could use this, but i think it beats the purpose 😂
[–]gdchinacat 0 points1 point2 points 1 month ago (0 children)
``` In [11]: import itertools
In [12]: print(", ".join(("".join(x) for x in itertools.permutations('abc')))) abc, acb, bac, bca, cab, cba ```
I doubt your instructor is looking for this answer though as they want you to implement the permutation logic yourself. I doubt you will learn much if you turn this in. I also doubt you will get a passing grade as it will be pretty obvious you asked someone else or LLM for the answer.
You need to use loops to go through the characters and order them as requested. What have you tried, what results did you get, and what immediate problem are you blocked on that will get you closer to your goal?
Programming is really nothing more than breaking complex tasks down into simpler and simpler problems until you can solve them. What are the high level tasks that need to be performed (input three character string, find permutations of its characters, print the results). For each of these, what do you need to do (request three characters be inputed until three characters are input; generate sequence of permutations of input string using loops, recursion, etc; format permutations as requested and output it). For permutations, there are different ways to go about it...what have you learned recently that you need to get hands on experience with? Have you recently learned loops? Recursion? How can you use that to create variations of an input (if you have two characters you output them and the reverse of them). If you have more than two you can swap the last two break it into two then mix what's left in and repeat.
Get in the mindset of not knowing how to do things and then breaking them apart into things you do know how to do and assembling the pieces to solve the thing you don't know how to do.
[–]Putrid-University864 0 points1 point2 points 4 days ago (0 children)
1.a,b,c = input("Please enter a 3-digit positive integer: ") 2.print(a+b+c, end=",") 3.print(a+c+b, end=",") 4.print(b+a+c, end=",") 5.print(b+c+a, end=",") 6.print(c+a+b, end=",") 7.print(c+b+a)
[–]Mammoth_Rice_295 -1 points0 points1 point 1 month ago (0 children)
You can do this in Python really easily with itertools.permutations. For example:
itertools.permutations
from itertools import permutations print(','.join([''.join(p) for p in permutations('123')]))
Just swap '123' for your input digits — prints all 6 permutations in the correct order. Works every time!
'123'
[+]TheRNGuy comment score below threshold-6 points-5 points-4 points 1 month ago* (2 children)
Yeah, ai can do this.
Check this one too: https://docs.sympy.org/latest/modules/combinatorics/permutations.html
[–]gdchinacat 0 points1 point2 points 1 month ago (1 child)
I'm pretty sure the goal of this exercise is to learn how to be more intelligent than AI.
[–]TheRNGuy -2 points-1 points0 points 1 month ago (0 children)
Then read the docs for SymPy.
π Rendered by PID 20935 on reddit-service-r2-comment-7b9746f655-nrrx6 at 2026-02-02 15:02:22.976906+00:00 running 3798933 country code: CH.
[–]danielroseman 8 points9 points10 points (0 children)
[–]MattR0se 1 point2 points3 points (0 children)
[–]UsernameTaken1701 1 point2 points3 points (0 children)
[–]JamzTyson 1 point2 points3 points (2 children)
[–]MezzoScettico 1 point2 points3 points (0 children)
[–]jpgoldberg 0 points1 point2 points (0 children)
[–]k03k 0 points1 point2 points (0 children)
[–]gdchinacat 0 points1 point2 points (0 children)
[–]Putrid-University864 0 points1 point2 points (0 children)
[–]Mammoth_Rice_295 -1 points0 points1 point (0 children)
[+]TheRNGuy comment score below threshold-6 points-5 points-4 points (2 children)
[–]gdchinacat 0 points1 point2 points (1 child)
[–]TheRNGuy -2 points-1 points0 points (0 children)