Skip to content

Commit a9efc6f

Browse files
committed
boggle
1 parent 15f43d9 commit a9efc6f

File tree

9 files changed

+551
-192
lines changed

9 files changed

+551
-192
lines changed

OUTLINE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
40. **word_search**: Find all the words hidden in the rows, columns, and diagonals in a block of text.
4242
41. **set**: Find "set" of cards from a deck of 81 where each of 4 attributes can have each of 3 values and a "set" of 3 cards is either the same or entirely different for each of the 4 attributes.
4343
42. **scrabble**: Find all possible words you could make from a random set of seven characters.
44+
43. **rummikub**: Program the tile-based Rummikub game where you find sets of the same number of different colors or consecutive runs of numbers in the same color.

bin/chapters.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ rot13
4646
word_search
4747
set
4848
scrabble
49+
rummikub
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#!/usr/bin/env python3
2-
"""Rummikub"""
2+
"""Boggle"""
33

44
import argparse
55
import os
6-
import sys
76
import random
8-
from itertools import product
7+
import sys
98

109

1110
# --------------------------------------------------
1211
def get_args():
1312
"""Get command-line arguments"""
1413

1514
parser = argparse.ArgumentParser(
16-
description='Rummikub',
15+
description='Boggle',
1716
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
1817

1918
# parser.add_argument('positional',
@@ -49,30 +48,32 @@ def get_args():
4948
return parser.parse_args()
5049

5150

52-
# --------------------------------------------------
53-
def make_tiles():
54-
"""Make tiles"""
55-
56-
return list(product(list('BYRK'), range(1, 14))) * 2
57-
58-
# --------------------------------------------------
59-
def test_make_tiles():
60-
"""Test make_tiles"""
61-
62-
tiles = make_tiles()
63-
assert len(tiles) == 104
64-
assert len(list(filter(lambda tile: tile[0] == 'R', tiles))) == 26
65-
assert len(list(filter(lambda tile: tile[1] == 1, tiles))) == 8
66-
67-
6851
# --------------------------------------------------
6952
def main():
7053
"""Make a jazz noise here"""
7154

7255
args = get_args()
7356
random.seed(args.seed)
74-
tiles = random.sample(make_tiles(), k=14)
75-
print(tiles)
57+
dice = ['U Qu H M N I',
58+
'O B J A O B',
59+
'F F S K A P',
60+
'N S I E U E',
61+
'E G H W E N',
62+
'S O A C H P',
63+
'T T R E Y L',
64+
'R N Z N H L',
65+
'R E V L Y D',
66+
'T U I C M O',
67+
'T D T Y S I',
68+
'O O W T T A',
69+
'N A E A E G',
70+
'R V T H E W',
71+
'L X E D R I',
72+
'O T S E S I']
73+
74+
show = list(map(lambda s: random.choice(s.split()), dice))
75+
76+
print(len(show))
7677

7778

7879
# --------------------------------------------------

0 commit comments

Comments
 (0)