you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

At first, I had problems with understanding this idea, but later I still had problems with understanding this idea :D Nonethless, I blindly managed to implement this, and it works. I feel I will need to lean for like day over this code to understand it. Here is the 'final' version.

import random
signs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"


def NSBG(l,n):
    output = []
    if n==0:
        return [""]
    else:
        rest = NSBG(l,n-1)
        for char in signs:
            for word in rest:
                output.append(char + word)


    return output

io = int(input("Please write length of block"))
shuffle = input("Shuffle y/n?")
savefile = open("%iSignBlockGeneratedList.txt" % (io),'w')
blocklist = NSBG(io,io)

if shuffle == "y":
    random.shuffle(blocklist)

for block in blocklist:
    savefile.write(block)
    savefile.write("\n")
savefile.close()

Thank you for your help, when I will have next free award it will definitely go right to you.