Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import random
- dict_path, n, m = sys.argv[1:4]
- n = int(n)
- m = int(m)
- words = list(map(str.rstrip, open(dict_path)))
- max_word_len = max(map(len, words))
- len_below = [[w for w in words if len(w) <= i] for i in range(max_word_len + 1)]
- print(m)
- print(n)
- lines = []
- for i in range(n):
- line = list(' ' * m)
- i = 0
- while i < m:
- ws = len_below[m - i] if m - i <= max_word_len else words
- if ws:
- word = random.choice(ws)
- for j, c in enumerate(word):
- line[i + j] = c
- i += len(word) + 1
- else:
- break
- lines.append(line)
- cols = list(map(''.join, zip(*lines)))
- random.shuffle(cols)
- print('\n'.join(cols))
- print()
- print(dict_path)
- print()
- print('\n'.join(map(''.join, lines)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement