@@ -0,0 +1,1204 @@
+#!/usr/bin/env python%0Aimport re%0A%0A%0Adef add(expression):%0A    if expression == %22%22:%0A        return 0%0A    numbers = parse_numbers(expression)%0A    numbers = %5Bn for n in numbers if n %3C= 1000%5D%0A    ensure_all_non_negative(numbers)%0A    return sum(numbers)%0A%0A%0Adef ensure_all_non_negative(numbers):%0A    negatives = %5Bn for n in numbers if n %3C 0%5D%0A    if negatives:%0A        raise ValueError(%22Negative numbers not allowed: %22 +%0A                         %22 %22.join(map(str, negatives)))%0A%0A%0Adef parse_numbers(expression):%0A    if expression.startswith(%22//%22):%0A        numbers = split_by_custom_delimiters(expression)%0A    else:%0A        numbers = split_by_newline_and_commas(expression)%0A    return map(int, numbers)%0A%0A%0Adef split_by_custom_delimiters(expression):%0A    m = re.search(%22//(.*)%5Cn(.*)%22, expression)%0A    delimiters = extract_custom_delimiters(m.group(1))%0A    numbers = re.split(delimiters, m.group(2))%0A    return numbers%0A%0A%0Adef extract_custom_delimiters(expression):%0A    delimiters = re.split('%5C%5B%7C%5C%5D', expression)%0A    delimiters = %5Bre.escape(d) for d in delimiters if d != ''%5D%0A    return '%7C'.join(delimiters)%0A%0A%0Adef split_by_newline_and_commas(expression):%0A    delimiters = %22,%7C%5Cn%22%0A    return re.split(delimiters, expression)%0A

Create calculator.py