import sys import csv moonidx = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, ] def moonorder(m): v = int(m[1:]) if m[0] == 'P': v += 1000 elif m[0] == 'E': v += 2000 return v def mooncode(problem): holds = problem.split(",") moves = [] for hold in holds: start, end = (False, False) if hold[0] == '+': start = True hold = hold[1:] elif hold[0] == '*': end = True hold = hold[1:] col = hold[0] row = int(hold[1:]) assert col >= 'A' and col <= 'K' assert row >= 1 and row <= 18 idx = (ord(col) - ord('A')) * 18 + row - 1 moves.append(f"{'S' if start else 'E' if end else 'P'}{moonidx[idx]}") moves.sort(key=moonorder) return f"l#{','.join(moves)}#" def main(): print(f"
{row[0]} ({row[1]}){isbenchmark}
") # print(f"{row[3]}