Created
June 8, 2015 09:24
-
-
Save andrewpatt24/29fd4199f54576dd488b to your computer and use it in GitHub Desktop.
"The best aptitude test" Hackerrank submission
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 scipy.stats.stats import pearsonr | |
n_tests = int(raw_input()) | |
def parse(): | |
n_cases = int(raw_input()) | |
#print n_cases | |
final_data = {} | |
final_data['gpa'] = [float(x) for x in raw_input().strip().split(' ')] | |
data = [] | |
for i in range(5): | |
data.append([float(x) for x in raw_input().strip().split(' ')]) | |
final_data['tests'] = data | |
final_data['n_cases'] = n_cases | |
#print final_data | |
return final_data | |
def calculate_correlation(data): | |
select = 1 | |
win_coef = 0 | |
for i in range(5): | |
coef = pearsonr(data['gpa'],data['tests'][i])[0] | |
if coef > win_coef or -coef > win_coef: | |
win_coef = coef | |
select = i+1 | |
return select | |
for i in range(n_tests): | |
print calculate_correlation(parse()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment