-3

I am quite new to python and i tried to write "cracker" (not really, just a programme that writes all possible combinations).

I used linecache and then just while loops (far too many).

The idea was to make a dictionary with a-Z and 0-9 characters and then using linecache get the characters and put them together

(It worked with only 2 characters changing but when i tried 8 characters...)

As i am new to python i am not really a friend with intendation, but somehow i made it to work BUT...

THE PROBLEM IS IT WILL NEVER DO:

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)
Bob
  • 347
  • 2
  • 3
  • 12
  • Unless I'm missing something, 36 to the 8th power divided by four (the 0.25-second sleep) is over 8,000 millennia for a worst-case scenario. That said, `x7` never changes within `while x7!=36:`, an infinite loop. I recommend the [official Python tutorial](https://docs.python.org/3.6/tutorial/index.html). – TigerhawkT3 Feb 16 '17 at 21:45
  • How? It looks good to me and i am looking on it half a day it, would had to be miracle or just help of somebody more experienced than me – Bob Feb 16 '17 at 21:45
  • 1
    Unless you really want to make it slow and inefficient, have a look at itertools.permutations. – Thierry Lathuille Feb 16 '17 at 21:45
  • I know about permutations, i looked at them when i was totaly hopeless but i would like to finish this becuase i think i am close xD – Bob Feb 16 '17 at 21:49
  • @TigerhawkT3 Thanks for answer! :-) Look at the end of the code on the IF's – Bob Feb 16 '17 at 21:50
  • Those `if` statements are not part of the `while x7!=36:` loop. – TigerhawkT3 Feb 16 '17 at 21:53
  • Your use of imbricated `while`s is a complicated way to write imbricated `for`s. And you don't have to use only numbers in Python. You can write things like `for char in "abcdef123"`. Reading some Python tutorial could definitely help you! – Thierry Lathuille Feb 16 '17 at 21:54
  • @TigerhawkT3 Is there a way how to make the IF statement's part of the while loop's? – Bob Feb 16 '17 at 22:09
  • Check the [official Python tutorial](https://docs.python.org/3.6/tutorial/index.html) I linked above and learn the basic structure of a Python program. – TigerhawkT3 Feb 16 '17 at 22:10

1 Answers1

0

SO here is the working code, if you have millennials of time definetely try it xD

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
Bob
  • 347
  • 2
  • 3
  • 12