Jump to content
Slark

mini program python!

Recommended Posts

Posted

is incepator.. l-am facut si eu cum am stiut si cu ce am stiut..

daca introduci de exemplu ad

Output va fii:

 
1 | aa
2 | ad
3 | da
4 | dd

iti da toate combinatile posibile (asa cred.. ca toate) dintr-un sir de "caractere"

preview

import random
import os

numar = 0
increment = 0
increment2 = 0
combinatie = ""
total_combinati = 0
lista_sir_litere = []
lista_combinati_posibile = []
litere = input("Ori ce: ")
numar_litere = len(litere)
numar = numar_litere - 1

for i in litere:
lista_sir_litere.append(i)

while increment2 < 10000:
nr_rand = random.randint(0, numar)
combinatie += lista_sir_litere[nr_rand]
increment += 1
if increment == numar_litere:
increment = 0
if combinatie not in lista_combinati_posibile:
lista_combinati_posibile.append(combinatie)
combinatie = ""
os.system("cls")
print("Loading....")
increment2 -= 1
elif combinatie in lista_combinati_posibile:
increment2 += 1
combinatie = ""
else:
continue

os.system("cls")
aranjate = sorted(lista_combinati_posibile)
for i in aranjate:
total_combinati += 1
print(total_combinati, "|", i)
input()

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...