making strings to put in a Doubly linked list

OK, I have no idea what purpose this will serve yet.  I was trying to find a way to sort data outside of the linked lists today with no results... but I did make this happen. Update has the way easier python way to make random strings

Update: 4-23-18
Much easier way to make random strings:

import random

stringsize = 10
x = ''.join(random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(stringsize))
print(x)




here is the method:
My goal was to try and give new nodes unique names and then sort them out.... but I realized, how do I sort through them with nothing to contain them?   So this method was made from that.  Don't know if I'll use it for anything, so off it goes to the archives.

The first one would be a one off, in a loop that just wanted to create a variable based on the given count given.  Like say,  10 times in the for loop, or the while loop ran 11 times... so on.










def create_variable_small(count):
    # I'm thinking with this, you'd assign a variable when you reached a place in an index
    # or count match and wanted to assign a variable at random to a node.
    #a = odd
    #b = even
    var = 'oic'
    spam = 0
 
    while spam < count:

        # doesn't matter what it is.  just that it's psuedo random, and every one is different.
     
        if spam % 2:
            var = var + 'b'
            spam += 1
        else:
            var = var + 'a'
            spam += 1

    return var

## goes up to 30 ####  rely's on container having a .push
## count will be the number of items you want to add.
def create_variable_large(count, container):
    #a - odd
    #b - even
    var = "wp"
    foo = "gr"
    bar = "te"
    spam = count
    while spam > 0:
        if spam < 10 and spam > 0:
            modulo 2  = even. else odd.
            if spam % 2:
                var = var + 'b'
            else:
                var = var + 'a'
            spam -= 1
            container.push(var)
        elif spam < 20 and spam >= 10:
         
            if spam % 2:
                foo = foo + 'c'
            else:
                foo = foo + 'd'
            spam -= 1
            container.push(foo)
        elif spam <= 30 and spam >= 20:
         
            if spam % 2:
                bar = bar + 'f'
            else:
                bar = bar + 'e'
            spam -= 1
            container.push(bar)
        else:
            spam -= 1

    return container



Comments

Popular posts from this blog

playing with color in powershell python

JavaScript Ascii animation with while loops and console.log

playing with trigonometry sin in pygame