Calculates the 1's complement sum for 16-bit numbers.

    Args:
        num1: 16-bit number.
        num2: 16-bit number.

    Returns:
        The calculated result.
421179
def ones_comp_sum16(num1: int, num2: int) -> int:
    

    carry = 1 << 16
    result = num1 + num2
    return result if result < carry else result + 1 - carry
302468
def base26int(s, _start=1 - ord('A')):
    
    return sum((_start + ord(c)) * 26**i for i, c in enumerate(reversed(s)))
1073409
public double innerproduct(double[] vec1, double[] vec2) {
    double sum = 0;

    for (int i = 0; i < vec1.length; i++) {
      sum += vec1[i] * vec2[i];
    }

    return sum;
  }
384893
public static double Cosine(double x1, double y1, double x2, double y2) {

        double sumProduct = x1 * x2 + y1 * y2;
        double sumP = Math.pow(Math.abs(x1), 2) + Math.pow(Math.abs(x2), 2);
        double sumQ = Math.pow(Math.abs(y1), 2) + Math.pow(Math.abs(y2), 2);
        sumP = Math.sqrt(sumP);
        sumQ = Math.sqrt(sumQ);

        double result = 1 - (sumProduct / (sumP * sumQ));
        return result;
    }
1256598
def fib_iter(n):
    

    # precondition
    assert n >= 0, 'n must be positive integer'

    fib_1 = 0
    fib_2 = 1
    sum = 0
    if n <= 1:
        return n
    for _ in range(n-1):
        sum = fib_1 + fib_2
        fib_1 = fib_2
        fib_2 = sum
    return sum
1195194
def sorensen(seq1, seq2):
	
	set1, set2 = set(seq1), set(seq2)
	return 1 - (2 * len(set1 & set2) / float(len(set1) + len(set2)))
865836
def isfib(number):
    

    num1 = 1
    num2 = 1
    while True:
        if num2 < number:
            tempnum = num2
            num2 += num1
            num1 = tempnum
        elif num2 == number:
            return True
        else:
            return False
25967
def decker_sum(a, b):
    
    x = a + b
    y = b - (x - a) if abs(a) > abs(b) else a - (x - b)
    return x, y
492652
def equation(operation, firstnum, secondnum):
    
    if operation == 'plus':
        return firstnum + secondnum
    elif operation == 'minus':
        return firstnum - secondnum
    elif operation == 'multiply':
        return firstnum * secondnum
    elif operation == 'divide':
        if not secondnum == 0:
            return firstnum / secondnum
        raise ZeroDivisionError("Unable to divide by 0.")
    raise ValueError('Invalid operation provided.')
767831
def plus_one_v1(digits):
    
    digits[-1] = digits[-1] + 1
    res = []
    ten = 0
    i = len(digits)-1
    while i >= 0 or ten == 1:
        summ = 0
        if i >= 0:
            summ += digits[i]
        if ten:
            summ += 1
        res.append(summ % 10)
        ten = summ // 10
        i -= 1
    return res[::-1]
870421
def compute_agreement_score(num_matches, num1, num2):
    
    denom = num1 + num2 - num_matches
    if denom == 0:
        return 0
    return num_matches / denom
471365
function numClose(x, y) {
  return (Number.isNaN(x) && Number.isNaN(y)) ||
    Math.abs(x - y) <= 1e-7;
}
207771
public static float calculate(Map<String, Integer> features1, Map<String, Integer> features2) {
        TreeSet<String> keys = new TreeSet<String>(features1.keySet());
        keys.addAll(features2.keySet());

        float sum = 0.0f;
        for (String key : keys) {
            Integer c1 = features1.get(key);
            Integer c2 = features2.get(key);

            c1 = c1 == null ? 0 : c1;
            c2 = c2 == null ? 0 : c2;
            sum += 1.0 - Math.abs(c1 - c2) / (c1 + c2);
        }

        return sum / keys.size();
    }
209379
function mpn_add(r, n1, n2, l) {
	var c = 0;
	for (var i = 0; i < l; ++i) {
		r[i] = (c = (c >>> 31) + n1[i] + n2[i]) & 0x7FFFFFFF;
	}
	return c >>> 31;
}
654827
public static double QuasiEuclidean(double x1, double y1, double x2, double y2) {

        if (Math.abs(x1 - x2) > Math.abs(y1 - y2)) {
            return Math.abs(x1 - x2) + (Constants.Sqrt2 - 1) * Math.abs(y1 - y2);
        }
        return (Constants.Sqrt2 - 1) * Math.abs(x1 - x2) + Math.abs(y1 - y2);

    }
1196857
def form_number(self):
		
		k1, o1, m2, s2 = (
			np.extract(self.model['constituent'] == c, self.model['amplitude'])
			for c in [constituent._K1, constituent._O1, constituent._M2, constituent._S2]
		)
		return (k1+o1)/(m2+s2)
978806
def compare(ver1, ver2):
    ''''''
    if ver1 == ver2:
        return 0
    ver1 = _cut(ver1)
    ver2 = _cut(ver2)
    # magic multiplier
    m = 1
    # if the first one is shorter, replace them
    if len(ver1) < len(ver2):
        ver1, ver2 = ver2, ver1
        # and reverse magic multiplier
        m = -1
    # compare all items that both have
    for i, part in enumerate(ver2):
        if ver1[i] > ver2[i]:
            return m * 1
        if ver1[i] < ver2[i]:
            return m * -1
    # if the first "extra" item is not negative, it's bigger
    if ver1[len(ver2)] >= 0:
        return m * 1
    else:
        return m * -1