/test.py Secret
Created
March 14, 2025 17:02
PI day quest part 2 wrong
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
data = {} | |
tickers = {} | |
letter_lookup = [] | |
with open('data2', 'r') as f: | |
for line in f.readlines(): | |
letter_lookup.extend(line.strip().split(' ')) | |
print(letter_lookup) | |
with open('data', 'r') as f: | |
for line in f.readlines(): | |
day, price, ticker = line.split() | |
day = int(day) | |
price_val = ''.join(price.split('.')) | |
price = float(price) | |
data[price_val] = [day, price, ticker] | |
tickers[ticker] = int(price_val) | |
print(data) | |
print(tickers) | |
curr = "31415926535897932384626433832795" | |
order = [] | |
while curr: | |
for k, v in data.items(): | |
if curr.startswith(k): | |
order.append((v[0], v[1], v[2])) | |
curr = curr[len(k):] | |
break | |
order.sort(key=lambda x: x[0]) | |
ans = [] | |
for day, price, ticker in order: | |
other_ticker = [] | |
for letter in ticker: | |
other_ticker.append(chr((tickers[ticker] + ord(letter) - ord('A')) % 26 + ord('A'))) | |
other_ticker = ''.join(other_ticker) | |
ans.append(letter_lookup[tickers[other_ticker] % 256]) | |
print(''.join(ans)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment