score = (x) -> if x == "Yes" 10 else 0 redistributed_weights = (weights, values) -> num_of_weighted_values = weights.length for value, index in values if value == "Not Applicable" num_of_weighted_values -= 1 redistributed_weight_value = weights[index] for weight, i in weights if weight == 0 continue weights[i] = weight + redistributed_weight_value/num_of_weighted_values weights[index] = 0 weights weights = (1/6 for i in [0...6]) water_withdrawal = [reduction_disclosure, reduction_target, water_stressed_area_dependency, withdrawal_from_water_stressed_areas, reduction_engagement, water_stressed_area_dependency_in_supply_chain] redistributed_weights(weights, water_withdrawal) weights.reduce((weighted_sum, weight, index) -> weighted_sum + weight*score(water_withdrawal[index]) , 0)