# Split to Achieve Gain

This is a second attempt at posing this question. I think my first attempt was unclear. First off, the problem can be found at: https://www.sololearn.com/learning/eom-project/1094/103 The code that I submitted can be found at: https://code.sololearn.com/cQEDIvXRgL3e A pedantic version of my code submission, with editable inputs and a detailed explanation of all outputs can be found at: https://code.sololearn.com/cO755SFZAUJ0 This seems like it should be a fairly simple coding task. All the functions and formulae are outputting as expected, and the two visible test cases on the problem both pass. All of the hidden tests cases fail. Since everything looks fine to me, I must be missing something. Here is the code: s = [int(x) for x in input().split()] a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] # Function to get counts for set and splits, to be used in later formulae. def setCount(n): return len(n) Cs = setCount(s) Ca = setCount(a) Cb = setCount(b) # Function to get sums of "True" values in each, for later formulae. def tSum(x): sum = 0 for n in x: if n == 1: sum += 1 return sum Ss = tSum(s) Sa = tSum(a) Sb = tSum(b) # Function to get percentage of "True" values in each, for later formulae. def getp(x, n): p = x/n return p Ps = (getp(Ss, Cs)) Pa = (getp(Sa, Ca)) Pb = (getp(Sb, Cb)) # Function to get Gini impurity for each, to be used in final formula. def gimp(p): return 2 * p * (1-p) Hs = (gimp(Ps)) Ha = (gimp(Pa)) Hb = (gimp(Pb)) # Final formula, intended to output information gain to five decimal places. infoGain = round((Hs - (Sa/Ss) * Ha - (Sb/Ss) * Hb),5) print(infoGain)