2017-02-16 5 views
-3

Je suis tout nouveau à python et j'ai essayé d'écrire "cracker" (pas vraiment, juste un programme qui écrit toutes les combinaisons possibles).Je ai essayé d'écrire "cracker" - OFC il ne fonctionne pas, mais je pense qu'il pourrait xD

J'ai utilisé linecache puis juste en boucle (beaucoup trop).

L'idée était de faire un dictionnaire avec aZ et 0-9 caractères, puis en utilisant linecache obtenir les personnages et les mettre ensemble

(Il a travaillé avec seulement deux personnages changer mais quand j'ai essayé 8 caractères ...)

Comme je suis nouveau je python ne suis pas vraiment un ami avec intendation, mais en quelque sorte je l'ai fait travailler mais ...

LE PROBLÈME EST iL nE JAMAIS FAIRE:

print("ITS HERE") 

................................................

import easygui 
import time 
import linecache 



x1=1 
x2=1 
x3=1 
x4=1 
x5=1 
x6=1 
x7=1 
x8=0 
p=0 

while p!=36: 
p=p+1 
while x1!=36: 
    while x2!=36: 
     while x3!=36: 
      while x4!=36: 
       while x5!=36: 
        while x6!=36: 
         while x7!=36: 

          while x8!=36: 
           x8=x8+1 

           Char1=linecache.getline("Dictionary.txt",x1).rstrip("\n") 
           Char2=linecache.getline("Dictionary.txt",x2).rstrip("\n") 
           Char3=linecache.getline("Dictionary.txt",x3).rstrip("\n") 
           Char4=linecache.getline("Dictionary.txt",x4).rstrip("\n") 
           Char5=linecache.getline("Dictionary.txt",x5).rstrip("\n") 
           Char6=linecache.getline("Dictionary.txt",x6).rstrip("\n") 
           Char7=linecache.getline("Dictionary.txt",x7).rstrip("\n") 
           Char8=linecache.getline("Dictionary.txt",x8).rstrip("\n") 
           print(Char1+Char2+Char3+Char4+Char5+Char6+Char7+Char8) 
           time.sleep(0.25) 


           if x2==36: 
            x1=x1+1 
            x2=0 
           if x3==36: 
            x2=x2+1 
            x3=0 
           if x4==36: 
            x3=x3+1 
            x4=0 


           if x5==36: 
            x4=x4+1 
            x5=0 
           if x6==36: 
            x5=x5+1 
            x6=0 
           if x7==36: 
            x6=x6+1 
            x7=0 
           if x8==36: 
            x7=x7+1 
            x8=0 






time.sleep (60000) 
+0

à moins que je me manque quelque chose, 36 à la puissance 8 divisé par quatre (le sommeil de 0,25 seconde) est plus de 8000 milliers d'années pour un scénario le plus défavorable. Cela dit, 'x7' ne change jamais dans' while x7! = 36: ', une boucle infinie. Je recommande le [tutoriel officiel de Python] (https://docs.python.org/3.6/tutorial/index.html). – TigerhawkT3

+0

Comment? Il me semble bon et je le regarde une demi-journée, il faudrait que ce soit miracle ou juste aider quelqu'un plus expérimenté que moi – CandyKing

+1

A moins que vous ne vouliez vraiment le rendre lent et inefficace, jetez un oeil à itertools.permutations. –

Répondre

0

Voici le code de fonctionnement, si vous avez des millennials de temps essayer xD definetely

import easygui 
import time 
import linecache 



x1=1 
x2=1 
x3=1 
x4=1 
x5=1 
x6=1 
x7=1 
x8=1 


while x8!=36: 


    Char1=linecache.getline("AlgoDictionary.txt",x1).rstrip("\n") 
    Char2=linecache.getline("AlgoDictionary.txt",x2).rstrip("\n") 
    Char3=linecache.getline("AlgoDictionary.txt",x3).rstrip("\n") 
    Char4=linecache.getline("AlgoDictionary.txt",x4).rstrip("\n") 
    Char5=linecache.getline("AlgoDictionary.txt",x5).rstrip("\n") 
    Char6=linecache.getline("AlgoDictionary.txt",x6).rstrip("\n") 
    Char7=linecache.getline("AlgoDictionary.txt",x7).rstrip("\n") 
    Char8=linecache.getline("AlgoDictionary.txt",x8).rstrip("\n") 
    print(Char1+Char2+Char3+Char4+Char5+Char6+Char7+Char8) 
    time.sleep (0.1) 
    x8=x8+1        

    if x2==36: 
     x1=x1+1 
     x2=1 
    if x3==36: 
     x2=x2+1 
     x3=1 
    if x4==36: 
     x3=x3+1 
     x4=1 
    if x5==36: 
     x4=x4+1 
     x5=1 
    if x6==36: 
     x5=x5+1 
     x6=1 
    if x7==36: 
     x6=x6+1 
     x7=1 
    if x8==36: 
     x7=x7+1 
     x8=1