Ejemplo n.º 1
0
def draw_letters():
    """Pick NUM_LETTERS letters randomly. Hint: use stdlib random"""
    k = min(NUM_LETTERS, len(POUCH))
    draw = random.sample(POUCH, k)
    for letter in draw:
        POUCH.remove(letter)
    return draw
Ejemplo n.º 2
0
def draw_letters(num_letters):
    letters = []
    for _ in range(num_letters):
        idx = rd.randint(0, len(POUCH))
        letters.append(POUCH[idx])
        POUCH.remove(POUCH[idx])
    return letters
Ejemplo n.º 3
0
def draw_letters():
    """Pick NUM_LETTERS letters randomly. Hint: use stdlib random"""
    letters = []
    for i in range(NUM_LETTERS):
        draw = random.choice(POUCH)
        POUCH.remove(draw)
        letters.append(draw)
    return letters
Ejemplo n.º 4
0
def draw_letters():
    """Pick NUM_LETTERS letters randomly. Hint: use stdlib random"""
    draw = []
    for num in range(NUM_LETTERS):
        rand_choice = POUCH.pop(random.choice(range(len(POUCH))))
        draw.append(rand_choice)
    return draw
Ejemplo n.º 5
0
def draw_letters():
    # pull letters from bag
    my_letters = []
    for i in range(7):
        position = random.randint(0, len(POUCH) - 1)
        # print(i, position, POUCH[position])
        my_letters.append(POUCH.pop(position))
    return my_letters
Ejemplo n.º 6
0
def draw_letters():
    """Draw 7 letters from POUCH"""
    me_pouch = list()
    pouch_len = len(POUCH)
    for _ in range(0, 7):
        position = random.randint(0, pouch_len - 1)
        me_pouch.append(POUCH.pop(position))
        pouch_len = pouch_len - 1
    return me_pouch
Ejemplo n.º 7
0
def draw_letters():
    letters = []
    for count in range(1, 8):
        letter = random.choice(POUCH)
        # Got a letter, need to remove it from POUCH so same letter is not drawn 2x
        for x in POUCH:
            if letter == x:
                idx = POUCH.index(x)
                del POUCH[idx]
                break
        letters.append(random.choice(POUCH))

    # Check if drawn letters are only vowels, redraw if so
    if _all_vowels(letters):
        print('Only vowels, repicking...')
        draw_letters()
    print("Letters drawn: {}".format(' '.join(letters)))
    return letters
Ejemplo n.º 8
0
def draw_letters():
    return [POUCH.pop().lower() for x in range(NUM_LETTERS)]
Ejemplo n.º 9
0
def draw_from_pouch(n):
    """Pop n randomly chosen letters out of pouch."""
    shuffle(POUCH)
    for _ in range(n):
        yield POUCH.pop()