20 odpowiedzi
+ 4
Sounds like you want itertools permutations.
Example of all permutations of 'abc'
You can easily covert this so it works with your digits and only returns the full length permutations.
https://docs.python.org/3/library/itertools.html
https://code.sololearn.com/cuAr5wOk4UV5/?ref=app
+ 2
What are those two numbers in your example above ? Is it 11 or 22 or just 2 ?
+ 2
You can do it by using nested loops to build up the sequences as strings and then convert to int.
The tricky part is that you don't know in advance how many loops you need.
+ 2
Hey! pedram ch yes you can do it using nested loop and itertools permautation.
for i in range(0,5)
for j in range(0,5)
print(str(i)+str(j))
If you want 5 digit long number you need to create 5 loops. Or you can do it using itertools which is included in python course.
I myself had created a wordlist of all possible number of 4 digit 1111,1112,1123……..
+ 1
✩✮★✮✩ that was brilliant and helped me understand concept of permutations ... thank you so much 🙏🙏
+ 1
pedram ch
You can make those conversions and then do a permutation of them as well and add them to the set of previous permutations. The code for which will depend on how your digits should be converted. For instance if you're only using 1's and 0's and given the digits as 100 or 001 or 010 should it also permutate 110 or 011 and/or 111?
+ 1
Vasiliy that just calculates how many permutations there are. It does not give the permutations.
0
Abhay the two numbers(I think I should have said digits) are "one" and "zero"
Which as I said for a 2 digit number would make 00,11,01,10
But I want it for a x digit number like 3 (000, 001, 011....) or more
0
Simon Sauter Ops .. so there is no math or binary method which could do this?
0
I doubt it, since it's not a math problem.
0
ChaoticDawg Pranto I checked out permutations. As said some conversions should be made and I need to find out how. Thank you so much for the hint
0
ChaoticDawg yes every possible ways of them. I was trying to figure out how does it work since passed '10' as argument and 4 as length but I understood the first arguments length should be as much as defined length in Secound argument . That was just what I was looking for
0
Mathematics is such a science that with its help it is possible to solve any problem, there would be knowledge. ☺️
an = a**n
Two digits - 0 and 1 in a two-digit number including 00:
an = 2**2
Two digits - 0 and 1 in a three-digit number including 000:
an = 2**3
Etc. ☺️
0
Simon Sauter I gave an answer for the number of iterations required. Write a "permutation" function and call it in a loop, or recursively, of your choice. ☺️
0
If you want to give it a try by yourself, try using recursion. This suggestion should point you in the right direction.
0
Vasiliy Not every problem... Ask Turing or Gödel.
0
Nboumakis 🤣🤣🤣 yes, they know the answer for sure.
The main thing is not to confuse tasks with problems. 🤣🤣🤣
0
Vasiliy No, if that were the case, there would exist an algorithm capable of solving the "Halting problem". But there is not. Anyway, since this is a different discussion, if you want to elaborate, you could contact me through the Direct Message feature.
- 2
Je sais comment ça marche