Last active
August 29, 2015 14:15
-
-
Save phaustin/f1b5f7a85ff831cfe43c to your computer and use it in GitHub Desktop.
swap answer key for eosc340
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
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 | |
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 __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