Skip to content

Instantly share code, notes, and snippets.

@inky
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inky/d8b17641c030409e1785 to your computer and use it in GitHub Desktop.
Save inky/d8b17641c030409e1785 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
"""
Random Scrabble tiles!
"""
from __future__ import unicode_literals
from random import shuffle
TILES = ('AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIIIIIIIIIJKLLL'
'LMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ__')
def random_tiles():
tiles = list(TILES)
shuffle(tiles)
return ''.join(tiles[:7])
def format_tile(tile):
assert len(tile) == 1
return '(blank)' if tile == '_' else tile
if __name__ == '__main__':
print ', '.join(format_tile(tile) for tile in random_tiles())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment