Last active
August 25, 2016 15:42
-
-
Save artemklevtsov/1b75ff367145113b1ef9e43e15b9572f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from sys import argv | |
| from random import choice | |
| def gen_letters(nrows = 60, ncols = 40): | |
| letters = "АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ" | |
| return "\n".join(" ".join(choice(letters) for i in range(ncols)) for j in range(nrows)) | |
| def gen_numbers(nrows = 60, ncols = 40): | |
| numbers = "0123456789" | |
| return "\n".join(" ".join(choice(numbers) for i in range(ncols)) for j in range(nrows)) | |
| if len(argv) == 1: | |
| print(gen_letters()) | |
| elif len(argv) == 3: | |
| nrows = int(argv[1]) | |
| ncols = int(argv[2]) | |
| print(gen_letters(nrows, ncols)) | |
| else: | |
| raise RuntimeError("Неверное число аргументов.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from sys import argv | |
| from random import randint | |
| def gen_gidits(nrows = 10, ncols = 20, sep = " "): | |
| res = "" | |
| for row in range(nrows): | |
| res += sep.join(str(randint(0, 9)) for i in range(ncols)) + "\n" | |
| res += sep.join(str(randint(0, 9)) for i in range(ncols)) + "\n" | |
| res += sep.join("_" for i in range(ncols)) + "\n\n" | |
| return res | |
| if len(argv) == 1: | |
| print(gen_gidits()) | |
| elif len(argv) == 3: | |
| nrows = int(argv[1]) | |
| ncols = int(argv[2]) | |
| print(gen_gidits(nrows, ncols)) | |
| else: | |
| raise RuntimeError("Неверное число аргументов.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from numpy import arange, random | |
| def get_table(): | |
| a = arange(1, 26).reshape(5, 5) | |
| random.shuffle(a) | |
| return "\n".join("\t".join(map(str, row)) for row in a) | |
| print(get_table()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from numpy import append, random | |
| def get_table(): | |
| a = append(range(1, 26), range(1, 25)).reshape(7, 7) | |
| random.shuffle(a) | |
| return "\n".join("\t".join(map(str, row)) for row in a) | |
| print(get_table()) | |
| """ | |
| #!/usr/bin/env python | |
| from numpy import append, random | |
| def get_table(): | |
| out = "<html><body><table>" | |
| cell1_tmpl = '<td><span style="font-weight:bold;color:black">{}</span></td>' | |
| cell2_tmpl = '<td><span style="font-weight:bold;color:red">{}</span></td>' | |
| row_tmpl = '<tr>{}</tr>' | |
| a = append([cell1_tmpl.format(i) for i in range(1, 26)], | |
| [cell2_tmpl.format(i) for i in range(1, 25)]) | |
| random.shuffle(a) | |
| a = a.reshape(7, 7) | |
| out += "".join(row_tmpl.format("".join(row)) for row in a) | |
| out += "</body></table></html>" | |
| return out | |
| print(get_table()) | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment