From f76fc1af01c4c3b56b01e31b9cb207873b188bbf Mon Sep 17 00:00:00 2001 From: Lars Palinckx Date: Fri, 3 Dec 2021 00:30:04 +0000 Subject: [PATCH] Upload solution.py --- battleship/solution.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 battleship/solution.py diff --git a/battleship/solution.py b/battleship/solution.py new file mode 100644 index 0000000..cab7196 --- /dev/null +++ b/battleship/solution.py @@ -0,0 +1,20 @@ + +msg = "EYTAQCTQRA{EYTCTARYEYRCTAEARYWQRCWQEYTQQHTQQHEQWAQHEYTY}" + +pfix = "EYTAQCTQRA" +flag = "EYTCTARYEYRCTAEARYWQRCWQEYTQQHTQQHEQWAQHEYTY" + +board = [['Q', 'W', 'E', 'R', 'T'], ['Y', 'U', 'I', 'O', 'P'], ['A', 'S', 'D', 'F', 'G'], ['H', 'K', 'L', 'Z', 'X'], ['C', 'V', 'B', 'N', 'M']] +cols = ['Q', 'Y', 'A', 'H', 'C'] +flat = sum(board, []) + +def secret(enc): + out = '' + pairs = [enc[i:i+2] for i in range(0, len(enc), 2)] + for p in pairs: + col = flat.index(p[0]) % 5 + row = cols.index(p[1]) + out += board[row][col] + return out + +print(secret(pfix), '{', secret(flag), '}')