Skip to content

Instantly share code, notes, and snippets.

@phaustin
Last active August 29, 2015 14:15
Show Gist options
  • Save phaustin/f1b5f7a85ff831cfe43c to your computer and use it in GitHub Desktop.
Save phaustin/f1b5f7a85ff831cfe43c to your computer and use it in GitHub Desktop.
swap answer key for eosc340
1 18 c
2 19 c
3 20 a
4 4 e
5 1 a
6 9 b
7 15 a
8 2 a
9 3 e
10 5 c
11 6 c
12 10 e
13 11 c
14 12 b
15 13 d
16 14 d
17 16 d
18 8 c
19 7 a
20 17 d
from __future__ import print_function
import re
space=re.compile('\s+')
store={}
b_string=''
with open('b_a.txt') as f:
print('b a answer')
for the_line in f.readlines():
nums=the_line.strip()
nums=space.split(nums)
if len(nums) == 3:
print(the_line.strip())
store[int(nums[0])]=(int(nums[1]), nums[2])
b_string+=nums[2]
print(b_string.upper())
a_string=''
reverse={v[0]:(k,v[1]) for k,v in store.items()}
the_keys=reverse.keys()
the_keys.sort()
for a_key in the_keys:
print(a_key,reverse[a_key])
a_string+=reverse[a_key][1]
print(a_string.upper())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment