Last active
February 11, 2020 15:49
-
-
Save goedel-gang/077b113481f7600bfae6423c9f03b811 to your computer and use it in GitHub Desktop.
Order sequences
This file contains 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
odseq.txt |
This file contains 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
from ast import literal_eval | |
import re | |
with open("odseq.txt", "r") as odseq_file: | |
odseq_data = odseq_file.read() | |
def read_record(record): | |
head, incidence = record.split("\n\n") | |
size, order_seqs = head.split("\n", maxsplit=1) | |
size = int(size) | |
# parse the actual order sequences. Currently unused | |
split_seqs = re.split(r"(?<=\])\s+(?=\[)", order_seqs) | |
split_seqs = [literal_eval(seq.replace("\n", "")) for seq in split_seqs] | |
incidence = literal_eval(incidence) | |
return size, split_seqs, incidence | |
by_group_size = odseq_data.split("\n\n\n") | |
yes_duplicates = [] | |
no_duplicates = [] | |
for record in by_group_size: | |
size, ordeq_seqs, incidence = read_record(record) | |
if set(incidence) == {1}: | |
no_duplicates.append(size) | |
else: | |
yes_duplicates.append(size) | |
print("orders of groups with duplicate order sequences:") | |
print(yes_duplicates) | |
print("\norders of groups without duplicate order sequences:") | |
print(no_duplicates) |
This file contains 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
output.txt: analyse.py odseq.txt | |
python3 analyse.py > $@ |
This file contains 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
orders of groups with duplicate order sequences: | |
[16, 27, 32, 48, 54, 64, 72, 80, 81, 96, 100, 108, 112, 125, 128, 135, 144, 147, 160, 162, 176, 189, 192, 200, 208, 216, 224, 240, 243, 250, 256, 260, 270, 272, 273, 288, 294, 297, 300, 304, 320, 324, 336, 340, 343, 351, 352, 360, 368, 375, 378, 384, 399, 400, 405, 416, 432, 441, 448, 459, 464, 480, 486, 496, 500, 504, 507] | |
orders of groups without duplicate order sequences: | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 126, 127, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 161, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191, 193, 194, 195, 196, 197, 198, 199, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 241, 242, 244, 245, 246, 247, 248, 249, 251, 252, 253, 254, 255, 257, 258, 259, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 289, 290, 291, 292, 293, 295, 296, 298, 299, 301, 302, 303, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 321, 322, 323, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 337, 338, 339, 341, 342, 344, 345, 346, 347, 348, 349, 350, 353, 354, 355, 356, 357, 358, 359, 361, 362, 363, 364, 365, 366, 367, 369, 370, 371, 372, 373, 374, 376, 377, 379, 380, 381, 382, 383, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 401, 402, 403, 404, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 433, 434, 435, 436, 437, 438, 439, 440, 442, 443, 444, 445, 446, 447, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 460, 461, 462, 463, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 481, 482, 483, 484, 485, 487, 488, 489, 490, 491, 492, 493, 494, 495, 497, 498, 499, 501, 502, 503, 505, 506, 508, 509, 510, 511] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment